<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SHAZAML! &#187; Development</title>
	<atom:link href="http://www.shazaml.com/archives/category/development/feed" rel="self" type="application/rss+xml" />
	<link>http://www.shazaml.com</link>
	<description>The Blog for Design &#38; Development Superheroes</description>
	<lastBuildDate>Wed, 28 Jul 2010 21:02:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Infragistics XamWebOutlookBar &amp; Caliburn</title>
		<link>http://www.shazaml.com/archives/infragistics-xamweboutlookbar-caliburn</link>
		<comments>http://www.shazaml.com/archives/infragistics-xamweboutlookbar-caliburn#comments</comments>
		<pubDate>Mon, 14 Jun 2010 21:38:44 +0000</pubDate>
		<dc:creator>Mark Tucker</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Caliburn]]></category>
		<category><![CDATA[Infragistics]]></category>
		<category><![CDATA[XamWebOutlookBar]]></category>

		<guid isPermaLink="false">http://www.shazaml.com/?p=571</guid>
		<description><![CDATA[Using the Infragistics Silverlight XamWebOutlookBar with Caliburn]]></description>
			<content:encoded><![CDATA[<p>Last week I set out to build a simple Caliburn sample that included the Infragistics Silverlight XamWebOutlookBar.  I made progress and got to a point where Rob Eisenberg was able to help me get the rest of the way.  The approach I was taking was trying to figure out what conventions I should add to get Caliburn to recognize the XamWebOutlookBar.  Rob’s answer was that not everything needs to be a convention.</p>
<p>When you run the application, you will see the XamWebOutlookBar hosted in a sidebar.  Both groups shown in the OutlookBar have corresponding ViewModels that in turn have associated Views:</p>
<p><a href="http://www.shazaml.com/wp-content/uploads/2010/06/image.png"><img style="display: inline; border: 0px;" title="image" src="http://www.shazaml.com/wp-content/uploads/2010/06/image_thumb.png" border="0" alt="image" width="261" height="202" /></a></p>
<p>At the end of the article is a link to the project source code.  In order to get the project to compile, you will need to download the Infragistics assemblies and add references to the following:</p>
<p><a href="http://www.shazaml.com/wp-content/uploads/2010/06/image1.png"><img style="display: inline; border: 0px;" title="image" src="http://www.shazaml.com/wp-content/uploads/2010/06/image_thumb1.png" border="0" alt="image" width="376" height="83" /></a></p>
<p>A trial of Infragistics can be downloaded from <a href="http://www.infragistics.com/dotnet/netadvantage/silverlight/line-of-businessdownloads.aspx">here</a>.</p>
<p>Here is the final project structure:</p>
<p><a href="http://www.shazaml.com/wp-content/uploads/2010/06/image2.png"><img style="display: inline; border: 0px;" title="image" src="http://www.shazaml.com/wp-content/uploads/2010/06/image_thumb2.png" border="0" alt="image" width="300" height="484" /></a></p>
<h2>Application</h2>
<p>In typical Caliburn style, the App.xaml has been changed to a CaliburnApplication:</p>
<pre class="brush: xml; gutter: false;">
&lt;cal:CaliburnApplication xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
             xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
             xmlns:cal=&quot;clr-namespace:Caliburn.PresentationFramework.ApplicationModel;assembly=Caliburn.PresentationFramework&quot;
             x:Class=&quot;InfragisticsCaliburn.App&quot;&gt;
    &lt;Application.Resources&gt;
    &lt;/Application.Resources&gt;
&lt;/cal:CaliburnApplication&gt;
</pre>
<p>In App.xaml.cs, we setup MEF as the container and the use MEF to find the ShellViewModel:</p>
<pre class="brush: csharp; gutter: false;">
protected override IServiceLocator CreateContainer()
{
    return new MEFAdapter(CompositionHost.Initialize(new AssemblyCatalog(Assembly.GetExecutingAssembly())));
}

protected override object CreateRootModel()
{
    var shell = ServiceLocator.Current.GetInstance&lt;IShell&gt;();

    if (IsRunningOutOfBrowser &amp;&amp; HasElevatedPermissions)
        MainWindow.Closing += (s, args) =&gt; { args.Cancel = !ServiceLocator.Current.GetInstance&lt;IShell&gt;().CanShutdown(); };

    return shell;
}
</pre>
<h2>ViewModels</h2>
<p>MEF is able to find ShellViewModel in the container using the IShell type because it implements IShell and Exports itself as IShell:</p>
<pre class="brush: csharp; gutter: false;">
[Export(typeof(IShell))]
public class ShellViewModel : ScreenConductor&lt;IScreen&gt;, IShell
{
    private readonly MainViewModel _firstScreen;

    [ImportingConstructor]
    public ShellViewModel(MainViewModel firstScreen)
    {
        _firstScreen = firstScreen;
    }

    protected override void OnInitialize()
    {
        this.OpenScreen(_firstScreen);
    }

}
</pre>
<p>Because of the ImportingConstructor attribute, an instance of MainViewModel is created.  The class is implemented as:</p>
<pre class="brush: csharp; gutter: false;">
[Export(typeof(MainViewModel))]
public class MainViewModel : ScreenConductor&lt;ISidebarItem&gt;.WithCollection.OneScreenActive
{
    [ImportingConstructor]
    public MainViewModel([ImportMany] IEnumerable&lt;ISidebarItem&gt; sidebars)
    {
        Screens.AddRange(sidebars);
        this.OpenScreen(Screens.First());
    }
}
</pre>
<p>For the XamWebOutlookBar implementation, the important thing to note is that MainViewModel is setup as a ScreenConductor that manages ISidebarItem instances where only one sidebar screen is active at a time.  The ImportingConstructor attribute then finds all items registered in the MEF container as ISidebarItem.</p>
<p>In this example, both ContentAViewAModel and ContentBViewModel are similar:</p>
<pre class="brush: csharp; gutter: false;">
[Export(typeof(ISidebarItem))]
public class ContentAViewModel : Screen, ISidebarItem
{
    string message = &quot;ContentA is working&quot;;

    public ContentAViewModel()
    {
        DisplayName = &quot;Content A Header&quot;;
    }

    public string Message
    {
        get { return message; }
        set
        {
            message = value;
            NotifyOfPropertyChange(() =&gt; Message);
        }
    }

    public string Icon
    {
        get { return @&quot;../../Images/briefcase2.png&quot;; }
    }
}
</pre>
<p>Each of the ViewModels export themselves as ISidebarItem, inherit from Screen, and implement ISidebarItem.</p>
<h2>Views</h2>
<p>In MainView.xaml, the DisplayName and Icon properties are used to render the group’s header and icon:</p>
<pre class="brush: xml; gutter: false;">
&lt;igOB:XamWebOutlookBar x:Name=&quot;sidebarOutlookBar&quot; 
        MinimizedWidth=&quot;35&quot; AllowMinimized=&quot;True&quot; 
        NavigationPaneMinimized=&quot;sidebarOutlookBar_NavigationPaneMinimized&quot;
        NavigationPaneExpanding=&quot;sidebarOutlookBar_NavigationPaneExpanding&quot;
        VerticalAlignment=&quot;Stretch&quot; HorizontalAlignment=&quot;Stretch&quot;
        GroupsSource=&quot;{Binding Screens}&quot;&gt;
    &lt;igOB:XamWebOutlookBar.GroupContentTemplate&gt;
        &lt;DataTemplate&gt;
            &lt;ContentControl cal:View.Model=&quot;{Binding}&quot; /&gt;
        &lt;/DataTemplate&gt;
    &lt;/igOB:XamWebOutlookBar.GroupContentTemplate&gt;
    &lt;igOB:XamWebOutlookBar.GroupHeaderTemplate&gt;
        &lt;DataTemplate&gt;
            &lt;TextBlock Text=&quot;{Binding DisplayName}&quot; /&gt;
        &lt;/DataTemplate&gt;
    &lt;/igOB:XamWebOutlookBar.GroupHeaderTemplate&gt;
    &lt;igOB:XamWebOutlookBar.DefaultLargeIconTemplate&gt;
        &lt;DataTemplate&gt;
            &lt;Image Source=&quot;{Binding Icon, Converter={StaticResource stringToImageSourceConverter}}&quot;/&gt;
        &lt;/DataTemplate&gt;
    &lt;/igOB:XamWebOutlookBar.DefaultLargeIconTemplate&gt;
    &lt;igOB:XamWebOutlookBar.DefaultSmallIconTemplate&gt;
        &lt;DataTemplate&gt;
            &lt;Image Source=&quot;{Binding Icon, Converter={StaticResource stringToImageSourceConverter}}&quot;/&gt;
        &lt;/DataTemplate&gt;
    &lt;/igOB:XamWebOutlookBar.DefaultSmallIconTemplate&gt;
&lt;/igOB:XamWebOutlookBar&gt;
</pre>
<p>Notice the GroupsSource property is bound to the Screens property that the ViewModel inherits from its base class.  The ContentControl for each group is set to the ViewModel representing the group.  The group header is bound to the DisplayName property and the small and large icons are set to the Icon property.</p>
<p>The Message property is bound in the View for the group content:</p>
<pre class="brush: xml; gutter: false;">
&lt;UserControl x:Class=&quot;InfragisticsCaliburn.Views.ContentAView&quot;
    xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:xhttp://schemas.microsoft.com/winfx/2006/xaml
    xmlns:d=http://schemas.microsoft.com/expression/blend/2008
    xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
    mc:Ignorable=&quot;d&quot;
    d:DesignHeight=&quot;300&quot; d:DesignWidth=&quot;400&quot;&gt;
    &lt;Grid x:Name=&quot;LayoutRoot&quot; Background=&quot;White&quot;&gt;
        &lt;TextBlock x:Name =&quot;Message&quot;/&gt;
    &lt;/Grid&gt;
&lt;/UserControl&gt;
</pre>
<p>Download the source of the project <a href="http://www.shazaml.com/downloads/InfragisticsCaliburn2.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shazaml.com/archives/infragistics-xamweboutlookbar-caliburn/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Caliburn Book: Chapters 1-3</title>
		<link>http://www.shazaml.com/archives/caliburn-book-chapters-1-3</link>
		<comments>http://www.shazaml.com/archives/caliburn-book-chapters-1-3#comments</comments>
		<pubDate>Mon, 07 Jun 2010 19:37:25 +0000</pubDate>
		<dc:creator>Mark Tucker</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Caliburn]]></category>
		<category><![CDATA[MVVM]]></category>

		<guid isPermaLink="false">http://www.shazaml.com/?p=545</guid>
		<description><![CDATA[Draft chapters from Caliburn book]]></description>
			<content:encoded><![CDATA[<p>Many months ago I put learning about the Caliburn framework on my “to do” list.  A few weeks ago I started the task and decided to write a book about it.  I don’t think that I am expert enough at the framework to actually publish a book.  Not yet anyway.  But I figured if I could grok it well enough to write about it that I would be well on my way to learning the framework. </p>
<p>You can download the book from <a href="http://www.shazaml.com/downloads/CaliburnBook.zip">here</a>.</p>
<p>The first chapter is a simple introduction to Caliburn.  Chapter 2 walks you through a simple, Hello Caliburn, application.  Chapter 3 is more ambitious and walks you through various aspects of the framework using the Silverlight GameLibrary sample.  It covers the same topics that Rob Eisenberg covered in his MIX10 talk.  There is also an Appendix included that lists some of the conventions found in Caliburn.</p>
<p>If I decide to write additional chapters, then I would include:</p>
<ul>
<li>Adding to Conventions</li>
<li>Overriding Conventions</li>
<li>TDD and Caliburn</li>
<li>Caliburn extensibility points</li>
<li>IResult implementations</li>
<li>Coroutines in more depth</li>
<li>UI patterns besides MVVM</li>
</ul>
<p>There is likely much more to Caliburn that I don’t even know what I don’t know yet.</p>
<p>Please reply with any feedback, corrections, further explanations, or additional chapter ideas.</p>
<p>If a book is ever published about Caliburn, Rob should be the one to do it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shazaml.com/archives/caliburn-book-chapters-1-3/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Windows Phone 7 Presentation at Desert Code Camp 2010</title>
		<link>http://www.shazaml.com/archives/windows-phone-7-presentation-at-desert-code-camp-2010</link>
		<comments>http://www.shazaml.com/archives/windows-phone-7-presentation-at-desert-code-camp-2010#comments</comments>
		<pubDate>Mon, 17 May 2010 14:00:32 +0000</pubDate>
		<dc:creator>Mark Tucker</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[MVVM]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://www.shazaml.com/?p=536</guid>
		<description><![CDATA[Create a Windows Phone 7 app using Silverlight, the MVVM Light toolkit, and Test-Driven Development]]></description>
			<content:encoded><![CDATA[<p>Last Saturday I presented at my second Desert Code Camp.  The presentation PowerPoint and code for “Windows Phone 7 Silverlight MVVM App the Test-Driven Way” is now available.</p>
<div id="__ss_4124792" style="width: 425px;"><strong style="display: block; margin: 12px 0 4px;"><a title="Windows Phone 7 Silverlight MVVM App the Test-Driven" href="http://www.slideshare.net/marktucker/windows-phone-7-silverlight-mvvm-app-the-testdriven-4124792">Windows Phone 7 Silverlight MVVM App the Test-Driven</a></strong><object id="__sse4124792" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=windows-phone-7-silverlight-mvvm-app-the-testdriven2875&amp;rel=0&amp;stripped_title=windows-phone-7-silverlight-mvvm-app-the-testdriven-4124792" /><param name="name" value="__sse4124792" /><param name="allowfullscreen" value="true" /><embed id="__sse4124792" type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=windows-phone-7-silverlight-mvvm-app-the-testdriven2875&amp;rel=0&amp;stripped_title=windows-phone-7-silverlight-mvvm-app-the-testdriven-4124792" allowscriptaccess="always" allowfullscreen="true" name="__sse4124792"></embed></object></div>
<div style="padding: 5px 0 12px;">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/marktucker">Mark Tucker</a>.</div>
<p>The code consists of two phone projects.  If you run the first, you will get the application UI. Running the second will bring up the test viewer.</p>
<p>Get the code <a href="http://www.shazaml.com/downloads/PhoneTDD2.zip">here</a>.</p>
<p>NOTE:</p>
<p>I told those attending the session that a video of the presentation would be available.  But due to an issue with Camtasia Studio, the video was not recorded.</p>
<p>Thanks again to all those who attended the presentation.  Let me know about the COOL apps you write for WP7.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shazaml.com/archives/windows-phone-7-presentation-at-desert-code-camp-2010/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ninject vs. MEF for ASP.NET MVC Apps</title>
		<link>http://www.shazaml.com/archives/ninject-vs-mef-for-asp-net-mvc-apps</link>
		<comments>http://www.shazaml.com/archives/ninject-vs-mef-for-asp-net-mvc-apps#comments</comments>
		<pubDate>Fri, 23 Apr 2010 13:33:55 +0000</pubDate>
		<dc:creator>Mark Tucker</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[MEF]]></category>
		<category><![CDATA[Ninject]]></category>

		<guid isPermaLink="false">http://www.shazaml.com/?p=530</guid>
		<description><![CDATA[Ninject vs. MEF in ASP.NET MVC 2]]></description>
			<content:encoded><![CDATA[<p>This week I have been looking at using a dependency injection container for an MVC 2 application.  Since I am using .NET Framework 4 with Managed Extensibility Framework (MEF) built in, it is one option to consider.  I have also heard good things about Ninject.  So lets do a quick comparison between <a href="http://ninject.org">Ninject</a> and MEF with the simplest of implementations.</p>
<h2>Ninject</h2>
<p>To start off, I downloaded the <a href="http://ninject.org/download">.NET Framework 3.5 release of Ninject assembly</a> and then reference that as I recompile the <a href="http://ninject.org/extensions">Ninject.Web.MVC assembly</a> for .NET 4. Then I created a new ASP.NET MVC 2 project and reference those assemblies:</p>
<p><a href="http://www.shazaml.com/wp-content/uploads/2010/04/image15.png"><img style="display: inline; border-width: 0px;" title="image" src="http://www.shazaml.com/wp-content/uploads/2010/04/image_thumb8.png" border="0" alt="image" width="200" height="83" /></a></p>
<p>Next I modified the MvcApplication class in Global.asax.cs to inherit from NinjectHttpApplication and use the OnApplicationStarted and CreateKernal overrides to wire Ninject</p>
<pre class="brush: csharp; gutter: false;">

public class MvcApplication : NinjectHttpApplication
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute(&quot;{resource}.axd/{*pathInfo}&quot;);

        routes.MapRoute(
            &quot;Default&quot;, // Route name
            &quot;{controller}/{action}/{id}&quot;, // URL with parameters
            new { controller = &quot;Home&quot;, action = &quot;Index&quot;, id = UrlParameter.Optional } // Parameter defaults
        );

    }

    protected override void OnApplicationStarted()
    {
        AreaRegistration.RegisterAllAreas();
        RegisterRoutes(RouteTable.Routes);

        RegisterAllControllersIn(Assembly.GetExecutingAssembly());
    }

    protected override IKernel CreateKernel()
    {
        var modules = new INinjectModule[]
            {
                new WebModule()
            };

        return new StandardKernel(modules);
    }

 </pre>
<p>To associate an interface to an implementation, I create a WebModule class that inherits from NinjectModule:</p>
<p><span id="more-530"></span></p>
<pre class="brush: csharp; gutter: false;">

public class WebModule : NinjectModule
{
    public override void Load()
    {
        Bind&lt;IHelloService&gt;()
            .To&lt;HelloService&gt;();
    }
}

 </pre>
<p>The service and interface are very basic:</p>
<pre class="brush: csharp; gutter: false;">

public interface IHelloService
{
    string GetMessage();
}

public class HelloService : IHelloService
{
    public string GetMessage()
    {
        return &quot;Hello there.&quot;;
    }
}

 </pre>
<p>Since the Controllers are now wired to use items bound in the module, we can use the interface as a parameter to the constructor or set a property using the [Inject] attribute:</p>
<p><strong>Constructor Injection</strong></p>
<pre class="brush: csharp; gutter: false;">

public class HomeController : Controller
{
    public IHelloService HelloService { get; set; }

    //Constructor injection
    public HomeController(IHelloService service)
    {
        this.HelloService = service;
    }

    public ActionResult Index()
    {
        ViewData[&quot;Message&quot;] = HelloService.GetMessage();

        return View();
    }
}

 </pre>
<p><strong>Property Injection</strong></p>
<pre class="brush: csharp; gutter: false;">

public class HomeController : Controller
{
    //Property injection
    [Inject]
    public IHelloService HelloService { get; set; }

    public ActionResult Index()
    {
        ViewData[&quot;Message&quot;] = HelloService.GetMessage();

        return View();
    }
}
</pre>
<p>So, how would we accomplish the same thing in MEF?</p>
<h2>MEF</h2>
<p>To make the comparison easier, I created MefHttpApplication and MefControllerFactory classes.</p>
<p>First, add a reference to System.ComponentModel.Composition as that is where MEF lives:</p>
<p><a href="http://www.shazaml.com/wp-content/uploads/2010/04/image16.png"><img style="display: inline; border: 0px;" title="image" src="http://www.shazaml.com/wp-content/uploads/2010/04/image_thumb9.png" border="0" alt="image" width="310" height="82" /></a> </p>
<p>To get similar functionality that Ninject has in its NinjectHttpApplication, I created a MefHttpApplication:</p>
<pre class="brush: csharp; gutter: false;">

public abstract class MefHttpApplication : HttpApplication
{
    public void Application_Start()
    {
        var catalog = CreateCatalog();
        var container = new CompositionContainer(catalog);

        ControllerBuilder.Current.SetControllerFactory(new MefControllerFactory(container));

        OnApplicationStarted();
    }

    protected virtual void OnApplicationStarted() {}

    protected abstract ComposablePartCatalog CreateCatalog();
}
</pre>
<p>When the application starts, the derived class gets the specify catalog used to gather composition information. The MefHttpApplication then creates a CompositionContainer based on that catalog, overrides MVC’s default ControllerFactory, and provides an OnApplicationStarted method for the derived class:</p>
<pre class="brush: csharp; gutter: false;">

public class MvcApplication : MefHttpApplication
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute(&quot;{resource}.axd/{*pathInfo}&quot;);

        routes.MapRoute(
            &quot;Default&quot;, // Route name
            &quot;{controller}/{action}/{id}&quot;, // URL with parameters
            new { controller = &quot;Home&quot;, action = &quot;Index&quot;, id = UrlParameter.Optional } // Parameter defaults
        );

    }

    protected override void OnApplicationStarted()
    {
        AreaRegistration.RegisterAllAreas();
        RegisterRoutes(RouteTable.Routes);
    }

    protected override ComposablePartCatalog CreateCatalog()
    {
        return new AssemblyCatalog(Assembly.GetExecutingAssembly());
    }
}
</pre>
<p>Comparing this to the NinjectHttpApplication-derived class, there is no need to register the controllers separately or to create a WebModule to define the mapping between IHelloService and HelloService.  This will be accomplished in a different way.  By creating an AssemblyCatalog for the currently executing assembly, all classes will be scanned to see if there are any Exports to register.  In our case, we have one Export on the HelloService:</p>
<pre class="brush: csharp; gutter: false;">

public interface IHelloService
{
    string GetMessage();
}

[Export(typeof(IHelloService))]
public class HelloService : IHelloService
{
    public string GetMessage()
    {
        return &quot;Hello there.&quot;;
    }
}
</pre>
<p>In MEF, we need to remember the triad: Export, Import, Compose.  We already have our Export and the corresponding Import can be found in the Controller on the HelloService property:</p>
<pre class="brush: csharp; gutter: false;">

public class HomeController : Controller
{
     [Import]
     public IHelloService HelloService { get; set; }

     public ActionResult Index()
     {
         ViewData[&quot;Message&quot;] = HelloService.GetMessage();

         return View();
     }

     public ActionResult About()
     {
         return View();
     }
}

 </pre>
<p>It is also possible to import via a constructor parameter by decorating the constructor with the ImportingConstructor attribute but this would require more work in the MefControllerFactory class:</p>
<pre class="brush: csharp; gutter: false;">

public class MefControllerFactory : DefaultControllerFactory
{
    private CompositionContainer container;

    public MefControllerFactory(CompositionContainer container)
    {
        this.container = container;
    }

    public override IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName)
    {
        IController controller = base.CreateController(requestContext, controllerName);

        container.ComposeParts(controller);

        return controller;
    }
}
</pre>
<p>In the MefHttpApplication we replaced the default ControllerFactory with the MefControllerFactory which is derived from DefaultControllerFactory.  Every time MVC creates a new Controller, it goes through this class which simply calls base to create the Controller.  Just before returning the Controller, the container.ComposeParts method is called passing in the controller which allows any Imports defined in the Controller to be satisfied by any Exports found in the catalog.  All three steps of composition have been completed.</p>
<h2>So Which Should I Use?</h2>
<p>As always, that depends on your specific situation.  If all you need is injection into your controllers, then Ninject is simple way to get that done.  If you don’t want to rely on a 3rd-party solution, don’t mind creating your own HttpApplication and ControllerFactory classes, or you want to use MEF in other scenarios then MEF might be a better choice.  One example is to use MEF to define a <a href="http://blog.maartenballiauw.be/post/2009/04/21/ASPNET-MVC-and-the-Managed-Extensibility-Framework-(MEF).aspx">Controller in a separate plug-in</a>.</p>
<p>In this example, we compared MEF to Ninject, but a similar comparison could be done for Unity, StructureMap, Castle Windor, or other.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shazaml.com/archives/ninject-vs-mef-for-asp-net-mvc-apps/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating a Hello World Application for Boxee</title>
		<link>http://www.shazaml.com/archives/creating-a-hello-world-application-for-boxee</link>
		<comments>http://www.shazaml.com/archives/creating-a-hello-world-application-for-boxee#comments</comments>
		<pubDate>Tue, 02 Feb 2010 15:58:49 +0000</pubDate>
		<dc:creator>Mark Tucker</dc:creator>
				<category><![CDATA[Boxee]]></category>

		<guid isPermaLink="false">http://www.shazaml.com/?p=421</guid>
		<description><![CDATA[This video shows you how to create &#038; test your first Boxee application.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.jashsayani.com/wp-content/uploads/boxee-300x300.png" alt="" width="240" height="240" /></p>
<p>My first exposure to <a href="http://www.boxee.tv/" target="_blank">Boxee</a> was a few weeks ago as I read the <a href="http://blog.boxee.tv/2010/01/13/boxee-ces-wrap-up/" target="_blank">news from CES 2010</a>. Boxee is media center software that runs on a variety of operating systems and touts itself as “the best way to enjoy entertainment from the Internet and computer on your TV.”</p>
<p>In its support forum knowledge base under the question “<a href="http://support.boxee.tv/forums/49598/entries/43764" target="_blank">What is Boxee?</a>” you can read the following:</p>
<blockquote><p>Boxee is a social media center. With Boxee you can play videos, music and pictures from your computer, local network, and the Internet. You can also share with your friends what albums you&#8217;re listening to, what movies and TV shows you&#8217;re watching, send recommendations and more.</p></blockquote>
<p>One of the most-talked about devices at CES 2010 was the Boxee Box, a hardware device running the Boxee software that promises “plug and enjoy” connectivity to online entertainment sources such as YouTube, Pandora, Netflix, flickr, Facebook photos, TED Talks, and many more.  Plus you can access pictures, video, and music from your home network.  The Boxee Box has a striking design and a remote that features a keyboard on the back:</p>
<p><img src="http://www.wired.com/images_blogs/gadgetlab/2009/12/boxee-box.jpg" alt="" width="320" height="141" /></p>
<p><span id="more-421"></span></p>
<p><a href="http://blog.boxee.tv/wp-content/uploads/2010/01/Boxee-Box-remote-1024x662.jpg"><img src="http://blog.boxee.tv/wp-content/uploads/2010/01/Boxee-Box-remote-1024x662.jpg" alt="" width="320" height="207" /></a></p>
<p>The great part for developers is that you can create and deploy your own Boxee applications using xml &amp; Python.</p>
<p>Here is a 6 minute video that walks you through the process of creating and testing your first Boxee application:</p>
<div id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:e6dae8cf-da32-4c4e-b18b-136e00589fd2" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<div><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/83Oj8w-7bYc&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;hl=en" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://www.youtube.com/v/83Oj8w-7bYc&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;hl=en"></embed></object></div>
</div>
<p>The files used in the video can be downloaded from here:</p>
<p><a href="http://www.shazaml.com/downloads/boxee-hello-world.zip"><img class="alignnone size-full wp-image-319" title="Zip" src="http://www.shazaml.com/wp-content/uploads/2009/10/Zip.png" alt="Zip" width="93" height="96" /> Source Code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.shazaml.com/archives/creating-a-hello-world-application-for-boxee/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hidden Object: Episode 14 – Shake it up</title>
		<link>http://www.shazaml.com/archives/hidden-object-episode-14</link>
		<comments>http://www.shazaml.com/archives/hidden-object-episode-14#comments</comments>
		<pubDate>Wed, 25 Nov 2009 13:05:17 +0000</pubDate>
		<dc:creator>Mark Tucker</dc:creator>
				<category><![CDATA[Hidden Object Game]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Action]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[ControlStoryboardAction]]></category>
		<category><![CDATA[EventTrigger]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[GlobalCounterMaxReachedTrigger]]></category>
		<category><![CDATA[IncrementGlobalCounterAction]]></category>
		<category><![CDATA[SetGlobalCounterAction]]></category>
		<category><![CDATA[Storyboard]]></category>
		<category><![CDATA[TimerTrigger]]></category>
		<category><![CDATA[Trigger]]></category>

		<guid isPermaLink="false">http://www.shazaml.com/?p=385</guid>
		<description><![CDATA[If the player clicks too many times within a 5 second time frame trying to find an item, play the shake animation.]]></description>
			<content:encoded><![CDATA[<p>So far in the game, we have particles when an item is clicked, a hint to show the location of an unfound item, but what should we do if the player goes berserk and wildly clicks all over the place in hopes of finding a difficult-to-find item? In this episode of <a href="http://www.shazaml.com/archives/creating-a-hidden-object-game-in-silverlight-3">Creating a Hidden Object Game is Silverlight 3</a> we will add an earthquake effect if the player clicks too many times in a 5 second interval.</p>
<p>Let&#8217;s first start with the shake effect.  The magnifierCanvas Canvas contains the background image and all Paths for each clickable item. We will create a new storyboard called ShakeStoryboard that will animate the Left property of the Canvas:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/112509_1805_HiddenObjec1.png" alt="" /></p>
<p> </p>
<p>Each of the 4 key frames set the Left property to a different value as shown in the storyboard XAML:</p>
<pre class="brush: xml; gutter: false;">
&lt;Storyboard x:Name=&quot;ShakeStoryboard&quot; RepeatBehavior=&quot;5x&quot; AutoReverse=&quot;False&quot; SpeedRatio=&quot;5&quot;&gt;
    &lt;DoubleAnimationUsingKeyFrames BeginTime=&quot;00:00:00&quot;
        Storyboard.TargetName=&quot;magnifierCanvas&quot;
        Storyboard.TargetProperty=&quot;(Canvas.Left)&quot;&gt;
            &lt;EasingDoubleKeyFrame KeyTime=&quot;00:00:00&quot; Value=&quot;0&quot;/&gt;
            &lt;EasingDoubleKeyFrame KeyTime=&quot;00:00:00.2000000&quot; Value=&quot;-10&quot;/&gt;
            &lt;EasingDoubleKeyFrame KeyTime=&quot;00:00:00.4000000&quot; Value=&quot;10&quot;/&gt;
            &lt;EasingDoubleKeyFrame KeyTime=&quot;00:00:00.6000000&quot; Value=&quot;0&quot;/&gt;
    &lt;/DoubleAnimationUsingKeyFrames&gt;
&lt;/Storyboard&gt;
</pre>
<p> </p>
<p>The Storyboard has the RepeatBehavior property set to repeat 5 times and the SpeedRatio property set to speed up the animation.</p>
<p>If the player clicks on the background image 10 times within a 5 second interval, then the ShakeStoryboard will play. To accomplish this we need three SetGlobalCounterAction instances and one ControlStoryboardAction added to the UserControl:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/112509_1805_HiddenObjec2.png" alt="" /></p>
<p>The first SetGlobalCounterAction sets the values for the TooManyClicks counter when the UserControl loads:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/112509_1805_HiddenObjec3.png" alt="" /></p>
<p> </p>
<p>The ControlStoryboardAction plays the ShakeStoryboard when the GlobalCounterMaxReachedTrigger is fired for the TooManyClicks key which we set previously to 10.</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/112509_1805_HiddenObjec4.png" alt="" /></p>
<p>When the counter reaches 10 we need to set it back to zero which is what the second SetGlobalCounterAction does:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/112509_1805_HiddenObjec5.png" alt="" /></p>
<p>The final SetGlobalCounterAction uses the TimerTrigger to reset the counter every 5 seconds:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/112509_1805_HiddenObjec6.png" alt="" /></p>
<p> </p>
<p>The only thing left to do is add the IncrementGlobalCounterAction to the background image to increment the counter by 1:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/112509_1805_HiddenObjec7.png" alt="" /></p>
<p> </p>
<p>So with 5 Action instances, 3 Trigger types, 1 Storyboard, and 0 lines of code we were able to quickly add this feature to the game.</p>
<p><a href="http://www.shazaml.com/downloads/ClutteredCubeSource14.zip"><img class="alignnone size-full wp-image-319" title="Zip" src="http://www.shazaml.com/wp-content/uploads/2009/10/Zip.png" alt="Zip" width="93" height="96" /> Source Code</a></p>
<p><a href="http://www.shazaml.com/hidden-object-game-episode-14-demo"><img class="alignnone size-full wp-image-320" title="silverlight" src="http://www.shazaml.com/wp-content/uploads/2009/10/silverlight.png" alt="silverlight" width="93" height="96" /> Demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.shazaml.com/archives/hidden-object-episode-14/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hidden Object: Episode 13 – Give me a Hint</title>
		<link>http://www.shazaml.com/archives/hidden-object-episode-13</link>
		<comments>http://www.shazaml.com/archives/hidden-object-episode-13#comments</comments>
		<pubDate>Tue, 17 Nov 2009 19:12:44 +0000</pubDate>
		<dc:creator>Mark Tucker</dc:creator>
				<category><![CDATA[Hidden Object Game]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Action]]></category>
		<category><![CDATA[Behavior]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[ControlStoryboardAction]]></category>
		<category><![CDATA[EventTrigger]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[GoToStateAction]]></category>
		<category><![CDATA[HintBehavior]]></category>
		<category><![CDATA[Storyboard]]></category>
		<category><![CDATA[StoryboardCompletedTrigger]]></category>
		<category><![CDATA[Visual State Manager]]></category>
		<category><![CDATA[VSM]]></category>

		<guid isPermaLink="false">http://www.shazaml.com/?p=349</guid>
		<description><![CDATA[Creating the hint feature requires a few animations and a custom behavior.]]></description>
			<content:encoded><![CDATA[<p>This is episode 13 of <a href="http://www.shazaml.com/archives/creating-a-hidden-object-game-in-silverlight-3">Creating a Hidden Object Game is Silverlight 3</a>. In this episode, we will add a hint feature to the game to help the players when they can&#8217;t find an item. This will require various animations and a custom behavior.</p>
<p>The hint feature can be segmented into three parts:</p>
<ul>
<li>Recharging hint button</li>
<li>Hint overlay image with animation</li>
<li>HintBehavior to randomly position the hint overlay image</li>
</ul>
<p> </p>
<h1>Hint Button</h1>
<p><img class="alignnone size-full wp-image-350" title="Hint Button" src="http://www.shazaml.com/wp-content/uploads/2009/11/hintbutton.Gif" alt="Hint Button" width="123" height="99" /></p>
<p>To make the hint button, we will use an image of a laptop, a TextBlock (hintTextBlock), and a ProgressBar (progressBar) wrapped in a Canvas (hintCanvas):</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/111709_1912_HiddenObjec1.png" alt="" /></p>
<p>The idea is that the TextBlock will contain the text &#8220;HINT&#8221; and act as a button to trigger the hint feature. When the TextBlock is clicked, the TextBlock is hidden and the ProgressBar shown. This is accomplished by adding a HintStates group to the main UserControl:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/111709_1912_HiddenObjec2.png" alt="" /></p>
<p>When the HintState is active, the TextBlock is shown and its IsHitTestVisible property is set to true so that it can be clicked. When the RechargeState is active, the TextBlock&#8217;s Opacity property is set to 0 and its IsHitTestVisible property is set to false so that it can&#8217;t be clicked.</p>
<p>To set the RechargeState, we add a GoToStateAction to the TextBlock:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/111709_1912_HiddenObjec3.png" alt="" /></p>
<p>A storyboard is added to change the value of the ProgressBar to indicate that the hint is recharging.</p>
<pre class="brush: xml; gutter: false;">
&lt;Storyboard x:Name=&quot;RechargingStoryboard&quot;&gt;
    &lt;DoubleAnimationUsingKeyFrames BeginTime=&quot;00:00:00&quot;
        Storyboard.TargetName=&quot;progressBar&quot;
        Storyboard.TargetProperty=&quot;(RangeBase.Value)&quot;&gt;
        &lt;EasingDoubleKeyFrame KeyTime=&quot;00:00:00&quot; Value=&quot;0&quot;/&gt;
        &lt;EasingDoubleKeyFrame KeyTime=&quot;00:00:10&quot; Value=&quot;100&quot;/&gt;
    &lt;/DoubleAnimationUsingKeyFrames&gt;
&lt;/Storyboard&gt;
</pre>
<p>In this example, the storyboard will recharge in 10 seconds. For the game, the recharge duration should be somewhere between 30 seconds and 2 minutes.</p>
<p>This storyboard is started using a ControlStoryboardAction on the TextBlock:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/111709_1912_HiddenObjec4.png" alt="" /></p>
<p> </p>
<p>The change from RechargeState to HintState is handled by the GoToStateAction and the StoryboardCompletedTrigger waiting on RechargingStoryboard. So as soon as the recharging animation ends, then the Hint button displays again.</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/111709_1912_HiddenObjec5.png" alt="" /></p>
<p> </p>
<h1>Hint Overlay</h1>
<p><img class="alignnone size-medium wp-image-351" title="Hint Overlay" src="http://www.shazaml.com/wp-content/uploads/2009/11/hintoverlay.Gif" alt="Hint Overlay" width="300" height="300" /></p>
<p>The hint overlay was created in Expression Design and consists of 10 starbursts or flares set in a circular pattern. After the image is added to the project, drag it onto the LayoutRoot Canvas and locate it &#8220;off screen&#8221; (Left = 500, Top = -300). Set the ZIndex of the image to 99 so that it will be over any item on the game screen, but always under the cursor image.</p>
<p> </p>
<p>When the hint TextBlock is clicked, two storyboards are started. The ShowHintStoryboard changes the opacity from 0% to 80% in 2 seconds and then auto reverses back to 0% over the next 2 seconds. The RotateHintStoryboard uses a RotateTransform to rotate the overlay 360 degrees over 4 seconds.</p>
<pre class="brush: xml; gutter: false;">
&lt;Storyboard x:Name=&quot;ShowHintStoryboard&quot; AutoReverse=&quot;True&quot;&gt;
    &lt;DoubleAnimationUsingKeyFrames BeginTime=&quot;00:00:00&quot;
        Storyboard.TargetName=&quot;hintFlareImage&quot;
        Storyboard.TargetProperty=&quot;(UIElement.Opacity)&quot;&gt;
        &lt;EasingDoubleKeyFrame KeyTime=&quot;00:00:00&quot; Value=&quot;0&quot;/&gt;
        &lt;EasingDoubleKeyFrame KeyTime=&quot;00:00:02&quot; Value=&quot;0.8&quot;/&gt;
    &lt;/DoubleAnimationUsingKeyFrames&gt;
&lt;/Storyboard&gt;

&lt;Storyboard x:Name=&quot;RotateHintStoryboard&quot;&gt;
    &lt;DoubleAnimationUsingKeyFrames BeginTime=&quot;00:00:00&quot;
        Storyboard.TargetName=&quot;hintFlareImage&quot;
        Storyboard.TargetProperty=&quot;(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)&quot;&gt;
        &lt;EasingDoubleKeyFrame KeyTime=&quot;00:00:00&quot; Value=&quot;0&quot;/&gt;
        &lt;EasingDoubleKeyFrame KeyTime=&quot;00:00:04&quot; Value=&quot;360&quot;/&gt;
    &lt;/DoubleAnimationUsingKeyFrames&gt;
&lt;/Storyboard&gt;
 </pre>
<p>To start the storyboards, use the ControlStoryboardAction with the EventTrigger:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/111709_1912_HiddenObjec6.png" alt="" /></p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/111709_1912_HiddenObjec7.png" alt="" /></p>
<p> </p>
<h1>Hint Behavior</h1>
<p>The last thing we need to do is figure out where to put the hint overlay image. To do this, we will use a behavior that exposes a ShowHint command as well as a HintItems collection and a HintOverlayName property:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/111709_1912_HiddenObjec8.png" alt="" /></p>
<p>In the same way that the MouseCursorBehavior exposes the CursorName property to allow selection of the cursor, the HintBehavior exposes the HintOverlayName so that we can select the hint overlay image. An EventTrigger causes the ShowHint command to fire when the HINT TextBlock is clicked.</p>
<p>The HintItems collection contains one HintItem object for each item that can have a hint. The HintItem object contains a TargetName property to identify the Path or object representing the item and an X and Y variance for the location of the overlay.</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/11/111709_1912_HiddenObjec9.png" alt="" /></p>
<p>The HintBehavior uses two NameResolver instances (see <a href="http://www.shazaml.com/archives/hidden-object-episode-12">episode 12</a>). The first NameResolver changes the HintOverlayName into a reference to the overlay image control. The second NameResolver is used once a HintItem is randomly picked to see if the object still exists and if so gets a reference to it. Even though a HintItem exists for all clickable items in the hidden object game, it may no longer exist in the visual tree as it could have been removed by the RemoveElementAction as discussed in <a href="http://www.shazaml.com/archives/hidden-object-episode-4">episode 4</a>.</p>
<p>When the ShowHint command is executed, the private OnShowHint method is called. This is the heart of the HintBehavior:</p>
<pre class="brush: csharp; gutter: false;">
private void OnShowHint()
{
  DependencyObject item = null;
 
  if (!this.IsHintOverlayNameSet)
    return;
 
  FrameworkElement hintOverlay = HintOverlay as FrameworkElement;
 
  //mix up the order of item names
  HintItems.Randomize();
 
  for (int index = 0; index &lt; HintItems.Count; index++)
  {
    this.ItemResolver.Name = HintItems[index].TargetName;
    item = this.ItemResolver.Object;
 
    if (item != null)
    {
      double itemX = (double)item.GetValue(Canvas.LeftProperty);
      double itemWidth = (double)item.GetValue(FrameworkElement.ActualWidthProperty);
      double itemY = (double)item.GetValue(Canvas.TopProperty);
      double itemHeight = (double)item.GetValue(FrameworkElement.ActualHeightProperty);
    
      double newX = RandomWithVariance(itemX + (itemWidth / 2) - (hintOverlay.ActualWidth / 2), HintItems[index].OriginXVariance);
      double newY = RandomWithVariance(itemY + (itemHeight / 2) - (hintOverlay.ActualHeight / 2), HintItems[index].OriginYVariance);
 
      hintOverlay.SetValue(Canvas.LeftProperty, newX);
      hintOverlay.SetValue(Canvas.TopProperty, newY);

      break;
    }
  }
}
</pre>
<p> </p>
<p>If the HintOverlayName is not set we exit the method, otherwise we get a reference to it. We then randomize the order of the items in the HintItems list. This is done using an extension method called Randomize(). Since some items named in the list may no longer exist on the Canvas, we do a null check after we access an item in the list and resolve it. If the item exists, then we determine the location of the item with its width and height so that we can center the overlay image over the item. The RandomWithVariance method uses the OriginXVariance and OriginYVariance values set on HintItem to make sure that the overlay image is over the item but that the item is not necessarily exactly centered.</p>
<p> </p>
<p>The hint feature of our hidden object game is fairly simple once we break it into its three main components and work on them individually. Stay tuned for the <a href="http://www.shazaml.com/archives/hidden-object-episode-14">next episode</a> of Creating a Hidden Object Game in Silverlight 3.</p>
<p><a href="http://www.shazaml.com/downloads/ClutteredCubeSource13.zip"><img class="alignnone size-full wp-image-319" title="Zip" src="http://www.shazaml.com/wp-content/uploads/2009/10/Zip.png" alt="Zip" width="93" height="96" /> Source Code</a></p>
<p><a href="http://www.shazaml.com/hidden-object-game-episode-13-demo"><img class="alignnone size-full wp-image-320" title="silverlight" src="http://www.shazaml.com/wp-content/uploads/2009/10/silverlight.png" alt="silverlight" width="93" height="96" /> Demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.shazaml.com/archives/hidden-object-episode-13/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Video: Creating a Silverlight 3 Casual Game using Blend 3 and Triggers, Actions, and Behaviors</title>
		<link>http://www.shazaml.com/archives/video-silverlight-casual-game</link>
		<comments>http://www.shazaml.com/archives/video-silverlight-casual-game#comments</comments>
		<pubDate>Mon, 09 Nov 2009 15:19:11 +0000</pubDate>
		<dc:creator>Mark Tucker</dc:creator>
				<category><![CDATA[Hidden Object Game]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Action]]></category>
		<category><![CDATA[Behavior]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[ChangePropertyAction]]></category>
		<category><![CDATA[ContinuousPlayMediaBehavior]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[GlobalCounterMinReachedTrigger]]></category>
		<category><![CDATA[GoToStateAction]]></category>
		<category><![CDATA[IncrementGlobalCounterAction]]></category>
		<category><![CDATA[InvokeCommandAction]]></category>
		<category><![CDATA[MagnifierOverBehavior]]></category>
		<category><![CDATA[MouseCursorBehavior]]></category>
		<category><![CDATA[ParticlesBehavior]]></category>
		<category><![CDATA[PlaySoundAction]]></category>
		<category><![CDATA[RemoveElementAction]]></category>
		<category><![CDATA[SetGlobalCounterAction]]></category>
		<category><![CDATA[SetInteractionPropertyAction]]></category>
		<category><![CDATA[ShowGlobalCounterBehavior]]></category>
		<category><![CDATA[Trigger]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[Visual State Manager]]></category>
		<category><![CDATA[VSM]]></category>

		<guid isPermaLink="false">http://www.shazaml.com/?p=333</guid>
		<description><![CDATA[Video presentation from Desert Code Camp 2009 - Silverlight 3 Casual Game]]></description>
			<content:encoded><![CDATA[<p>On Saturday, November 7, 2009 at 9:00am I presented at the Desert Code Camp in Phoenix, AZ. The topic of my presentation was Silverlight casual game development. In less than an hour I demonstrated how to use triggers, actions, and behaviors in Blend 3 to create a hidden object game. Because all code was contained in the TABs (Triggers, Actions, and Behaviors) there was no code behind for the main UserControl.</p>
<p>Here is a link to the <a title="Video - Creating a Silverlight 3 Casual Game using Blend 3 and Triggers, Actions, and Behaviors" href="http://www.shazaml.com/downloads/DesertCodeCamp2009-Silverlight3CasualGame.wmv">presentation video</a> in WMV format.</p>
<p>If you like you can see <a href="http://www.shazaml.com/archives/creating-a-hidden-object-game-in-silverlight-3">all the episodes</a> and follow along with the tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shazaml.com/archives/video-silverlight-casual-game/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
<enclosure url="http://www.shazaml.com/downloads/DesertCodeCamp2009-Silverlight3CasualGame.wmv" length="63294285" type="video/x-ms-wmv" />
		</item>
		<item>
		<title>Hidden Object: Episode 12 – Custom Mouse Cursor Behavior</title>
		<link>http://www.shazaml.com/archives/hidden-object-episode-12</link>
		<comments>http://www.shazaml.com/archives/hidden-object-episode-12#comments</comments>
		<pubDate>Tue, 27 Oct 2009 14:07:09 +0000</pubDate>
		<dc:creator>Mark Tucker</dc:creator>
				<category><![CDATA[Hidden Object Game]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Behavior]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[MouseCursorBehavior]]></category>

		<guid isPermaLink="false">http://www.shazaml.com/?p=309</guid>
		<description><![CDATA[With the MouseCursorBehavior it is easy to set custom mouse cursors.]]></description>
			<content:encoded><![CDATA[<p>This is episode 12 of <a href="http://www.shazaml.com/archives/creating-a-hidden-object-game-in-silverlight-3">Creating a Hidden Object Game is Silverlight 3</a>. In this episode, we will create a behavior that allows us to set the shape of the mouse cursor to any Image or Path we desire.</p>
<p>Let start this tutorial in <a href="http://www.microsoft.com/expression/products/Design_Overview.aspx">Expression Design</a>. Create a new document that is 25&#215;25 pixels and on the single layer add the shapes shown:</p>
<p> </p>
<p><a href="http://www.shazaml.com/wp-content/uploads/2009/10/102709_1407_HiddenObjec1.png"><img class="alignnone size-medium wp-image-303" title="102709_1407_HiddenObjec1.png" src="http://www.shazaml.com/wp-content/uploads/2009/10/102709_1407_HiddenObjec1-300x201.png" alt="102709_1407_HiddenObjec1.png" width="300" height="201" /></a> </p>
<p>Export the document as a PNG making sure that both Transparency and Antialias are checked.</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/10/102709_1407_HiddenObjec2.png" alt="" /></p>
<p> </p>
<p>If you don&#8217;t have a copy of Expression Design, you can use a vector graphics program like <a href="http://www.inkscape.org/">Inkscape</a>.</p>
<p> </p>
<p>Add the image to the Visual Studio project and drag it onto the Canvas. Let&#8217;s position the cursor image off screen at: Top = -50 and Left = -5. The -5 positions the cursor so the tip of the arrow is right in the corner and the -50 just to get it off screen. Since this image needs to be over all other objects including the screen Canvas objects, let&#8217;s set the ZIndex property to 1000.</p>
<p>We will compensate for the Top value with the OffsetY value in the MouseCursorBehavior that we will create:</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/10/102709_1407_HiddenObjec3.png" alt="" /></p>
<p> </p>
<p>The two offset values are dependency properties of type Double whereas CursorName is a string. You will notice that the cursor name has the artboard element picker (target symbol) that allows you to pick an object from the artboard.</p>
<p>Under the Interactivity folder, create a folder called MouseCursor and add three class files: MouseCursorBehavior, NameResolvedEventArgs, and NameResolver.</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/10/102709_1407_HiddenObjec4.png" alt="" /></p>
<p>To get NameResolver and NameResolvedEventArgs, I admit that I used <a href="http://www.red-gate.com/products/reflector/">.NET Reflector</a> to understand how the TargetedTriggerAction class was able to get a reference to an instance of the Target class using the string dependency property, TargetName.</p>
<p>Here is a sample usage of the NameResolver class as it relates to the MouseCursorBehavior:</p>
<pre class="brush: csharp; gutter: false;">
NameResolver cursorResolver = new NameResolver();
cursorResolver.NameScopeReferenceElement = AssociatedObject;
cursorResolver.Name = &quot;cursorArrow&quot;;
DependencyObject cursor = cursorResolver.Object;
 </pre>
<p>After creating an instance of the NameResolver, we must assign an object as the NameScopeReferenceElement and set the name of the element that will be our cursor. Calling the Object property on the resolver will return a reference to the object specified by the Name property. The key method in NameResolver is UpdateObjectFromName:</p>
<pre class="brush: csharp; gutter: true;">
private void UpdateObjectFromName(DependencyObject oldObject)
{
    DependencyObject resolvedObject = null;
    this.ResolvedObject = null;
 
    if (this.NameScopeReferenceElement != null)
    {
        if (!IsElementLoaded(this.NameScopeReferenceElement))
        {
            this.NameScopeReferenceElement.Loaded += new RoutedEventHandler(this.OnNameScopeReferenceLoaded);
            this.PendingReferenceElementLoad = true;
            return;
        }
        if (!string.IsNullOrEmpty(this.Name))
        {
            FrameworkElement actualNameScopeReferenceElement = this.ActualNameScopeReferenceElement;
            if (actualNameScopeReferenceElement != null)
            {
                resolvedObject = actualNameScopeReferenceElement.FindName(this.Name) as DependencyObject;
            }
        }
    }
    this.HasAttempedResolve = true;
    this.ResolvedObject = resolvedObject;
    if (oldObject != this.Object)
    {
        this.OnObjectChanged(oldObject, this.Object);
    }
}
</pre>
<p> </p>
<p>Line 19 shows how NameScopeReferenceElement and Name are used to resolve the actual object.</p>
<p>The MouseCursorBehavior class defines three dependency properties with their corresponding .NET properties:</p>
<pre class="brush: csharp; gutter: false;">
public static readonly DependencyProperty CursorNameProperty =
     DependencyProperty.Register(&quot;CursorName&quot;, typeof(string), typeof(MouseCursorBehavior),
     new PropertyMetadata(new PropertyChangedCallback(OnCursorNameChanged)));
 
public static readonly DependencyProperty OffsetXProperty =
    DependencyProperty.Register(&quot;OffsetX&quot;, typeof(double), typeof(MouseCursorBehavior), null);
    
public static readonly DependencyProperty OffsetYProperty =
    DependencyProperty.Register(&quot;OffsetY&quot;, typeof(double), typeof(MouseCursorBehavior), null);
 </pre>
<p>In the constructor of the behavior, a NameResolver called cursorResolver is created. In the OnAttached method, the resolver&#8217;s NameScopeReferenceElement is set to the AssociatedObject. And in the OnCursorChanged method, the Name property is set to the name of the object to be used as the cursor:</p>
<pre class="brush: csharp; gutter: false;">
private static void OnCursorNameChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
    MouseCursorBehavior behavior = (MouseCursorBehavior)obj;
    behavior.CursorResolver.Name = (string)args.NewValue;
}
</pre>
<p>To get the artboard element picker to show in the Properties panel for the CursorName, add the CustomPropertyValueEditor attribute to the CursorName property and specify the editor for an Element:</p>
<pre class="brush: csharp; gutter: false;">
[CustomPropertyValueEditor(CustomPropertyValueEditor.Element)]
public string CursorName
{
    get
    {
        return (string)base.GetValue(CursorNameProperty);
    }
    set
    {
        base.SetValue(CursorNameProperty, value);
    }
}
 </pre>
<p>The Cursor property is where the CursorName value is resolved by the NameResolver and the object reference is returned.</p>
<p>Now the behavior has a reference to the image that is being used as a cursor, now it needs to use that instead of the default cursor. In the OnAttached method, the behavior registers to handle the MouseEnter and MouseLeave events of the AssociatedObject. In our case, the MouseCursorBehavior will be attached to the MainPage UserControl which becomes the AssociatedObject. So whenever the mouse enters the area of the UserControl, it will be changed to the arrow:</p>
<pre class="brush: csharp; gutter: false;">
private void AssociatedObject_MouseEnter(object sender, MouseEventArgs e)
{
    if (!this.IsCursorNameSet)
        return;
 
    FrameworkElement cursor = Cursor as FrameworkElement;
 
    cursor.Visibility = Visibility.Visible;
    AssociatedObject.Cursor = Cursors.None;
    cursor.IsHitTestVisible = false;
 
    this.AssociatedObject.MouseMove += new MouseEventHandler(AssociatedObject_MouseMove);
}
</pre>
<p>The cursor variable has a reference to the resolved object which is the Image named cursorArrow. We make the image visible and hide the real cursor. We must make the image &#8220;invisible&#8221; to mouse events so we set the IsHitTestVisible property to false. Finally, we register for the MouseMove event which is responsible for positioning the image wherever the mouse should be:</p>
<p> </p>
<pre class="brush: csharp; gutter: false;">
private void AssociatedObject_MouseMove(object sender, MouseEventArgs e)
{
    if (!this.IsCursorNameSet)
        return;
 
    FrameworkElement cursor = Cursor as FrameworkElement;
 
    Point mousePosition = e.GetPosition(null);
    cursor.Margin = new Thickness(mousePosition.X + OffsetX, mousePosition.Y + OffsetY, 0, 0);
 
}
</pre>
<p>To position the image, we use the trick of specifying the top and left values of its Margin based on the current mouse postion and the OffsetX and OffsetY dependency properties we defined.</p>
<p> </p>
<p>In the MouseLeave event handler, we simply undo what we set in the MouseEnter handler.</p>
<p> </p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/10/102709_1407_HiddenObjec5.png" alt="" /></p>
<p> </p>
<p>I&#8217;ve seen a similar approach to custom cursors various places on the Internet. One requirement that I had was the need to specify a cursor at the UserControl level as shown, but then to have a child (or grandchild, etc.) object of that UserControl also have a unique cursor. If you move the mouse over a hidden rectangle on the left side of the screen the cursor will change to a left-facing arrow. Clicking the arrow will take you to another screen which has a hidden rectangle on the right that displays a right-facing arrow to get you pack to the original screen.</p>
<p> </p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/10/102709_1407_HiddenObjec6.png" alt="" /></p>
<p> </p>
<p>In the code, I created two path objects for the arrows just to show that any element could be used for a cursor. If I wanted, I could even have a cursor with multiple objects grouped in a Canvas that use animation storyboards.</p>
<p> </p>
<p>When you look at the complete source for this project, you will notice that I use a Stack data structure to keep track of the nested cursors. I am not completely satisfied with the code as it stands, but it works for the present situation. Two things to note. First, the hidden rectangle must have space all around it so that the cursor properly changes from the left arrow to the cursorArrow. Second, I had to do a workaround because the shapes generated from the ParticlesBehavior was interfering with the custom cursor as sometimes a MouseEnter event was being fired with the star shapes but no MouseLevent event.</p>
<p> <br />
Check out the code and let me know if you come up with a better solution.</p>
<p><a href="http://www.shazaml.com/downloads/ClutteredCubeSource12.zip"><img class="alignnone size-full wp-image-319" title="Zip" src="http://www.shazaml.com/wp-content/uploads/2009/10/Zip.png" alt="Zip" width="93" height="96" /> Source Code</a></p>
<p><a href="http://www.shazaml.com/hidden-object-episode-12-demo"><img class="alignnone size-full wp-image-320" title="silverlight" src="http://www.shazaml.com/wp-content/uploads/2009/10/silverlight.png" alt="silverlight" width="93" height="96" /> Demo</a></p>
<p>In the <a href="http://www.shazaml.com/archives/hidden-object-episode-13">next episode</a>, we will add a hint feature that allows the player to see an area of the screen that still has an object to find.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shazaml.com/archives/hidden-object-episode-12/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hidden Object: Episode 11 – Add Custom Shapes to the Particles Behavior</title>
		<link>http://www.shazaml.com/archives/hidden-object-episode-11</link>
		<comments>http://www.shazaml.com/archives/hidden-object-episode-11#comments</comments>
		<pubDate>Tue, 06 Oct 2009 00:05:27 +0000</pubDate>
		<dc:creator>Mark Tucker</dc:creator>
				<category><![CDATA[Hidden Object Game]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Behavior]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[ParticlesBehavior]]></category>

		<guid isPermaLink="false">http://www.shazaml.com/?p=292</guid>
		<description><![CDATA[Add sizzle to the Particles Behavior by allowing particle custom shapes.]]></description>
			<content:encoded><![CDATA[<p>This is episode 11 of <a href="http://www.shazaml.com/archives/creating-a-hidden-object-game-in-silverlight-3">Creating a Hidden Object Game is Silverlight 3</a>.</p>
<p>Growing up our family didn&#8217;t splurge on Lucky Charms cereal, but I remember the TV commercials with Lucky the leprechaun talking about all the fun marshmallow shapes: pink hearts, yellow moons, orange stars, green clovers, and blue diamonds. In later years other shapes appeared such as purple horseshoes, red balloons, rainbows, and pots of gold.</p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/10/100609_0005_HiddenObjec1.jpg" alt="" /></p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/10/100609_0005_HiddenObjec2.jpg" alt="" /></p>
<p> </p>
<p>What does this have to do with our hidden object game? Currently the ParticleControl creates only one shape. Circles. Wouldn&#8217;t it be great if you could specify the shape of the particles? That&#8217;s what I thought and I knew it could easily be done once I saw this <a href="http://stringtopathgeometry.codeplex.com/Thread/View.aspx?ThreadId=66283">discussion post</a> on the <a href="http://www.codeplex.com/">CodePlex</a> site for the <a href="http://stringtopathgeometry.codeplex.com/">Silverlight String-To-PathGeometry Converter</a>.</p>
<p>To the existing ParticlesBehavior, we will add two dependency properties with corresponding property get/set blocks:</p>
<p> </p>
<pre class="brush: csharp; gutter: false;">
public static readonly DependencyProperty ParticleShapeProperty =
    DependencyProperty.Register(&quot;ParticleShape&quot;, typeof(ParticleShape),
    typeof(ParticlesBehavior), null);

public static readonly DependencyProperty CustomShapePathDataProperty =
    DependencyProperty.Register(&quot;CustomShapePathData&quot;, typeof(string),
    typeof(ParticlesBehavior), null);
</pre>
<p> </p>
<p>The ParticleShape property is an enum with a list of possible shapes and a custom option:</p>
<pre class="brush: csharp; gutter: false;">
public enum ParticleShape
{
    Circle,
    Square,
    Star4,
    Star5,
    Star8,
    Custom
}
</pre>
<p> </p>
<p>The CustomShapePathData property is a string that holds a special <a href="http://msdn.microsoft.com/en-us/library/ms752293.aspx">XAML Path markup syntax</a> and is used when the ParticleShape property is set to Custom. Here is an example of a path definition for a triangle:</p>
<p> </p>
<pre class="brush: xml; gutter: false;">
&lt;Path Data=&quot;F1 M 50,7.62939e-006L -1.02561e-005,100L 100,100L 50,7.62939e-006 Z &quot;/&gt;
</pre>
<p> </p>
<p>The value of the Data property is what is set on CustomShapePathData.</p>
<p> </p>
<p>The only other change we need to make to ParticlesBehavior is in the OnShowParticles method where we set the ParticleShape and CustomShapePathData on the instance of ParticleControl.</p>
<p> </p>
<p>In ParticleControl, we add the same two dependency properties for ParticleShape and CustomShapePathData with their corresponding property get and set.</p>
<p> </p>
<p>The Ellipse, Rectangle, and Path all inherit from the Shape base class. So we change all the methods in ParticleControl that worked on an Ellipse to a Shape. In the SpawnParticle method, we call the newly created CreateShape method:</p>
<p> </p>
<pre class="brush: csharp; gutter: false;">
private Shape CreateShape()
{
    string pathData = &quot;&quot;;

    switch (ParticleShape)
    {
        case ParticleShape.Circle:
            return new Ellipse();
 
        case ParticleShape.Square:
            return new Rectangle();

        case ParticleShape.Star4:
            pathData = star4;
            break;

        case ParticleShape.Star5:
            pathData = star5;
            break;

        case ParticleShape.Star8:
            pathData = star8;
            break;

        case ParticleShape.Custom:
            if (string.IsNullOrEmpty(CustomShapePathData))
                return new Ellipse();
            else
                pathData = CustomShapePathData;
            break;

        default:
            return new Ellipse();
    }

    string xamlPath = string.Format(&quot;&lt;Path xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' &quot; +
             &quot;xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' &quot; +
             &quot;Data='{0}' Stretch='Fill'/&gt;&quot;, pathData);

    Path path = (Path)System.Windows.Markup.XamlReader.Load(xamlPath);

    return path;
}
</pre>
<p> </p>
<p>If the ParticleShape property is set to Circle or Square, then a new Ellipse or Rectangle is created and returned. If the selected shape is a 4, 5, or 8-pointed star then a string constant containing the Path data syntax is set and a new Path is created using the XamlReader.Load method. If it is a custom shape, then the data is set based on the value of the CustomShapePathData property. If there is no custom path data, then an Ellipse is created.</p>
<p> </p>
<p>When we compile the project and open Blend, we will now see the additional properties:</p>
<p> </p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/10/100609_0005_HiddenObjec3.png" alt="" /></p>
<p> </p>
<p>Here is what the custom triangle particles look like as well as the built-in shapes:</p>
<p> </p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/10/100609_0005_HiddenObjec4.png" alt="" /></p>
<p> </p>
<p>One of the best ways to create these custom shapes is in Expression Design. Create a new document that is 100&#215;100 pixels. Use the Pen, Polygon, or Polyline tools to create a path to your desired shape. Or create multiple paths and use Path operations (Unite, Front Minus Back, etc.) to create a single path.</p>
<p> </p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/10/100609_0005_HiddenObjec5.png" alt="" /></p>
<p>Select the Path and on the Edit menu select Copy XAML. Paste the XAML into Notepad and copy the Data property string and paste it as the CustomShapePathData value:</p>
<p> </p>
<pre class="brush: xml; gutter: false;">
&lt;Canvas xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    x:Name=&quot;Layer_1_4&quot; Width=&quot;100&quot; Height=&quot;100&quot; Canvas.Left=&quot;0&quot; Canvas.Top=&quot;0&quot;&gt;

    &lt;Path Width=&quot;99.7292&quot; Height=&quot;100.79&quot;
        Canvas.Left=&quot;-1.84403&quot; Canvas.Top=&quot;-1.13409&quot;
        Stretch=&quot;Fill&quot; StrokeLineJoin=&quot;Round&quot; Stroke=&quot;#FF000000&quot;

        Data=&quot;F1 M 31.5808,99.156C 34.4917,98.2985 37.4026,97.441 40.1509,96.3542C 42.8991,95.2675 45.4846,93.9515 47.874,92.4426C 50.2634,90.9336 52.4566,89.2317 54.4271,87.3777C 56.3976,85.5237 58.1453,83.5175 59.6511,81.4035C 61.1568,79.2895 62.4206,77.0676 63.4311,74.7844C 64.4415,72.5011 65.1986,70.1565 65.699,67.7977C 66.1994,65.439 66.4431,63.0661 66.6868,60.6933C 67.6642,61.334 68.6416,61.9748 69.581,62.7785C 70.5203,63.5821 71.4217,64.5487 72.2503,65.6721C 73.0789,66.7954 73.8349,68.0754 74.4845,69.4997C 75.1342,70.9239 75.6777,72.4923 76.0837,74.1863C 76.4897,75.8803 76.7583,77.6999 76.8615,79.6207C 76.9647,81.5416 76.9025,83.5637 76.6513,85.6577C 76.4,87.7517 75.9597,89.9176 75.5194,92.0835C 76.6639,89.273 77.8084,86.4624 78.6723,83.6362C 79.5361,80.81 80.1193,77.9681 80.4293,75.1592C 80.7393,72.3503 80.7762,69.5744 80.5552,66.8778C 80.3342,64.1813 79.8555,61.564 79.1415,59.0687C 78.4275,56.5734 77.4784,54.2 76.3232,51.9865C 75.1681,49.7729 73.8071,47.7191 72.2749,45.8572C 70.7427,43.9953 69.0395,42.3253 67.3363,40.6554C 68.4466,40.2907 69.557,39.926 70.771,39.6927C 71.985,39.4594 73.3028,39.3573 74.6976,39.4098C 76.0925,39.4624 77.5646,39.6695 79.0832,40.0495C 80.6018,40.4296 82.1669,40.9826 83.7444,41.7214C 85.322,42.4601 86.912,43.3846 88.4781,44.5016C 90.0443,45.6185 91.5865,46.9279 93.067,48.4299C 94.5475,49.9319 95.9663,51.6266 97.3851,53.3212C 95.9014,50.6741 94.4176,48.027 92.7466,45.5895C 91.0756,43.152 89.2173,40.9241 87.2145,38.9304C 85.2117,36.9367 83.0644,35.1771 80.8184,33.6686C 78.5723,32.1601 76.2276,30.9026 73.8315,29.905C 71.4354,28.9074 68.9881,28.1697 66.5372,27.6927C 64.0864,27.2156 61.632,26.9993 59.2211,27.0363C 56.8101,27.0733 54.4425,27.3637 52.075,27.6541C 52.4822,26.5587 52.8893,25.4632 53.4638,24.3686C 54.0383,23.2739 54.7801,22.18 55.6909,21.1222C 56.6017,20.0644 57.6814,19.0426 58.9254,18.0923C 60.1693,17.142 61.5775,16.2632 63.1387,15.4904C 64.6999,14.7176 66.414,14.0509 68.2638,13.5228C 70.1135,12.9948 72.0987,12.6054 74.1961,12.3844C 76.2935,12.1634 78.5031,12.1107 80.7127,12.058C 77.7179,11.5676 74.7232,11.0772 71.7757,10.8639C 68.8281,10.6506 65.9276,10.7144 63.1202,11.0372C 60.3127,11.36 57.5982,11.9418 55.0184,12.7573C 52.4386,13.5727 49.9936,14.6219 47.7197,15.8732C 45.4458,17.1245 43.3432,18.578 41.4421,20.1967C 39.5411,21.8155 37.8416,23.5994 36.3674,25.5075C 34.8931,27.4156 33.644,29.4477 32.3949,31.4798C 31.7923,30.4784 31.1897,29.4771 30.6921,28.3454C 30.1944,27.2137 29.8017,25.9518 29.5425,24.5802C 29.2834,23.2085 29.1577,21.7273 29.1903,20.1622C 29.223,18.5971 29.4138,16.9482 29.783,15.2458C 30.1522,13.5434 30.6997,11.7875 31.4402,10.0121C 32.1806,8.23676 33.114,6.44186 34.2489,4.66424C 35.3838,2.88662 36.7202,1.12626 38.0567,-0.634094C 35.8061,1.40149 33.5555,3.4371 31.5509,5.60862C 29.5464,7.78015 27.7879,10.0876 26.2898,12.4839C 24.7918,14.8801 23.5542,17.3651 22.5833,19.8904C 21.6124,22.4158 20.9082,24.9816 20.4687,27.5396C 20.0293,30.0976 19.8547,32.6477 19.935,35.1433C 20.0153,37.6388 20.3505,40.0798 20.9231,42.4221C 21.4956,44.7643 22.3056,47.0079 23.1156,49.2515C 21.957,49.0983 20.7984,48.9451 19.6033,48.6286C 18.4083,48.3121 17.1768,47.8323 15.9428,47.1797C 14.7089,46.5272 13.4724,45.7019 12.2692,44.7006C 11.0659,43.6993 9.89571,42.522 8.79491,41.1719C 7.69411,39.8218 6.66265,38.299 5.73625,36.6131C 4.80985,34.9273 3.9885,33.0785 3.3063,31.0828C 2.6241,29.0872 2.08106,26.9447 1.53801,24.8023C 1.72628,27.8311 1.91455,30.8598 2.36251,33.781C 2.81047,36.7021 3.51811,39.5156 4.45754,42.1809C 5.39696,44.8461 6.56816,47.3631 7.93723,49.6967C 9.30631,52.0304 10.8733,54.1807 12.5992,56.1191C 14.3251,58.0575 16.2101,59.784 18.2112,61.2772C 20.2124,62.7704 22.3298,64.0303 24.5181,65.043C 26.7063,66.0557 28.9654,66.8213 31.2246,67.5869C 30.3824,68.3972 29.5402,69.2075 28.5477,69.9445C 27.5551,70.6815 26.4122,71.3452 25.1326,71.903C 23.8531,72.4609 22.4369,72.913 20.9038,73.2295C 19.3707,73.546 17.7207,73.7268 15.9788,73.7457C 14.237,73.7646 12.4033,73.6215 10.5076,73.2947C 8.61196,72.9679 6.65438,72.4573 4.66878,71.7464C 2.68319,71.0355 0.669576,70.1243 -1.34403,69.2131C 1.14133,70.9543 3.62669,72.6955 6.18983,74.1666C 8.75297,75.6376 11.3939,76.8386 14.0634,77.7659C 16.7329,78.6932 19.4309,79.3468 22.1091,79.7314C 24.7872,80.116 27.4453,80.2316 30.037,80.0908C 32.6286,79.95 35.1537,79.5528 37.5688,78.9192C 39.9839,78.2856 42.2891,77.4156 44.4452,76.3362C 46.6014,75.2568 48.6085,73.9679 50.6156,72.6789C 50.724,73.8426 50.8324,75.0063 50.7898,76.2418C 50.7472,77.4773 50.5534,78.7847 50.1918,80.1329C 49.8302,81.4811 49.3007,82.8702 48.5923,84.2661C 47.8838,85.6621 46.9964,87.0649 45.9251,88.4385C 44.8539,89.8121 43.5987,91.1566 42.1613,92.4349C 40.7239,93.7132 39.1042,94.9254 37.3104,96.0345C 35.5166,97.1437 33.5487,98.1498 31.5808,99.156 Z &quot;/&gt;
&lt;/Canvas&gt;
</pre>
<p> </p>
<p>It&#8217;s that easy:</p>
<p> </p>
<p><img src="http://www.shazaml.com/wp-content/uploads/2009/10/100609_0005_HiddenObjec6.png" alt="" /><br />
 <br />
<a href="http://www.shazaml.com/downloads/ClutteredCubeSource11.zip">Source code</a><br />
<a href="http://www.shazaml.com/hidden-object-episode-11-demo">Demo</a></p>
<p>In the <a href="http://www.shazaml.com/archives/hidden-object-episode-12">next episode</a>, we will create a custom mouse cursor and manage its use with a behavior.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shazaml.com/archives/hidden-object-episode-11/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
