<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Programming</title>
        <link>http://nimblecoder.com/blog/category/19.aspx</link>
        <description>Generic programming information</description>
        <language>en-US</language>
        <copyright>Ryan Van Slooten</copyright>
        <generator>Subtext Version 2.1.1.1</generator>
        <item>
            <title>Animated Clocks for SVG and Silverlight</title>
            <link>http://nimblecoder.com/blog/archive/2009/12/30/animated-clocks-for-svg-and-silverlight.aspx</link>
            <description>&lt;p&gt;At one point in time I found a cool clock graphic and I was looking for it again because it gave a fairly detailed explanation on making a nice looking vector based clock (it was the Codeproject article by &lt;a href="http://www.codeproject.com/KB/dotnet/vgclock.aspx"&gt;Marc Clifton&lt;/a&gt;). During my search I found numerous implementations of both SVG and Silverlight clocks and I decided to catalog my findings.&lt;/p&gt;  &lt;p&gt;The animated clocks are not necessarily practical to display on web pages, but an interesting exercise and fun as well.&lt;/p&gt;  &lt;h2&gt;SVG Clocks&lt;/h2&gt;  &lt;h3&gt;&lt;a href="http://www.adobe.com/svg/demos/clock.html" target="_blank"&gt;Adobe SVG Clock&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://www.adobe.com/svg/demos/clock.html"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="AdobeSvgClock" border="0" alt="AdobeSvgClock" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/AdobeSvgClock.png" width="185" height="217" /&gt;&lt;/a&gt; by Adobe (unknown date)&lt;/p&gt;  &lt;p&gt;A very basic looking clock that uses three &amp;lt;animateTransform type="rotate"&amp;gt; for the hour, minute, and second hands along with a load script to initialize the hands. Note that Adobe has discontinued their SVG Viewer and there are conflicts between SVG and Flash.    &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://realtech.burningbird.net/graphics/svg/experiments-svg-clock" target="_blank"&gt;Experiments: SVG Clock&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/BurningBirdSvgClock.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="BurningBirdSvgClock" border="0" alt="BurningBirdSvgClock" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/BurningBirdSvgClock_thumb.png" width="215" height="213" /&gt;&lt;/a&gt; by Shelley Powers on November 30, 2007&lt;/p&gt;  &lt;p&gt;This is an improvement on a very simple SVG clock by Jason Davis (the original link was not working). This implementation supports displaying time in a different time zone rather than the user’s current time using the statement: &lt;span style="font-family: courier new, fixed"&gt;setInterval("setClock(calcTime(-6))", 1000);&lt;/span&gt;. The code is licensed with LGPL.&lt;/p&gt;  &lt;p&gt;I had to download the file directly as it was not shown in FF 3.5. The author has a rather appropriate statement in the article:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Is the clock worth the extra burden on the client's machine? Yes, and no. As a demonstration of what you can do with SVG and simple animation, I think it's a valuable tool. There is a Catch 22 about SVG: we don't use SVG because browser support is incomplete or inefficient; effort to better incorporate SVG is of secondary importance because SVG is little used. The only way to break this cycle is to actually start using the specification, and pushing a bit at the edges while we go about it.&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;&lt;a href="http://en.wikipedia.org/wiki/File:Binary_clock.svg" target="_blank"&gt;Binary Clock&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/File:Binary_clock.svg"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="200px-Binary_clock_svg" border="0" alt="200px-Binary_clock_svg" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/200pxBinary_clock_svg.png" width="200" height="147" /&gt;&lt;/a&gt; by Alexander Jones &amp;amp; Eric Pierce from Wikipedia on October 14, 2006&lt;/p&gt;  &lt;p&gt;This is Wikipedia entry that I thought was animated but it turns out it is not animated. Bummer. It wouldn’t be hard to animate though.  &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://kamhungsoh.com/000d.xhtml"&gt;SVG + Javascript Analogue Clocks&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://kamhungsoh.com/000d.xhtml"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SvgJavascriptAnalogueClock" border="0" alt="SvgJavascriptAnalogueClock" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/SvgJavascriptAnalogueClock.png" width="240" height="118" /&gt;&lt;/a&gt; by Kam-Hung Soh&lt;/p&gt;  &lt;p&gt;This example uses Javascript at the DOM document level rather than inside the SVG document to rotate the clock hands. It also uses a regular expression to change the rotation angle.    &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://tavmjong.free.fr/INKSCAPE/DRAWINGS/clock2.svg" target="_blank"&gt;Animated SVG Clock Gears&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://tavmjong.free.fr/INKSCAPE/DRAWINGS/clock2.svg"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="AnimatedClockGears" border="0" alt="AnimatedClockGears" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/AnimatedClockGears.png" width="244" height="87" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;by &lt;a href="http://tavmjong.free.fr/" target="_blank"&gt;Tavmjong Bah&lt;/a&gt; (unknown date)&lt;/p&gt;  &lt;p&gt;This is a really cool example created with &lt;a href="http://www.inkscape.org/" target="_blank"&gt;Inkscape&lt;/a&gt; where every gear is independent and does not interfere with other gears. According to the author, the gears outlines were generated with a Python script by Aaron Spike.     &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://oskamp.dyndns.org/SiemensClock/SVG/" target="_blank"&gt;Siemens Wall Clock&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://oskamp.dyndns.org/SiemensClock/SVG/"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SiemensWallClockSvg" border="0" alt="SiemensWallClockSvg" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/SiemensWallClockSvg.png" width="240" height="236" /&gt;&lt;/a&gt; by &lt;a href="http://oskamp.dyndns.org/" target="_blank"&gt;Stefan Oskamp&lt;/a&gt; (unknown date)&lt;/p&gt;  &lt;p&gt;A nice looking clock that uses inline SVG along with a Javascript setInterval function to adjust the rotate attributes for the hour, minute, and second hands. The actual background is a 256 x 256 PNG file, rather than a vector based image.    &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://labs.ibuildstuff.net/?p=svgclock" target="_blank"&gt;An SVG Clock&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://labs.ibuildstuff.net/?p=svgclock"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SvgClockWithCountdown" border="0" alt="SvgClockWithCountdown" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/SvgClockWithCountdown.png" width="200" height="209" /&gt;&lt;/a&gt; by Damien Dawber (ibuildstuff.net)&lt;/p&gt;  &lt;p&gt;This clock is a self generated SVG image using JavaScript and the &lt;a href="http://raphaeljs.com/"&gt;Raphael&lt;/a&gt; JavaScript Vector Library.     &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://anomaly.org/wade/projects/svgClocks/" target="_blank"&gt;SVG Clock Gallery&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/SimpleAnalogClock.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SimpleAnalogClock" border="0" alt="SimpleAnalogClock" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/SimpleAnalogClock_thumb.png" width="220" height="210" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;by &lt;a href="http://anomaly.org/wade/index.html"&gt;G. Wade Johnson&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;A clock with a sunburst effect that uses an external script to drive the animation. The author also has a version that runs backwards by simply changing a parameter in the initialization script.    &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://staticfree.info/projects/24h_clock/" target="_blank"&gt;24-Hour '12'-at-the-top Analog Clock&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://staticfree.info/projects/24h_clock/"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="24h_clock_v2.2" border="0" alt="24h_clock_v2.2" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/24h_clock_v2.2.png" width="240" height="239" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;by &lt;a href="http://staticfree.info/"&gt;Steve Pomery&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;A nice looking clock created using Inkscape. Now at version 2.2.  &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://chriswjohnson.blogspot.com/2008/04/svg-resurgent.html" target="_blank"&gt;SVG Resurgent&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://chriswjohnson.blogspot.com/2008/04/svg-resurgent.html"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SvgResurgentClock" border="0" alt="SvgResurgentClock" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/SvgResurgentClock.png" width="200" height="200" /&gt;&lt;/a&gt; by &lt;a href="http://chriswjohnson.blogspot.com/"&gt;Chris W. Johnson&lt;/a&gt; on April 29, 2008&lt;/p&gt;  &lt;p&gt;An inline base64 encoded SVG clock. The SVG has a version of the Google analytics tracking script "because it's nice to know if people care."    &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h2&gt;Silverlight Clocks&lt;/h2&gt;  &lt;h3&gt;&lt;a href="http://silverlight.net/samples/1.0/clock/default.html" target="_blank"&gt;Microsoft Silverlight Clock Samples&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://silverlight.net/samples/1.0/clock/default.html"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Silverlight1ClockSample" border="0" alt="Silverlight1ClockSample" align="left" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/Silverlight1ClockSample.png" width="240" height="212" /&gt;&lt;/a&gt; by Microsoft&lt;/p&gt;  &lt;p&gt;A &lt;a href="http://silverlight.net/samples/1.0/clock/default.html"&gt;clock sample&lt;/a&gt; from the Silverlight 1.0 SDK which uses clock.xaml and clock.js to create the clock. The result is actually very similar to some of the SVG implementations since Silverlight 1.0 did not have codebehind capability.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://silverlight.net/content/samples/sl2/clock/run/index.html"&gt;Version 2.0&lt;/a&gt; of the clock uses codebehind along with a XAP file. There is also a &lt;a href="http://www.silverlight.net/content/samples/sl2/ruby-clock/index.html"&gt;version using IronRuby&lt;/a&gt; although the XAP file is significantly larger (11KB vs 1MB!) because it includes several assemblies in the XAP. Then there is the &lt;a href="https://silverlight.net/content/samples/sl2/python-clock/index.html"&gt;Python version&lt;/a&gt; as well which is almost identical to the Ruby version except for the language substitution.&lt;/p&gt;  &lt;p&gt;There is also a Microsoft walk-through: &lt;a href="http://msdn.microsoft.com/en-us/library/bb404709%28VS.95%29.aspx"&gt;Creating a Silverlight Clock by Using Expression Blend or Code&lt;/a&gt;, which has a detailed step by step guide for Expression Blend.     &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.codeproject.com/KB/dotnet/vgclock.aspx" target="_blank"&gt;A Vector Graphics Rendered Animated Clock&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://www.codeproject.com/KB/dotnet/vgclock.aspx"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="VectorGraphicsRenderedClock" border="0" alt="VectorGraphicsRenderedClock" align="left" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/VectorGraphicsRenderedClock.png" width="209" height="210" /&gt;&lt;/a&gt; by Marc Clifton on April 18, 2004&lt;/p&gt;  &lt;p&gt;A very nice looking clock complete with a walkthrough on how to create the look and feel of the clock. Technically this isn’t a Silverlight clock as it is intended for the (now defunct) &lt;a href="http://www.myxaml.com/"&gt;MyXaml&lt;/a&gt; and then improved upon by &lt;a href="http://www.vgdotnet.com/"&gt;VG.net&lt;/a&gt;. The graphics should be mostly compatible with Silverlight though I haven’t tested it yet.     &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.silverlightshow.net/items/Developing-Silverlight-Analog-Clock-pattern-oriented-approach.aspx" target="_blank"&gt;Developing Silverlight Analog Clock – pattern oriented approach&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://www.silverlightshow.net/items/Developing-Silverlight-Analog-Clock-pattern-oriented-approach.aspx"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="SilverlightClockPatternOriented" border="0" alt="SilverlightClockPatternOriented" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/SilverlightClockPatternOriented.png" width="207" height="204" /&gt;&lt;/a&gt; &lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/SilverlightClockPatternOriented2.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SilverlightClockPatternOriented2" border="0" alt="SilverlightClockPatternOriented2" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/SilverlightClockPatternOriented2_thumb.png" width="239" height="240" /&gt;&lt;/a&gt; by Pencho Popadiyn on October 30, 2008&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.silverlightshow.net/items/Developing-Silverlight-Analog-Clock-pattern-oriented-approach.aspx"&gt;Version 1&lt;/a&gt; introduces the MVP design pattern and the design of the clock using the MVP pattern.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.silverlightshow.net/items/Developing-Silverlight-AnalogClock-part-2-Enhancing-the-view.aspx" target="_blank"&gt;Version 2&lt;/a&gt; - This implementation uses VS2008, .NET 3.5, Silverlight 2 using an MVP pattern. The sample has a very nice looking graphic and improves upon the Clock view.     &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://hybridclock.codeplex.com/" target="_blank"&gt;Hybrid Clock in Silverlight 2&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://hybridclock.codeplex.com/"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="HybridClock" border="0" alt="HybridClock" align="left" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/HybridClock.png" width="167" height="155" /&gt;&lt;/a&gt; by &lt;a href="http://www.alexanderbell.us/"&gt;Alex Bell&lt;/a&gt; on November 7, 2008 (based on SVN timestamps)&lt;/p&gt;  &lt;p&gt;A modest clock using Silverlight although the author claims: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Hybrid Clock is, by far, the most sophisticated animated Date/Time visualization control developed for Microsoft Silverlight™ 2.0.      &lt;br clear="left" /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;&lt;a href="http://blogs.msdn.com/synergist/archive/2008/05/24/beauty-with-silverlight.aspx" target="_blank"&gt;Beauty with Silverlight: Ball Watch Animation&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/BallWatchSilverlight.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="BallWatchSilverlight" border="0" alt="BallWatchSilverlight" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/BallWatchSilverlight_thumb.png" width="200" height="200" /&gt;&lt;/a&gt;by Michael S. Scherotter on April 24, 2008&lt;/p&gt;  &lt;p&gt;This is a gorgeous clock using Silverlight, Expression Blend, and Expression Design. For some reason this is a Silverlight 1.0 applet instead of 2.0 which means it uses some Javascript event triggering for the loading, but it looks great.    &lt;br clear="left" /&gt;&lt;/p&gt;  &lt;h3&gt;Miscellaneous Silverlight Clocks&lt;/h3&gt;  &lt;p&gt;I was taking way too much time, so here are other implementations without screen shots.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.c-sharpcorner.com/UploadFile/nipuntomar/SilverlightClock08122008132436PM/SilverlightClock.aspx" href="http://www.c-sharpcorner.com/UploadFile/nipuntomar/SilverlightClock08122008132436PM/SilverlightClock.aspx"&gt;http://www.c-sharpcorner.com/UploadFile/nipuntomar/SilverlightClock08122008132436PM/SilverlightClock.aspx&lt;/a&gt; – A good Silverlight clock.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://pixelplastic.de/2008/01/12/ZoomableUltraHighResolutionSilverlightClock.aspx" href="http://pixelplastic.de/2008/01/12/ZoomableUltraHighResolutionSilverlightClock.aspx"&gt;http://pixelplastic.de/2008/01/12/ZoomableUltraHighResolutionSilverlightClock.aspx&lt;/a&gt; – A Silverlight clock that allows the user to drag and move the clock. The applet did not work in IE or FF, so I assume it was developed with a pre-release version and has not been updated on the blog article. You can download the source code though. Marcel Hoyer has an &lt;a href="http://pixelplastic.de/2008/10/20/UpdatedSilverlightDemosClockAttractorBezier.aspx"&gt;older version of the clock&lt;/a&gt; as well as other cool Silverlight examples on his blog.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://weblogs.asp.net/andrewrea/archive/2009/08/12/programmatic-drawing-with-silverlight-2-0-3-0-an-analogue-clock.aspx" href="http://weblogs.asp.net/andrewrea/archive/2009/08/12/programmatic-drawing-with-silverlight-2-0-3-0-an-analogue-clock.aspx"&gt;http://weblogs.asp.net/andrewrea/archive/2009/08/12/programmatic-drawing-with-silverlight-2-0-3-0-an-analogue-clock.aspx&lt;/a&gt; – A basic looking clock although the clock is mostly generated by code (tick marks, etc.) which is cool. The blog post has a lengthy code listing and downloadable code.&lt;/p&gt;  &lt;h2&gt;WPF Clocks&lt;/h2&gt;  &lt;h3&gt;&lt;a href="http://www.charlespetzold.com/blog/2006/04/070132.html" target="_blank"&gt;Another Xamlifferous Experience (an All-XAML Clock)&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/AllXamlClock.png" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="AllXamlClock" border="0" alt="AllXamlClock" align="left" src="http://www.nimblecoder.com/blog/Images/nimblecoder_com/blog/WindowsLiveWriter/SilverlightClocks_12166/AllXamlClock_thumb.png" width="228" height="224" /&gt;&lt;/a&gt; by &lt;a href="http://www.charlespetzold.com/"&gt;Charles Petzold&lt;/a&gt; on April 7, 2006&lt;/p&gt;  &lt;p&gt;This is an all XAML clock without any C# or .NET code. It was based on a Microsoft sample and Charles Petzold improved upon that sample by eliminating the C# code, improved the animation technique, and eliminated the repetition in the XAML. The clock graphic is basic and not fancy, but practical.    &lt;br clear="left" /&gt;&lt;/p&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/78.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2009/12/30/animated-clocks-for-svg-and-silverlight.aspx</guid>
            <pubDate>Wed, 30 Dec 2009 07:17:17 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/78.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2009/12/30/animated-clocks-for-svg-and-silverlight.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/78.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/78.aspx</trackback:ping>
        </item>
        <item>
            <title>Spinning Wait Symbol in Silverlight, Part 2</title>
            <link>http://nimblecoder.com/blog/archive/2008/10/20/spinning-wait-symbol-in-silverlight-part-2.aspx</link>
            <description>&lt;p&gt;After my &lt;a href="http://www.nimblecoder.com/blog/archive/2008/10/08/spinning-wait-symbol-in-silverlight.aspx"&gt;previous spinning wait symbol&lt;/a&gt;, I decided to see how difficult it would be to create a &lt;a href="http://silverlight.net/"&gt;Silverlight&lt;/a&gt; version of the &lt;a href="http://en.wikipedia.org/wiki/Spinning_wait_cursor_(Mac_OS_X)"&gt;Mac OSX wait cursor&lt;/a&gt; that I referenced in the &lt;a href="http://www.nimblecoder.com/blog/archive/2008/10/08/spinning-wait-symbol-in-silverlight.aspx"&gt;previous post&lt;/a&gt;. The Mac OSX cursor is commonly referred to as the "Spinning Pizza of Death" or the "Marble of Doom" and in fact there is a &lt;a href="http://marbleofdoom.com/"&gt;Marble of Doom&lt;/a&gt; web site dedicated to the amount of time spent waiting while watching the spinning cursor. The Marble of Doom web site has a very nice and large version of the cursor using Flash although it doesn't have any vector information but is using video frames (they probably just published the final product and did not include the vector/animation information). The purpose of this post is to programmatically build the cursor and then in later posts to animate it.&lt;/p&gt; &lt;h4&gt;Step 1: Decide on the initial interface properties&lt;/h4&gt; &lt;p&gt;I realized quickly that I would need a little geometry to programmatically build the cursor, but the first step was to build the interface requirements. The essential properties were:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: navy"&gt;public int &lt;/span&gt;&lt;span style="color: maroon"&gt;SliceCount &lt;/span&gt;{ &lt;span style="color: navy"&gt;get&lt;/span&gt;; &lt;span style="color: navy"&gt;set&lt;/span&gt;; }
&lt;span style="color: navy"&gt;public double &lt;/span&gt;&lt;span style="color: maroon"&gt;SliceCenterAngle &lt;/span&gt;{ &lt;span style="color: navy"&gt;get&lt;/span&gt;; &lt;span style="color: navy"&gt;private set&lt;/span&gt;; }
&lt;span style="color: navy"&gt;public double &lt;/span&gt;&lt;span style="color: maroon"&gt;SliceRotationAngle &lt;/span&gt;{ &lt;span style="color: navy"&gt;get&lt;/span&gt;; &lt;span style="color: navy"&gt;set&lt;/span&gt;; }
&lt;span style="color: navy"&gt;public double &lt;/span&gt;&lt;span style="color: maroon"&gt;RadiusX &lt;/span&gt;{ &lt;span style="color: navy"&gt;get&lt;/span&gt;; &lt;span style="color: navy"&gt;set&lt;/span&gt;; }
&lt;span style="color: navy"&gt;public double &lt;/span&gt;&lt;span style="color: maroon"&gt;RadiusY &lt;/span&gt;{ &lt;span style="color: navy"&gt;get&lt;/span&gt;; &lt;span style="color: navy"&gt;set&lt;/span&gt;; }
&lt;/pre&gt;
&lt;p&gt;The &lt;span style="color: maroon"&gt;SliceCount&lt;/span&gt; determines how many slices or divisions to create, and the &lt;span style="color: maroon"&gt;SliceCenterAngle&lt;/span&gt; is simply 360° / &lt;span style="color: maroon"&gt;SliceCount&lt;/span&gt;. The &lt;span style="color: maroon"&gt;SliceRotationAngle&lt;/span&gt; is the angle to twist or bend the slice. I decided to have a &lt;span style="color: maroon"&gt;RadiusX&lt;/span&gt; and &lt;span style="color: maroon"&gt;RadiusY&lt;/span&gt; to support ellipses in the future as well.&lt;/p&gt;
&lt;h4&gt;Step 2: Manually create a slice&lt;/h4&gt;
&lt;p&gt;&lt;a href="http://nimblecoder.com/blog/images/nimblecoder_com/blog/WindowsLiveWriter/SpinningWaitSymbolinSilverlightPart2_96B0/SpinningCursor1-SliceInBlend.png"&gt;&lt;img height="147" alt="Manual slice in Blend" src="http://nimblecoder.com/blog/images/nimblecoder_com/blog/WindowsLiveWriter/SpinningWaitSymbolinSilverlightPart2_96B0/SpinningCursor1-SliceInBlend_thumb.png" width="240" align="right" /&gt;&lt;/a&gt; Before I could programmatically create a slice, I needed to find out how to create a slice using XAML and Blend. The points on the slice would be in the center of the circle, and then two points on the circle determined by the &lt;span style="color: maroon"&gt;SliceCenterAngle&lt;/span&gt;. The biggest question was how to create the arc and maintain the circular appearance. Fortunately, the &lt;a href="http://msdn.microsoft.com/en-us/library/ms751808.aspx"&gt;Geometry Overview&lt;/a&gt; on MSDN was very helpful and got me started on the right track with the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.media.pathgeometry.aspx"&gt;PathGeometry&lt;/a&gt;. I was able to create the simplest scenario with a single slice from a circle with four slices:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path &lt;/span&gt;&lt;span style="color: red"&gt;Stroke&lt;/span&gt;&lt;span style="color: blue"&gt;="Black" &lt;/span&gt;&lt;span style="color: red"&gt;StrokeThickness&lt;/span&gt;&lt;span style="color: blue"&gt;="1"&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path.Data&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathGeometry&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;            &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathGeometry.Figures&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="50,50"&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                    &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure.Segments&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LineSegment &lt;/span&gt;&lt;span style="color: red"&gt;Point&lt;/span&gt;&lt;span style="color: blue"&gt;="0,50" /&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ArcSegment &lt;/span&gt;&lt;span style="color: red"&gt;Size&lt;/span&gt;&lt;span style="color: blue"&gt;="50,50" &lt;/span&gt;&lt;span style="color: red"&gt;IsLargeArc&lt;/span&gt;&lt;span style="color: blue"&gt;="False"
                            &lt;/span&gt;&lt;span style="color: red"&gt;RotationAngle&lt;/span&gt;&lt;span style="color: blue"&gt;="90" &lt;/span&gt;&lt;span style="color: red"&gt;SweepDirection&lt;/span&gt;&lt;span style="color: blue"&gt;="CounterClockwise" &lt;/span&gt;&lt;span style="color: red"&gt;Point&lt;/span&gt;&lt;span style="color: blue"&gt;="50,100" /&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LineSegment &lt;/span&gt;&lt;span style="color: red"&gt;Point&lt;/span&gt;&lt;span style="color: blue"&gt;="50,50" /&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                    &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure.Segments&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;            &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathGeometry.Figures&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathGeometry&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path.Data&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The next step was to create the same quarter-circle except with two slices:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path &lt;/span&gt;&lt;span style="color: red"&gt;Stroke&lt;/span&gt;&lt;span style="color: blue"&gt;="Black" &lt;/span&gt;&lt;span style="color: red"&gt;StrokeThickness&lt;/span&gt;&lt;span style="color: blue"&gt;="1"&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path.Data&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathGeometry&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;            &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathGeometry.Figures&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="50,50"&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                    &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure.Segments&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LineSegment &lt;/span&gt;&lt;span style="color: red"&gt;Point&lt;/span&gt;&lt;span style="color: blue"&gt;="0,50" /&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ArcSegment
                            &lt;/span&gt;&lt;span style="color: red"&gt;Size&lt;/span&gt;&lt;span style="color: blue"&gt;="50,50"
                            &lt;/span&gt;&lt;span style="color: red"&gt;Point&lt;/span&gt;&lt;span style="color: blue"&gt;="14.645,85.355" 
                            &lt;/span&gt;&lt;span style="color: red"&gt;RotationAngle&lt;/span&gt;&lt;span style="color: blue"&gt;="45" 
                            &lt;/span&gt;&lt;span style="color: red"&gt;IsLargeArc&lt;/span&gt;&lt;span style="color: blue"&gt;="False"
                            &lt;/span&gt;&lt;span style="color: red"&gt;SweepDirection&lt;/span&gt;&lt;span style="color: blue"&gt;="CounterClockwise" 
                        /&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LineSegment &lt;/span&gt;&lt;span style="color: red"&gt;Point&lt;/span&gt;&lt;span style="color: blue"&gt;="50,50" /&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                    &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure.Segments&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                
                &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="50,50"&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                    &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure.Segments&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LineSegment &lt;/span&gt;&lt;span style="color: red"&gt;Point&lt;/span&gt;&lt;span style="color: blue"&gt;="14.645,85.355" /&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ArcSegment
                            &lt;/span&gt;&lt;span style="color: red"&gt;Size&lt;/span&gt;&lt;span style="color: blue"&gt;="50,50"
                            &lt;/span&gt;&lt;span style="color: red"&gt;Point&lt;/span&gt;&lt;span style="color: blue"&gt;="50, 100" 
                            &lt;/span&gt;&lt;span style="color: red"&gt;RotationAngle&lt;/span&gt;&lt;span style="color: blue"&gt;="45" 
                            &lt;/span&gt;&lt;span style="color: red"&gt;IsLargeArc&lt;/span&gt;&lt;span style="color: blue"&gt;="False"
                            &lt;/span&gt;&lt;span style="color: red"&gt;SweepDirection&lt;/span&gt;&lt;span style="color: blue"&gt;="CounterClockwise" 
                        /&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LineSegment &lt;/span&gt;&lt;span style="color: red"&gt;Point&lt;/span&gt;&lt;span style="color: blue"&gt;="50,50" /&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                    &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure.Segments&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;                &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathFigure&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;            &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathGeometry.Figures&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;        &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;PathGeometry&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="background: #ffffe6"&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path.Data&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;h4&gt;Step 3: Create a slice programmatically&lt;/h4&gt;
&lt;p&gt;The general idea is to create one slice and then rotate the slice around the circle to create the complete circle.&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
/// &lt;/span&gt;&lt;span style="color: green"&gt;Create an ellipse using rotated slices to build the ellipse
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
&lt;/span&gt;&lt;span style="color: navy"&gt;void &lt;/span&gt;&lt;span style="color: maroon"&gt;CreateSlicePaths&lt;/span&gt;(&lt;span style="color: #a65300"&gt;Canvas &lt;/span&gt;&lt;span style="color: maroon"&gt;cursorCanvas&lt;/span&gt;)
{
    &lt;span style="color: maroon"&gt;SliceCenterAngle &lt;/span&gt;= &lt;span style="background: #e6ffff"&gt;360.0&lt;/span&gt; / &lt;span style="color: maroon"&gt;SliceCount&lt;/span&gt;;

    &lt;span style="color: green"&gt;// Create Slices
    &lt;/span&gt;&lt;span style="color: navy"&gt;for &lt;/span&gt;(&lt;span style="color: navy"&gt;int &lt;/span&gt;&lt;span style="color: maroon"&gt;index &lt;/span&gt;= &lt;span style="background: #e6ffff"&gt;0&lt;/span&gt;; &lt;span style="color: maroon"&gt;index &lt;/span&gt;&amp;lt; &lt;span style="color: maroon"&gt;SliceCount&lt;/span&gt;; ++&lt;span style="color: maroon"&gt;index&lt;/span&gt;)
    {
        &lt;span style="color: #a65300"&gt;PathFigure &lt;/span&gt;&lt;span style="color: maroon"&gt;pathFigure &lt;/span&gt;= &lt;span style="color: maroon"&gt;CreateSliceFigure&lt;/span&gt;();

        &lt;span style="color: #a65300"&gt;PathGeometry &lt;/span&gt;&lt;span style="color: maroon"&gt;pathGeometry &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #a65300"&gt;PathGeometry&lt;/span&gt;();
        &lt;span style="color: maroon"&gt;pathGeometry&lt;/span&gt;.&lt;span style="color: maroon"&gt;Figures&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: maroon"&gt;pathFigure&lt;/span&gt;);

        &lt;span style="color: #a65300"&gt;Path &lt;/span&gt;&lt;span style="color: maroon"&gt;path &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #a65300"&gt;Path&lt;/span&gt;();
        &lt;span style="color: maroon"&gt;path&lt;/span&gt;.&lt;span style="color: maroon"&gt;Stroke &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #a65300"&gt;SolidColorBrush&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Color&lt;/span&gt;.&lt;span style="color: maroon"&gt;FromArgb&lt;/span&gt;(&lt;span style="background: #e6ffff"&gt;255&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0&lt;/span&gt;));
        &lt;span style="color: maroon"&gt;path&lt;/span&gt;.&lt;span style="color: maroon"&gt;StrokeThickness &lt;/span&gt;= &lt;span style="background: #e6ffff"&gt;1.0&lt;/span&gt;;
        &lt;span style="color: maroon"&gt;path&lt;/span&gt;.&lt;span style="color: maroon"&gt;Data &lt;/span&gt;= &lt;span style="color: maroon"&gt;pathGeometry&lt;/span&gt;;

        &lt;span style="color: green"&gt;// Rotate the slice for all slices after the first slice
        &lt;/span&gt;&lt;span style="color: navy"&gt;if &lt;/span&gt;(&lt;span style="color: maroon"&gt;index &lt;/span&gt;&amp;gt; &lt;span style="background: #e6ffff"&gt;0&lt;/span&gt;)
        {
            &lt;span style="color: #a65300"&gt;RotateTransform &lt;/span&gt;&lt;span style="color: maroon"&gt;t1 &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #a65300"&gt;RotateTransform&lt;/span&gt;();
            &lt;span style="color: maroon"&gt;t1&lt;/span&gt;.&lt;span style="color: maroon"&gt;CenterX &lt;/span&gt;= &lt;span style="color: maroon"&gt;RadiusX&lt;/span&gt;;
            &lt;span style="color: maroon"&gt;t1&lt;/span&gt;.&lt;span style="color: maroon"&gt;CenterY &lt;/span&gt;= &lt;span style="color: maroon"&gt;RadiusY&lt;/span&gt;;
            &lt;span style="color: maroon"&gt;t1&lt;/span&gt;.&lt;span style="color: maroon"&gt;Angle &lt;/span&gt;= &lt;span style="color: maroon"&gt;SliceCenterAngle &lt;/span&gt;* &lt;span style="color: maroon"&gt;index&lt;/span&gt;;

            &lt;span style="color: #a65300"&gt;TransformGroup &lt;/span&gt;&lt;span style="color: maroon"&gt;transformGroup &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #a65300"&gt;TransformGroup&lt;/span&gt;();
            &lt;span style="color: maroon"&gt;transformGroup&lt;/span&gt;.&lt;span style="color: maroon"&gt;Children&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: maroon"&gt;t1&lt;/span&gt;);
            &lt;span style="color: maroon"&gt;path&lt;/span&gt;.&lt;span style="color: maroon"&gt;RenderTransform &lt;/span&gt;= &lt;span style="color: maroon"&gt;transformGroup&lt;/span&gt;;
        }

        &lt;span style="color: maroon"&gt;cursorCanvas&lt;/span&gt;.&lt;span style="color: maroon"&gt;Children&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: maroon"&gt;path&lt;/span&gt;);
    }
}

&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
/// &lt;/span&gt;&lt;span style="color: green"&gt;Create the base shape for the slice
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
&lt;/span&gt;&lt;span style="color: navy"&gt;private &lt;/span&gt;&lt;span style="color: #a65300"&gt;PathFigure &lt;/span&gt;&lt;span style="color: maroon"&gt;CreateSliceFigure&lt;/span&gt;()
{
    &lt;span style="color: green"&gt;// Start at the center of the ellipse
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Point &lt;/span&gt;&lt;span style="color: maroon"&gt;point0 &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Point&lt;/span&gt;(&lt;span style="color: maroon"&gt;RadiusX&lt;/span&gt;, &lt;span style="color: maroon"&gt;RadiusY&lt;/span&gt;);

    &lt;span style="color: green"&gt;// Next point is the left side of the ellipse
    //Point point1 = new Point(0.0, RadiusY); // if no rotation
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Point &lt;/span&gt;&lt;span style="color: maroon"&gt;point1 &lt;/span&gt;= &lt;span style="color: maroon"&gt;CalculatePointOnEllipse&lt;/span&gt;(&lt;span style="color: maroon"&gt;SliceRotationAngle&lt;/span&gt;);

    &lt;span style="color: green"&gt;// Calculate the bottom point on the ellipse
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Point &lt;/span&gt;&lt;span style="color: maroon"&gt;point2 &lt;/span&gt;= &lt;span style="color: maroon"&gt;CalculatePointOnEllipse&lt;/span&gt;(&lt;span style="color: maroon"&gt;SliceRotationAngle &lt;/span&gt;+ &lt;span style="color: maroon"&gt;SliceCenterAngle&lt;/span&gt;);

    &lt;span style="color: green"&gt;// Starting point
    &lt;/span&gt;&lt;span style="color: #a65300"&gt;PathFigure &lt;/span&gt;&lt;span style="color: maroon"&gt;pathFigure &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #a65300"&gt;PathFigure&lt;/span&gt;();
    &lt;span style="color: maroon"&gt;pathFigure&lt;/span&gt;.&lt;span style="color: maroon"&gt;StartPoint &lt;/span&gt;= &lt;span style="color: maroon"&gt;point0&lt;/span&gt;;

    &lt;span style="color: green"&gt;// Create the first line
    &lt;/span&gt;&lt;span style="color: #a65300"&gt;LineSegment &lt;/span&gt;&lt;span style="color: maroon"&gt;seg1 &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #a65300"&gt;LineSegment&lt;/span&gt;();
    &lt;span style="color: maroon"&gt;seg1&lt;/span&gt;.&lt;span style="color: maroon"&gt;Point &lt;/span&gt;= &lt;span style="color: maroon"&gt;point1&lt;/span&gt;;
    &lt;span style="color: maroon"&gt;pathFigure&lt;/span&gt;.&lt;span style="color: maroon"&gt;Segments&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: maroon"&gt;seg1&lt;/span&gt;);

    &lt;span style="color: green"&gt;// Use an arc for the circular side
    &lt;/span&gt;&lt;span style="color: #a65300"&gt;ArcSegment &lt;/span&gt;&lt;span style="color: maroon"&gt;seg2 &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #a65300"&gt;ArcSegment&lt;/span&gt;();
    &lt;span style="color: maroon"&gt;seg2&lt;/span&gt;.&lt;span style="color: maroon"&gt;Point &lt;/span&gt;= &lt;span style="color: maroon"&gt;point2&lt;/span&gt;;
    &lt;span style="color: maroon"&gt;seg2&lt;/span&gt;.&lt;span style="color: maroon"&gt;Size &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Size&lt;/span&gt;(&lt;span style="color: maroon"&gt;RadiusX&lt;/span&gt;, &lt;span style="color: maroon"&gt;RadiusY&lt;/span&gt;);
    &lt;span style="color: maroon"&gt;seg2&lt;/span&gt;.&lt;span style="color: maroon"&gt;RotationAngle &lt;/span&gt;= &lt;span style="color: maroon"&gt;SliceCenterAngle&lt;/span&gt;;
    &lt;span style="color: maroon"&gt;seg2&lt;/span&gt;.&lt;span style="color: maroon"&gt;IsLargeArc &lt;/span&gt;= (&lt;span style="color: maroon"&gt;SliceCenterAngle &lt;/span&gt;&amp;gt; &lt;span style="background: #e6ffff"&gt;180.0&lt;/span&gt;);
    &lt;span style="color: maroon"&gt;seg2&lt;/span&gt;.&lt;span style="color: maroon"&gt;SweepDirection &lt;/span&gt;= &lt;span style="color: #2b91af"&gt;SweepDirection&lt;/span&gt;.&lt;span style="color: maroon"&gt;Counterclockwise&lt;/span&gt;;
    &lt;span style="color: maroon"&gt;pathFigure&lt;/span&gt;.&lt;span style="color: maroon"&gt;Segments&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: maroon"&gt;seg2&lt;/span&gt;);

    &lt;span style="color: green"&gt;// Close shape by going back to the starting point
    &lt;/span&gt;&lt;span style="color: #a65300"&gt;LineSegment &lt;/span&gt;&lt;span style="color: maroon"&gt;seg3 &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #a65300"&gt;LineSegment&lt;/span&gt;();
    &lt;span style="color: maroon"&gt;seg3&lt;/span&gt;.&lt;span style="color: maroon"&gt;Point &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Point&lt;/span&gt;(&lt;span style="color: maroon"&gt;point0&lt;/span&gt;.&lt;span style="color: maroon"&gt;X&lt;/span&gt;, &lt;span style="color: maroon"&gt;point0&lt;/span&gt;.&lt;span style="color: maroon"&gt;Y&lt;/span&gt;);
    &lt;span style="color: maroon"&gt;pathFigure&lt;/span&gt;.&lt;span style="color: maroon"&gt;Segments&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: maroon"&gt;seg3&lt;/span&gt;);

    &lt;span style="color: maroon"&gt;pathFigure&lt;/span&gt;.&lt;span style="color: maroon"&gt;IsClosed &lt;/span&gt;= &lt;span style="color: navy"&gt;true&lt;/span&gt;;
    &lt;span style="color: maroon"&gt;pathFigure&lt;/span&gt;.&lt;span style="color: maroon"&gt;IsFilled &lt;/span&gt;= &lt;span style="color: navy"&gt;true&lt;/span&gt;;

    &lt;span style="color: navy"&gt;return &lt;/span&gt;&lt;span style="color: maroon"&gt;pathFigure&lt;/span&gt;;
}

&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
/// &lt;/span&gt;&lt;span style="color: green"&gt;Returns a point on the ellipse based on the rotationAngle, using
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;RadiusX/Y as the center (0, 0).
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
&lt;/span&gt;&lt;span style="color: navy"&gt;private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Point &lt;/span&gt;&lt;span style="color: maroon"&gt;CalculatePointOnEllipse&lt;/span&gt;(&lt;span style="color: navy"&gt;double &lt;/span&gt;&lt;span style="color: maroon"&gt;rotationAngle&lt;/span&gt;)
{
    &lt;span style="color: navy"&gt;double &lt;/span&gt;&lt;span style="color: maroon"&gt;angleRadians &lt;/span&gt;= &lt;span style="color: maroon"&gt;rotationAngle &lt;/span&gt;* &lt;span style="color: #a65300"&gt;Math&lt;/span&gt;.&lt;span style="color: maroon"&gt;PI &lt;/span&gt;/ &lt;span style="background: #e6ffff"&gt;180.0&lt;/span&gt;;
    &lt;span style="color: navy"&gt;double &lt;/span&gt;&lt;span style="color: maroon"&gt;x &lt;/span&gt;= &lt;span style="color: #a65300"&gt;Math&lt;/span&gt;.&lt;span style="color: maroon"&gt;Cos&lt;/span&gt;(&lt;span style="color: maroon"&gt;angleRadians&lt;/span&gt;);
    &lt;span style="color: maroon"&gt;x &lt;/span&gt;= &lt;span style="color: maroon"&gt;RadiusX &lt;/span&gt;* &lt;span style="color: maroon"&gt;x&lt;/span&gt;;
    &lt;span style="color: navy"&gt;double &lt;/span&gt;&lt;span style="color: maroon"&gt;y &lt;/span&gt;= &lt;span style="color: #a65300"&gt;Math&lt;/span&gt;.&lt;span style="color: maroon"&gt;Sin&lt;/span&gt;(&lt;span style="color: maroon"&gt;angleRadians&lt;/span&gt;);
    &lt;span style="color: maroon"&gt;y &lt;/span&gt;= &lt;span style="color: maroon"&gt;RadiusY &lt;/span&gt;* &lt;span style="color: maroon"&gt;y&lt;/span&gt;;

    &lt;span style="color: #2b91af"&gt;Point &lt;/span&gt;&lt;span style="color: maroon"&gt;result &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Point&lt;/span&gt;(&lt;span style="color: maroon"&gt;x&lt;/span&gt;, &lt;span style="color: maroon"&gt;y&lt;/span&gt;);
    &lt;span style="color: maroon"&gt;result&lt;/span&gt;.&lt;span style="color: maroon"&gt;X &lt;/span&gt;= &lt;span style="color: maroon"&gt;RadiusX &lt;/span&gt;- &lt;span style="color: maroon"&gt;x&lt;/span&gt;;
    &lt;span style="color: maroon"&gt;result&lt;/span&gt;.&lt;span style="color: maroon"&gt;Y &lt;/span&gt;= &lt;span style="color: maroon"&gt;RadiusY &lt;/span&gt;+ &lt;span style="color: maroon"&gt;y&lt;/span&gt;;
    &lt;span style="color: navy"&gt;return &lt;/span&gt;&lt;span style="color: maroon"&gt;result&lt;/span&gt;;
}
&lt;/pre&gt;
&lt;h4&gt;Step 4: Going Forward&lt;/h4&gt;
&lt;p&gt;&lt;a href="http://nimblecoder.com/blog/images/nimblecoder_com/blog/WindowsLiveWriter/SpinningWaitSymbolinSilverlightPart2_96B0/SpinningCursor1-TestPage_1.png"&gt;&lt;img height="181" alt="SpinningCursor1-TestPage" src="http://nimblecoder.com/blog/images/nimblecoder_com/blog/WindowsLiveWriter/SpinningWaitSymbolinSilverlightPart2_96B0/SpinningCursor1-TestPage_thumb_1.png" width="240" align="right" /&gt;&lt;/a&gt; Obviously this still needs a lot of improvement before it approaches the appeal of the Marble of Doom, which I will work on in the coming posts. However, the initial effort to create the "pizza" slices has been achieved and it is easier to build upon a base.&lt;/p&gt;
&lt;p&gt;I added a grid in the background when I had some difficulty with the path geometry, but it is useful to I added two text boxes for the number of slices and rotation angle so that I could see the shape update dynamically.&lt;/p&gt;
&lt;p&gt;Since I just used LineSegments to connect the slice points, the shape does not have the swirl or twist effect yet. Next time I will add the twist as well as rotation.&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f5e14260-1dfe-4501-958f-a487a74b5e5d" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/C#" rel="tag"&gt;C#&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Silverlight" rel="tag"&gt;Silverlight&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fwww.nimblecoder.com%2fblog%2farchive%2f2008%2f10%2f20%2fspinning-wait-symbol-in-silverlight-part-2.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.nimblecoder.com%2fblog%2farchive%2f2008%2f10%2f20%2fspinning-wait-symbol-in-silverlight-part-2.aspx" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/73.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2008/10/20/spinning-wait-symbol-in-silverlight-part-2.aspx</guid>
            <pubDate>Mon, 20 Oct 2008 20:08:58 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/73.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2008/10/20/spinning-wait-symbol-in-silverlight-part-2.aspx#feedback</comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/73.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/73.aspx</trackback:ping>
        </item>
        <item>
            <title>Constant Prototyping and Design</title>
            <link>http://nimblecoder.com/blog/archive/2008/07/31/constant-prototyping-and-design.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://nimblecoder.com/blog/images/nimblecoder_com/blog/WindowsLiveWriter/ConstantPrototypingandDesign_885D/BalletDancer_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="Ballet" src="http://nimblecoder.com/blog/images/nimblecoder_com/blog/WindowsLiveWriter/ConstantPrototypingandDesign_885D/BalletDancer_thumb.png" width="188" align="left" border="0" /&gt;&lt;/a&gt;A co-worker gave a presentation on a project we worked on a long time ago and he asked me to update an feature in the web application. The web app was originally programmed in ASP and I had almost forgotten how painful it was to work in that environment. The new request was to enable live presence information in a web part using the new &lt;a href="http://msdn.microsoft.com/en-us/library/ms931946.aspx" target="_blank"&gt;RTC&lt;/a&gt; libraries. Fortunately, another developer had a component to perform all of the calls using the RTC libraries, but I needed to retrieve the group members for the selected group and cross-reference the group members with online presence.&lt;/p&gt; &lt;p&gt;The actual details involved opening "MTSAdmin.Catalog.1" object and looking for a specific COM+ package, enumerating the "RolesInPackage", and then getting the "UsersInRole". There were several layers of filtering going on and I wanted an elegant solution. Unfortunately I kept trying to be too elegant and I was getting hung up on how to make it more elegant. I wanted to have a "before", "item", and "after" callback functions at each of the function depth levels where the "item" function would occur in the iteration loop. This would allow for scenarios where items might need to be collected after iteration, particularly to avoid making multiple unnecessary calls to the lower filtering methods.&lt;/p&gt; &lt;h3&gt;Small example from jQuery&lt;/h3&gt;&lt;pre class="js" name="code"&gt;ajax: function( s ) {
  &lt;span class="rem"&gt;// Extend the settings, but re-extend 's' so that it can be&lt;/span&gt;
  &lt;span class="rem"&gt;// checked again later (in the test suite, specifically)&lt;/span&gt;
  s = jQuery.extend(&lt;span class="kwrd"&gt;true&lt;/span&gt;, s, jQuery.extend(&lt;span class="kwrd"&gt;true&lt;/span&gt;, {}, jQuery.ajaxSettings, s));

  &lt;span class="rem"&gt;// ... snip, snip, snip ...&lt;/span&gt;

  &lt;span class="rem"&gt;// Allow custom headers/mimetypes&lt;/span&gt;
  &lt;span class="kwrd"&gt;if&lt;/span&gt; ( s.beforeSend &amp;amp;&amp;amp; s.beforeSend(xhr, s) === &lt;span class="kwrd"&gt;false&lt;/span&gt; ) {
    &lt;span class="rem"&gt;// cleanup active request counter&lt;/span&gt;
    s.global &amp;amp;&amp;amp; jQuery.active--;
    &lt;span class="rem"&gt;// close opended socket&lt;/span&gt;
    xhr.abort();
    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;
  }
&lt;/pre&gt;
&lt;p&gt;The example above from jQuery only uses the "before" concept that I mentioned above, but it shows a very nice implementation where the 's' object is based on jQuery.ajaxSettings. Just before the AJAX call is about to be made, jQuery checks for any custom headers and calls the 'beforeSend' function if it exists.&lt;/p&gt;
&lt;h3&gt;Start Simple and Add Progressive Elegance&lt;/h3&gt;
&lt;p&gt;&lt;a href="http://www.flickr.com/photos/ableman/234145236/"&gt;&lt;img height="160" alt="BaseballHomerun" src="http://nimblecoder.com/blog/images/nimblecoder_com/blog/WindowsLiveWriter/ConstantPrototypingandDesign_885D/BaseballHomerun_3.jpg" width="240" align="right" border="0" /&gt;&lt;/a&gt; I did manage to get the function working correctly, but I had to take a step back and start simple and progressively build additional functionality into the component. Sometimes you have inspiration and you can just design and code and everything is great. Other times it can take a while before the inspiration comes. It is better to start coding and have something you can refine rather than wait and lose valuable time.&lt;/p&gt;
&lt;p&gt;To use a baseball analogy: Don't try to hit a homerun every time; sometimes you need to play "&lt;a href="http://en.wikipedia.org/wiki/Small_Ball"&gt;small ball&lt;/a&gt;" and get people in scoring position and just try to make contact. A similar soccer (futból!) analogy would be don't just try to dribble down the field and score every time, but you need to pass and set up the players around you to maximize the scoring opportunity.&lt;/p&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/70.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2008/07/31/constant-prototyping-and-design.aspx</guid>
            <pubDate>Thu, 31 Jul 2008 16:28:32 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/70.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2008/07/31/constant-prototyping-and-design.aspx#feedback</comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/70.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/70.aspx</trackback:ping>
        </item>
        <item>
            <title>On Sample Simplicity</title>
            <link>http://nimblecoder.com/blog/archive/2008/06/13/on-sample-simplicity.aspx</link>
            <description>&lt;p&gt;I was working through a Communications sample of connecting &lt;a href="http://silverlight.net/" target="_blank"&gt;SilverLight&lt;/a&gt; to &lt;a href="http://en.wikipedia.org/wiki/Plain_Old_XML" target="_blank"&gt;POX&lt;/a&gt;, then &lt;a href="http://en.wikipedia.org/wiki/Web_services" target="_blank"&gt;Web Services&lt;/a&gt;, and finally &lt;a href="http://msdn.microsoft.com/en-us/library/ms735119.aspx" target="_blank"&gt;WCF&lt;/a&gt; and I came across the following instructions:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;(Part 1: POX) The Generic handler will process an incoming request using the code declared in the &lt;em&gt;ProcessRequest&lt;/em&gt; function. This function should create some new instances of CityData and add them to the myCities list. Here are some examples of cities with longitude and latitude { (London, 51.5, 0), (Stratford-upon-Avon, 52.3, -1.71), (Edinburgh, 55.95, -3.16) }. See if you can write the code to do this.&lt;/p&gt; &lt;p&gt;(And later in the lab...)&lt;/p&gt; &lt;p&gt;In this example your ASHX served up hard-coded data for 1 city. Can you build it so that it can accept parameters on the URI string (i.e. http://localhost:8001/Sample1Web/GetData.ashx?city=whatever)?&lt;/p&gt; &lt;p&gt;(And even further in the lab...)&lt;/p&gt; &lt;p&gt;Write a function that takes in a country and builds a List&amp;lt;CityData&amp;gt; of several cities for that country. Here are some cities and their latitudes and longitudes:&lt;/p&gt;&lt;pre class="code"&gt;(&lt;span style="background: #ffffe6"&gt;"Paris"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;48.87&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;2.33&lt;/span&gt;);
(&lt;span style="background: #ffffe6"&gt;"Lourdes"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;43.1&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0.05&lt;/span&gt;);
(&lt;span style="background: #ffffe6"&gt;"Toulouse"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;43.6&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;1.38&lt;/span&gt;);
(&lt;span style="background: #ffffe6"&gt;"London"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;51.5&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0&lt;/span&gt;);
(&lt;span style="background: #ffffe6"&gt;"Stratford-Upon-Avon"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;52.3&lt;/span&gt;, -&lt;span style="background: #e6ffff"&gt;1.71&lt;/span&gt;);
(&lt;span style="background: #ffffe6"&gt;"Edinburgh"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;55.95&lt;/span&gt;, -&lt;span style="background: #e6ffff"&gt;3.16&lt;/span&gt;);
(&lt;span style="background: #ffffe6"&gt;"Berlin"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;52.52&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;13.42&lt;/span&gt;);
(&lt;span style="background: #ffffe6"&gt;"Munich"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;48.13&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;11.57&lt;/span&gt;);
(&lt;span style="background: #ffffe6"&gt;"Hamburg"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;53.58&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;9.98&lt;/span&gt;);&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/blockquote&gt;
&lt;h3&gt;Provided Solution&lt;/h3&gt;
&lt;p&gt;The sample provided "solution" code at the end of the instructions. The code is basic and unimaginative, but perhaps that is all the is needed of sample code (I would offer that samples are the perfect to push the boundaries -- lead by example).&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: green"&gt;// File: CityData.cs
&lt;/span&gt;&lt;span style="color: navy"&gt;public class &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData
&lt;/span&gt;{
    &lt;span style="color: navy"&gt;public string &lt;/span&gt;&lt;span style="color: maroon"&gt;CityName &lt;/span&gt;{ &lt;span style="color: navy"&gt;get&lt;/span&gt;; &lt;span style="color: navy"&gt;set&lt;/span&gt;; }
    &lt;span style="color: navy"&gt;public double &lt;/span&gt;&lt;span style="color: maroon"&gt;Latitude &lt;/span&gt;{ &lt;span style="color: navy"&gt;get&lt;/span&gt;; &lt;span style="color: navy"&gt;set&lt;/span&gt;; }
    &lt;span style="color: navy"&gt;public double &lt;/span&gt;&lt;span style="color: maroon"&gt;Longitude &lt;/span&gt;{ &lt;span style="color: navy"&gt;get&lt;/span&gt;; &lt;span style="color: navy"&gt;set&lt;/span&gt;; }

    &lt;span style="color: navy"&gt;public &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="color: navy"&gt;string &lt;/span&gt;&lt;span style="color: maroon"&gt;strCityName&lt;/span&gt;, &lt;span style="color: navy"&gt;double &lt;/span&gt;&lt;span style="color: maroon"&gt;nLatitude&lt;/span&gt;, &lt;span style="color: navy"&gt;double &lt;/span&gt;&lt;span style="color: maroon"&gt;nLongitude&lt;/span&gt;)
    {
        &lt;span style="color: maroon"&gt;CityName &lt;/span&gt;= &lt;span style="color: maroon"&gt;strCityName&lt;/span&gt;;
        &lt;span style="color: maroon"&gt;Latitude &lt;/span&gt;= &lt;span style="color: maroon"&gt;nLatitude&lt;/span&gt;;
        &lt;span style="color: maroon"&gt;Longitude &lt;/span&gt;= &lt;span style="color: maroon"&gt;nLongitude&lt;/span&gt;;
    }

    &lt;span style="color: navy"&gt;public &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;()
    {
    }
}

&lt;span style="color: green"&gt;// File: GetData.ashx
&lt;/span&gt;&lt;span style="color: navy"&gt;public class &lt;/span&gt;&lt;span style="color: maroon"&gt;GetData &lt;/span&gt;: &lt;span style="color: maroon"&gt;IHttpHandler
&lt;/span&gt;{
    &lt;span style="color: navy"&gt;private &lt;/span&gt;&lt;span style="color: maroon"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt; &lt;span style="color: maroon"&gt;getCities&lt;/span&gt;(&lt;span style="color: navy"&gt;string &lt;/span&gt;&lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;)
    {
        &lt;span style="color: maroon"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt; &lt;span style="color: maroon"&gt;ret &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt;();

        &lt;span style="color: navy"&gt;switch &lt;/span&gt;(&lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;)
        {
        &lt;span style="color: navy"&gt;case &lt;/span&gt;&lt;span style="background: #ffffe6"&gt;"france"&lt;/span&gt;:
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Paris"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;48.87&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;2.33&lt;/span&gt;));
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Lourdes"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;43.1&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0.05&lt;/span&gt;));
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Toulouse"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;43.6&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;1.38&lt;/span&gt;));
            &lt;span style="color: navy"&gt;break&lt;/span&gt;;

        &lt;span style="color: navy"&gt;case &lt;/span&gt;&lt;span style="background: #ffffe6"&gt;"uk"&lt;/span&gt;:
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"London"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;51.5&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0&lt;/span&gt;));
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Stratford-Upon-Avon"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;52.3&lt;/span&gt;, -&lt;span style="background: #e6ffff"&gt;1.71&lt;/span&gt;));
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Edinburgh"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;55.95&lt;/span&gt;, -&lt;span style="background: #e6ffff"&gt;3.16&lt;/span&gt;));
            &lt;span style="color: navy"&gt;break&lt;/span&gt;;

        &lt;span style="color: navy"&gt;case &lt;/span&gt;&lt;span style="background: #ffffe6"&gt;"germany"&lt;/span&gt;:
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Berlin"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;52.52&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;13.42&lt;/span&gt;));
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Munich"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;48.13&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;11.57&lt;/span&gt;));
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Hamburg"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;53.58&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;9.98&lt;/span&gt;));
            &lt;span style="color: navy"&gt;break&lt;/span&gt;;

        &lt;span style="color: navy"&gt;default&lt;/span&gt;:
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"London"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;51.5&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0&lt;/span&gt;));
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Stratford-Upon-Avon"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;52.3&lt;/span&gt;, -&lt;span style="background: #e6ffff"&gt;1.71&lt;/span&gt;));
            &lt;span style="color: maroon"&gt;ret&lt;/span&gt;.&lt;span style="color: maroon"&gt;Add&lt;/span&gt;(&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Edinburgh"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;55.95&lt;/span&gt;, -&lt;span style="background: #e6ffff"&gt;3.16&lt;/span&gt;));
            &lt;span style="color: navy"&gt;break&lt;/span&gt;;
        }
        &lt;span style="color: navy"&gt;return &lt;/span&gt;&lt;span style="color: maroon"&gt;ret&lt;/span&gt;;
    }
}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;h3&gt;Alternative 1&lt;/h3&gt;
&lt;p&gt;I wanted to explore alternatives to the supplied code, so I decided to initialize the CityData list with the data instead of using "Add". In C++ this was more efficient (it set the initial list size instead of using the default capacity sizing algorithm among other things), but I'm not sure of performance in terms of C#. I would not expect any significant performance difference with this small sample though.&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: navy"&gt;public &lt;/span&gt;&lt;span style="color: maroon"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt; &lt;span style="color: maroon"&gt;getCities&lt;/span&gt;(&lt;span style="color: navy"&gt;string &lt;/span&gt;&lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;)
{
    &lt;span style="color: maroon"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt; &lt;span style="color: maroon"&gt;ret &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt;();

    &lt;span style="color: navy"&gt;switch &lt;/span&gt;( &lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;.&lt;span style="color: maroon"&gt;ToLower&lt;/span&gt;() )
    {
        &lt;span style="color: navy"&gt;case &lt;/span&gt;&lt;span style="background: #ffffe6"&gt;"france"&lt;/span&gt;:
            &lt;span style="color: maroon"&gt;ret &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt;() {
                &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Paris"&lt;/span&gt;, &lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;48.87&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;2.33&lt;/span&gt;),
                &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Lourdes"&lt;/span&gt;, &lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;43.1&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0.05&lt;/span&gt;),
                &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Toulouse"&lt;/span&gt;, &lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;43.6&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;1.38&lt;/span&gt;)
            };
            &lt;span style="color: navy"&gt;break&lt;/span&gt;;

        &lt;span style="color: navy"&gt;case &lt;/span&gt;&lt;span style="background: #ffffe6"&gt;"germany"&lt;/span&gt;:
            &lt;span style="color: maroon"&gt;ret &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt;() {
                &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Berlin"&lt;/span&gt;, &lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;52.52&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;13.42&lt;/span&gt;),
                &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Munich"&lt;/span&gt;, &lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;48.13&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;11.57&lt;/span&gt;),
                &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Hamburg"&lt;/span&gt;, &lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;53.58&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;9.98&lt;/span&gt;)
            };
            &lt;span style="color: navy"&gt;break&lt;/span&gt;;

        &lt;span style="color: navy"&gt;case &lt;/span&gt;&lt;span style="background: #ffffe6"&gt;"uk"&lt;/span&gt;:
        &lt;span style="color: navy"&gt;default&lt;/span&gt;:
            &lt;span style="color: maroon"&gt;strCountry &lt;/span&gt;= &lt;span style="background: #ffffe6"&gt;"UK"&lt;/span&gt;;
            &lt;span style="color: maroon"&gt;ret &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt;() {
                &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"London"&lt;/span&gt;, &lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;51.5&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0&lt;/span&gt;),
                &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Stratford-Upon-Avon"&lt;/span&gt;, &lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;52.3&lt;/span&gt;, -&lt;span style="background: #e6ffff"&gt;1.71&lt;/span&gt;),
                &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Edinburgh"&lt;/span&gt;, &lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;55.95&lt;/span&gt;, -&lt;span style="background: #e6ffff"&gt;3.16&lt;/span&gt;)
            };
            &lt;span style="color: navy"&gt;break&lt;/span&gt;;
    }
    &lt;span style="color: navy"&gt;return &lt;/span&gt;&lt;span style="color: maroon"&gt;ret&lt;/span&gt;;
}
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;h3&gt;Alternative 2&lt;/h3&gt;
&lt;p&gt;I haven't worked very much with LINQ, so I wanted to compare the same functionality using LINQ. I added a string "Country" to the CityData class and here is the result:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: navy"&gt;private static &lt;/span&gt;&lt;span style="color: #a65300"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt; &lt;span style="color: maroon"&gt;cityList &lt;/span&gt;= &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: #a65300"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt;()
{
    &lt;span style="color: green"&gt;// UK
    &lt;/span&gt;&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Paris"&lt;/span&gt;, &lt;span style="background: #ffffe6"&gt;"UK"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;48.87&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;2.33&lt;/span&gt;),
    &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Lourdes"&lt;/span&gt;, &lt;span style="background: #ffffe6"&gt;"UK"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;43.1&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0.05&lt;/span&gt;),
    &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Toulouse"&lt;/span&gt;, &lt;span style="background: #ffffe6"&gt;"UK"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;43.6&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;1.38&lt;/span&gt;),

    &lt;span style="color: green"&gt;// France
    &lt;/span&gt;&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Paris"&lt;/span&gt;, &lt;span style="background: #ffffe6"&gt;"France"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;48.87&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;2.33&lt;/span&gt;),
    &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Lourdes"&lt;/span&gt;, &lt;span style="background: #ffffe6"&gt;"France"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;43.1&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;0.05&lt;/span&gt;),
    &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Toulouse"&lt;/span&gt;, &lt;span style="background: #ffffe6"&gt;"France"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;43.6&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;1.38&lt;/span&gt;),

    &lt;span style="color: green"&gt;// Germany
    &lt;/span&gt;&lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Berlin"&lt;/span&gt;, &lt;span style="background: #ffffe6"&gt;"Germany"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;52.52&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;13.42&lt;/span&gt;),
    &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Munich"&lt;/span&gt;, &lt;span style="background: #ffffe6"&gt;"Germany"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;48.13&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;11.57&lt;/span&gt;),
    &lt;span style="color: navy"&gt;new &lt;/span&gt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;(&lt;span style="background: #ffffe6"&gt;"Hamburg"&lt;/span&gt;, &lt;span style="background: #ffffe6"&gt;"Germany"&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;53.58&lt;/span&gt;, &lt;span style="background: #e6ffff"&gt;9.98&lt;/span&gt;)
};

&lt;span style="color: navy"&gt;public &lt;/span&gt;&lt;span style="color: maroon"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt; &lt;span style="color: maroon"&gt;getCities&lt;/span&gt;(&lt;span style="color: navy"&gt;string &lt;/span&gt;&lt;span style="color: maroon"&gt;strCountry&lt;/span&gt;)
{
    &lt;span style="color: maroon"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt; &lt;span style="color: maroon"&gt;data &lt;/span&gt;= &lt;span style="color: maroon"&gt;from city &lt;/span&gt;&lt;span style="color: navy"&gt;in &lt;/span&gt;&lt;span style="color: maroon"&gt;cityList
                                 where city&lt;/span&gt;.&lt;span style="color: maroon"&gt;Country &lt;/span&gt;== &lt;span style="color: maroon"&gt;strCountry
                                 select city&lt;/span&gt;;
    &lt;span style="color: navy"&gt;return new &lt;/span&gt;&lt;span style="color: maroon"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: maroon"&gt;CityData&lt;/span&gt;&amp;gt;(&lt;span style="color: maroon"&gt;data&lt;/span&gt;);
}
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;This is still not the most efficient or optimal method, but I think it looks nice and is helps introduce LINQ in an understandable manner.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Samples and labs should be simple and yet it is a perfect time to include new technologies and push the boundaries so to speak. One thing I certainly don't want to see in samples are basic programming inefficiencies (things that make you cringe) due to lack of effort by the sample creator. That was not necessarily the case with this sample, but it would have been better to present alternatives such as the examples I listed.&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:673666a2-582b-4be1-983b-acae922063a9" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/C#" rel="tag"&gt;C#&lt;/a&gt;, &lt;a href="http://technorati.com/tags/LINQ" rel="tag"&gt;LINQ&lt;/a&gt;&lt;/div&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/69.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2008/06/13/on-sample-simplicity.aspx</guid>
            <pubDate>Fri, 13 Jun 2008 21:08:44 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/69.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2008/06/13/on-sample-simplicity.aspx#feedback</comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/69.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/69.aspx</trackback:ping>
        </item>
        <item>
            <title>Automatically setting the Specified property in WSDL Generated files</title>
            <link>http://nimblecoder.com/blog/archive/2008/04/01/automatically-setting-the-specified-property-in-wsdl-generated-files.aspx</link>
            <description>&lt;p&gt;The wsdl.exe tool with Visual Studio can be used to manually generate a code file to use with a project. If you use the nillable or minOccurs attributes in the XSD though, the wsdl.exe tool generates a boolean 'Specified' field that must be set to true in order to transmit the data through the web service. For example:&lt;/p&gt; &lt;h3&gt;WSDL File (myfile.wsdl)&lt;/h3&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;xs:element&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="duedate"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="xs:dateTime"&lt;/span&gt; &lt;span class="attr"&gt;nillable&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt; &lt;span class="attr"&gt;minOccurs&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="attr"&gt;maxOccurs&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;h3&gt;Generated CS File (wsdl.exe myfile.wsdl)&lt;/h3&gt;&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// ...&lt;/span&gt;

&lt;span class="kwrd"&gt;private&lt;/span&gt; System.Nullable&amp;lt;System.DateTime&amp;gt; duedateField;

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; duedateFieldSpecified;

&lt;span class="rem"&gt;// ...&lt;/span&gt;

&lt;span class="rem"&gt;/// &amp;lt;remarks/&amp;gt;&lt;/span&gt;
[System.Xml.Serialization.XmlElementAttribute(IsNullable=&lt;span class="kwrd"&gt;true&lt;/span&gt;)]
&lt;span class="kwrd"&gt;public&lt;/span&gt; System.Nullable&amp;lt;System.DateTime&amp;gt; duedate {
    get {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.duedateField;
    }
    set {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.duedateField = &lt;span class="kwrd"&gt;value&lt;/span&gt;;
    }
}

&lt;span class="rem"&gt;/// &amp;lt;remarks/&amp;gt;&lt;/span&gt;
[System.Xml.Serialization.XmlIgnoreAttribute()]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; duedateSpecified {
    get {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.duedateFieldSpecified;
    }
    set {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.duedateFieldSpecified = &lt;span class="kwrd"&gt;value&lt;/span&gt;;
    }
}
&lt;/pre&gt;
&lt;h3&gt;"Breaking Change"&lt;/h3&gt;
&lt;p&gt;What I wanted was simply add the line to the 'duedate' setter to check if the newly assigned value was null or not (the assumption is that a non-null value would mean the field is 'specified'):&lt;/p&gt;&lt;pre class="csharpcode"&gt;    set {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.duedateField = &lt;span class="kwrd"&gt;value&lt;/span&gt;;
&lt;span style="background-color: #ecf6f9"&gt;        &lt;span class="kwrd"&gt;this&lt;/span&gt;.duedateFieldSpecified = (&lt;span class="kwrd"&gt;value&lt;/span&gt; != &lt;span class="kwrd"&gt;null&lt;/span&gt;);&lt;/span&gt;
    }

&lt;/pre&gt;
&lt;p&gt;I looked around for a solution, but all I found a &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=90727" target="_blank"&gt;very good suggestion&lt;/a&gt; to add this functionality to the wsdl.exe tool. Unfortunately the status was "Closed (Won't Fix)" and the comment was:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Thank you for the suggestion.&lt;br /&gt;This would be nice enhancement, but unfortunately this also is a breaking change: in the previous versions of the .net framework setting value of 'xxx' field did not toggle the xxxSepcified value, so if we change this runtime behavior of some existing applications may change and will require user code change to run the same way as before.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;On the contrary, I contend it would not be difficult or breaking to simply add the functionality through optional parameters, such as: 
&lt;/p&gt;&lt;p&gt;wsdl.exe /autospecified:1 myfile.wsdl 
&lt;/p&gt;&lt;p&gt;The optional parameters would not affect default operation nor break existing code, but instead we have to deal with a short-sighted decision. 
&lt;/p&gt;&lt;h3&gt;Quick and Dirty Solution&lt;/h3&gt;
&lt;p&gt;I decided to write a quick script to try and automatically generate the extra line of code for each setter. I decided to use awk (there are a number of sources for a Windows awk/gawk - &lt;a href="http://www.cygwin.com/" target="_blank"&gt;cygwin&lt;/a&gt;, &lt;a href="http://unxutils.sourceforge.net/" target="_blank"&gt;unxutils&lt;/a&gt;, and more) as it is very quick to implement and script. The following script is the result:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;#!/usr/bin/awk -f&lt;/span&gt;

&lt;span class="rem"&gt;# This is a quick and dirty script to add automatically set the&lt;/span&gt;
&lt;span class="rem"&gt;# 'myFieldSpecified' variables generated from the Visual Studio&lt;/span&gt;
&lt;span class="rem"&gt;# wsdl.exe tool. The script searches for System.Nullable types &lt;/span&gt;
&lt;span class="rem"&gt;# (myField) and verifies a specified variable exists &lt;/span&gt;
&lt;span class="rem"&gt;# (myFieldSpecified). It then searches for the setter and adds&lt;/span&gt;
&lt;span class="rem"&gt;# the line: this.myFieldSpecified = (value != null);&lt;/span&gt;
&lt;span class="rem"&gt;#&lt;/span&gt;
&lt;span class="rem"&gt;# Copyright (C) 2008 Ryan Van Slooten&lt;/span&gt;
&lt;span class="rem"&gt;#&lt;/span&gt;
&lt;span class="rem"&gt;# Version:&lt;/span&gt;
&lt;span class="rem"&gt;#   1.0     2008-04-01      Initial release&lt;/span&gt;
&lt;span class="rem"&gt;#&lt;/span&gt;

BEGIN { FS = &lt;span class="str"&gt;" "&lt;/span&gt;; }

&lt;span class="rem"&gt;# Match the nullable types in the file: int, DateTime, etc.&lt;/span&gt;
/[ \t]*&lt;span class="kwrd"&gt;private&lt;/span&gt; System.Nullable/ {
    print $0;

    &lt;span class="rem"&gt;# Add name of field to nullable array&lt;/span&gt;
    name = substr($3, 1, length($3)-1);
    nullable[name] = &lt;span class="str"&gt;""&lt;/span&gt;;
    next; 
}

&lt;span class="rem"&gt;# Match the xxxFieldSpecified variables&lt;/span&gt;
/[ \t]*&lt;span class="kwrd"&gt;private&lt;/span&gt; .*FieldSpecified;/ {
    print $0;

    &lt;span class="rem"&gt;# Increment value of 'specified' null field to nullable array&lt;/span&gt;
    name = substr($3, 1, length($3)-10);
    specified = substr($3, 1, length($3)-1);
    nullable[name] = specified;
    next; 
}

&lt;span class="rem"&gt;# Match the field setter and check if it is nullable and specified&lt;/span&gt;
/[ \t]*this.* = value;/ {
    print $0;

    &lt;span class="rem"&gt;# Check if field is nullable and has a specified property&lt;/span&gt;
    name = substr($1, 6);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (name &lt;span class="kwrd"&gt;in&lt;/span&gt; nullable) {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (length(nullable[name]) &amp;gt; 0) {
            &lt;span class="rem"&gt;# Fix lost indentation level&lt;/span&gt;
            indent = substr($0, 1, index($0, $1)-1);

            &lt;span class="rem"&gt;# Adjust the xxxFieldSpecified value&lt;/span&gt;
            $1 = $1 &lt;span class="str"&gt;"Specified"&lt;/span&gt;;
            $3 = &lt;span class="str"&gt;"("&lt;/span&gt; substr($3, 1, length($3)-1) &lt;span class="str"&gt;" != null);"&lt;/span&gt;;
            print indent $0;

            &lt;span class="rem"&gt;# Remove element from array&lt;/span&gt;
            delete nullable[name];
        }
    }
    next;
}

&lt;span class="rem"&gt;# default line handler&lt;/span&gt;
{ print $0; }

&lt;/pre&gt;
&lt;div&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fnimblecoder.com%2fblog%2farchive%2f2008%2f04%2f01%2fautomatically-setting-the-specified-property-in-wsdl-generated-files.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fnimblecoder.com%2fblog%2farchive%2f2008%2f04%2f01%2fautomatically-setting-the-specified-property-in-wsdl-generated-files.aspx" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:874bc33b-2c0b-430a-8b9b-8e9d17ea1460" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/awk" rel="tag"&gt;awk&lt;/a&gt;, &lt;a href="http://technorati.com/tags/c#" rel="tag"&gt;c#&lt;/a&gt;, &lt;a href="http://technorati.com/tags/wsdl" rel="tag"&gt;wsdl&lt;/a&gt;, &lt;a href="http://technorati.com/tags/web%20services" rel="tag"&gt;web services&lt;/a&gt;&lt;/div&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/61.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2008/04/01/automatically-setting-the-specified-property-in-wsdl-generated-files.aspx</guid>
            <pubDate>Tue, 01 Apr 2008 20:51:15 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/61.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2008/04/01/automatically-setting-the-specified-property-in-wsdl-generated-files.aspx#feedback</comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/61.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/61.aspx</trackback:ping>
        </item>
        <item>
            <title>SOAP Acronym Doesn't Mean Anything</title>
            <link>http://nimblecoder.com/blog/archive/2008/01/21/soap-acronym-doesnt-mean-anything.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://nimblecoder.com/blog/images/nimblecoder_com/blog/WindowsLiveWriter/SOAPAcronymDoesntMeanAnything_C8A0/Love_symbol_2_2.png"&gt;&lt;img height="149" alt="Love_symbol_2" src="http://nimblecoder.com/blog/images/nimblecoder_com/blog/WindowsLiveWriter/SOAPAcronymDoesntMeanAnything_C8A0/Love_symbol_2_thumb.png" width="125" align="left" /&gt;&lt;/a&gt; Well, you learn something new every day. I didn't know that the acronym &lt;a title="A rather famous formerly-known artist" href="http://en.wikipedia.org/wiki/Prince_%28musician%29" target="_blank"&gt;formerly-known&lt;/a&gt; as SOAP, aka Simple Object Access Protocol, is no longer an acronym and is just a protocol and means nothing.&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Note:&lt;br /&gt;In previous versions of this specification the SOAP name was an acronym. This is no longer the case.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Source: &lt;a href="http://www.w3.org/TR/2007/REC-soap12-part1-20070427/" target="_blank"&gt;SOAP Version 1.2 Part 1&lt;/a&gt;&lt;/p&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/56.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2008/01/21/soap-acronym-doesnt-mean-anything.aspx</guid>
            <pubDate>Mon, 21 Jan 2008 20:14:19 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/56.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2008/01/21/soap-acronym-doesnt-mean-anything.aspx#feedback</comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/56.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/56.aspx</trackback:ping>
        </item>
    </channel>
</rss>