The Weekly Source Code 23 - Big Solution Edition
My source code reading didn't have any rhyme or reason to it this week, but most of them were large, so this is the Big Solution Edition. In my new ongoing quest to read source code to be a better developer, Dear Reader, I present to you twenty-third in a infinite number of posts of "The Weekly Source Code."
Vertigo Software, the folks that did the Deep Zoom Hard Rock site at Mix have released to CodePlex their mouse-wheel support in a project called Big Picture. When I saw this initially, I said, "meh" but then realized upon reading it that there's some clever stuff here that goes beyond the mouse-wheel support that folks rushed to add (myself included) to their DeepZoom Helloworld Examples.
First, they've figured out (as of Silverlight 2.0 beta 1) how to disable the initial "zoom from nowhere" animation in DeepZoom. They turn UseSprings off initially, then turn it back on after the first motion has completed:
/// Handles the "MotionFinished" event fired by the MultiScaleImage, but only re-enables the "UseSprings"
/// property after the first motion completes (a little trick to properly bypass the initial "zoom in
/// from nowhere" animation when first loading)
/// The MultiScaleImage instance.
/// Unused RoutedEvent arguments.
void image_InitialMotionFinished(object sender, RoutedEventArgs e)
isInitialMotionFinished = true;
image.UseSprings = true;
Simple, and obvious after the fact, but I hadn't figured it out. They also handle the issue of funky Uris in development vs. production by using App.Current.Host.Source:
if (Uri.TryCreate(App.Current.Host.Source, "/Collection/items.bin", out collectionUri))
image.Source = collectionUri;
They've also created a nice MultiScaleImageWrapper to encapsulate all the panning and zooming into one class.
I wasn't sure what to make of this project when I started looking at it. The Project Description kind of made my eyes gloss over:
NetFXHarmonics DevServer is a web server hosting environment built on WPF and WCF technologies that allows multiple instances of Cassini-like web servers to run in parallel. DevServer also includes tracing capabilities for monitoring requests and responses, request filtering, automatic ViewState and ControlState parsing, visually enhanced HTTP status codes, IP binding modes for both local-only as well as remote access, and easy to use XML configuration.
Other than the WCF app we built at my last company, I haven't seen a lot of WCF stuff, and DevServer is an interesting and complete example of a Cassini-like Web Server. He wrote it because he wanted to more easily debug multiple WCF Services and ASP.NET Web Sites all working together. Rather than using client-side or sniffing tools, why not just take over the server?
The source is interesting to read holistically, but is also full of little useful utility methods. He parses out, decodes, and displays ViewState, shows headers, formatted and raw content, etc.
David Betz is a very prolific writer of code and has a number of projects up on CodePlex he's given back to the community. One particularly interesting one is his Minima .NET 3.5 Blog Engine that he uses as a training tool. It also, of course, runs his blog. Spend some time over there, there's lots to learn.
Visual LINQ Query Builder
LINQ is a little confusing and it can be difficult to visualize your queries and write them. Mitsu from MS France and his two French Students Simon Ferquel and Johanna Piou have written a Visual Query Builder for LINQ and enabled it in Visual Studio as an Add-In.
The Add-In uses WPF and has a number of cool animations and a fresh UI design. You can drag your LINQ to SQL classes in from the Class View and visually build the LINQ query using dynamically generated Listboxes and an innovative Tree View I've not seen before.
The Results pane shows not only a preview of the data that will be returned, but also the generated SQL and the generated LINQ query and code. The results are put in a static method in a static utility class.
All the better, the code is available and while it feels early and beta-esque, it's an interesting read. I really enjoy looking at how folks lay out their solution structures.
They've also made liberal use of Class Diagrams, presumably because they're students, but also because they are attentive to detail, so for the harder parts, like Query Formatting, there is an associated Class Diagram. Another feature of VS2008 I always forget.
They've factored out an interesting VS Integration Project that could be of help to folks who are interested in making a Visual Designer and plugging it into Visual Studio. There's also a number of interesting WPF Controls like a "MultiStepControl" and "TreeListView."
This is an exceedingly large amount of work, and it's going to take me a while to digest it. In some ways it feels brilliant and in others it seems incredibly complex, possibly overly so. Fortunately, you don't have to read the source, you can just use by installing their MSI if you like.