Musings of a PC

Thoughts about Windows, TV and technology in general

Win8 development: using the Multilingual App Toolkit

The Multilingual App Toolkit (or MAT for short!) integrates into Visual Studio 2012 and is intended to make it easy to manage the translation of strings through features such as import & export of translations and the use of Microsoft Translator to automate some of the processes.

There are some good videos (http://go.microsoft.com/fwlink/?LinkId=266600, http://go.microsoft.com/fwlink/?LinkId=266603 and http://go.microsoft.com/fwlink/?LinkId=266604) and articles (http://msdn.microsoft.com/en-us/library/windows/apps/xaml/JJ572370(v=win.10).aspx and http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh965329.aspx) on how to use MAT but I still couldn’t get my app to use the translated strings. The app continued to use the strings that I was putting into my English resource file.

Here is the answer: you must mark each and every string as Signed off in the Multilingual Editor (so that the blob on the left hand side of the window goes green) before those strings are used. Once you’ve done that, you should then see the strings being used so long as you’ve set your display language appropriate in Windows.

 

Win8 Development: getting icons

One of the significant improvements from developing for the Windows Phone platform is that Windows 8 supports XAML as an image type, allowing you to provide vector graphics rather than rasterised. This ensures that you get the crispest, cleanest iconography you can have because the OS will scale the images appropriately.

One of the sites that I’ve used in the past is the Noun Project. They have some stunning icons, all of which can be downloaded in SVG format … but how to then get that into XAML?

The simplest method I’ve found so far is Mike Swanson’s free Adobe Illustrator to XAML Export plug-in. Download, copy to the right directory, open the SVG file in AI, choose Export > XAML.

Job done.

Well, almost. You’ve then got to incorporate that into the project as a resource, but that’s for another blog ;-).

 

Win8 Development: major gotcha in page navigation

One of the major differences in page navigation between Windows Phone 7 and Windows 8 “Modern UI” apps is that the latter allows you to pass an object to the page whereas Windows Phone 7 is pretty much limited to simple items because navigation is done in the form of a URL.

Unfortunately, it turns out that while passing objects to a page does work, it causes a problem with the SuspensionManager because the object cannot be serialized. If you try, the call that SuspensionManager makes to Frame.GetNavigationState() results in an exception.

This took me a while to figure out (mainly because I’d forgotten that I’d been extending my code by passing objects to the pages) but also because I didn’t read the debug output closely enough to see this message:

WinRT information: GetNavigationState doesn’t support serialization of a parameter type which was passed to Frame.Navigate.

So, the upshot is that if you’ve written a Windows Phone app, you can pretty much stick to the same navigation methodology, passing simple objects to the page.

Reference: Microsoft Connect

How to inspect SQLite databases?

For the purposes of looking at the databases that my fledgling Windows 8 app creates, I’ve decided to try SQLite Administrator: http://sqliteadmin.orbmu2k.de/. This is a free tool that allows you to enter SQL queries to execute against the database. It means I need to brush up on my SQL but the tool isn’t too bad. Depending on how much I end up needing to look at the data, I may decide to try SQLite Spy (http://www.yunqa.de/delphi/doku.php/products/sqlitespy/index) which was another tool suggested by a discussion on StackOverflow, which in turn also references a big list of tools on SQLite’s own web site … so my journey to find a nice tool may not end here …

Win8 Development: coping without EntityRef and EntitySet

In a recent post, I mentioned that the version of the .Net framework being used by Windows Store apps doesn’t have any support for EntityRef and EntitySet. I have used these extensively in my WP app to link database tables together. I posted on StackOverflow to see if there were any suggestions and one was to use System.Data.SQLite, which provides ADO.NET interfaces to SQLite. However, I was put off this suggestion for a few reasons:

  1. The FAQ says that all System.Data.SQLite objects that implement IDisposable, either directly or indirectly, should be explicitly disposed when they are no longer needed in order to avoid memory leaks. The way it was worded was a bit off-putting in as much as how am I supposed to figure out which objects implement IDisposable, particularly indirectly?
  2. There doesn’t appear to be a WinRT version yet. There are 32-bit and 64-bit Windows versions but what about ARM?
  3. Would this work with SQLite-net or instead of? SQLite-net has good support for asynchronous working which may be lost if this works instead of that library.

So, in the end, I’ve decided to take a simpler approach and deal with it by hand. Where a child table is linked to a parent table, the child has an extra row defined that is a nullable int to store the ID for that parent table. Then, in the class for the parent table, I define an “Add” function like this:

public ChildClass Add(ChildClass child)
{
    Debug.Assert(this.ID != 0);
    child.ParentClass = this.ID;
    return child;
}

The purpose of the Assert is to make sure that the parent class has been inserted into the database and therefore has its primary key column set. In my code, when I want to create a new child class, I have a routine called AddChild which then returns the new child object. Because the above Add routine returns the class that is passed to it, this allows me to go:

_db.Update(_parent.Add(AddChild(parameters)));

The AddChild routine creates a new instance of the Child class and then calls _db.Insert(_child) so that the Child instance is added to the database and gets it’s ID value. The rest of AddChild does other bits to the members of the class but doesn’t call _db.Update. I rely on the above line to do the setting of the parent’s ID and calling Update all in one go so that writes to the database are minimised.

The above works but isn’t ideal. One way in which EntityRef and EntitySet are clearly better is that they enforce the correct class usage. For example, if the Child class could be linked to Parent and StepParent, my method wouldn’t do anything to stop me inadvertently setting the child’s ParentClass value to the ID of the StepParent class if I got my logic wrong somewhere. EnttiyRef/EntitySet would handle that because of the type linkage.

Win8 Development: Stumbling Block #1

This could be a bit of a show-stopper but Windows Store apps have their own flavour of .NET – yes, yet another variant of the framework and it seems even more restrictive than the Silverlight version that Windows Phone has.

The stumbling block in my case is the complete absence of EntityRef and EntitySet. These are used extensively in my WP app to link tables together and I’m struggling to figure out how to get the code to work without them. I’m still searching …

Windows 8 Development

Something I had intended to do while I was working on my first Windows Phone app was to keep track of web sites/pages/blogs that were helping me along the way, as well as snippets of knowledge that I figured out to solve a problem.

Well, that didn’t happen, did it!?!?

So, now that the first Phone app is done and dusted, I’m turning my attention to my first “Modern UI” app (or whatever Microsoft are calling this week). The app will rely on a database, something that isn’t supported natively by Windows 8, so that is where I’m starting.

The proposed solution for programmers requiring a database is SQLite. This, like SQL CE, is not a client/server solution but is, instead, providing database-aspects on top of a single file. From what I’ve read about SQLite, it looks to be a big improvement over SQL CE so I can see why Microsoft are recommending it rather than baking their own.

To get started, I’m following the instructions in a blog posting by Tim Heuer. He documents the steps required to install SQLite then configure your project to use the DLL then incorporate a LINQ wrapper.

I can see that I’ve got quite a learning curve ahead of me, though. Apart from anything else, moving from an environment where you can build for “Any CPU” to one where you have to essentially build three times (x86, x64 and ARM) means learning more about Visual Studio (some might say I ought to know these bits anyway) and more testing/debugging.

Fun times ahead!

 

Thoughts on “Penn & Teller” live in Las Vegas

My earliest memory of Penn and Teller is a TV show that had a section where they got you to record the show so that you could then use that recording as the reveal in a card trick on an unsuspecting member of the family.

I’ve always enjoyed watching them perform. Sometimes, I’ve enjoyed where they “reveal” how a magic trick is done, only to then re-do the trick in a way that their previous explanation just wouldn’t cope with. At other times, I’ve loved the sheer skill of the trick, where you just watch in wonderment and admiration of the hours of practice it would have taken to make it look so effortless.

When I realised I had the opportunity to visit Las Vegas on my own, thankfully my wife didn’t take much persuading to allow me to go & see their show at the Rio. Tonight, I’ve just seen that show and here are my thoughts …

My main takeaway from the show is that it is primarily aimed at an American audience and I say this for two reasons:

1. As a UK resident, I’ve recently seen Penn & Teller in two seasons of a show called “Penn & Teller: Fool Us” where magicians were challenged to perform a trick right in from of them in the hope that they wouldn’t know how it was done. At the end of each show, they performed one of their own tricks for the audience. Unfortunately, a fair number of these have made their way into their Rio show. Now, that isn’t necessarily a bad thing, particularly since US audiences are unlikely to have seen “Fool Us” and they are very good routines, but it takes a little bit of the edge off.

2. There were a number of references to the Constitution and Amendments. As a non-US citizen, I don’t know which Amendment covers what, so that dialogue left me a bit in the dark and wondering what the patter was all about.

That aside, it was a great show – over a bit too quickly for my liking but the fact that time went very quickly is a sign of how much I enjoyed myself. Stand-out routines were Teller as a Little Teapot – a routine that at first glance seems to be very trivial and simple but I rather suspect belies the amount of thought and effort that has gone into it – and Teller manipulating a large red ball with a hoop. This was actually a very good example of P&T telling us how the routine is done – with a thread – but is an excellent example of how the routine itself goes way beyond that simple example, with Teller manipulating the ball in ways that leaves your brain thinking “err, if the ball is attached to the thread, how did he get it to do that?”.

For me, the weakest point in the show was the “close up magic” routine. Unfortunately, I found myself waiting for the reveal that I predicted pretty much the moment it started. As a result, the patter and routine left me a bit cold. A shame as I suspect I would have really enjoyed it if I hadn’t been expecting the denouement. If anything, a really good example of why you don’t want to know how magic tricks are done. It just spoils it.

I’m glad I went to see them, though. They are a fantastically great double-act and complement each other’s skills and attributes brilliantly.

 

Easy Listening Music for Wedding Guests

I was recently asked to put together a set of “easy listening” music that would be played as background in some of the rooms at Gareth & Helen’s music.

My wife & I are fans of Michael Bublé, and of the style of music he sings, so that greatly influenced our final choices.

For those of you who attending the ceremony or evening reception, or are just curious about the music we picked, here is the play list, in the order it was played. Enjoy!

Everything (Bob Rock Mix) by Michael Bublé [Crazy Love, disc 2]
Summertime, sung by Peter Gabriel [The Glory of Gershwin]
The Best Is Yet to Come by Michael Bublé [Call Me Irresponsible]
I Will by the Beatles [White Album]
Crazy Love by Michael Bublé [Crazy Love]
Let There Be Love by Nat King Cole [Music to Watch Girls Go By]
For Once in My Life by Michael Bublé [Sway]
The Man I Love, sung by Kate Bush [The Glory of Gershwin]
Crazy Little Thing Called Love by Michael Bublé [Sway]
Anyone at All by Carole King [You’ve Got Mail]
Hold On by Michael Bublé [Crazy Love]
Wives and Lovers by Jack Jones [More Music to Watch Girls Go By]
Wonderful Tonight by Michael Bublé [Call Me Irresponsible]
I Couldn’t Live Without Your Love by Petula Clark [More Music to Watch Girls Go By]
Baby (You’ve Got What It Takes) by Michael Bublé [Crazy Love]
Magic Moments by Perry Como [Music to Watch Girls Go By]
I’ve Got the World on a String by Michael Bublé [Call Me Irresponsible]
What a Wonderful World by Louis Armstrong [More Music to Watch Girls Go By]
The Way You Look Tonight by Michael Bublé [Sway]
It Ain’t Necessarily So, sung by Cher [The Glory of Gershwin]
I’ve Got You Under My Skin by Michael Bublé [It’s Time]
Somebody Loves Me, sung by Meat Loaf [The Glory of Gershwin]
All I Do Is Dream of You by Michael Bublé [Crazy Love]

and then, to mark the start of their honeymoon,

Circle of Life from The Lion King

Now available: The Release Candidate for System Center Virtual Machine Manager 2012

Really pleased to see the Release Candidate made available:

http://blogs.technet.com/b/scvmm/archive/2011/09/08/now-available-the-release-candidate-for-system-center-virtual-machine-manager-2012.aspx

It has been interesting learning about VMM 2012 by using the beta VHD but it became frustrating recently when the provided copy of SQL Server expired. I didn’t have the mental energy to move the databases onto our production SQL Server so I’m glad that a refresh of the VHD is now out.

Evaluating VMM 2012 by using the VHD is, in my opinion, the simplest way to start playing around with VMM and learning what it can do. Download, attach to a virtual server and away you go!

It is also possible – and supported – to upgrade from VMM 2008 R2 SP1 to VMM 2012 RC and then to VMM 2012 RTM, so if you have an existing VMM 2008 R2 SP1 estate, you can upgrade to VMM 2012 RC safe in the knowledge that you’ll be able to upgrade to RTM when it arrives.

Speaking of which, I wonder when it will arrive? Are the various System Center products going to be released independently or in one big hit? If the latter, I suspect we may be waiting a while because I think VMM is the first Release Candidate … DPM has only recently hit beta!

I can’t see any support listed for Linux, though, which is a shame given that RHEL, amongst others, are supposed to be supported guests of Hyper-V.