March 2009 Archives

You were a frakkin good show

So say we all!

Battlestar Galactica coming to a close, but Caprica remains inbound.

A few weeks ago, for the first time in my life, I watched a TV episode twice. Back to back, with no break in between. Blood on the Scales, for me, was pure gold. The story was incredible, especially if you got the chance to see the webisodes that supplied important context for it. The acting was top-notch. Alessandro Juliani in particular, who has had a relatively small amount of screen time before now, really stepped up to deliver a wonderful moving performance. The music—oh my sweet god the music. Anyone who knows me well will know my love for the BSG soundtracks, but the music in this particular episode spoke to me on such a profound level that I literally missed dialog at points and had to rewind to hear it again. I will be shocked, pleasantly, if I ever watch another episode of any other TV show that affects me like this one.

This Friday begins the final countdown for Battlestar. It will be the first in a three episode arc to end the series. On one hand I am sad to see it go. I will miss not just watching it, but hopping online afterward to read Bear McCreary’s enthralling behind-the-scenes summary of the score. But on the other hand, I would rather see it get the strong finish it deserves than see it become the proverbial Old Yeller like Stargate: SG-1 did.

But Caprica will be starting early next year, so maybe all is not lost. I worry about them milking the mythos to death in it, but these guys transformed a corny 70s show into something amazing, so I have a lot of hope. Earlier this month, Bear gave an early preview performance of the music of Caprica.

Alex Filo has the right idea, UniformWrapPanel

WPF’s WrapPanel is missing a key feature: the ability to create vertical columns, but still fill the maximum amount of width available. One less annoyance in WPF, thanks to Alex Filo’s UniformWrapPanel.

Qt 4.5 released, still using three year old GCC

Qt 4.5 is out, along with Qt Creator. It’s still using GCC 3.4.5, from a January 2006 codebase. Sigh.

Databinding TextBlocks with XAML

I’ve become frustrated lately with trying to databind a list of strings to a textblock. Ie, if I have:

string[] mytext = new string[] { "a", "b", "c" };

And I want the effective end result to be:

<TextBlock>a, b, c</TextBlock>

Or maybe I want something more complex like hyperlinks:


Basically what I’m looking for is a ItemsControl that works on TextBlocks (or Spans, etc.), with a Separator template to insert those “, ” in between the items.

Your first instinct might be to use a StackPanel instead, but StackPanel wasn’t made for displaying text. It might fool you initially, but you quickly notice it doesn’t behave anything like text: there’s no proper kerning, RTL, wrapping, or anything else the text classes were made to support.

I’m pretty surprised that WPF doesn’t have anything like this, as it seems like displaying lists as text would be a common enough thing for any app. Unfortunately I’m still not well versed enough in WPF to create such a custom control for myself, and haven’t had a whole lot of time to investigate it.

Using HSL colors in WPF

One thing that has always irritated me about WPF is you’re still stuck specifying colors in RGB. HSL just feels so much more natural from a design standpoint. Well, we’re not completely out of luck—we’ve got markup extensions.

So I created my own HslColor and HslBrush extensions which are fairly simple to use:

<Window xmlns:e="clr-namespace:WpfExtensions"
        Background="{e:HslBrush H=300,S=50,L=75,A=80}"/>

Hue is specified in degrees from 0 to 360, while Saturation, Lightness, and Alpha are from 0 to 100. The parameters are all doubles and it converts to scRGB behind the scenes, which means you actually get a much higher color precision than if you had just used the equivalent RGB hex. With Windows 7 having native support for scRGB, this will future-proof your application to make good use of upcoming monitors with Deep Color support.