Nick Recommends…

March 25th, 2007

Here’s a few things I’ve stumbled on lately that I thought a person who reads my blog might enjoy. So basically…I just totally called you a nerd!


The Physics of SuperHeroes


If you are an ultra geek, (or a closet ultra geek like myself), this book is probably right up your alley. The author does an amazing job of applying basic physics to common comic book heroes. For example: In the first Superman comic book the author takes the fact that Superman can jump tall buildings and using basic principle of physics determines the mass and size of Krypton and then shows why the planet exploded! Seriously…ultra geek reading material here. But don’t worry, the author has a great sense of humor and rarely bogs the reader down with over the top equations and calculations.


WPF Unleashed

If you consider yourself a serious WPF developer and/or designer and you haven’t purchased this book yet…for shame. This book is easy to read, very well structured, and I love the glossy colored pages. Yes, even I, with my seemingly limitless caverns of knowledge, learned a lot of “tips” and “tricks” from this book.


CopySourceAsHTML

/// <summary>

/// Great way to get code to your blog!

/// </summary>

public class CopySourceAsHtmlExample

{

    public static string ThisVisualStudioAddInRocks()

    {

        string ThisIs = “I totally”;

        string Very = “wrote this”;

        string BadAss = “in Visual Studio.”;

 

        return ThisIs + Very + BadAss;

    }

}

This is a great Visual Studio add-in for bloggers who hate having to convert their code/markup to html for post examples. (I’ve always just taken screenshots because I like to have the Visual Colors in my examples…and I’m lazy.)
It did take me a bit to install on Vista but it was well worth it. The example to the left was literally copy/pasted right out of Visual Studio in Wordpress.


“IE Tab” Add-On for Firefox

So I admit it, I’m not the biggest fan of IE7. I’m not looking to get into a browser debate, to each his own is my view, but suffice it to say I use Firefox. Of course this does make it a pain when dealing with xbaps or xaml files…or it was until I found this Firefox add-on.
All I had to do was tell it if the url being navigated too ends in “.xbap” or “.xaml” open the page in a IE tab. It works beautifully!


That’s it! The titles and images are hyperlinks if any of these peeked your interest.


SpanningStackPanel

March 12th, 2007

05/21/07 EDIT: Fil Fortes was kind enough to point out I’ve put up a non-bindable panel. If you want a good version of this panel you should check out: http://fortes.com/2007/05/07/uniformpanel/

I’m guessing the following scenario hasn’t only happened to me.

You know how a Grid and it’s children will automatically fill all available space?

How many times have you mistakenly attempted to ask StackPanel to do the same thing? For example: I want to have six buttons span the width of my window.

Doh! I’ve done this more times than I’d like to admit.

So your probably thinking to yourself, “So just put them in a Grid and create columns you fool! It’s easy!” And you’re right, that’s what I usually end up doing. But what if you’re dynamically adding/removing objects to your Grid? Then you have to create the rows/columns in code each time a child is added or removed. What a pain! Using a Grid’s Columns/Rows really falls apart if you need this layout to occur in an ItemsControl and your setting the ItemsControl.ItemsPanel property! Now you’re screwed and you’re going to have to write a custom control…like I did.

If you were able to follow the ramblings of that last paragraph then you’ve probably figured how I built SpanningStackPanel. All I did was inherit from Grid and then, depending on Orientation and FlowDirection, I add Columns/Rows when a UIElement is added/removed to the Children collection.

NOTE: I remember Kevin Moore once telling me it’s not worth the overhead of inheriting from anything other than Panel, but in this case I felt it was easier to let Grid do the work it was already programmed to do. This way I didn’t have to mess with any of that ArrangeOverride or MeasureOverride nonsense one usually has when building a custom panel.

There were a couple of things I did to make the panel mimic some of StackPanel’s behavior. Like I mentioned before I have Orientation and FlowDirection properties that control the layout as seen below.

And lastly, to mimic Grid’s behavior I don’t give a control more or less space if it has a hard set Width/Height property. The following screenshot shows the green button with it’s Width property set to 25px.

So that’s it! A panel that acts like a StackPanel while laying out like a Grid.

You can snag the source from here if you want to play around with it.

SpanningStackPanelExample Source

At some point I’ll probably come back to this control and change the way it determines if a control has a set height/width. I don’t like the way I currently implemented it but it works for now. Maybe I’ll come up with a better name then SpanningStackPanel too. SuperUltraliciousMaskedAvengerPanel…that has a nice ring to it.


RSS Feeds

March 11th, 2007

For those of you out there using aggregators:

I recently redesigned my site and decided I’d rather manage one blog instead of having to manage multiple blogs on sub-domains. Of course this means that those of you interested in wpf content are finding dull boring pictures and comments aimed at my friends and family. If you’re only interested in specific content you can change the source of your rss feed to one of the following.

Main (All Posts) - http://wpf.nickthuesen.com/wp-rss2.php

WPF Posts - http://wpf.nickthuesen.com/wp-rss2.php?cat=2

Friend/Family Posts - http://wpf.nickthuesen.com/wp-rss2.php?cat=3

Rants - http://wpf.nickthuesen.com/wp-rss2.php?cat=4


So Long Captain America

March 7th, 2007

So I have to hear about this through Times Reader! You think I’d have gotten a phone call or a visit from a 4 star general. But nope…there it is on the front page of the Times Reader. Cuts deep I tell yah.