Developing for Windows Mobile – Mobile XAML?

I’ve now included a “first cut” XAML parser (ultra simplistic) within v0.2 of my Mobile UI Framework.

Allows me to convert:

<?xml version="1.0" encoding="utf-8" ?>
<GradientRectangleElement DesiredSize="Unbound" StartColor="240,240,240" EndColor="200,80,0"/>
<TextElement DesiredSize="400,500" Foreground="200,200,200" Text="Demo" Angle="315" AutoSize="True" 
HorizontalAlignment="Center" VerticalAlignment="Center"
/> <DrawingPanel DesiredSize="Unbound" Background="{null}"> <DrawingPanel.LayoutEngine> <StackLayout Margin="8,4" Padding="4"/> </DrawingPanel.LayoutEngine> <ButtonBar Text="Animations" SecondaryText="Animate properties of graph primitives"
DesiredSize="UnboundAxis, 80" Background="{null}"
/> <ButtonBar Text="Trasitions" SecondaryText="Optimized bitmap animations"
DesiredSize="UnboundAxis, 80" Background="{null}"
/> <ButtonBar Text="Primitives" SecondaryText="Polygon, Ellipse, Image, Text"
DesiredSize="UnboundAxis, 80" Background="{null}"
/> <ButtonBar Text="Behaviours" SecondaryText="Drag with slide"
DesiredSize="UnboundAxis, 80" Background="{null}" Command="{Binding DragDemoCommand}"
/> <ButtonBar Text="Layout" SecondaryText="Stack, Wrap and Radial"
DesiredSize="UnboundAxis, 80" Background="{null}" Command="{Binding LayoutDemoCommand}"
/> </DrawingPanel> </DrawingPanel>


I was getting really sick of doing it the “old fashioned way”

So far I support simple value type converters (float, bool), pen and brush converters, size and padding converters, resource naming (x:Name), complex properties (DrawingPanel.LayoutEngine) and loading types from other CLR namespaces via XML namespace (xmlns:sysDrawing).

Developing for Windows Mobile – Guru Meditation

I’ve been working away for a few nights now trying to put together a simple framework for building user interfaces on a Windows Mobile device. It’s only taken a few nights to build something that I’m pretty happy with… and I was thinking of maybe even posting some source code.

It was at this moment of course that I had a visit from my Inner Guru. You know the one… that little voice in your head that sniggers impolitely whenever you struggle to convert a loop into a LINQ expression. Or when you’re hacking out some prototype code and you need to new up an instance. You know that really its going to need an IOC container, you look around, no-ones watching… in goes the explicit “new Foo()”. Immediately your Inner Guru can be heard muttering to themselves, “tut… tut.. will he never learn…”.

Anyhow, my Inner Guru popped in for a visit just the other day and we had a quick chat about the work I’d been doing on my mobile framework. The conversation went something like this:

Me: Hey – check out this framework I’ve been building for Windows Mobile – pretty cool huh?

Guru: Hmm… yes it appears you’ve made quite some progress.

Me: Yeah – look it can do animations.

Guru: Very impressive. Did you have trouble using the DirectX libraries?

Me: Ah well, err no it’s just using GDI.

Guru: Ah, I see. Does that give you full hardware acceleration on the device?

Me: Um… no I don’t think so.

Guru: Ah, I see. Commendable that you have support for an opacity on each element.

Me: Yeah, well I mean no. It seemed like a good idea at the time but I haven’t done that yet.

Guru: Ah, I see. It appears all objects support using a RotateTransform?

Me: Yeah, well I mean no. I couldn’t figure out how to rotate images an arbitrary amount with decent performance.

Guru: Ah, I see. I notice that your transforms all inherit from a base class which of course must perform the Matrix calculations.

Me: Yeah, well actually no. I mean there is a base class but I haven’t bothered implementing the transforms using Matrix math – they’re just, you-know, hard coded.

Guru: Ah, I see. It seems you’ve done some work building the framework for a layout engine that can be plugged into any container control. Seems a bit WinForms’ish to me, not very WPF like.

Me: Well I didn’t think it was so bad, although I haven’t actually written that bit yet.

Guru: Ah, I see. So no actual layout panels yet, not even the most simple stack panel?

Me: Err, well no – but it wouldn’t be hard to add.

Guru: But you haven’t done it – even though it wouldn’t be hard.

Me: Well no.

Guru: Hmm.

Me: I was thinking of posting the source code.

Guru: I see. So despite the obvious architectural flaws, the missing classes, the lacklustre performance, the questionable code formatting you feel it adequate for public viewing, or perhaps that may be ridicule? I see you’re still using foreach loops – can’t quite seem to wrap your head around LINQ can you dear boy?

Me: Umm…

Fortunately it was at this point that my Inner Guru hit an untrapped exception deep in his runtime. The following image began blinking away in my head.

I suppressed an evil chuckle and posted the code: