WPF in Story of Resources.

As I started to play with WPF and XAML one of first things was to get some free vector images. Those images came already formated as XAML resources:

<ResourceDictionary ...>
    <DrawingImage x:Key="Horizon_Image_Up1">
        ...
    </DrawingImage>
</ResourceDictionary>

All one needed to do was to include them as resource. I personally like to do that at application level:

<Application ...>
    <Application.Resources>
        <ResourceDictionary Source="Resources/Left1.xaml" />
        <ResourceDictionary Source="Resources/Down1.xaml" />
        <ResourceDictionary Source="Resources/Up1.xaml" />
    </Application.Resources>
</Application>

Once we do this there will be error message greeting: “Property ‘Resources’ accepts only one object.”

There are two solutions to this problem. First one is obvious - put all resources in same file. I personally tend to avoid it since I like to reuse resources in multiple projects and I hate carrying bunch of unused images.

Second solution is to merge all those dictionaries into one. Fortunately, there is simple way to do it:

<Application ...>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <Application.Resources>
                <ResourceDictionary Source="Resources/Left1.xaml" />
                <ResourceDictionary Source="Resources/Down1.xaml" />
                <ResourceDictionary Source="Resources/Up1.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

With that you have single dictionary consisting of all individual images. Do notice that, if there is same key defined in different files, only image that was defined last will be used.

The Only Winning Move Is Not to Play

Illustration

I own BeBook mini for quite some time now. Once it gets noticed I get quite a few questions. Usually people wonder about eInk screen, supported formats, battery life… Lately question that comes quite often is “Are you sorry?”

They point that there are bigger devices, better screens, shinier features… New e-book readers come out almost every month.

With current progress in technology, I am not sure that there is single moment you can make purchase and not have something better and cheaper coming out in next month or two. You will not spend your money on unnecessary purchase only if you don’t purchase anything. That is not destiny I wish to share.

And no, I am not sorry.

Adventures From SVG to XAML

Illustration

As huge fan of ribbon interface it was just a matter of time before I started playing with WPF flavored version. First thing that became obvious is that my standard toolbar bitmaps are not good anymore.

My default 16x16 icons looked slightly blurry on higher DPI settings when used in Windows Forms applications and I didn’t mind it much. Same icons in WPF looked just plain awful. I spent some time playing with various settings to get better results but even best settings could not hide fact that bitmaps were used. It was quite obvious that vector-based icons were what I needed.

There are some free XAML toolbar icons available but any meaningful project will have problems finding right (free) icon for the job. Since there is quite a selection of free SVG icons, thought came about converting one into another. How hard it can be to convert one vector drawing into another one.

I decided to test this on various media buttons since that was exactly what I needed for one project.

First thoughts went toward InkScape. This is great vector drawing tool with option to save files as XAML. Resulting file used canvas for positioning various elements and thus it was not possible to use it as ribbon image. Simplest solution failed me.

Another solution was exporting file in PDF and then importing that into Expression Design and exporting it as XAML. It worked. However, results were less than satisfactory. All gradients were rendered as image instead of vector. Scaling picture didn’t quite feel right.

I spent better part of night and nothing quite worked.

Best results that I got were with Svg2Xaml library. It is LGPL project in very early phase (version 0.2) of development but I do not see any alternative library that is half as good.

Examples included with that library are quite good but I decided to create another one just for fun. As always, result of that tinkering is available for download.

WinDays 10

Illustration

Biggest Croatian IT conference WinDays will be held in Rovinj this year. And, as two previous years, yours truly will have one presentation.

This year I will be talking about Bing Maps and presentation will be held on Wednesday, 21st April 2010 at 11:00. If you, readers of this blog, happen to be in Rovinj that day (or day before/after) I would like to meet you in person.

As always, presentation will be available for download minutes after I stop bothering attendants.

Am I Secret Admirer?

Illustration

Most of my YouTube playlist consists of Starcraft and cooking videos. From time to time I also take look at YouTube recommendations since they usually reflect my taste. But sometimes I just have a laugh.

I was quite surprised when I saw Susan Boyle video among those recommended for me. Fortunately YouTube also told me why. That left me even more puzzled since YouTube though that I would like Susan because I watched Starcraft Winners League match between Samsung Khan and Estro. I dare not think how many Starcraft fans watched both those videos for YouTube to connect them.

Starcraft fans are peculiar bunch…