Formula 1 has the Fastest Cars — NOT ANY MORE

Posted on March 27th, 2007 in Uncategorized by Puneet Sarda

Top Gear does what no Formula 1 Car has ever done. It takes Bugatti Veyron to a smashing 253 mph i.e. 407 kmh at the Volkswagen Track in Germany. The Concord of Cars has arrived!!

WPF Talk at Boston .NET User Group

Posted on March 15th, 2007 in WPF, Talks by Puneet Sarda

I had a great time yesterday talking about Windows Presentation Foundation at the Boston .NET User Group meeting in Waltham, MA. I have a lot of post session material for all those who attended. Thank you for attending.

Slides (in .XPS format, will open in IE) and XAMLPad Code.

Source Code from Application = Code + Markup (We explored examples in chapter 8 and 9 yesterday).

My blog article on WPF Architecture with links to Channel9 Videos.

Resources:

We looked at the WPF Controls Gallery and Sample Gallery in SDK yesterday. Click on the screenshot below to see where to find them in the sdk documentation.

SDK Sample Tree

Tim Sneath maintains a list of WPF bloggers as well has an opml file so you can directly add them to your rss reader

Real World WPF Applications:

You will find many more at Tim’s site as he maintains a list of those too.

 

IBM Keyboard Usability

Posted on March 11th, 2007 in Usability by Puneet Sarda

I have started paying attention to everyday things in my life and see how they work to make me better at what I do. Are there ways to optimize them, tweak them in simple or complex ways so that some small quirk of mine can be addressed.

So I found this extra IBM USB enhanced keyboard in my colleague’s cube and asked her if she was using it or was it just lying around. Fortunately, she wasn’t and I thought I would like to try it out as I was bored of using the one I had for a year now. One of the reasons I liked it was the number of shortcut buttons it had and they were preprogrammed to open specific folders/applications. So I download the drivers for this guy from IBM and install it. I expected to find the drivers package to contain some software which would allow me to reprogram the keyboard buttons to applications I prefer rather than the defaults.

Keyboard(Click to enlarge)

However, what really impressed me was the label printing feature in the software. Once I had programmed each button, it allowed me to print of a label indicating what each button was for and then slide it into the label slot. I have seen keyboards which come with programmable keys but this one went just one step further in helping me not having to remember which one was for what. It simply prints it in a right size with the instructions to tear the appropriate section and stick it into the slot.

Now that’s what you call designing with the user in mind.

WPF Architecture

Posted on March 7th, 2007 in WPF by Puneet Sarda

I looked on the net for some detailed article on WPF Architecture. I found the MSDN Documentation but its too detailed and goes into the namespaces even before explaining the basics. I found a video on Channel9 of Chris Anderson doing a whiteboard session explaining the architecture. Greg Schechter also has an hour long video on Channel9 where he talks about WPF architecture , Windows Vista DWM and many other things.

I thought all that I learned from watching these videos could be summarized in an article to explain the architecture and save others the trouble of watching the videos (only if you dont have the time for it, otherwise you would learn a lot from them).

In WPF you have a Visual Tree of all the objects in your XAML file. This is a tree with all the visible UIElements as well as the other visual core components that make up each object. Now the UI thread running your application manages the Visual Tree. WPF has a Single Threaded Model and your UI thread is the only thread you as a developer have to manage. Any UI element must be accessed via this thread. Apart from the UI thread, there is a Render thread running in the background. The Render thread is responsible for creating and managing a Composition Tree based on the Visual Tree. Remember that in WPF a button can have its content as a Grid which might have an Image as the content of its each cell. In other words, elements can be composed of other elements and this composition can be as nested as you want it to be. The Composition Tree layouts the entire compositon of all the elements in the XAML file. The Render Thread is responsible for navigating through this entire tree and rendering the elements.

Visual Tree and Composition Tree

An important point to note here is that as changes happen on the visual tree e.g.: a radio button is selected, only those deltas are communicated to the render thread and accordingly the composition tree is updated. Also the re-rendering happens only for those deltas instead re-rendering or repainting the whole screen. The render thread is responsible for talking to Direct3D and rendering the content. Lets see how that happens.

WPF architecture

The above diagram explains the WPF architecture. At the lower most level you have the Kernel , your graphics drivers etc… on top of it you have 2 modules. USER32 is reponsible for deciding what window goes where on your screen. So each window gets its allocated space by this guy. Direct3D is responsible for rendering the content of each of these windows. Direct3D talks to the graphics drivers and sets the pixels on the monitor. milcore is not a publically exposed API but futured versions of WPF might see it opened up to developers maybe via other interfaces than the ones explained below.

On top of Direct3D, the WPF team built milcore.dll. MIL is an acronym for Media Integration Library. This is an unmanaged module and is basically the composition engine thats providing features like 2D, 3D, animation etc… Its the one that directly communicates to Direct3D and can be thought of as a middle man between the rest of WPF and Direct3D. There is also a WindCodecs.dll which houses the unmanaged implementation of various imaging codecs like png, jpeg etc…

On top of this you have the .NET 3.0 Common Language Runtime. Above this layer is the PresentationCore which is a mix of managed and unmanaged code. This is a low level API exposed by WPF providing features for 2D, 3D, Geometry etc… Above this is the managed PresentationFramework. I provides access to high level features like applications, controls, styles etc.. Also you have access to layouts, data, content and actions which help you build up your entire application.

So thats the WPF architecture.