Pixa – the drawing tool

April 6, 2008

I’m happy to introduce you to Pixa!

Pixa is a drawing program that takes full advantage of WPF. While it looks like a typical raster editor it is actually a vector editor, every stroke you paint on Pixa is actually a Geometry object, this allows you to zoom and resize without affecting the drawing quality.

pixa3

I have launched a CodePlex project for Pixa, so you can download and play with it or contribute if you wish.

Please take into consideration that Pixa is a “PRE-ALPHA” version and is a long way from stable, I’m releasing it now so I can get feedback and share it with you (if you are interested in the code or your have an artistic soul ;) ).

I will talk in following posts about Pixa’s roadmap, features and explain how I implemented some of the main features.

I will be happy to know what you think.


WPF Enhancements

February 21, 2008

Scott Guthrie blogged about the .NET 3.5 client product roadmap. Check out the post for full detail, and here’s a short list of the things to expect:

  1. DropShadow and Blur Bitmap effects will be hardware accelerated.
  2. Improvements on Text.
  3. Media and Video Performance.
  4. New WriteableBitmap API will enable real time bitmap manipulation.
  5. New Controls like DataGrid, Ribbon and Calendar/DatePicker.
  6. Improvements on the VS 2008 WPF Designer.

And one more thing you do not need to recompile your applications to befit from the new features!!! As long as you have the latest updates installed.


Using Merged Resource Dictionaries inside Themes/generic.xaml

December 20, 2007

For some reason including a ResourceDictionary into the Themes/generic.xaml does not behave the same as including a ResourceDictionary into App.xaml.

If you include a ResouceDictionary into Themes/generic.xaml you will receive an exception telling you that the dictionary cannot be assigned to property ‘Source’ of object, yada, yada, yada, very informative.

Exception:’MyDictionary.xaml’ value cannot be assigned to property ‘Source’ of object ‘System.Windows.ResourceDictionary’. Cannot loc
ate resource ‘mydictionary.xaml’.  Error at object ‘System.Windows.ResourceDictionary’, Line 9 Position 23.

What the exception is trying to tell you is that the included ResourceDictionary file was not found on the output folder, (meaning that it was expected to be an external resource).

What to do then, instead of:

<ResourceDictionary.MergedDictionaries>

    <ResourceDictionary Source=”MyDictionary.xaml” />

</ResourceDictionary.MergedDictionaries>

You should write it like this (specifying that the included resource is embedded into the assembly):

<ResourceDictionary.MergedDictionaries>

    <ResourceDictionary Source=”/My.Controls;component/themes/MyDictionary.xaml” />

</ResourceDictionary.MergedDictionaries>


Microsoft Expression Blend 2 December Preview is Here

December 8, 2007

The Microsoft Expression Blend 2 December Preview is here. Some of the new features are: Support for VS2008, Path Editing and Animation, Adding Multiple Projects to a single solution and etc.

Enjoy.


RadioButton IsChecked Binding Problem in .NET 3.5 RTM

November 22, 2007

I have written two posts in the past about a bug in WPF’s RadioButton IsChecked property change notification.

On my first post I described the problem and in second post I proposed and demonstrated a workaround to the problem.

Now after the release of the .NET Frameworks 3.5, I checked it again and hoping that it was fixed, but unfortunately it wasn’t fixed 8O . But the same workarounds that I described in my previous post in this issue still do the jobs.


Pistachio

November 12, 2007

Grant Hinkson from Infragistics created Pistachio, a resource visualizer utility, which identifies all resources defined within the project and show you which resources are used and where they are used.

It’s a helpful tool to clean up unused resources and to understand the current resource structure, especially when working with large WPF projects where resources are extensible use.

It’s free to download at the moment and worth to try it!

                           


Microsoft Surface SDK

November 11, 2007

If you were wondering about how you can develop software for the Microsoft Surface….

Matt Davey pointed on his blog to the Surface team blog. The place, you may what to follow and catch up on the new developments of the Surface SDK.

From what I have read the SDK is divided in two layers, core and WPF. The core layer supports any .NET UI Framework that provides an hwnd and its XNA oriented, the WPF layer supports all the functionality of the core layer but it remains consistent with WPF’s methodology.

Also don’t miss to cool Hello world demo video!


ScrollViewer Frustrations Moments

November 1, 2007

Let say that you have a custom control that uses the command ApplicationCommands.Copy, and you expects that when you press Ctrl+C the command is executed, so far so good.

Now you want to wrap your control with ScrollViewer, that’s ok.

And you expect that the Ctrl+C will be handled, yes?

Well… NOOOOO!

Why! Because ScrollViewer overrides the OnKeyDown method and it’s preventing it to bubble any further.

Not an expected behavior in my opinion.

What to do? Set the Focusable property of the ScrollViewer to false, and it’s done.


Embedding Bitmaps inside XAML

October 8, 2007

I needed a type of BitmapSource that allows me to embed an image inside a XAML file. WPF has a number of derived BitmapSource classes, each one for its specialized task, one specific, BitmapImage, allows you to load images using XAML, but BitmapImage refer to external images in XAML files and does not embed images in a XAML file.

So I decided to create my own class to achieve the task.

What did I do?

  1. A BitmapSource derived class that expose a property with the bitmap info and can act as a reference to another BitmapSource.
  2. A container struct, BitmapInfo, to hold all the information needed to reconstruct the image, pixel array, size, format, etc.
  3. A TypeConverter that convert BitmapInfo to a serialized byte64 string and vice versa.

Using the EmbeddedBitmapSource is seamless as using any other derived BitmapSource class. For example:

Image myImage = new Image();

BitmapImage bmpImage = new BitmapImage( new Uri( “someimage.jpg” ) );

myImage.Source = new EmbeddedBitmapSource( bmpImage );

I included the sources with a sample application that let you save the image into a XAML file (the XAML file can be found after saving where the assembly is) and later to load it.

EmbeddedSample

On the upper right side is the original image and on the lower part of the window is the embedded image that was loaded from the XAML file.

Source code (VS2008 project) can be downloaded from here (Remember to change the .DOC extension to .ZIP)

By the way, I took the picture some year ago in Chile near Puerto Tranquilo. In Lake General Carrera are marble caves formations, called the Capilla de marmol and Catedral de marmol that were carved by water over time. One of those from a specific angle a dog’s head can be seen.


Huge News!! Microsoft is releasing part of the .NET Framework source code

October 3, 2007

Huge news!! Microsoft is releasing the Source Code for the .NET Framework Libraries, which includes ASP.NET, Windows Forms, WPF and much more.