Scott Hanselman

The Weekly Source Code 23 - Big Solution Edition

April 10, 2008 Comment on this post [8] Posted in Source Code
Sponsored By

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."

BigPicture

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)
{
if (!isInitialMotionFinished)
{
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:

Uri collectionUri;
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.

DevServer

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.

image_2

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.

 vlinq

image 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.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
April 10, 2008 18:00
Hello Scott,

I installed the query builder and I find so cool. I'm a big fan of your podcasts and I deeply appreciate the effort you put so that we stay in touch with the latest technologies.
Keep up the good work!

ps: There are some errors on your website when displayed with firefox, but I'm sure you are aware of this

Regards,
Razvan Dimescu
April 10, 2008 20:00
Is this blog layout borked for anyone else in FF2? On my system comment/content section takes up 100% of the width and the right sidebar is below the comment/content section.
April 10, 2008 20:03
Ok, it's just this one post and the main page.
April 10, 2008 20:16
Yes, the layout width is maxed for me as well (FF2)
April 10, 2008 22:55
Fixed! Sorry.
April 11, 2008 3:17
FANTASTIC: SINGLE LINE CODE SNIPPETS IN RSS FEED!
April 11, 2008 8:07
Scott, as always thanks for providing great resources for us to check out.
April 17, 2008 1:28
That Visual LINQ add-in is pretty amazing, thanks for the link!

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.