Windows (Home) Server 2008

Last weekend I went down to the local (geek) hardware store and bought myself a 640Gb drive and 2Gb of RAM for my home made Windows Home Server box (for a total of AU$150). After a painless hardware upgrade I then downloaded and installed the latest Virtual Server 2005. I installed the 640Gb drive as a “back-up drive” instead of adding it to the Windows Home Server “disk pool” using the Windows Home Server Power Pack 1 Beta. This gave me two benefits – first it meant that I could then use the drive to actually backup the server shares automatically, and secondly it meant that the drive was not going to be affected by the routine “disk balancing” that Windows Home Server performs on the storage pool.

Windows Home Server Power Pack 1

So with plenty of spare RAM and disk space I could then easily create a virtual machine instance running Windows Server 2008 with a copy of SQL Server 2008 RC0. This is the first real chance I’ve had to take a look at the new features in SQL Server 2008 (the main reason for the install). Initial thoughts… new DataTypes – nice! Built in Change Tracking in conjunction with ADO.NET Sync Services… funky!

Billy Hollis on dnrTV

Just finished watching Billy Hollis demo a WPF application on dnrTV that he and his business partners have been working on for one of their clients. I thought it was a great example of how a WPF application can take advantage of WPFs strengths to add some new UI interaction around common requirements for line of business applications. These included things like navigation, dirty checking, modal forms etc. Well worth watching. Billy also commented that the application was put together without the aid of a UI designer – just three developers with a bent for good UI design.

Dynamic Data

Tonight on the commute home I listened to a recent DNR podcast (show 349) where Carl and Richard interview Scott Hunter a program manager on the ASP.NET team working on Dynamic Data. I’ve heard enough about the topic before (e.g. his interview with Scott Hanselman) to understand the basics. But what I really liked about the DNR interview was when Scott described that their intent to have it work with multiple client technologies – web forms, MVC ASP.NET, Silverlight and one would have to assume WPF.

The Dynamic Data attributes have been specifically placed in a UI agnostic namespace – System.ComponentModel.DataAnnotations. It makes me feel all warm and fuzzy when I see the MS teams communicating or thinking “big picture”. I’m still hopeful we might get a System.ComponentModel.Validation namespace?

"Star"tlingly Bad Code

Scott Hanselman’s got my attention this morning with his recent endeavour to launch a community driven reference application for WPF. If you haven’t already read about BabySmash! go read about it here and check it out on codeplex here.

Scott mentions that the whole thing was put together whilst his wife was watching a rather unappealing movie. He then goes on to mention that the code is bad – really bad. What gets me though is that he has the audacity, nay the gall to suggest that just because he is capable of writing lame-ass code that by some bizarre form of association that his readers too sometimes write code like this. Now – I’ve downloaded the source code for BabySmash! – and let me tell you the code is pretty ugly. If Scott thinks that I’d ever let code like that be published under my name then… wait… ah… BUGGER! He’s used some of my code! What’s worse – he used probably the MOST lame-ass piece of code I’ve ever blogged (oh heck – yes OK I’m sure there are even worse examples of mine).

The code in question was a class I blogged about in November last year. I should point out that I made it very clear at the top of the post that this was more or less a rant – “dribble code” if you will. Its a very simply class that derives from Shape to draw a Star.

The method I used to draw the star was to take a triangle and simply “stamp” it out multiple times, rotating it around a central axis. The very clever WPF GetOutlinedPathGeometry is then used to clean up all the mess and consolidate into just the outline of the star.

Here’s the original code that appears now in Scott’s BabySmash:

public static Geometry CreateStarGeometry(int numberOfPoints)
GeometryGroup group = new GeometryGroup();
group.FillRule = FillRule.Nonzero;
Geometry triangle = PathGeometry.Parse("M 0,-30 L 10,10 -10,10 0,-30");
double deltaAngle = 360 / numberOfPoints;
double currentAngle = 0;
for (int index = 1; index < numberOfPoints; index++)
currentAngle += deltaAngle;
triangle = triangle.CloneCurrentValue();
triangle.Transform = new RotateTransform(currentAngle, 0, 0);
Geometry outlinePath = group.GetOutlinedPathGeometry();
return outlinePath;

The code that I replaced that with the first time I actually used the Star class in an application (for a rating indicator) is shown below. It takes what I think is a much neater approach and is a little easier to configure with an inner and outer radius.

public static Geometry CreateStarGeometry2(
int numberOfPoints,
int outerRadius,
int innerRadius,
Point offset) { List<PathSegment> segments = new List<PathSegment>(); double angleOffset = Math.PI * 2 / numberOfPoints; for (double angle = 0; angle < Math.PI * 2; angle += angleOffset) { double innerAngle = angle + angleOffset / 2; Point outerPoint = new Point(
Math.Sin(angle) * outerRadius + offset.X,
Math.Cos(angle) * -outerRadius + offset.Y); Point innerPoint = new Point(
Math.Sin(innerAngle) * innerRadius + offset.X,
Math.Cos(innerAngle) * -innerRadius + offset.Y); segments.Add(new LineSegment(outerPoint, true)); segments.Add(new LineSegment(innerPoint, true)); } List<PathFigure> figures = new List<PathFigure>(); figures.Add(new PathFigure(
new Point(0 + offset.X, -outerRadius + offset.Y),
segments, true)); Geometry star = new PathGeometry(figures); return star; }

As embarrassed as I am that my Star class has meandered its way to such a large audience – I must admit I kinda got a kick out of seeing this in Scott’s code .

In terms of the BabySmash! application itself – I think this is a great idea. Firstly from the point of view that I also have two young kids who love spending time with me on the computers. The younger two year old is at the stage where she recognizes most of the alphabet and loves typing random letters and seeing them appear on the screen. I wrote my WinForms animation sample primarily because my oldest(then 4) got a kick out of watching the bits dance around the screen (a later version included A-Z characters). [Alas he’s now turned 5 and has since moved on to solving Bloxorz levels – scary!]

Secondly the idea of a community driven WPF application just sounds like a great idea. I’ve been very slowly trying to build my own “hobby” application using WPF. Stumbling and being sidetracked at every turn – all very educational for me – but certainly delaying any semblance of a deliverable. Maybe Scott’s approach is the way to go – hack it together ASAP – then let the community work together to discuss, refactor and enhance?