<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Coding4Fun : windows</title><link>http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx</link><description>Tags: windows</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Shutdown/Restart/Logoff your PC using TweetMyPC</title><link>http://blogs.msdn.com/coding4fun/archive/2009/06/23/9709252.aspx</link><pubDate>Tue, 23 Jun 2009 22:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9709252</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9709252.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9709252</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9709252</wfw:comment><description>&lt;p&gt;In this article I will show you how you can use Twitter API to Shutdown/Restart/Logoff your PC remotely using VB.net.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Compiled version: &lt;/b&gt;&lt;a href="http://tweetmypc.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=26541#DownloadId=66390"&gt;CodePlex.com&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Source Code:&lt;/b&gt; &lt;a href="http://tweetmypc.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=26542#DownloadId=66391"&gt;Codeplex.com&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Difficulty:&lt;/b&gt; Beginner&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Time Required:&lt;/b&gt; 2 hours&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Cost:&lt;/b&gt; Free&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Software Needed:&lt;/b&gt; &lt;a href="http://www.microsoft.com/express/download/"&gt;Visual Basic or Visual C# Express&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Libraries: &lt;/b&gt;&lt;a href="http://devblog.yedda.com/index.php/2007/05/16/twitter-c-library/"&gt;Yedda Twitter Library&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Introduction&lt;/h3&gt;  &lt;p&gt;I have a very slow internet connection at home and most of the time Downloads takes hours to complete. I decided to write an application which will help me Shutdown my PC from a remote location. I wanted to use it to shutdown when I go out when some downloading is going on in my laptop. Instead of using a server and client architecture I decided to use Twitter API and use “My Timeline” to supply commands. One other reason to use Twitter is that I will be able to tweet from my mobile as well. I don’t need to look for a computer with an internet connection when I am on the move.&lt;/p&gt;  &lt;h4&gt;Why Yedda Twitter framework?&lt;/h4&gt;  &lt;p&gt;The &lt;a href="http://apiwiki.twitter.com/Twitter-API-Documentation"&gt;Twitter REST API&lt;/a&gt; methods allow developers to access core Twitter data. This includes update timelines, status data, and user information. It’s very easy to connect to Twitter and get user time line using .net. But I dint wanted to reinvent wheel and decided to use an existing Twitter library. Yedda Twitter framework is the best open source Twitter library available in the internet. You can learn more and download the library from &lt;a href="http://devblog.yedda.com/index.php/2007/05/16/twitter-c-library/"&gt;yedda’s home page&lt;/a&gt;.&lt;/p&gt;  &lt;h4&gt;Designing the Interface&lt;/h4&gt;  &lt;p&gt;I wanted the interface to be as simple as possible. Below is the screenshot of TweetMyPC’s interface which does not have more than 2 Text Boxes, 1 Check Box, Label and a Button.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/ShutdownRestartLogoffyourPCusingTweetMyP_D2B1/clip_image001_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/ShutdownRestartLogoffyourPCusingTweetMyP_D2B1/clip_image001_thumb.jpg" width="288" height="250" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The form also has a Notify Icon, Context Menu Strip and a Timer. Following are the names of all the controls in the form.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;From : &lt;b&gt;frmTweetMyPc&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;Text Boxes : &lt;b&gt;txtUserName&lt;/b&gt;, &lt;b&gt;txtPassword&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;Button : &lt;b&gt;btnSave&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;Check Box : &lt;b&gt;chkStartAutomatic&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;Timer : &lt;b&gt;tmrTweet&lt;/b&gt; (Interval : 10000)&lt;/li&gt;    &lt;li&gt;Label : &lt;b&gt;lblSatus&lt;/b&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;There are few &lt;a href="http://msdn.microsoft.com/en-us/library/saa62613(VS.80).aspx"&gt;My.settings&lt;/a&gt; properties to store user information. These properties are shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/ShutdownRestartLogoffyourPCusingTweetMyP_D2B1/clip_image002_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/ShutdownRestartLogoffyourPCusingTweetMyP_D2B1/clip_image002_thumb.jpg" width="388" height="139" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;The Code&lt;/b&gt;&lt;b&gt;     &lt;br /&gt;&lt;/b&gt;Add the following code which minimizes the Form on Load and Enable Timer to check for Tweets every 1 minute. &lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;Me&lt;/span&gt;.WindowState = FormWindowState.Minimized
&lt;span class="kwrd"&gt;Me&lt;/span&gt;.ShowInTaskbar = &lt;span class="kwrd"&gt;False&lt;/span&gt;
tmrTweet.Enabled = True&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The following code in Button’s Click event will validate Twitter username, Password and save it to My.Settings.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;If&lt;/span&gt; txtUserName.Text.Trim = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;
    lblSatus.Text = &lt;span class="str"&gt;&amp;quot;Please enter Twitter Username&amp;quot;&lt;/span&gt;
    txtUserName.Focus()
    &lt;span class="kwrd"&gt;Exit&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;
&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;
&lt;span class="kwrd"&gt;If&lt;/span&gt; txtPassword.Text.Trim = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;
    lblSatus.Text = &lt;span class="str"&gt;&amp;quot;Please enter Twitter Password&amp;quot;&lt;/span&gt;
    txtPassword.Focus()
    &lt;span class="kwrd"&gt;Exit&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;
&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;

lblSatus.Text = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;


&lt;span class="rem"&gt;'Check for valid Username and Password and then Save Settings&lt;/span&gt;
&lt;span class="kwrd"&gt;Dim&lt;/span&gt; objTwitter &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; Yedda.Twitter
&lt;span class="kwrd"&gt;Dim&lt;/span&gt; Updates &lt;span class="kwrd"&gt;As&lt;/span&gt; XmlDocument

&lt;span class="kwrd"&gt;Try&lt;/span&gt; &lt;span class="rem"&gt;'Try Logging in&lt;/span&gt;
    Updates = objTwitter.GetUserTimelineAsXML(txtUserName.Text.Trim, txtPassword.Text.Trim)
    My.Settings.UserName = txtUserName.Text.Trim
    My.Settings.Password = txtPassword.Text.Trim
    &lt;span class="kwrd"&gt;Me&lt;/span&gt;.WindowState = FormWindowState.Minimized
    &lt;span class="kwrd"&gt;Me&lt;/span&gt;.ShowInTaskbar = &lt;span class="kwrd"&gt;False&lt;/span&gt;
    tmrTweet.Enabled = &lt;span class="kwrd"&gt;True&lt;/span&gt;
&lt;span class="kwrd"&gt;Catch&lt;/span&gt; ex &lt;span class="kwrd"&gt;As&lt;/span&gt; Exception
    MsgBox(&lt;span class="str"&gt;&amp;quot;Failed to Login to Twitter with the values supplied. Please check your login details.&amp;quot;&lt;/span&gt;)
    txtUserName.Focus()
    &lt;span class="kwrd"&gt;Exit&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;
&lt;span class="kwrd"&gt;End&lt;/span&gt; Try&lt;/pre&gt;

&lt;p&gt;Yedda library is used to login to Twitter to check for valid username and password. The Label &lt;b&gt;lblSatus&lt;/b&gt; is used to display any error messages.&lt;/p&gt;

&lt;p&gt;Add the following code to the Checkbox’s &lt;strong&gt;CheckChanged&lt;/strong&gt; event which will add the required registry keys to start this app on Window’s startup&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;If&lt;/span&gt; chkStartAutomatic.Checked = &lt;span class="kwrd"&gt;True&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; My.Settings.AutomaticStart = &lt;span class="kwrd"&gt;True&lt;/span&gt;
      &lt;span class="kwrd"&gt;Dim&lt;/span&gt; regKey &lt;span class="kwrd"&gt;As&lt;/span&gt; RegistryKey
      regKey = Registry.CurrentUser.OpenSubKey(&lt;span class="str"&gt;&amp;quot;Software\Microsoft\Windows\CurrentVersion\Run&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;True&lt;/span&gt;)
      regKey.SetValue(Application.ProductName, Application.ExecutablePath)
      regKey.Close()
&lt;span class="kwrd"&gt;Else&lt;/span&gt;
      My.Settings.AutomaticStart = &lt;span class="kwrd"&gt;False&lt;/span&gt;
      &lt;span class="kwrd"&gt;Dim&lt;/span&gt; regKey &lt;span class="kwrd"&gt;As&lt;/span&gt; RegistryKey
      regKey = Registry.CurrentUser.OpenSubKey(&lt;span class="str"&gt;&amp;quot;Software\Microsoft\Windows\CurrentVersion\Run&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;True&lt;/span&gt;)
      regKey.DeleteValue(Application.ProductName)
      regKey.Close()
&lt;span class="kwrd"&gt;End&lt;/span&gt; If&lt;/pre&gt;

&lt;p&gt;The following code in Timer’s Tick event will do the job of checking Twitter Timeline every one minute and Shutdown/Restart/Log off the system based on the Tweet.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;If&lt;/span&gt; My.Settings.UserName.Trim = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;
    &lt;span class="kwrd"&gt;Exit&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;
&lt;span class="kwrd"&gt;Else&lt;/span&gt;
    &lt;span class="rem"&gt;'Check for new Tweet &lt;/span&gt;
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; objTwitter &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; Yedda.Twitter
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; Updates &lt;span class="kwrd"&gt;As&lt;/span&gt; XmlDocument
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; node &lt;span class="kwrd"&gt;As&lt;/span&gt; XmlNode
    &lt;span class="kwrd"&gt;Try&lt;/span&gt; &lt;span class="rem"&gt;'Try Logging in&lt;/span&gt;
        Updates = objTwitter.GetUserTimelineAsXML(My.Settings.UserName.Trim, My.Settings.Password.Trim)
        &lt;span class="kwrd"&gt;Catch&lt;/span&gt; ex &lt;span class="kwrd"&gt;As&lt;/span&gt; Exception
        MsgBox(&lt;span class="str"&gt;&amp;quot;Error : Failed to Login to Twitter with the values supplied. Please check your login details.&amp;quot;&lt;/span&gt;)
        &lt;span class="kwrd"&gt;Exit&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Try&lt;/span&gt;
    &lt;span class="kwrd"&gt;Try&lt;/span&gt;
        node = Updates.SelectSingleNode(&lt;span class="str"&gt;&amp;quot;/statuses/status/id&amp;quot;&lt;/span&gt;)
        &lt;span class="kwrd"&gt;If&lt;/span&gt; node.InnerText.Trim &amp;lt;&amp;gt; My.Settings.LastID.Trim &lt;span class="kwrd"&gt;Then&lt;/span&gt; 
            &lt;span class="rem"&gt;'Compare the Tweet ID to check for new tweets&lt;/span&gt;
            My.Settings.LastID = node.InnerText.Trim
            node = Updates.SelectSingleNode(&lt;span class="str"&gt;&amp;quot;/statuses/status/text&amp;quot;&lt;/span&gt;)
            ProcessTweet(node.InnerText.Trim)
          &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;
    &lt;span class="kwrd"&gt;Catch&lt;/span&gt; ex &lt;span class="kwrd"&gt;As&lt;/span&gt; Exception
        &lt;span class="kwrd"&gt;Exit&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Try&lt;/span&gt;
&lt;span class="kwrd"&gt;End&lt;/span&gt; If&lt;/pre&gt;

&lt;p&gt;If the Tweet is new then we process the tweet.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; ProcessTweet(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; Tweet &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;)
    &lt;span class="kwrd"&gt;If&lt;/span&gt; Tweet = &lt;span class="str"&gt;&amp;quot;Shutdown&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;
        System.Diagnostics.Process.Start(&lt;span class="str"&gt;&amp;quot;shutdown&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;-s -f -t 100&amp;quot;&lt;/span&gt;) &lt;span class="rem"&gt;'Shutdown&lt;/span&gt;
    &lt;span class="kwrd"&gt;ElseIf&lt;/span&gt; Tweet = &lt;span class="str"&gt;&amp;quot;Logoff&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;
        System.Diagnostics.Process.Start(&lt;span class="str"&gt;&amp;quot;shutdown&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;-l -f -t 100&amp;quot;&lt;/span&gt;) &lt;span class="rem"&gt;'Logoff&lt;/span&gt;
    &lt;span class="kwrd"&gt;ElseIf&lt;/span&gt; Tweet = &lt;span class="str"&gt;&amp;quot;Restart&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;
        System.Diagnostics.Process.Start(&lt;span class="str"&gt;&amp;quot;shutdown&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;-r -f -t 100&amp;quot;&lt;/span&gt;) &lt;span class="rem"&gt;' Restart&lt;/span&gt;
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;
&lt;span class="kwrd"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;

&lt;p&gt;The Context Menu strip has two menu items. They are Edit Setting and Exit.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/ShutdownRestartLogoffyourPCusingTweetMyP_D2B1/clip_image003_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image003" border="0" alt="clip_image003" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/ShutdownRestartLogoffyourPCusingTweetMyP_D2B1/clip_image003_thumb.jpg" width="292" height="253" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add the following code the “Edit Settings” Client event and Notify Icon’s Mouse Double Click Event. &lt;/p&gt;

&lt;pre class="csharpcode"&gt;tmrTweet.Enabled = &lt;span class="kwrd"&gt;False&lt;/span&gt;
txtUserName.Text = My.Settings.UserName.Trim
txtPassword.Text = My.Settings.Password.Trim
&lt;span class="kwrd"&gt;If&lt;/span&gt; My.Settings.AutomaticStart = &lt;span class="kwrd"&gt;True&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt; chkStartAutomatic.Checked = &lt;span class="kwrd"&gt;True&lt;/span&gt;
&lt;span class="kwrd"&gt;Me&lt;/span&gt;.WindowState = FormWindowState.Normal
&lt;span class="kwrd"&gt;Me&lt;/span&gt;.ShowInTaskbar = True&lt;/pre&gt;

&lt;p&gt;TweetMyPC runs silently on startup. To Edit Settings double click/Right Click the notify icon.&lt;/p&gt;

&lt;h4&gt;Working&lt;/h4&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:60558cb3-f672-4422-85cf-fea80c9effce" class="wlWriterEditableSmartContent"&gt;&lt;div id="28e191ed-c541-4d5a-85ef-992feaf927fd" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://www.youtube.com/watch?v=yPxd2IwWjoU" target="_new"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/ShutdownRestartLogoffyourPCusingTweetMyP_D2B1/video770b8dbba191.jpg" style="border-style: none" galleryimg="no" onload="var downlevelDiv = document.getElementById('28e191ed-c541-4d5a-85ef-992feaf927fd'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;object width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;param name=\&amp;quot;movie\&amp;quot; value=\&amp;quot;http://www.youtube.com/v/yPxd2IwWjoU&amp;amp;hl=en\&amp;quot;&amp;gt;&amp;lt;\/param&amp;gt;&amp;lt;embed src=\&amp;quot;http://www.youtube.com/v/yPxd2IwWjoU&amp;amp;hl=en\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/object&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Even though TweetMyPC is a simple app it has lot of interesting potential. Think about switching off your TV or washing machine using Twitter. It is possible with a little extra hardware and a simple .net program. TweetMyPC is free and open source. Feel free to download the sour code and add more functionality.&lt;/p&gt;

&lt;h3&gt;About The Author&lt;/h3&gt;

&lt;p&gt;Shoban Kumar is a Senior Software Engineer working for Allianz Cornhill India. Programming is his passion. He also writes about .net in &lt;a href="http://www.dotnetcurry.com/"&gt;http://www.dotnetcurry.com/&lt;/a&gt; and an active participator in &lt;a href="http://stackoverflow.com/users/12178/shoban"&gt;stackoverflow&lt;/a&gt; and speaker in &lt;a href="http://k-mug.org/"&gt;Microsoft user group&lt;/a&gt; sessions. You also can follow him in &lt;a href="http://twitter.com/shobankr"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9709252" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/utility/default.aspx">utility</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/home+automation/default.aspx">home automation</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category></item><item><title>Adding Sidetone to Skype</title><link>http://blogs.msdn.com/coding4fun/archive/2009/06/09/9583391.aspx</link><pubDate>Wed, 10 Jun 2009 00:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9583391</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9583391.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9583391</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9583391</wfw:comment><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/AddingSidetonetoSkype_B0D/clip_image001_2.jpg"&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="clip_image001" border="0" alt="clip_image001" align="right" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/AddingSidetonetoSkype_B0D/clip_image001_thumb.jpg" width="240" height="91" /&gt;&lt;/a&gt;Ever use a headset with Skype – and were frustrated that it was &lt;i&gt;too&lt;/i&gt; quiet? This article shows how to add the sound of your own voice to the headset and not feel exhausted from shouting to be heard.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Compiled version: &lt;/b&gt;&lt;a href="http://skypesidetone.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=25436"&gt;Download&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Source Code:&lt;/b&gt; &lt;a href="http://skypesidetone.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=25435"&gt;Download C#&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Difficulty:&lt;/b&gt; Intermediate &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Time Required:&lt;/b&gt; 1-3 hours &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Cost:&lt;/b&gt; free &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Software Needed:&lt;/b&gt; &lt;a href="http://skype.com/"&gt;Skype&lt;/a&gt; (&lt;a href="https://developer.skype.com/Download"&gt;Sype4Com&lt;/a&gt;), &lt;a href="http://www.microsoft.com/windows/directx/default.mspx"&gt;DirectX&lt;/a&gt;, &lt;a href="http://www.microsoft.com/express/download/"&gt;Visual Basic or Visual C# Express&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Hardware:&lt;/b&gt; none &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Skype: I find your lack of feedback disturbing.&lt;/h3&gt;  &lt;p&gt;This article will discuss how to build a software tool that makes it easier to talk into Skype with a headset.&lt;/p&gt;  &lt;p&gt;Recently my family began experimenting with Skype, but we found that talking over Skype can be exhausting with headphones. After doing a little research, I learned that the problem was that we only heard the other party. You’d think that this is a good thing, but we have a social brain that works hard to gauge our behavior and adjust.&lt;/p&gt;  &lt;p&gt;The answer is to feed a little bit of the microphone back into the earpiece, so that our brain knows how loud we're talking. This is called &lt;i&gt;side tone&lt;/i&gt; in the telecommunication industry. Without it, we talk louder and louder until we’re sure that we’ll be heard.&lt;/p&gt;  &lt;p&gt;I couldn’t find a Skype plug-in to do this… but I had just read a &lt;a href="http://blogs.msdn.com/coding4fun/archive/2009/02/02/9391048.aspx"&gt;Coding4Fun article, by Mark Heath, about adding audio effects to Skype&lt;/a&gt;. I decided I was going to write a tool to add this feedback.&lt;/p&gt;  &lt;h4&gt;How to use the tool&lt;/h4&gt;  &lt;p&gt;First, let’s take a look at how to use the application. Once it is running, there will be a microphone icon in the lower right hand corner of the screen:&lt;/p&gt;  &lt;p&gt;Figure 1: Icon in the system notification tray&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/AddingSidetonetoSkype_B0D/clip_image004_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/AddingSidetonetoSkype_B0D/clip_image004_thumb.jpg" width="160" height="53" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Clicking on it, will get the application control window:&lt;/p&gt;  &lt;p&gt;Figure 2: The application's controls&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/AddingSidetonetoSkype_B0D/clip_image006_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/AddingSidetonetoSkype_B0D/clip_image006_thumb.jpg" width="447" height="333" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Let’s look at the side tone controls:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The “Side Tones” check box enables or disables the side tone. If you have headphones, you'll want this on; if you have loud speakers, you'll want it off. &lt;/li&gt;    &lt;li&gt;The slider controls the volume of the microphone in the headset. You can change it while talking. The volume will vary with microphone and headset. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;You can do a “sound check” to see if the feedback is working by clicking on the Sound Check button, and adjusting the volume. I found that the volume setting that works best in a conversation is much, much lower than what works in a sound check.&lt;/p&gt;  &lt;p&gt;Next, let’s look at the AGC (“Automatic Gain Control”) section. When making a call, the software can automatically adjust how loud you sound to the other party:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;When “Low Pass” is checked, the headphone feedback is at 44100 samples/sec. The microphone sound is filtered to keep only the sounds below 8 Khz, converted to 16000/samples per second and sent to Skype. When it is not checked, headphone feedback is at 16000 samples/sec, and sent to Skype without the low pass filter. &lt;/li&gt;    &lt;li&gt;When &amp;quot;Skype AutoGain&amp;quot; is checked, it signals to Skype that Skype can use its own algorithm. When clear, Skype is told not to apply any adjustments. &lt;/li&gt;    &lt;li&gt;When &amp;quot;AutoGain&amp;quot; is checked, the custom Automatic Gain Control algorithm is used. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The Automatic Gain Control has three sliders:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The “Cutoff” slider controls the distinction between background noise and conversation. Sound below this level is cutoff and silence is sent to Skype. This will vary with microphone – more sensitive (expensive) microphones will pick more background noise and be better with a higher setting.&lt;/li&gt;    &lt;li&gt;The “Normal” slider controls the volume when you are talking normally. The Gain Control tries to raise the volume to this level. &lt;/li&gt;    &lt;li&gt;The “Loud” slider controls the volume when you talk exceptionally loud. This rarely happens, but when you &lt;i&gt;do&lt;/i&gt; talk louder than the Normal level, the Gain Control tries to adjust the volume to this level. &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;How the Software Works&lt;/h3&gt;  &lt;p&gt;I originally started this project by creating an effect for the &lt;a href="http://blogs.msdn.com/coding4fun/archive/2009/02/02/9391048.aspx"&gt;Skype Voice Changer&lt;/a&gt;. My plan was to open a WaveStream, begin playing it on the headphones and copy the microphone stream to it.&lt;/p&gt;  &lt;p&gt;I quickly found that this was not the way to add feedback. The underlying “WaveOut” system had a huge latency: Everything I heard in the headphones was at least a second or more behind what I was saying. This made it even harder to talk than before, and I had to abandon it.&lt;/p&gt;  &lt;p&gt;While researching the problem I found a DirectSound code sample that I could modify into doing what I wanted. (This initial prototype didn’t coordinate with Skype – it attached to the microphone and copied the sounds to the output, at a lower volume. But it was on &lt;i&gt;always on.&lt;/i&gt;) The sound in the headphones is still slightly behind (the microphone) but is barely perceptible, and we’ll muffle it a bit more to make it less distinguishable.&lt;/p&gt;  &lt;p&gt;From here on I shall describe the major – or technically interesting – components of the program. We’ll look at:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;DirectSound and Circular buffers &lt;/li&gt;    &lt;li&gt;Sample Window and Sizing the buffers &lt;/li&gt;    &lt;li&gt;Using WaitHandle’s to Synchronize with DirectSound &lt;/li&gt;    &lt;li&gt;IIR Filters &lt;/li&gt;    &lt;li&gt;Automatic Gain Control &lt;/li&gt;    &lt;li&gt;Estimating loudness &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Note: I won’t be describing how to connect to Skype. Mark Heath’s description is very good.&lt;/p&gt;  &lt;h4&gt;DirectSound and Circular Buffers&lt;/h4&gt;  &lt;p&gt;The DirectSound code is in AudioLoop.cs. The module sets DirectSound to capture sound from the default recording device at 16bits / sample at either 16000 or 44100 samples per second. The capture and playback buffers are configured in “looping” mode to act as circular buffers. The capture buffer eventually overwrites samples, and we’ll lose them if we don’t act fast enough; if we don’t update the playback buffer, it will repeat the same sound over and over.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;StartMicrophone() &lt;/strong&gt;procedure sets up the capture and playback buffers. Then it creates a thread to do the work. The thread is at a high priority so that if the OS has a choice between (say) email or processing sound, it does the sound.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;StopMicrophone() &lt;/strong&gt;procedure stops the worker thread and cleans up the resources.&lt;/p&gt;  &lt;p&gt;The software processes a fixed number of samples at a time, called the “sample window.” The buffers are several times the size of sample window, so that the system can keep capturing and playing while the software is processing them. The sound processing loop is the heart of the application:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Wait for the next sample window to be ready &lt;/li&gt;    &lt;li&gt;Copy the samples from the capture buffer &lt;/li&gt;    &lt;li&gt;Process the samples and send the results to the playback buffer &lt;/li&gt;    &lt;li&gt;Process the samples and sends the results to Skype &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;b&gt;C#      &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;while&lt;/span&gt; (Runnable)
{
    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; I = 0, offset = 0; Runnable &amp;amp;&amp;amp; I &amp;lt; _bufferPositions; I++, offset += bufferSize)
    {
        &lt;span class="rem"&gt;// Wait for the sample areas to be ready&lt;/span&gt;
        notificationEvent[I].WaitOne(Timeout.Infinite, &lt;span class="kwrd"&gt;true&lt;/span&gt;);

        &lt;span class="rem"&gt;// Get the sound samples&lt;/span&gt;
        &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buffer = (&lt;span class="kwrd"&gt;byte&lt;/span&gt;[]) captureBuffer.Read(offset, &lt;span class="kwrd"&gt;typeof&lt;/span&gt; (&lt;span class="kwrd"&gt;byte&lt;/span&gt;), LockFlag.None, bufferSize);

        &lt;span class="rem"&gt;// Convert samples to 16bit PCM &lt;/span&gt;
        &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; L = buffer.Length, J = 10, K = 0; K &amp;lt; L; K += 2)
            PCM16Buffer[J++] = (Int16) ((UInt16) buffer[K] | (((UInt16) buffer[K + 1]) &amp;lt;&amp;lt; 8));

        &lt;span class="rem"&gt;// Play them out to the ear, if applicable&lt;/span&gt;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;null&lt;/span&gt; != playbackBuffer)
        {
            &lt;span class="rem"&gt;// Perform a low pass filter to &amp;quot;muffle&amp;quot; the sound&lt;/span&gt;
            Butterworth(PCM16Buffer, 10, LPSample, Coefs);

            &lt;span class="rem"&gt;// put the muffled sample into the output buffer&lt;/span&gt;
            &lt;span class="rem"&gt;// -- The lock flag seems to work, but others may work too&lt;/span&gt;
            playbackBuffer.Write(Idx, LPSample, LockFlag.None);
            Idx += buffer.Length;
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (Idx &amp;gt;= 4*bufferSize)
                Idx -= 4*bufferSize;
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!playing)
            {
                playbackBuffer.Volume = _Volume;
                playbackBuffer.Play(0, BufferPlayFlags.Looping);
                playing = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            }
        }

        &lt;span class="rem"&gt;// Process the sound and deliver it to Skype&lt;/span&gt;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;null&lt;/span&gt; != outStream)
        {
            &lt;span class="kwrd"&gt;int&lt;/span&gt; L = AGC.Process(PCM16Buffer, 10, buffer);
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (0 != L)
                outStream.BeginSend(buffer, 0, L, SocketFlags.None, SendCallback, &lt;span class="kwrd"&gt;null&lt;/span&gt;);
            &lt;span class="rem"&gt;// Note: could send out pink noise if L == 0&lt;/span&gt;
        }

        &lt;span class="rem"&gt;// Move the sliding window of the previous 10 samples into the start&lt;/span&gt;
        &lt;span class="rem"&gt;// of the PCM16Buffer&lt;/span&gt;
        &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; K = 0, J = PCM16Buffer.Length - 10; K &amp;lt; 10; K++, J++)
            PCM16Buffer[K] = PCM16Buffer[J];
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Note the “for” loop at the bottom of the code. This preserves the last 10 incoming samples at the start of the buffer. This is needed to make the sound processing smooth, and will be discussed a bit later.&lt;/p&gt;

&lt;h4&gt;Sample Window and Sizing the Buffers&lt;/h4&gt;

&lt;p&gt;How big should the sample window be? This is bit of a trade off in responsiveness and design complexity.&lt;/p&gt;

&lt;p&gt;I chose a window big enough to hold 10 milliseconds of sound. Since the ear is sensitive sound to delays of even 30 milliseconds, I cut this done so that a delay wouldn’t be perceptible. (When I tried a 50 millisecond window, my voice came out the headphone sounding like an echo... and I found myself talking slower and slower.) The sample window could be made smaller, but I am sure that there is a point where the OS won’t schedule the audio loop to wake-n-run more frequently. And, as the sample window gets smaller, the processing may drop in quality, because it doesn’t have enough to work with.&lt;/p&gt;

&lt;p&gt;The capture buffer is 8 times the size of the sample window. This ratio is arbitrary, but I wanted the buffer to be about an order of magnitude larger. My rationale is that if the processing falls behind, the sound – for the Skype call – won’t be dropped. I feel that it is more important to preserve sound quality for the other party than to preserve the quality of feedback.&lt;/p&gt;

&lt;p&gt;The playback buffer is four times the sample window. I wanted it small, so that if the processing fell behind, the replaying of a sound will seem to be a continuation of a current sound.&lt;/p&gt;

&lt;p&gt;When writing the sound to the playback buffer, we have to track where in the buffer to put the samples. I tried to use GetCurrentPosition() to find where to write to next into the playback buffer; this created terrible sound. Instead, the software uses a local variable to track where to write next.&lt;/p&gt;

&lt;h4&gt;DirectSound and Notifications&lt;/h4&gt;

&lt;p&gt;How do we keep in sync with the sound capture – how do we know when a sample buffer is ready?&lt;/p&gt;

&lt;p&gt;The application gives a table of buffer indices and WaitHandle’s to DirectSound. When the capture buffer’s write index reaches one of those indices, it signals the corresponding WaitHandle. The worker thread cycles performs a WaitOne() one each of the WaitHandle’s, one at a time. As a convenience, we use a specific kind of WaitHandle called AutoResetEvent. This type of WaitHandle sets itself back to a “wait” state once WaitOne() returns.&lt;/p&gt;

&lt;p&gt;If the thread has gotten behind, the WaitOne will return immediately, the loop processes the sample, and begins to catch up with the work.&lt;/p&gt;

&lt;p&gt;We must use a separate AutoResetEvent for each of the 8 capture windows. The AutoResetEvent doesn’t tell us if it was signaled multiple times. If only one AutoResetEvent handle were used, it wouldn’t know that two (or more) sample windows were ready. Instead, it would process just one, falling further behind, adding latency. This would happen randomly overtime, and be hard to test consistently.&lt;/p&gt;

&lt;h4&gt;IIR: Infinite Impulse Response Filters&lt;/h4&gt;

&lt;p&gt;This project came together so quickly, so easy – once I found the right approach – that I couldn't resist getting fancy. I added a low-pass filter to muffle the feedback a little. And I added automatic gain control, as an experimental option.&lt;/p&gt;

&lt;p&gt;For both of these I used a filtering algorithm called “IIR” (this stands for Infinite Impulse Response – but that term is a confusing mouthful, so let’s just call it IIR). IIR is a special purpose virtual machine. Low-pass filters, high-pass filters, combinations of those filters, and even equalizers, can be specified, and use very specific techniques (like a compiler) to convert them into an IIR implementation.&lt;/p&gt;

&lt;p&gt;(You could, instead, “compile” the filters to be the resistor values to use in a hardware circuit. &lt;i&gt;That’s programming in solder!)&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;The machine code for these IIR virtual machines is just two list of coefficients, called A &amp;amp; B. The software emulator is code that &lt;i&gt;looks&lt;/i&gt; like the following bit of code:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Out[0] = Sample[0];
Out[1] = Sample[1];
&lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; Idx = 2; Idx &amp;lt; N; Idx++)
{
    Out[Idx] =
    B0 * Sample[Idx]
 + B1 * Sample[Idx - 1]
 + B2 * Sample[Idx - 2]
        &lt;span class="rem"&gt;// … more like this …&lt;/span&gt;
        &lt;span class="rem"&gt;// Next, the feed back&lt;/span&gt;
 - A1 * Out[Idx - 1]
 - A2 * Out[Idx - 2]
        &lt;span class="rem"&gt;// … more like this …&lt;/span&gt;
 ;
}&lt;/pre&gt;

&lt;p&gt;IIRs are easy to implement - and take less CPU power than other methods. But sometimes they sound poor; if they sound too bad, you’ll want to use a different technique. I found that the low-pass filters in this project work will for some microphones, and add a slight crackle to others.&lt;/p&gt;

&lt;h4&gt;Example Low Pass Filter&lt;/h4&gt;

&lt;p&gt;For the low pass filter to create the muffling, I used a Butterworth filter, using the code below. It takes a buffer of signed, 16-bit samples, and then converts the 16-bit values into a byte array suitable for the sound buffer.&lt;/p&gt;

&lt;p&gt;The filter code is a bit different than the example code in the previous section. Most of the differences are for speed.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;This code doesn’t use a buffer for the old values, instead uses separate variables for the elements of the buffer.&amp;#160; It uses I_0,I_1,I_2 instead of Sample[Idx], Sample[Idx-1], and Sample[Idx-2]. It also uses O_1, and O_2 instead of Out[Idx-1] and Out[Idx-2]. &lt;/li&gt;

  &lt;li&gt;The A and B coefficients are put into a single array. It also &lt;i&gt;adds&lt;/i&gt; two of the sample input values, and is missing a coefficient; this is because the B0 and B2 coefficients are always the same for this kind of filter. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is one difference that is not for speed. These are tricks done to make the filter smooth, and needed because the sample window is so small. They preserve the state of filter. If we didn’t preserve them, the filter would be starting and stopping so frequently that it would add distracting clicks to the output sound. The filters performance would be weakened, because the sample window isn’t big enough to hold sounds lower than (about) 200 Hz. Preserving these values, the filter isn’t starting and stopping, and doesn’t really know about the sample window. All of the IIR filters in this program use similar techniques.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;O_1, O_2 are explicitly preserved across calls by being stored in class variables &lt;/li&gt;

  &lt;li&gt;I_1 and I_2 are preserved by the audio loop (remember the warning about preserving 10 samples at the bottom of the loop?) The audio loop preserves the last 10 samples at the start of InBuffer. When this procedure is called, it retrieves the last two samples. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; O_1 = 0.0, O_2=0.0;

&lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Butterworth(Int16[] InBuffer, &lt;span class="kwrd"&gt;int&lt;/span&gt; Ofs, &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] OutBuffer, &lt;span class="kwrd"&gt;double&lt;/span&gt;[] Coefs)
{
  &lt;span class="kwrd"&gt;double&lt;/span&gt; C0=Coefs[0], C1=Coefs[1], C2 = Coefs[2], C3=Coefs[3];
  &lt;span class="kwrd"&gt;double&lt;/span&gt; I_1=InBuffer[Ofs-1], I_2= InBuffer[Ofs-2];
  &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; L = InBuffer . Length, J=0, I = Ofs; I &amp;lt; L; I++)
  {
     &lt;span class="kwrd"&gt;double&lt;/span&gt; I_0 = InBuffer[I];

     &lt;span class="rem"&gt;// Filter the samples&lt;/span&gt;
     &lt;span class="kwrd"&gt;double&lt;/span&gt; A = (I_0 + I_2) * C0 + I_1 * C1;
     I_2 = I_1;
     I_1 = I_0;

     A = A - O_1 * C2 - O_2 * C3;
     O_2 = O_1;
     O_1 = A;

     &lt;span class="rem"&gt;// Convert it back to 16 bit&lt;/span&gt;
     Int16 S;
     &lt;span class="kwrd"&gt;if&lt;/span&gt; (A &amp;lt; -32767) S = -32767;
     &lt;span class="kwrd"&gt;if&lt;/span&gt; (A &amp;gt; 32767)  S = 32767;
     &lt;span class="kwrd"&gt;else&lt;/span&gt; S = (Int16) A;

     &lt;span class="rem"&gt;// Store it&lt;/span&gt;
     OutBuffer[J++] = (&lt;span class="kwrd"&gt;byte&lt;/span&gt;)(S &amp;amp; 0xFF);
     OutBuffer[J++] = (&lt;span class="kwrd"&gt;byte&lt;/span&gt;)(((UInt16)S &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
  }
}&lt;/pre&gt;

&lt;p&gt;Automatic Gain Control&lt;/p&gt;

&lt;p&gt;I decided next to tackle a problem where my wife's voice did not carry well on calls. This happens a lot to her with cell phones – and answering machines. I was pretty sure that the problem was poor automatic-gain-control (AGC). The typical amplifier in a headset (and in Skype) estimates how loud our voice is, then increases – or decreases – the volume to a reasonable level. It was deciding that my wife's voice was background noise, and cutting her off.&lt;/p&gt;

&lt;p&gt;I chose to write an alternate gain control that amplified the sound and passed it to Skype. That way we'd have four to choose from: The one built into the Microphone, the Soundcard’s, Mine, and Skype’s. (To be fair, these automatic gain controls work well in most cases).&lt;/p&gt;

&lt;p&gt;The main portion of the gain control is implemented in the file GainControl.cs. The control algorithm is:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Calculate (or estimate) how loud we are currently talking (using the Analyze() procedure) &lt;/li&gt;

  &lt;li&gt;If the loudness is very low, no one is talking… so set the output to zero. (Without this step, the volume of noise and hum would be cranked up) &lt;/li&gt;

  &lt;li&gt;Otherwise, compute the guess-gain by dividing how loud the sound of our voice should be by how loud it currently is &lt;/li&gt;

  &lt;li&gt;Compute the gain (called MaxGain) at which the sound will start clipping. If the guess-gain is louder than this, reduce it to MaxGain. &lt;/li&gt;

  &lt;li&gt;The software adjusts the gain for a gentle transition – especially in the case when we go from absolute quiet, to the start of talking. It does this by tracking the gain (called PrevGain) used in previous sample and the current one. &lt;/li&gt;

  &lt;li&gt;Multiple all the samples by this gain value. &lt;/li&gt;

  &lt;li&gt;If the sample rate is greater than 16000 samples/sec 
    &lt;ol&gt;
      &lt;li&gt;Do a low pass filter at 8 khz (again in IIR form). This helps prevent artifacts from down sampling &lt;/li&gt;

      &lt;li&gt;Resample the sound to 16000 &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The portion of code that calculates the gain looks like (CutOff_dB, LowGain_dB, and TgtGain_dB are the three slider values):&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (!AutoGain)
    Gain = 1.0;
&lt;span class="kwrd"&gt;else&lt;/span&gt;
{
    &lt;span class="kwrd"&gt;double&lt;/span&gt; MaxGain;
    &lt;span class="kwrd"&gt;double&lt;/span&gt; dB = Analyze(InBuffer, Ofs, &lt;span class="kwrd"&gt;out&lt;/span&gt; MaxGain);

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (dB &amp;lt; CutOff_dB)
        Gain = 0.0;
    &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (dB &amp;lt; LowGain_dB + 4.0)
    {
        Gain = Math.Exp((LowGain_dB - dB) * db2log);
    }
    &lt;span class="kwrd"&gt;else&lt;/span&gt;
    {
        Gain = Math.Exp((TgtGain_dB - dB) * db2log);
    }
    Gain = (0.4 * Gain + 0.6 * PrevGain);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (Gain &amp;gt; MaxGain)
        Gain = MaxGain;
    PrevGain = Gain;
}

&lt;span class="rem"&gt;// Skip further process if there is silence&lt;/span&gt;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (0.0 == Gain)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; 0;
}&lt;/pre&gt;

&lt;p&gt;If you look at the code, you’ll see that we don’t compare directly with LowGain_db; rather we compare the estimate volume with LowGain_db+4. This gives a little “hysteresis” – if we raise our voice momentarily, the software won’t suddenly make it the highest possible volume. Instead, the software lowers the volume a little bit.&lt;/p&gt;

&lt;p&gt;When the software changes the sample rate, it basically needs to know how many input samples to skip. At the start of a call, the software computes this, calling it InInc:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// Calculate how we resample to 16Khz&lt;/span&gt;
InInc = (&lt;span class="kwrd"&gt;int&lt;/span&gt;)(1024.0 * SampleRate / 16000.0);&lt;/pre&gt;

&lt;p&gt;The process of applying the gain adjustment, performing a low pass filter and re-sampling is below:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;int&lt;/span&gt; NumSamples = InBuffer.Length;
&lt;span class="kwrd"&gt;int&lt;/span&gt; End = OutBuffer.Length;
&lt;span class="kwrd"&gt;int&lt;/span&gt; NextIdxForOut = -InInc;
&lt;span class="kwrd"&gt;int&lt;/span&gt; OutIdx = 0;
&lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; I = Ofs; OutIdx &amp;lt; End &amp;amp;&amp;amp; I &amp;lt; NumSamples; I++)
{
    &lt;span class="rem"&gt;// Retrieve the sample&lt;/span&gt;
    Int16 S = InBuffer[I];
    &lt;span class="kwrd"&gt;double&lt;/span&gt; I_0 = S;

    &lt;span class="rem"&gt;// Apply Gain&lt;/span&gt;
    I_0 *= Gain;

    &lt;span class="rem"&gt;// 8khz low pass filter &lt;/span&gt;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (DoLP)
    {
        &lt;span class="rem"&gt;// Simple Butterworth 8KHz low-pass filter&lt;/span&gt;
        &lt;span class="kwrd"&gt;double&lt;/span&gt; A = (I_0 + DS_I_2) * LP[0] + DS_I_1 * LP[1];
        DS_I_2 = DS_I_1;
        DS_I_1 = I_0;
        I_0 = A - DS_O_1 * LP[2] - DS_O_2 * LP[3];
        DS_O_2 = DS_O_1;
        DS_O_1 = I_0;

        &lt;span class="rem"&gt;// Change sample rate&lt;/span&gt;
        &lt;span class="kwrd"&gt;int&lt;/span&gt; Tmp = NextIdxForOut / 1024;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (I &amp;lt; Tmp)
            &lt;span class="kwrd"&gt;continue&lt;/span&gt;;
        NextIdxForOut += InInc;
    }

    &lt;span class="rem"&gt;// Convert it back to 16 bit&lt;/span&gt;
    S = (Int16)I_0;

    &lt;span class="rem"&gt;// Store it&lt;/span&gt;
    OutBuffer[OutIdx++] = (&lt;span class="kwrd"&gt;byte&lt;/span&gt;)(S &amp;amp; 0xFF);
    OutBuffer[OutIdx++] = (&lt;span class="kwrd"&gt;byte&lt;/span&gt;)(((UInt16)S &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
}&lt;/pre&gt;

&lt;p&gt;Estimating Volume&lt;/p&gt;

&lt;p&gt;How loud “it should be” is controlled by a slider on the screen. The software estimates how loud the sound is by using &lt;a href="http://replaygain.hydrogenaudio.org/equal_loudness.html"&gt;an algorithm devised by David Robinson&lt;/a&gt; that takes into account how it sounds &lt;i&gt;to a person&lt;/i&gt;. This way we can increase the gain on hard to hear sounds, and reduce the gain on sounds that a person is very sensitive to.&lt;/p&gt;

&lt;p&gt;The loudness estimator, implemented in the Analysis procedure in GainAnalysis.cs, uses the following algorithm:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Uses a combination of two (IIR) filters to make the sound to reflect how our ears hear it. &lt;/li&gt;

  &lt;li&gt;Compute the Mean-Square value of the filtered sound (called MS) &lt;/li&gt;

  &lt;li&gt;Track the last 750 ms of these values. &lt;/li&gt;

  &lt;li&gt;Make a sorted copy of these. &lt;/li&gt;

  &lt;li&gt;Retrieve the first non-zero value at least 95% of the way into the buffer. This is so that we don’t take the loudest sample and assume that is how the person is talking. &lt;/li&gt;

  &lt;li&gt;If MS (the value computed in step 2) is much quieter, use that one instead &lt;/li&gt;

  &lt;li&gt;Convert this value into dB scale by performing a logarithm on it. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The code to “normalize” the sound into how a person hears it is below. Along the way it computes the square of the samples (used in step 2). Like the earlier IIR filters, these preserves their variables across the calls. The first IIR is a yulewalk filter, but it preserves it old intermediary values in an array. Like the trick in AudioLoop, where we copy the last 10 samples into the start of the current buffer, the analysis procedure copies the last 10 immediate values into the start of YuleTmp array.&lt;/p&gt;

&lt;p&gt;The output of the yulewalk filter is feed into a 150Hz high pass filter. It is essentially the same as the low-pass filter described earlier.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; L = Samples.Length, N = Ofs; N &amp;lt; L; N++)
{
    &lt;span class="kwrd"&gt;int&lt;/span&gt; _V = Samples[N];
    &lt;span class="kwrd"&gt;double&lt;/span&gt; V = _V;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (_V &amp;gt; MaxSample) MaxSample = _V;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (-_V &amp;gt; MaxSample) MaxSample = -_V;

    &lt;span class="rem"&gt;// Perform yulewalk filter&lt;/span&gt;
    &lt;span class="kwrd"&gt;double&lt;/span&gt; S = V * YuleCoefs[0];
    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; J = N - 1, I = 1; I &amp;lt; 11; I++, J--)
        S += Samples[J] * YuleCoefs[I];
    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; J = N - 1, I = 11; I &amp;lt; 21; I++, J--)
        S -= YuleTmp[J] * YuleCoefs[I];

    &lt;span class="rem"&gt;// Store for the feedback into the next stage of the yule walk&lt;/span&gt;
    YuleTmp[N] = S;


    &lt;span class="rem"&gt;// Perform butterworth high-pass filter stage, using S as an input&lt;/span&gt;
    &lt;span class="kwrd"&gt;double&lt;/span&gt; Accum =
       (S + GA_I_2) * HPCoefs[0]
       + GA_I_1 * HPCoefs[1];
    GA_I_2 = GA_I_1;
    GA_I_1 = S;
    Accum = Accum - GA_O_1 * HPCoefs[2] - GA_O_2 * HPCoefs[3];

    GA_O_2 = GA_O_1;
    GA_O_1 = Accum;

    &lt;span class="rem"&gt;// The square of the filtered results&lt;/span&gt;
    Sum += Accum * Accum;
}

&lt;span class="rem"&gt;// Copy the intermediate yulewalk state for the next&lt;/span&gt;
&lt;span class="rem"&gt;// (this is needed since we are looking at a fairly small time window)&lt;/span&gt;
&lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; I = 0, J = YuleTmp.Length - 10; I &amp;lt; 10; I++)
    YuleTmp[I] = YuleTmp[J];&lt;/pre&gt;

&lt;p&gt;The mean-squared is computed:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// The mean square of the filtered results&lt;/span&gt;
&lt;span class="kwrd"&gt;double&lt;/span&gt; MS = Sum / NumSamples;&lt;/pre&gt;

&lt;p&gt;Tracking the last 750ms of samples is a simple matter of putting it into a circular queue:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;MSQueue[QIdx++] = MS;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (QIdx &amp;gt;= MSQueue . Length)
   QIdx = 0;&lt;/pre&gt;

&lt;p&gt;Next, is the code to finding the first non-zero value 95% of the way into the buffer. It is a straightforward copy-the-array, sort it, and fetch:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Array.Copy(MSQueue, SortedQ, MSQueue.Length);
Array.Sort(SortedQ);

&lt;span class="rem"&gt;// Return the 95% &lt;/span&gt;
&lt;span class="kwrd"&gt;double&lt;/span&gt; X = SortedQ[Q95Idx]; 
&lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; I = Q95Idx +1; X &amp;lt; 400.0 &amp;amp;&amp;amp; I &amp;lt; SortedQ . Length; I++)
      X = SortedQ[I];&lt;/pre&gt;

&lt;p&gt;Next, override this value if the current sample window is very, very quiet – that is, the user stopped talking. (If we don’t do this, we’ll amplify background noise between words)&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (MS &amp;lt; X * 0.40 &amp;amp;&amp;amp; MS &amp;lt; 12800.0)
   X = MS;&lt;/pre&gt;

&lt;p&gt;Finally, convert the result into decibels (or a reasonable approximation of a decibel)&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;return&lt;/span&gt; 10.0 * Math . Log10 (X * 0.5 + &lt;span class="kwrd"&gt;double&lt;/span&gt; . Epsilon);&lt;/pre&gt;

&lt;p&gt;Note: The logarithm function takes a positive, non-zero floating point number. However, the value we pass to it can be zero; if we pass a zero, though, the Logarithm function would return a bad value. The simplest thing to do is check to see if the value we are passing is “zero” and not call Logarithm. However, I learned a long time ago to just add “epsilon” to the value to whatever we pass. This can really improve performance on number crunching.&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;This concludes how to add a little bit feedback and fancy amplification to you Skype phone calls.&lt;/p&gt;

&lt;p&gt;If you want to try this out, the download link for the source code is at the top of the article!&lt;/p&gt;

&lt;p&gt;If you’d like to experiment further, here are ideas of what can be done:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;DirectSound has echo cancellation and noise suppression. These seem desirable, esp. if you wanted to try making your own speakerphone. I was not able to get them to work and I would love to learn how. &lt;/li&gt;

  &lt;li&gt;I’m sure it is possible to trim even more latency off of the side-tone playback, and I would be interested in learning better techniques to do so. &lt;/li&gt;

  &lt;li&gt;Another would be to create the ideal equalizer from Robinson’s Equal Loudness model, and use that filter and amplify the sound. &lt;/li&gt;

  &lt;li&gt;It might be useful for the other party to control the settings, so that they decide when your voice has the right volume. &lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;Resources and References&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;David Robinson (while doing his PhD at University of Essex on human hearing). &lt;a href="http://replaygain.hydrogenaudio.org/equal_loudness.html"&gt;His algorithm&lt;/a&gt; is intended to find the overall loudness of an album. He includes &lt;a href="http://replaygain.hydrogenaudio.org/mfiles/equalloudfilt.m"&gt;MATLAB scripts to compute coefficients&lt;/a&gt; at custom sample rates, as well as some &lt;a href="http://replaygain.hydrogenaudio.org/equal_loud_coef.txt"&gt;pre-computed coefficients&lt;/a&gt;. &lt;/li&gt;

  &lt;li&gt;Mark Heath’s &lt;a href="http://blogs.msdn.com/coding4fun/archive/2009/02/02/9391048.aspx"&gt;Skype Voice Changer&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;Derek Pierson’s &lt;a href="http://blogs.msdn.com/coding4fun/archive/2006/11/02/938703.aspx"&gt;DirectX tutorial&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;About The Author&lt;/h3&gt;

&lt;p&gt;Randall Maas writes firmware for medical devices, and consults in embedded software. Before that he did a lot of other things… like everyone else in the software industry. You can contact him at &lt;a href="mailto:randym@acm.org"&gt;randym@acm.org&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9583391" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/utility/default.aspx">utility</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/web+miscellaneous/default.aspx">web miscellaneous</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Creating a Utility Framework</title><link>http://blogs.msdn.com/coding4fun/archive/2009/04/14/9535026.aspx</link><pubDate>Tue, 14 Apr 2009 19:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9535026</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9535026.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9535026</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9535026</wfw:comment><description>&lt;p&gt;In this article I demonstrate how you can take advantage of a light application framework when creating simple utilities.&amp;#160; Instead of working on lower-level plumbing, just create the code for whatever tool you need, and this framework can get you working faster.&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="157"&gt;         &lt;p align="center"&gt;Arian Kulp, &lt;a href="http://www.ariankulp.com" target="_blank"&gt;blog&lt;/a&gt;             &lt;br /&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="481"&gt;         &lt;p&gt;&lt;b&gt;Source Code:&lt;/b&gt; &lt;a href="http://utilrunner.codeplex.com" target="_blank"&gt;CodePlex.com&lt;/a&gt;&lt;/p&gt;          &lt;p&gt;&lt;b&gt;Difficulty:&lt;/b&gt; Intermediate             &lt;br /&gt;&lt;b&gt;Time Required:&lt;/b&gt; 4 hours             &lt;br /&gt;&lt;b&gt;Cost:&lt;/b&gt; Free             &lt;br /&gt;&lt;b&gt;Software Needed:&lt;/b&gt; &lt;a href="http://www.microsoft.com/express/download/"&gt;Visual Basic or Visual C# Express 2008&lt;/a&gt;&lt;b&gt;              &lt;br /&gt;&lt;/b&gt;&lt;b&gt;Libraries:&lt;/b&gt; &lt;a href="http://www.codeplex.com/MEF"&gt;MEF&lt;/a&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;h3&gt;Introduction&lt;/h3&gt;  &lt;p&gt;When you write small utilities, there’s a certain amount of tedious repetitive work to get it up and going. Creating the main window, the tray icon (including the icon and context menu), and other common tasks just get in the way. In this article, I’ve created a reusable utility framework and will show you how to make use of it.&lt;/p&gt;  &lt;p&gt;To run this code, you’ll need to use Visual Studio 2008 SP1, Express Edition or higher. If you haven’t downloaded it yet, go to &lt;a href="http://www.microsoft.com/express"&gt;http://www.microsoft.com/express&lt;/a&gt;. You can either use Visual Basic or Visual C# to work with the main project or create add-ins for this project.&lt;/p&gt;  &lt;h3&gt;A Framework?&lt;/h3&gt;  &lt;p&gt;So what did I actually create for this article? We all know that using base classes is a great way to tie together closely-related objects. As a very practical example, a base window or control class lets you add functionality to something that already exists without reinventing the wheel, so to speak. Windows exposes a number of code execution models such as services, console apps, Sidebar gadgets, Windows forms, WPF, COM, and more. Each of these provides a certain amount of functionality that you don’t need to worry about, such as start/stop hooks for services, or the system message loop for Windows forms and WPF.&lt;/p&gt;  &lt;p&gt;Having built a good number of small utilities over the years, I’ve definitely realized that I’m copying or rewriting too much code. What a waste! Since I always create a notification icon (shows up by the system clock), and I like to hide to tray on minimize, and remember window settings, I implement these in each project. I probably should have created a project template in Visual Studio as a shortcut, but this has a disadvantage. If I added a cool new feature to my framework, I’d need to recompile and rework the older apps to take advantage of it&lt;/p&gt;  &lt;p&gt;The better solution was to create a “base application.” This would actually be its own application that exposes a notification icon and menu, and a main window. If you move the window, the location is saved. Individual utilities can then be added as plugins. I originally envisioned a framework able to host multiple applications, but that creates some interesting design challenges with visual apps. In the end, I settled on a reusable application which can host a single utility.&lt;/p&gt;  &lt;h3&gt;A Common User Interface&lt;/h3&gt;  &lt;p&gt;I decided to write this in WPF since it affords so many great options for layout and interactivity. I still write some Winforms code, but WPF is just an incredible way to build your application declaratively (not that XAML is required…) and it enables a nice clean code layout. If you are really tied to Windows Forms, you can always use the &lt;b&gt;WindowsFormsHost&lt;/b&gt; control to expose it.&lt;/p&gt;  &lt;p&gt;The basic application isn’t very complicated. It lets you set the application name which it uses in the tray menu and in the main window title. You can also set whether it minimizes to tray or not. If not, the close button will actually kill the application. Minimize always minimizes as normal.&lt;/p&gt;  &lt;p&gt;Finally, the main window shows both the preferences UI. Most small utility apps don’t really have a UI other than settings. You can always show dialogs and windows, but if all you have is a few settings, you can just create a UserControl to contain them and the application will host it.&lt;/p&gt;  &lt;p&gt;As an example, I created a utility add-in. It looks like some sort of file watching utility. It’s not actually functional – it’s just a collection of controls in a UserControl. This is paired up with the application name, icon, and more.&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/SimplifyingUtilityDevelopment_28D/clip_image002_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure 1 : Main Window" border="0" alt="Figure 1 : Main Window" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/SimplifyingUtilityDevelopment_28D/clip_image002_thumb.jpg" width="409" height="338" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="center"&gt;&lt;em&gt;Figure 1 : Main Application Window&lt;/em&gt;&lt;/p&gt;  &lt;h3&gt;Modularity&lt;/h3&gt;  &lt;p&gt;So I mentioned before that one of my motivations with this project was to allow me to update the framework without needing to recompile the utilities themselves. To be clear, this won’t be possible 100% of the time, but as long as I leave the public interfaces alone, it should work well. So here’s the cool implementation: Managed Extensibility Framework, or MEF.&lt;/p&gt;  &lt;p&gt;MEF allows you to build extensibility into your applications with little effort. Build your interfaces or contracts, and as long as plugins use that contract, code can be compiled into separate assemblies with no dependencies. When the application starts up, you tell it where to find extensions and it takes care of loading them. The contract for addins (&lt;b&gt;IWpfService&lt;/b&gt;) is defined as:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Visual C#&lt;/strong&gt;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IWpfService
{
    &lt;span class="rem"&gt;// Gets the custom control to display in the host preferences dialog.&lt;/span&gt;
    UserControl OptionsUserControl { get; }

    &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; }
    System.Drawing.Icon TrayIcon { get; }
    &lt;span class="kwrd"&gt;string&lt;/span&gt; Description { get; }
    &lt;span class="kwrd"&gt;string&lt;/span&gt; Author { get; }
    Version Version { get; }
    Uri AuthorUri { get; }
    &lt;span class="kwrd"&gt;bool&lt;/span&gt; HideOnClose { get; }
    &lt;span class="kwrd"&gt;string&lt;/span&gt; Status { get; set; }

    &lt;span class="kwrd"&gt;void&lt;/span&gt; Initialize();
    &lt;span class="kwrd"&gt;void&lt;/span&gt; Start();
    &lt;span class="kwrd"&gt;void&lt;/span&gt; Stop();

    &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler StatusUpdated;
}&lt;/pre&gt;
&lt;style type="text/css"&gt;





.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Visual Basic&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Interface&lt;/span&gt; IWpfService
    &lt;span class="rem"&gt;' Gets the custom control to display in the host preferences dialog.&lt;/span&gt;
    &lt;span class="kwrd"&gt;ReadOnly&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; OptionsUserControl() &lt;span class="kwrd"&gt;As&lt;/span&gt; UserControl

    &lt;span class="kwrd"&gt;ReadOnly&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; Name() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;
    &lt;span class="kwrd"&gt;ReadOnly&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; TrayIcon() &lt;span class="kwrd"&gt;As&lt;/span&gt; System.Drawing.Icon
    &lt;span class="kwrd"&gt;ReadOnly&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; Description() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;
    &lt;span class="kwrd"&gt;ReadOnly&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; Author() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;
    &lt;span class="kwrd"&gt;ReadOnly&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; Version() &lt;span class="kwrd"&gt;As&lt;/span&gt; Version
    &lt;span class="kwrd"&gt;ReadOnly&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; AuthorUri() &lt;span class="kwrd"&gt;As&lt;/span&gt; Uri
    &lt;span class="kwrd"&gt;ReadOnly&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; HideOnClose() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;
    &lt;span class="kwrd"&gt;Property&lt;/span&gt; Status() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;

    &lt;span class="kwrd"&gt;Sub&lt;/span&gt; Initialize()
    &lt;span class="kwrd"&gt;Sub&lt;/span&gt; Start()
    &lt;span class="kwrd"&gt;Sub&lt;/span&gt; [&lt;span class="kwrd"&gt;Stop]&lt;/span&gt;()

    &lt;span class="kwrd"&gt;Event&lt;/span&gt; StatusUpdated &lt;span class="kwrd"&gt;As&lt;/span&gt; EventHandler

&lt;span class="kwrd"&gt;End&lt;/span&gt; Interface&lt;/pre&gt;

&lt;p&gt;The UserControl reference is a composite control with any necessary user interface elements for configuring the application. This could be a file dialog, checkboxes for options, buttons to start or stop processing threads, or whatever makes sense. The base application (the host) then provides access to them based on user request. The &lt;b&gt;Name&lt;/b&gt;, &lt;b&gt;TrayIcon&lt;/b&gt;, &lt;b&gt;Description&lt;/b&gt;, and other such properties are used to generate information such as found in an About dialog. The methods are used by the host to control the lifecycle, similar to a Windows service. The &lt;b&gt;Initialize()&lt;/b&gt; method is called on startup, followed by &lt;b&gt;Start()&lt;/b&gt;. &lt;b&gt;Stop()&lt;/b&gt; is called at shutdown/close. The hosted utility doesn’t need to worry about many of the general application logic – just specific units of work.&lt;/p&gt;

&lt;p align="center"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/SimplifyingUtilityDevelopment_28D/clip_image004_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure 2 : Showing About this Application" border="0" alt="Figure 2 : Showing About this Application" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/SimplifyingUtilityDevelopment_28D/clip_image004_thumb.jpg" width="438" height="377" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="center"&gt;&lt;em&gt;Figure 2 : Showing About this Application&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;b&gt;ExtensibleWpfApp &lt;/b&gt;project contains a base class called &lt;b&gt;ApplicationWindow&lt;/b&gt;, which descends from Window. This can be used by any application that wants a simple tray menu, position and size saving, and minimize to tray. On top of that is the &lt;b&gt;MainAppWindow&lt;/b&gt; class. This descends from &lt;b&gt;ApplicationWindow&lt;/b&gt; and also implements &lt;b&gt;IWpfHost&lt;/b&gt;. This takes care of creating a main window that displays the application metadata and settings. You’re welcome to take either class as a base class, but then you wouldn’t get the benefit of MEF extensibility.&lt;/p&gt;

&lt;p&gt;During the instantiation of the &lt;b&gt;MainAppWindow &lt;/b&gt;class it also initializes itself and its base class using properties from the add-in:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Visual C#&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; MainAppWindow()
{
    InitializeComponent();

    Compose();

    &lt;span class="rem"&gt;// Settings menu item on or off, ShowApp menu item on or off, Wire up callbacks, etc.&lt;/span&gt;
    CurrentAddin.Start();

    &lt;span class="kwrd"&gt;this&lt;/span&gt;.ApplicationName = CurrentAddin.Name;
    &lt;span class="kwrd"&gt;this&lt;/span&gt;.HideOnClose = CurrentAddin.HideOnClose;

    &lt;span class="rem"&gt;// Sets a custom icon or leaves it as default&lt;/span&gt;
    &lt;span class="kwrd"&gt;if&lt;/span&gt;( CurrentAddin.TrayIcon != &lt;span class="kwrd"&gt;null&lt;/span&gt; )
    {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.TrayIcon = CurrentAddin.TrayIcon;
    }

    dockPanelAddinInfo.DataContext = CurrentAddin;

    Application.Current.Exit += &lt;span class="kwrd"&gt;new&lt;/span&gt; ExitEventHandler(CurrentApp_Exit);
    CurrentAddin.StatusUpdated += &lt;span class="kwrd"&gt;new&lt;/span&gt; EventHandler(CurrentAddin_StatusUpdated);
}&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Visual Basic&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt;()
    InitializeComponent()

    Compose()

    &lt;span class="rem"&gt;' Settings menu item on or off, ShowApp menu item on or off, Wire up callbacks, etc.&lt;/span&gt;
    CurrentAddin.Start()

    &lt;span class="kwrd"&gt;Me&lt;/span&gt;.ApplicationName = CurrentAddin.Name
    &lt;span class="kwrd"&gt;Me&lt;/span&gt;.HideOnClose = CurrentAddin.HideOnClose

    &lt;span class="rem"&gt;' Sets a custom icon or leaves it as default&lt;/span&gt;
    &lt;span class="kwrd"&gt;If&lt;/span&gt; CurrentAddin.TrayIcon IsNot &lt;span class="kwrd"&gt;Nothing&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;
        &lt;span class="kwrd"&gt;Me&lt;/span&gt;.TrayIcon = CurrentAddin.TrayIcon
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;

    dockPanelAddinInfo.DataContext = CurrentAddin

    &lt;span class="kwrd"&gt;AddHandler&lt;/span&gt; Application.Current.&lt;span class="kwrd"&gt;Exit&lt;/span&gt;, &lt;span class="kwrd"&gt;AddressOf&lt;/span&gt; CurrentApp_Exit
    &lt;span class="kwrd"&gt;AddHandler&lt;/span&gt; CurrentAddin.StatusUpdated, &lt;span class="kwrd"&gt;AddressOf&lt;/span&gt; CurrentAddin_StatusUpdated
&lt;span class="kwrd"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;

&lt;p&gt;Notice how it has the concept of application name and a tray icon – something a standard application doesn’t have. It’s easy enough to add these things, but it can be tedious, and beginner programmers just have that much more to figure to get started.&lt;/p&gt;

&lt;h3&gt;Next Steps&lt;/h3&gt;

&lt;p&gt;Though the application is a good start, I see a need for more. The application could invoke add-in features on a timer with the framework prompting the user for the interval and handling that automatically. The concept of saving and cancelling settings changes should really be built into the framework. It might also be good for the add-in to have access to show/hide the window as needed. Hooking into the system Event Log or other logging and other tracing mechanisms could also be handled by the framework.&lt;/p&gt;

&lt;p&gt;The key is to find common services that applications can use which also normally require some user configuration. If the framework can handle that automatically, it makes for less work for each utility.&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;First of all, this is only the first part of this article. Next time I’ll dig into the MEF implementation and explain how an add-in works in better detail. I’ll flesh out the sample add-in a bit as a point of reference and hopefully you’ll see how you might benefit from it as well.&lt;/p&gt;

&lt;p&gt;Building reusable application code can make a huge difference over time. Unfortunately it always takes longer the first time to do it right. Good code ends up being reused, but copy-and-paste reuse isn’t as good as binary reuse (referencing an assembly/DLL), and that’s still not as good as composition where new components bind to a framework at runtime. Frameworks like MEF, System.Addin, PRISM, and others make it much easier than it used to be to create extension points so code can fit in later. Used wisely this can lead to a more streamlined code base where you can rely on other contributors or communities to implement new features instead of coming to you each time. You can focus on creating a solid foundation and let people create niche or mainstream features as they see fit. You’ll be happier and your users will love it too!&lt;/p&gt;

&lt;p&gt;If you haven’t already, download Visual Studio Express Edition today and get started.&lt;/p&gt;

&lt;h3&gt;About the Author&lt;/h3&gt;

&lt;table border="0" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="157"&gt;
        &lt;p align="center"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Arian Kulp" border="0" alt="Arian Kulp" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/SimplifyingUtilityDevelopment_28D/Avatar80_3.jpg" width="90" height="100" /&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="481"&gt;
        &lt;p&gt;&lt;strong&gt;Arian Kulp&lt;/strong&gt; is a software developer living in the Midwest.&amp;#160; He has been writing software since the fifth grade (though not always professionally).&amp;#160; Arian creates developer evangelism stuff, speaks at INETA and Code Camps, and loves to stay on the cutting edge of technology.&amp;#160; In his spare time, he enjoys nature, photography, and his family.&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9535026" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows+miscellaneous/default.aspx">windows miscellaneous</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category></item><item><title>TwitterDrive – Author Interview</title><link>http://blogs.msdn.com/coding4fun/archive/2009/04/01/9525555.aspx</link><pubDate>Wed, 01 Apr 2009 10:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9525555</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9525555.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9525555</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9525555</wfw:comment><description>&lt;p&gt;&lt;img style="border-right-width: 0px; margin: 0px 10px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="tDrive" border="0" alt="tDrive" align="left" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDriveAuthorInterview_264E/tDrive_3.jpg" width="79" height="45" mce_src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDriveAuthorInterview_264E/tDrive_3.jpg" /&gt; In case you haven’t heard, &lt;a href="http://www.brianpeek.com/media/p/3413.aspx" mce_href="http://www.brianpeek.com/media/p/3413.aspx"&gt;TwitterDrive&lt;/a&gt; is going to revolutionize the way files are stored and shared on the Internet.&amp;#160; Today, we had the rare privilege of sitting down and talking with &lt;a href="http://www.brianpeek.com/" mce_href="http://www.brianpeek.com/"&gt;Brian Peek&lt;/a&gt;, creator of this cutting edge product.&lt;/p&gt;  &lt;p&gt;&lt;b&gt; Q: Thanks for taking the time to speak with us today.&amp;#160; Why don’t you tell us a little bit about yourself?&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;A: I’m surprised I even considered this.&amp;#160; I’m so above you people now.&amp;#160; But anyway, my name is Brian Peek, and until I developed this app, I was working, like you people, at a job that was pointless.&amp;#160; Now, I’m on the cusp of owning people like you.&amp;#160; Once this takes off, I can finally pursue my life’s other passion:&amp;#160; hip-hop music.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDriveAuthorInterview_264E/30872-480-360_2.png" mce_href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDriveAuthorInterview_264E/30872-480-360_2.png"&gt;&lt;img style="border-right-width: 0px; margin: 0px 10px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="30872-480-360" border="0" alt="30872-480-360" align="left" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDriveAuthorInterview_264E/30872-480-360_thumb.png" width="364" height="274" mce_src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDriveAuthorInterview_264E/30872-480-360_thumb.png" /&gt;&lt;/a&gt; Q: I don’t doubt it.&amp;#160; So why don’t you tell us a little bit about TwitterDrive and how you came up with the idea?&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;A: TwitterDrive is the next “big thing” in cloud storage.&amp;#160; There are a ton of cloud storage providers out there now, most of which cost money or have limited disk space available.&amp;#160; But why should we live with limitations like these?&amp;#160; Twitter provides their users with unlimited storage for sending and saving their “tweets”.&amp;#160; My amazingly brilliant idea was to take this service to the next level:&amp;#160; using it to store and share files.&amp;#160; That is, free cloud storage.&amp;#160; Bet you wish you thought of that. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;b&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="shatner" border="0" alt="shatner" align="left" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDriveAuthorInterview_264E/shatner_3.png" width="185" height="250" /&gt;&lt;/b&gt;Q: I sure do.&amp;#160; So how does TwitterDrive work? &lt;/b&gt;&lt;/p&gt;  &lt;p&gt;A: It works perfectly.&amp;#160; Simply run the TwitterDrive application, provide your Twitter user credentials, and then start uploading and downloading files.&amp;#160; Files are compressed, base64 encoded, and then uploaded to Twitter 140 bytes at a time, fully maximizing the amount of space allowed per tweet.&lt;/p&gt;  &lt;p&gt;Imagine…uploading 14 thousand bytes of data per hour!&amp;#160; Or downloading two megabytes per hour!&amp;#160; Match that, SkyDrive.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Q: That sounds amazing.&amp;#160; Unlimited storage for free.&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;It is amazing.&amp;#160; Which is why I thought of it and you didn’t.&amp;#160; Welcome to the future.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Q: So are there any limitations?&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Only if you consider uploading 14 thousand &lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDriveAuthorInterview_264E/mp_main_wide_EarlyComputerMarketing_2.png" mce_href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDriveAuthorInterview_264E/mp_main_wide_EarlyComputerMarketing_2.png"&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="mp_main_wide_EarlyComputerMarketing" border="0" alt="mp_main_wide_EarlyComputerMarketing" align="right" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDriveAuthorInterview_264E/mp_main_wide_EarlyComputerMarketing_thumb.png" width="364" height="282" mce_src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDriveAuthorInterview_264E/mp_main_wide_EarlyComputerMarketing_thumb.png" /&gt;&lt;/a&gt;bytes per hour a limitation.&amp;#160; But really, who has that much data?&amp;#160; 14k should be enough for everybody.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Q: What about data protection?&amp;#160; Is the file data protected in any way?&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;The data is compressed, encoded and chunked up into bits.&amp;#160; Who needs more security than that?&amp;#160; Besides, users would need to know your TwitterDrive account username to get at the data.&amp;#160; Security through obscurity is a win for everyone!&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Q: Do you have any new features planned for TwitterDrive?&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;New features?&amp;#160; No.&amp;#160; It’s already the most complete, useful and bug free application ever developed.&amp;#160; It doesn’t require any additional features.&lt;/p&gt;  &lt;p&gt;Now if you’ll excuse me, I have to start planning which jet I want to buy.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Well there you have it, folks.&amp;#160; We are at the cusp of a revolution.&amp;#160; Are you ready?&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.brianpeek.com/media/p/3413.aspx" mce_href="http://www.brianpeek.com/media/p/3413.aspx"&gt;Download TwitterDrive here&lt;/a&gt;.&amp;#160; Want to learn more?&amp;#160; Learn &lt;a href="http://blogs.msdn.com/coding4fun/archive/2009/04/01/9525376.aspx" mce_href="http://blogs.msdn.com/coding4fun/archive/2009/04/01/9525376.aspx"&gt;how it was made&lt;/a&gt;!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9525555" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/utility/default.aspx">utility</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/productivity/default.aspx">productivity</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/web/default.aspx">web</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/april+fools+day/default.aspx">april fools day</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/holiday/default.aspx">holiday</category></item><item><title>TwitterDrive – The Revolution in Cloud Storage</title><link>http://blogs.msdn.com/coding4fun/archive/2009/04/01/9525376.aspx</link><pubDate>Wed, 01 Apr 2009 10:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9525376</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9525376.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9525376</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9525376</wfw:comment><description>&lt;table border="0" cellspacing="0" cellpadding="1" width="100%"&gt;&lt;tbody&gt;     &lt;tr class="entry_overview"&gt;       &lt;td width="50"&gt;&amp;#160;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tDrive" border="0" alt="tDrive" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDrive_36DE/tDrive_3.jpg" width="75" height="41" /&gt; &lt;/td&gt;        &lt;td&gt;&lt;span class="entry_description"&gt;In this article, Brian Peek will provide a technical overview of TwitterDrive, an application used to store and retrieve files via the Twitter messaging service.&lt;/span&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td colspan="2"&gt;         &lt;div class="entry_author"&gt;&lt;a href="http://www.brianpeek.com/" target="_blank" mce_href="http://www.brianpeek.com/"&gt;Brian Peek&lt;/a&gt;&lt;/div&gt;          &lt;div class="entry_company"&gt;&lt;a href="http://www.aspsoft.com/" mce_href="http://www.aspsoft.com/"&gt;ASPSOFT, Inc.&lt;/a&gt;&lt;/div&gt;          &lt;br /&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Difficulty: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Intermediate&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Time Required:&lt;/b&gt; 2&lt;span class="entry_details_input"&gt;-3 hours&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Cost: &lt;/b&gt;Free&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Software: &lt;/b&gt;&lt;span class="entry_details_input"&gt;&lt;a href="http://msdn.com/express/"&gt;Visual C# Express 2008 SP1, Visual Basic Express 2008 SP1, or Visual Studio 2008 SP1, .NET Framework 3.5 SP1&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Hardware: &lt;/b&gt;None&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Download: &lt;/b&gt;&lt;a href="http://www.brianpeek.com/media/p/3413.aspx" target="_blank"&gt;Application&lt;/a&gt;, &lt;a href="http://www.brianpeek.com/media/p/3414.aspx" target="_blank"&gt;Source Code&lt;/a&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Discussion Forum: &lt;/b&gt;&lt;a href="http://www.brianpeek.com/forums/44.aspx" target="_blank"&gt;Forum&lt;/a&gt;&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Introduction&lt;/h3&gt;  &lt;p&gt;As you’ve probably guessed by now, &lt;b&gt;TwitterDrive&lt;/b&gt; is my April Fool’s Day application for Coding4Fun this year.&amp;#160; While the application does actually work, the limitations of Twitter make it functionally useless.&amp;#160; That said, I’ll still take you through the important parts as there is some value in the code with regard to the Twitter API, LINQ to XML, threading, and a couple other things.&lt;/p&gt;  &lt;h4&gt;How It Works&lt;/h4&gt;  &lt;p&gt;Not very well, actually.&amp;#160; The concept is we take a file, compress it, uuencode/base64 encode it (that is, make a text representation of the binary contents), and then upload it 140 characters at a time to Twitter as status messages.&amp;#160; When the file upload is complete, an index is written of every file that is currently stored on Twitter with some information that can be used to later retrieve the file.&lt;/p&gt;  &lt;h4&gt;Twitter&lt;/h4&gt;  &lt;p&gt;Let’s start with the Twitter API.&amp;#160; Full documentation on this API can be found at:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://apiwiki.twitter.com/" href="http://apiwiki.twitter.com/"&gt;http://apiwiki.twitter.com/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;TwitterDrive only requires a very small subset of this functionality to work.&amp;#160; We need the ability to post a new status message, download a user timeline, destroy a status, and verify the user’s credentials.&amp;#160; All of these things are handled in the &lt;b&gt;TwitterService&lt;/b&gt; class.&lt;/p&gt;  &lt;p&gt;The heart of this class consists of two methods:&amp;#160; &lt;b&gt;GetTwitter &lt;/b&gt;and &lt;b&gt;PostTwitter&lt;/b&gt;.&amp;#160; &lt;b&gt;GetTwitter&lt;/b&gt; will make a GET request to Twitter of the specified URL, and &lt;b&gt;PostTwitter&lt;/b&gt; will make a POST request to Twitter of the specified URL with the supplied data.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; XDocument GetTwitter(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; url)&lt;br /&gt;{&lt;br /&gt;    WebClient wc = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; WebClient();&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// only authenticate if we have a password&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(!&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;.IsNullOrEmpty(Password))&lt;br /&gt;        wc.Credentials = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; NetworkCredential(Username, Password);&lt;br /&gt;&lt;br /&gt;    Stream s = wc.OpenRead(url);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// return an XDocument for LINQ&lt;/span&gt;&lt;br /&gt;    XmlTextReader xmlReader = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; XmlTextReader(s);&lt;br /&gt;    XDocument xdoc = XDocument.Load(xmlReader);&lt;br /&gt;    xmlReader.Close();&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; xdoc;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; XDocument PostTwitter(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; url, &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; data)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;byte&lt;/span&gt;[] bytes = Encoding.ASCII.GetBytes(data);&lt;br /&gt;&lt;br /&gt;    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);&lt;br /&gt;    request.Method = &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;POST&amp;quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// if we're writing, we need to authenticate&lt;/span&gt;&lt;br /&gt;    request.Credentials = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; NetworkCredential(Username, Password);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// if this is 'true', Twitter breaks&lt;/span&gt;&lt;br /&gt;    request.ServicePoint.Expect100Continue = &lt;span style="color: rgb(0,0,255)"&gt;false&lt;/span&gt;;&lt;br /&gt;    request.ContentType = &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;application/x-www-form-urlencoded&amp;quot;&lt;/span&gt;;&lt;br /&gt;    request.ContentLength = bytes.Length;&lt;br /&gt;&lt;br /&gt;    Stream reqStream = request.GetRequestStream();&lt;br /&gt;    reqStream.Write(bytes, 0, bytes.Length);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// turn the response into an XDocument for use with LINQ&lt;/span&gt;&lt;br /&gt;    HttpWebResponse resp = (HttpWebResponse)request.GetResponse();&lt;br /&gt;    XmlReader xmlReader = XmlReader.Create(resp.GetResponseStream());&lt;br /&gt;    XDocument xdoc = XDocument.Load(xmlReader);&lt;br /&gt;    xmlReader.Close();&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; xdoc;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; GetTwitter(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; url &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XDocument&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; wc &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; WebClient()&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' only authenticate if we have a password&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; (&lt;span style="color: rgb(0,0,255)"&gt;Not&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;.IsNullOrEmpty(Password)) &lt;span style="color: rgb(0,0,255)"&gt;Then&lt;/span&gt;&lt;br /&gt;        wc.Credentials = &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; NetworkCredential(Username, Password)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; s &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Stream = wc.OpenRead(url)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' return an XDocument for LINQ&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; xmlReader &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; XmlTextReader(s)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; xdoc &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XDocument = XDocument.Load(xmlReader)&lt;br /&gt;    xmlReader.Close()&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; xdoc&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; PostTwitter(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; url &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; data &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XDocument&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; bytes() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Byte&lt;/span&gt; = Encoding.ASCII.GetBytes(data)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; request &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; HttpWebRequest = &lt;span style="color: rgb(0,0,255)"&gt;CType&lt;/span&gt;(WebRequest.Create(url), HttpWebRequest)&lt;br /&gt;    request.Method = &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;POST&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' if we're writing, we need to authenticate&lt;/span&gt;&lt;br /&gt;    request.Credentials = &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; NetworkCredential(Username, Password)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' if this is 'true', Twitter breaks&lt;/span&gt;&lt;br /&gt;    request.ServicePoint.Expect100Continue = &lt;span style="color: rgb(0,0,255)"&gt;False&lt;/span&gt;&lt;br /&gt;    request.ContentType = &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;application/x-www-form-urlencoded&amp;quot;&lt;/span&gt;&lt;br /&gt;    request.ContentLength = bytes.Length&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; reqStream &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Stream = request.GetRequestStream()&lt;br /&gt;    reqStream.Write(bytes, 0, bytes.Length)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' turn the response into an XDocument for use with LINQ&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; resp &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; HttpWebResponse = &lt;span style="color: rgb(0,0,255)"&gt;CType&lt;/span&gt;(request.GetResponse(), HttpWebResponse)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; xmlReader &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XmlReader = XmlReader.Create(resp.GetResponseStream())&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; xdoc &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XDocument = XDocument.Load(xmlReader)&lt;br /&gt;    xmlReader.Close()&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; xdoc&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Each of these methods will use the &lt;b&gt;NetworkCredentials&lt;/b&gt; object to authenticate to Twitter for reading or writing, as required.&amp;#160; Twitter API methods return simple XML objects.&amp;#160; Both &lt;b&gt;GetTwitter&lt;/b&gt; and &lt;b&gt;PostTwitter&lt;/b&gt; take these XML documents and turn them into &lt;b&gt;XDocument&lt;/b&gt; objects that can be easily queried with LINQ to XML later.&lt;/p&gt;

&lt;p&gt;We only need to call two Twitter “get” methods: &lt;b&gt;user_timeline &lt;/b&gt;and &lt;b&gt;verify_credentials&lt;/b&gt;.&amp;#160; There are two overloaded methods which call the &lt;b&gt;user_timeline&lt;/b&gt; API:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; IList&amp;lt;Status&amp;gt; GetUserTimeline(&lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; page, &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; count)&lt;br /&gt;{&lt;br /&gt;    XDocument xdoc = GetTwitter(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;.Format(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;&lt;a class="linkification-ext" title="Linkification: http://twitter.com/statuses/user_timeline.xml?count=" href="http://twitter.com/statuses/user_timeline.xml?count="&gt;http://twitter.com/statuses/user_timeline.xml?count=&lt;/a&gt;{0}&amp;amp;page={1}&amp;amp;id={2}&amp;quot;&lt;/span&gt;, count, page, Username));&lt;br /&gt;    IList&amp;lt;Status&amp;gt; statuses = ParseStatuses(xdoc);&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; statuses;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; IList&amp;lt;Status&amp;gt; GetUserTimeline(&lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; since_id, &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; max_id, &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; page, &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; count)&lt;br /&gt;{&lt;br /&gt;    XDocument xdoc = GetTwitter(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;.Format(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;&lt;a class="linkification-ext" title="Linkification: http://twitter.com/statuses/user_timeline.xml?since_id=" href="http://twitter.com/statuses/user_timeline.xml?since_id="&gt;http://twitter.com/statuses/user_timeline.xml?since_id=&lt;/a&gt;{0}&amp;amp;max_id={1}&amp;amp;count={2}&amp;amp;page={3}&amp;amp;id={4}&amp;quot;&lt;/span&gt;, since_id, max_id, count, page, Username));&lt;br /&gt;    IList&amp;lt;Status&amp;gt; statuses = ParseStatuses(xdoc);&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; statuses;&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; GetUserTimeline(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; page &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; count &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; IList(Of Status)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; xdoc &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XDocument = GetTwitter(&lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;.Format(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;&lt;a class="linkification-ext" title="Linkification: http://twitter.com/statuses/user_timeline.xml?count=" href="http://twitter.com/statuses/user_timeline.xml?count="&gt;http://twitter.com/statuses/user_timeline.xml?count=&lt;/a&gt;{0}&amp;amp;page={1}&amp;amp;id={2}&amp;quot;&lt;/span&gt;, count, page, Username))&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; statuses &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; IList(Of Status) = ParseStatuses(xdoc)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; statuses&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; GetUserTimeline(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; since_id &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; max_id &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; page &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; count &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; IList(Of Status)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; xdoc &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XDocument = GetTwitter(&lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;.Format(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;&lt;a class="linkification-ext" title="Linkification: http://twitter.com/statuses/user_timeline.xml?since_id=" href="http://twitter.com/statuses/user_timeline.xml?since_id="&gt;http://twitter.com/statuses/user_timeline.xml?since_id=&lt;/a&gt;{0}&amp;amp;max_id={1}&amp;amp;count={2}&amp;amp;page={3}&amp;amp;id={4}&amp;quot;&lt;/span&gt;, since_id, max_id, count, page, Username))&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; statuses &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; IList(Of Status) = ParseStatuses(xdoc)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; statuses&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Each of these methods creates a URL with the appropriate query string arguments (see the Twitter API docs for the full list) and then calls our ParseStatuses method with the returned XDocument, which will give us a List of Status objects. The Twitter-returned status contains a variety of data, such as:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;status&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;created_at&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;Mon Mar 30 07:20:57 +0000 2009&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;created_at&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;1234567123&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;text&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;Status text&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;text&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;source&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;web&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;source&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;truncated&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;false&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;truncated&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;in_reply_to_status_id&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;in_reply_to_user_id&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;favorited&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;false&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;favorited&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;user&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;12345678&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;Some Person&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;screen_name&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;myscreenname&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;screen_name&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;description&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;location&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;profile_image_url&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;a class="linkification-ext" title="Linkification: http://static.twitter.com/images/default_profile_normal.png" href="http://static.twitter.com/images/default_profile_normal.png"&gt;http://static.twitter.com/images/default_profile_normal.png&lt;/a&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;profile_image_url&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;url&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;protected&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;false&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;protected&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;followers_count&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;1&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;followers_count&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;user&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;status&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;We only care about a few elements and only parse those, namely id, text, user (which is in itself an XML chunk), and created_at.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; IList&amp;lt;Status&amp;gt; ParseStatuses(XContainer container)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// return a list of Status objects&lt;/span&gt;&lt;br /&gt;    var query = from status &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; container.Descendants(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;statuses&amp;quot;&lt;/span&gt;).Descendants(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;status&amp;quot;&lt;/span&gt;)&lt;br /&gt;                select ParseStatus(status);&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; query.ToList();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; Status ParseStatus(XDocument xdoc)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// create a Status object from the returned XML&lt;/span&gt;&lt;br /&gt;    var query = from status &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; xdoc.Descendants(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;status&amp;quot;&lt;/span&gt;)&lt;br /&gt;                select ParseStatus(status);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; query.SingleOrDefault();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; Status ParseStatus(XElement xelement)&lt;br /&gt;{&lt;br /&gt;    Status s = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; Status()&lt;br /&gt;                {&lt;br /&gt;                    ID = (&lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt;)xelement.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;),&lt;br /&gt;                    Text = (&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;)xelement.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;text&amp;quot;&lt;/span&gt;),&lt;br /&gt;                    UserInformation = ParseUserInformation(xelement.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;user&amp;quot;&lt;/span&gt;)),&lt;br /&gt;                    &lt;span style="color: rgb(0,128,0)"&gt;// HTTP-formatted date&lt;/span&gt;&lt;br /&gt;                    CreatedAt = DateTime.ParseExact(xelement.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;created_at&amp;quot;&lt;/span&gt;).Value,&lt;br /&gt;                            &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;ddd MMM dd HH:mm:ss zzzz yyyy&amp;quot;&lt;/span&gt;,&lt;br /&gt;                            CultureInfo.GetCultureInfoByIetfLanguageTag(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;en-us&amp;quot;&lt;/span&gt;),&lt;br /&gt;                            DateTimeStyles.AllowWhiteSpaces)&lt;br /&gt;                };&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; s;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; ParseStatuses(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; container &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XContainer) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; IList(Of Status)&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' return a list of Status objects&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; query = _&lt;br /&gt;        From status &lt;span style="color: rgb(0,0,255)"&gt;In&lt;/span&gt; container.Descendants(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;statuses&amp;quot;&lt;/span&gt;).Descendants(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;status&amp;quot;&lt;/span&gt;) _&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Select&lt;/span&gt; ParseStatus(status)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; query.ToList()&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; ParseStatus(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; xdoc &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XDocument) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Status&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' create a Status object from the returned XML&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; query = _&lt;br /&gt;        From status &lt;span style="color: rgb(0,0,255)"&gt;In&lt;/span&gt; xdoc.Descendants(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;status&amp;quot;&lt;/span&gt;) _&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Select&lt;/span&gt; ParseStatus(status)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; query.SingleOrDefault()&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; ParseStatus(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; xelement &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XElement) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Status&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; s &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; Status() &lt;span style="color: rgb(0,0,255)"&gt;With&lt;/span&gt; { _&lt;br /&gt;        .ID = &lt;span style="color: rgb(0,0,255)"&gt;CInt&lt;/span&gt;(xelement.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;)), _&lt;br /&gt;        .Text = &lt;span style="color: rgb(0,0,255)"&gt;CStr&lt;/span&gt;(xelement.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;text&amp;quot;&lt;/span&gt;)), _&lt;br /&gt;        .UserInformation = ParseUserInformation(xelement.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;user&amp;quot;&lt;/span&gt;)), _&lt;br /&gt;        .CreatedAt = DateTime.ParseExact(xelement.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;created_at&amp;quot;&lt;/span&gt;).Value, _&lt;br /&gt;                    &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;ddd MMM dd HH:mm:ss zzzz yyyy&amp;quot;&lt;/span&gt;, CultureInfo.GetCultureInfoByIetfLanguageTag(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;en-us&amp;quot;&lt;/span&gt;), DateTimeStyles.AllowWhiteSpaces) }&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; s&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;These methods use LINQ to XML to drill down into the XML document to parse out individual status objects and return them as a list.&amp;#160; You will notice the user element contains a &lt;strong&gt;user_information&lt;/strong&gt; XML chunk, and the &lt;b&gt;ParseUserInformation&lt;/b&gt; method parses that data&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; UserInformation ParseUserInformation(XContainer container)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// parse and return a UserInformation object&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; UserInformation&lt;br /&gt;    {&lt;br /&gt;        ID = (&lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt;)container.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;),&lt;br /&gt;        Name = (&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;)container.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;),&lt;br /&gt;        ScreenName = (&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;)container.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;screen_name&amp;quot;&lt;/span&gt;)&lt;br /&gt;    };&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; ParseUserInformation(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; container &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XContainer) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; UserInformation&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' parse and return a UserInformation object&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; ui &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; UserInformation() &lt;span style="color: rgb(0,0,255)"&gt;With&lt;/span&gt; { _&lt;br /&gt;        .ID = &lt;span style="color: rgb(0,0,255)"&gt;CInt&lt;/span&gt;(container.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;)), _&lt;br /&gt;        .Name = &lt;span style="color: rgb(0,0,255)"&gt;CStr&lt;/span&gt;(container.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;)), _&lt;br /&gt;        .ScreenName = &lt;span style="color: rgb(0,0,255)"&gt;CStr&lt;/span&gt;(container.Element(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;screen_name&amp;quot;&lt;/span&gt;)) }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; ui&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The &lt;b&gt;verify_credentials&lt;/b&gt; API is called in a similar manner, but in this case we will “listen” for a 401 (Unauthorized) exception and return true or false appropriately:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;bool&lt;/span&gt; VerifyTwitterCredentials(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; username, &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; password)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;try&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;        WebClient wc = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; WebClient();&lt;br /&gt;        wc.Credentials = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; NetworkCredential(username, password);&lt;br /&gt;        Stream s = wc.OpenRead(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;&lt;a class="linkification-ext" title="Linkification: http://twitter.com/account/verify_credentials.xml" href="http://twitter.com/account/verify_credentials.xml"&gt;http://twitter.com/account/verify_credentials.xml&lt;/a&gt;&amp;quot;&lt;/span&gt;);&lt;br /&gt;        s.Close();&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;catch&lt;/span&gt;(WebException we)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;((we.Response &lt;span style="color: rgb(0,0,255)"&gt;as&lt;/span&gt; HttpWebResponse).StatusCode == HttpStatusCode.Unauthorized)&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;false&lt;/span&gt;;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;throw&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;true&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;With the “get” methods out of the way, we can write our “post” methods.&amp;#160; We only need two methods here as well:&amp;#160; &lt;b&gt;update&lt;/b&gt; and &lt;b&gt;destroy&lt;/b&gt;.&amp;#160; Update is used to write a new tweet to Twitter, and destroy is used to remove an existing tweet.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; Status UpdateStatus(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; status)&lt;br /&gt;{&lt;br /&gt;    XDocument doc = PostTwitter(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;&lt;a class="linkification-ext" title="Linkification: http://twitter.com/statuses/update.xml" href="http://twitter.com/statuses/update.xml"&gt;http://twitter.com/statuses/update.xml&lt;/a&gt;&amp;quot;&lt;/span&gt;, &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;status=&amp;quot;&lt;/span&gt; + status);&lt;br /&gt;    Status s =  ParseStatus(doc);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// if we don't get the text we sent, we hit the rate limit...&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(s.Text != HttpUtility.UrlDecode(status))&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;throw&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; TwitterRateLimitException(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;Twitter upload limit reached.&amp;quot;&lt;/span&gt;);&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; s;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; Status Destroy(&lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; status)&lt;br /&gt;{&lt;br /&gt;    XDocument doc = PostTwitter(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;&lt;a class="linkification-ext" title="Linkification: http://twitter.com/statuses/destroy/" href="http://twitter.com/statuses/destroy/"&gt;http://twitter.com/statuses/destroy/&lt;/a&gt;&amp;quot;&lt;/span&gt; + status + &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;.xml&amp;quot;&lt;/span&gt;, &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;id=&amp;quot;&lt;/span&gt; + status);&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; ParseStatus(doc);&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; VerifyTwitterCredentials(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; username &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; password &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Boolean&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Try&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; wc &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; WebClient()&lt;br /&gt;        wc.Credentials = &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; NetworkCredential(username, password)&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; s &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Stream = wc.OpenRead(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;&lt;a class="linkification-ext" title="Linkification: http://twitter.com/account/verify_credentials.xml" href="http://twitter.com/account/verify_credentials.xml"&gt;http://twitter.com/account/verify_credentials.xml&lt;/a&gt;&amp;quot;&lt;/span&gt;)&lt;br /&gt;        s.Close()&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Catch&lt;/span&gt; we &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; WebException&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; (&lt;span style="color: rgb(0,0,255)"&gt;TryCast&lt;/span&gt;(we.Response, HttpWebResponse)).StatusCode = HttpStatusCode.Unauthorized &lt;span style="color: rgb(0,0,255)"&gt;Then&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;False&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Throw&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Try&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;True&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The &lt;b&gt;UpdateStatus&lt;/b&gt; method has a bit of code to determine whether we hit Twitter’s upload rate limit.&amp;#160; Twitter will limit you to about 100 tweets per hour.&amp;#160; The only way to determine if you’ve hit the upload limit (that I found at least) is to compare the text from &lt;b&gt;status&lt;/b&gt; element returned from the update to the text that was sent.&amp;#160; If the upload limit is hit, the last valid &lt;b&gt;status&lt;/b&gt; element will be returned, and therefore the text blocks will not match.&amp;#160; If this happens, we throw our own custom &lt;b&gt;TwitterRateLimitException&lt;/b&gt; up the stack for the UI to handle.&lt;/p&gt;

&lt;h4&gt;TwitterDrive&lt;/h4&gt;

&lt;p&gt;Now that we can talk to Twitter, the next step is to write the code that uses these methods to store and retrieve our file data.&amp;#160; This code is located in the &lt;b&gt;TwitterDrive&lt;/b&gt; class.&lt;/p&gt;

&lt;p&gt;One of the goals I had was to make this application thread-happy to provide a responsive UI while files are uploaded and downloaded.&amp;#160; Therefore, this class sets up three events which can be hooked by the UI to receive periodic status information:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;class&lt;/span&gt; ChunkEventArgs : EventArgs&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; Status Status;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; ChunkLength;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; Total;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; ChunkEventArgs(Status status, &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; length, &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; total)&lt;br /&gt;    {&lt;br /&gt;        Status = status;&lt;br /&gt;        ChunkLength = length;&lt;br /&gt;        Total = total;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,128,0)"&gt;// event handlers for async file transfer&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;event&lt;/span&gt; EventHandler&amp;lt;ChunkEventArgs&amp;gt; ChunkUpload;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;event&lt;/span&gt; EventHandler&amp;lt;ChunkEventArgs&amp;gt; ChunkDownload;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;event&lt;/span&gt; EventHandler&amp;lt;EventArgs&amp;gt; TransferComplete;&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Class&lt;/span&gt; ChunkEventArgs&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Inherits&lt;/span&gt; EventArgs&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; Status &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Status&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; ChunkLength &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; Total &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt;(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; status &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Status, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; length &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; total &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;)&lt;br /&gt;        Status = status&lt;br /&gt;        ChunkLength = length&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Me&lt;/span&gt;.Total = total&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Class&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;These events will be called at the appropriate times and provide information to allow the UI to draw a progress bar and other status information.&lt;/p&gt;

&lt;p&gt;The &lt;b&gt;UploadFile&lt;/b&gt; method does exactly what you think: it uploads the file specified.&amp;#160; The file contents are loaded into memory, compressed, base64 encoded, and finally URL encoded.&amp;#160; Then, this large string is cut into 140 character chunks and sent to Twitter, one chunk at a time.&amp;#160; After each chunk is uploaded, the &lt;b&gt;ChunkUpload&lt;/b&gt; event is called.&amp;#160; Finally, when all chunks are uploaded, a new &lt;b&gt;FileEntry&lt;/b&gt; object is created, added to the in-memory file index, and that index is finally written to the top of the Twitter status list.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&amp;#160;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;void&lt;/span&gt; UploadFile(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; path)&lt;br /&gt;{&lt;br /&gt;    Status s = &lt;span style="color: rgb(0,0,255)"&gt;null&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; startID = 0;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; length = 0;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; chunkLength = 140;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// encode the file&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; file = EncodeFile(path);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// upload the chunks&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;for&lt;/span&gt;(&lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; i = 0; i &amp;lt; file.Length; i+= chunkLength)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;// get the proper length (i.e. don't get full 140 if we're at the end)&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; chunk = file.Substring(i, Math.Min(chunkLength, file.Length-i));&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;// handle the case where we chopped a chunk in the middle of an encoded character&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;// in this case, chop off the encoded data and reset the counter&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(chunk.EndsWith(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;%2&amp;quot;&lt;/span&gt;))&lt;br /&gt;        {&lt;br /&gt;            chunk = chunk.Substring(0, chunk.Length-2);&lt;br /&gt;            i -= 2;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(chunk.EndsWith(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;%&amp;quot;&lt;/span&gt;))&lt;br /&gt;        {&lt;br /&gt;            chunk = chunk.Substring(0, chunk.Length-1);&lt;br /&gt;            i -= 1;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;try&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: rgb(0,128,0)"&gt;// upload the chunk&lt;/span&gt;&lt;br /&gt;            s = _twitter.UpdateStatus(chunk);&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: rgb(0,128,0)"&gt;// notify listeners that we uploaded&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(ChunkUpload != &lt;span style="color: rgb(0,0,255)"&gt;null&lt;/span&gt;)&lt;br /&gt;                ChunkUpload(&lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; ChunkEventArgs(s, chunk.Length, file.Length));&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;catch&lt;/span&gt;(TwitterRateLimitException)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;throw&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; TwitterDriveException(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;Twitter upload limit reached.  Please try again later.&amp;quot;&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(i == 0)&lt;br /&gt;            startID = s.ID;&lt;br /&gt;&lt;br /&gt;        length++;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// create a new FileEntry for this file&lt;/span&gt;&lt;br /&gt;    FileEntry fe = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; FileEntry()&lt;br /&gt;    {&lt;br /&gt;        Filename = Path.GetFileName(path),&lt;br /&gt;        StartStatus = startID,&lt;br /&gt;        EndStatus = s.ID,&lt;br /&gt;        Length = length,&lt;br /&gt;        FileIndex = GetNextIndex()&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// update the index&lt;/span&gt;&lt;br /&gt;    UpdateFileIndex(fe);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// notify we're done&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(TransferComplete != &lt;span style="color: rgb(0,0,255)"&gt;null&lt;/span&gt;)&lt;br /&gt;        TransferComplete(&lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;null&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; UploadFile(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; filepath &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; s &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Status = &lt;span style="color: rgb(0,0,255)"&gt;Nothing&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; startID &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt; = 0&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; length &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt; = 0&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; chunkLength &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt; = 140&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' encode the file&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; file &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt; = EncodeFile(filepath)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' upload the chunks&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;For&lt;/span&gt; i &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt; = 0 &lt;span style="color: rgb(0,0,255)"&gt;To&lt;/span&gt; file.Length - 1 &lt;span style="color: rgb(0,0,255)"&gt;Step&lt;/span&gt; chunkLength&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;' get the proper length (i.e. don't get full 140 if we're at the end)&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; chunk &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt; = file.Substring(i, Math.Min(chunkLength, file.Length-i))&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;' handle the case where we chopped a chunk in the middle of an encoded character&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;' in this case, chop off the encoded data and reset the counter&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; chunk.EndsWith(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;%2&amp;quot;&lt;/span&gt;) &lt;span style="color: rgb(0,0,255)"&gt;Then&lt;/span&gt;&lt;br /&gt;            chunk = chunk.Substring(0, chunk.Length-2)&lt;br /&gt;            i -= 2&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; chunk.EndsWith(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;%&amp;quot;&lt;/span&gt;) &lt;span style="color: rgb(0,0,255)"&gt;Then&lt;/span&gt;&lt;br /&gt;            chunk = chunk.Substring(0, chunk.Length-1)&lt;br /&gt;            i -= 1&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Try&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(0,128,0)"&gt;' upload the chunk&lt;/span&gt;&lt;br /&gt;            s = _twitter.UpdateStatus(chunk)&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: rgb(0,128,0)"&gt;' notify listeners that we uploaded&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;RaiseEvent&lt;/span&gt; ChunkUpload(&lt;span style="color: rgb(0,0,255)"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; ChunkEventArgs(s, chunk.Length, file.Length))&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Catch&lt;/span&gt; e1 &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; TwitterRateLimitException&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;Throw&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; TwitterDriveException(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;Twitter upload limit reached.  Please try again later.&amp;quot;&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Try&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; i = 0 &lt;span style="color: rgb(0,0,255)"&gt;Then&lt;/span&gt;&lt;br /&gt;            startID = s.ID&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        length += 1&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Next&lt;/span&gt; i&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' create a new FileEntry for this file&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; fe &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; FileEntry() &lt;span style="color: rgb(0,0,255)"&gt;With&lt;/span&gt; {.Filename = Path.GetFileName(filepath), .StartStatus = startID, .EndStatus = s.ID, .Length = length, .FileIndex = GetNextIndex()}&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' update the index&lt;/span&gt;&lt;br /&gt;    UpdateFileIndex(fe)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' notify we're done&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;RaiseEvent&lt;/span&gt; TransferComplete(&lt;span style="color: rgb(0,0,255)"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;Nothing&lt;/span&gt;)&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Let’s take a closer look at the &lt;b&gt;EncodeFile&lt;/b&gt; method:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; EncodeFile(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; path)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// load the file&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;byte&lt;/span&gt;[] buff = File.ReadAllBytes(path);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// compress&lt;/span&gt;&lt;br /&gt;    MemoryStream ms = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; MemoryStream();&lt;br /&gt;    GZipStream gs = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; GZipStream(ms, CompressionMode.Compress);&lt;br /&gt;    gs.Write(buff, 0, buff.Length);&lt;br /&gt;    gs.Close();&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;byte&lt;/span&gt;[] buffCompressed = ms.ToArray();&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// base64, urlencode&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; HttpUtility.UrlEncode(Convert.ToBase64String(buffCompressed));&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; EncodeFile(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; path &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' load the file&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; buff() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Byte&lt;/span&gt; = File.ReadAllBytes(path)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' compress&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; ms &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; MemoryStream()&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; gs &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; GZipStream(ms, CompressionMode.Compress)&lt;br /&gt;    gs.Write(buff, 0, buff.Length)&lt;br /&gt;    gs.Close()&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; buffCompressed() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Byte&lt;/span&gt; = ms.ToArray()&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' base64, urlencode&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; HttpUtility.UrlEncode(Convert.ToBase64String(buffCompressed))&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The code here reads the bytes of a file into a byte array.&amp;#160; Then, a &lt;b&gt;MemoryStream&lt;/b&gt; object is created and tied to a &lt;b&gt;GZipStream&lt;/b&gt; (compression) object.&amp;#160; Next, the byte array is written to the stream which will compress the data on the fly.&amp;#160; Once the stream is closed, calling &lt;b&gt;ToArray&lt;/b&gt; on the &lt;b&gt;MemoryStream&lt;/b&gt; will return a byte array of the compressed data.&amp;#160; The byte array is base64 encoded (turned into text) and finally URL encoded so it can be sent to Twitter.&lt;/p&gt;

&lt;p&gt;The file index is written at the end of each file upload.&amp;#160; The index is comprised of a delimited string which contains the data in the &lt;b&gt;FileEntry&lt;/b&gt; object.&amp;#160; Each file is uploaded as one tweet, with an end marker to denote where the file index ends.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;void&lt;/span&gt; WriteFileEntries()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// write an end marker (write this first since they come out in reverse order later)&lt;/span&gt;&lt;br /&gt;    _twitter.UpdateStatus(FileEntryEnd);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;for&lt;/span&gt;(&lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; i = 0; i &amp;lt; _fileEntries.Count; i++)&lt;br /&gt;        WriteFileEntry(_fileEntries[i]);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;void&lt;/span&gt; WriteFileEntry(FileEntry fe)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// simple delimited list of data&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; entry = &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;.Format(FileEntryHeader +&lt;br /&gt;                                &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;{0}&amp;quot;&lt;/span&gt; + FileEntrySeparator + &lt;br /&gt;                                &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;{1}&amp;quot;&lt;/span&gt; + FileEntrySeparator +&lt;br /&gt;                                &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;{2}&amp;quot;&lt;/span&gt; + FileEntrySeparator +&lt;br /&gt;                                &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;{3}&amp;quot;&lt;/span&gt; + FileEntrySeparator +&lt;br /&gt;                                &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;{4}&amp;quot;&lt;/span&gt;, &lt;br /&gt;                                fe.Filename, fe.StartStatus, fe.EndStatus, fe.Length, fe.FileIndex);&lt;br /&gt;    _twitter.UpdateStatus(entry);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; WriteFileEntries()&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' write an end marker (write this first since they come out in reverse order later)&lt;/span&gt;&lt;br /&gt;    _twitter.UpdateStatus(FileEntryEnd)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; i &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt; = 0&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Do&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;While&lt;/span&gt; i &amp;lt; _fileEntries.Count&lt;br /&gt;        WriteFileEntry(_fileEntries(i))&lt;br /&gt;        i += 1&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Loop&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; WriteFileEntry(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; fe &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; FileEntry)&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' simple delimited list of data&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; entry &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt; = &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;.Format(FileEntryHeader &amp;amp; &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;{0}&amp;quot;&lt;/span&gt; &amp;amp; FileEntrySeparator &amp;amp; &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;{1}&amp;quot;&lt;/span&gt; &amp;amp; FileEntrySeparator &amp;amp; &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;{2}&amp;quot;&lt;/span&gt; &amp;amp; FileEntrySeparator &amp;amp; &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;{3}&amp;quot;&lt;/span&gt; &amp;amp; FileEntrySeparator &amp;amp; &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;{4}&amp;quot;&lt;/span&gt;, fe.Filename, fe.StartStatus, fe.EndStatus, fe.Length, fe.FileIndex)&lt;br /&gt;    _twitter.UpdateStatus(entry)&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;A file list can be retrieved and parsed out with the following code:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; IList&amp;lt;FileEntry&amp;gt; GetFileIndex()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;bool&lt;/span&gt; end = &lt;span style="color: rgb(0,0,255)"&gt;false&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt; page = 1;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// the index should be the last things tweeted, but if we have a failed upload, it may not be&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;while&lt;/span&gt;(!end &amp;amp;&amp;amp; page &amp;lt; 5)&lt;br /&gt;    {&lt;br /&gt;        IList&amp;lt;Status&amp;gt; indexes = _twitter.GetUserTimeline(page, 200);&lt;br /&gt;&lt;br /&gt;        _fileEntries.Clear();&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;// parase out the file entries&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;foreach&lt;/span&gt;(Status index &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; indexes)&lt;br /&gt;        {&lt;br /&gt;            FileEntry fe = ParseFileIndexString(index.Text);&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(fe != &lt;span style="color: rgb(0,0,255)"&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                fe.IndexStatusId = index.ID;&lt;br /&gt;                _fileEntries.Add(fe);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(index.Text.StartsWith(FileEntryEnd))&lt;br /&gt;            {&lt;br /&gt;                end = &lt;span style="color: rgb(0,0,255)"&gt;true&lt;/span&gt;;&lt;br /&gt;                &lt;span style="color: rgb(0,0,255)"&gt;break&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        page++;&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; _fileEntries;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;private&lt;/span&gt; FileEntry ParseFileIndexString(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; index)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(!index.StartsWith(FileEntryHeader))&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;[] fileEntry = index.Split(Convert.ToChar(FileEntrySeparator));&lt;br /&gt;    FileEntry fe = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; FileEntry()&lt;br /&gt;                    {&lt;br /&gt;                        Filename = fileEntry[0].Replace(FileEntryHeader, &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt;.Empty),&lt;br /&gt;                        StartStatus = &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt;.Parse(fileEntry[1]),&lt;br /&gt;                        EndStatus = &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt;.Parse(fileEntry[2]),&lt;br /&gt;                        Length = &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt;.Parse(fileEntry[3]),&lt;br /&gt;                        FileIndex = &lt;span style="color: rgb(0,0,255)"&gt;int&lt;/span&gt;.Parse(fileEntry[4])&lt;br /&gt;                    };&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; fe;&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; GetFileIndex() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; IList(Of FileEntry)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; [&lt;span style="color: rgb(0,0,255)"&gt;end&lt;/span&gt;] &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Boolean&lt;/span&gt; = &lt;span style="color: rgb(0,0,255)"&gt;False&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; page &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt; = 1&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' the index should be the last things tweeted, but if we have a failed upload, it may not be&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Do&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;While&lt;/span&gt; (&lt;span style="color: rgb(0,0,255)"&gt;Not&lt;/span&gt; [&lt;span style="color: rgb(0,0,255)"&gt;end&lt;/span&gt;]) &lt;span style="color: rgb(0,0,255)"&gt;AndAlso&lt;/span&gt; page &amp;lt; 5&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; indexes &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; IList(Of Status) = _twitter.GetUserTimeline(page, 200)&lt;br /&gt;&lt;br /&gt;        _fileEntries.Clear()&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;' parase out the file entries&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;For&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Each&lt;/span&gt; index &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Status &lt;span style="color: rgb(0,0,255)"&gt;In&lt;/span&gt; indexes&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; fe &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; FileEntry = ParseFileIndexString(index.Text)&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; fe IsNot &lt;span style="color: rgb(0,0,255)"&gt;Nothing&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Then&lt;/span&gt;&lt;br /&gt;                fe.IndexStatusId = index.ID&lt;br /&gt;                _fileEntries.Add(fe)&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; index.Text.StartsWith(FileEntryEnd) &lt;span style="color: rgb(0,0,255)"&gt;Then&lt;/span&gt;&lt;br /&gt;                [&lt;span style="color: rgb(0,0,255)"&gt;end&lt;/span&gt;] = &lt;span style="color: rgb(0,0,255)"&gt;True&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: rgb(0,0,255)"&gt;Exit&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;For&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Next&lt;/span&gt; index&lt;br /&gt;        page += 1&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Loop&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; _fileEntries&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; ParseFileIndexString(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; index &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; FileEntry&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; (&lt;span style="color: rgb(0,0,255)"&gt;Not&lt;/span&gt; index.StartsWith(FileEntryHeader)) &lt;span style="color: rgb(0,0,255)"&gt;Then&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Nothing&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; fileEntry() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt; = index.Split(Convert.ToChar(FileEntrySeparator))&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; fe &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; FileEntry() &lt;span style="color: rgb(0,0,255)"&gt;With&lt;/span&gt; {.Filename = fileEntry(0).Replace(FileEntryHeader, &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;.Empty), .StartStatus = &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;.Parse(fileEntry(1)), .EndStatus = &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;.Parse(fileEntry(2)), .Length = &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;.Parse(fileEntry(3)), .FileIndex = &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;.Parse(fileEntry(4))}&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; fe&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;This code will retrieve the user’s timeline, loop through the tweets, looking for file index entries (those that start with the proper delimiter).&amp;#160; When one is found, the data is parsed back into a &lt;b&gt;FileEntry&lt;/b&gt; object and added to the in-memory cache.&amp;#160; You will note that the &lt;b&gt;GetFileIndex&lt;/b&gt; method will read up to 1000 tweets looking for the end marker before giving up.&lt;/p&gt;

&lt;p&gt;Now that we can upload files and build the index, we need to be able to download, decode and save a file.&amp;#160; This is done in the obviously named &lt;b&gt;DownloadFile &lt;/b&gt;method:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;void&lt;/span&gt; DownloadFile(FileEntry fe, &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; path)&lt;br /&gt;{&lt;br /&gt;    StringBuilder sb = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; StringBuilder(fe.Length * 140);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// get statuses for this user starting/ending at the IDs for this file&lt;/span&gt;&lt;br /&gt;    IList&amp;lt;Status&amp;gt; chunks = _twitter.GetUserTimeline(fe.StartStatus-1, fe.EndStatus, 1, 200);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// order them from oldest to newest&lt;/span&gt;&lt;br /&gt;    var orderedChunks = from chunk &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; chunks&lt;br /&gt;                        orderby chunk.ID ascending&lt;br /&gt;                        select chunk;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;foreach&lt;/span&gt;(Status chunk &lt;span style="color: rgb(0,0,255)"&gt;in&lt;/span&gt; orderedChunks)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;// trim off any extra characters&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; newChunk = chunk.Text.TrimEnd(&lt;span style="color: rgb(0,96,128)"&gt;'.'&lt;/span&gt;).Trim();&lt;br /&gt;        sb.Append(newChunk);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;// notify listeners that we downloaded a chunk&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(ChunkDownload != &lt;span style="color: rgb(0,0,255)"&gt;null&lt;/span&gt;)&lt;br /&gt;            ChunkDownload(&lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; ChunkEventArgs(chunk, newChunk.Length, fe.Length * 140));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// decode and write the file&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;byte&lt;/span&gt;[] buff = DecodeFile(sb.ToString());&lt;br /&gt;    File.WriteAllBytes(Path.Combine(path, fe.Filename), buff);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// notify that we're done&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(TransferComplete != &lt;span style="color: rgb(0,0,255)"&gt;null&lt;/span&gt;)&lt;br /&gt;        TransferComplete(&lt;span style="color: rgb(0,0,255)"&gt;this&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;null&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; DownloadFile(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; fe &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; FileEntry, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; filepath &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; sb &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; StringBuilder(fe.Length * 140)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' get statuses for this user starting/ending at the IDs for this file&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; chunks &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; IList(Of Status) = _twitter.GetUserTimeline(fe.StartStatus-1, fe.EndStatus, 1, 200)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' order them from oldest to newest&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; orderedChunks = _&lt;br /&gt;        From chunk &lt;span style="color: rgb(0,0,255)"&gt;In&lt;/span&gt; chunks _&lt;br /&gt;        Order By chunk.ID Ascending _&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Select&lt;/span&gt; chunk&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;For&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Each&lt;/span&gt; chunk &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Status &lt;span style="color: rgb(0,0,255)"&gt;In&lt;/span&gt; orderedChunks&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;' trim off any extra characters&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; newChunk &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt; = chunk.Text.TrimEnd(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;c).Trim()&lt;br /&gt;        sb.Append(newChunk)&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,128,0)"&gt;' notify listeners that we downloaded a chunk&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0,0,255)"&gt;RaiseEvent&lt;/span&gt; ChunkDownload(&lt;span style="color: rgb(0,0,255)"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; ChunkEventArgs(chunk, newChunk.Length, fe.Length * 140))&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Next&lt;/span&gt; chunk&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' decode and write the file&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; buff() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Byte&lt;/span&gt; = DecodeFile(sb.ToString())&lt;br /&gt;    File.WriteAllBytes(Path.Combine(filepath, fe.Filename), buff)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' notify that we're done&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;RaiseEvent&lt;/span&gt; TransferComplete(&lt;span style="color: rgb(0,0,255)"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;Nothing&lt;/span&gt;)&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;This method returns the user’s timeline starting and ending at the tweets specified in the &lt;b&gt;FileEntry&lt;/b&gt; object.&amp;#160; The status list is ordered in ascending order (i.e. oldest to newest).&amp;#160; Each status is appended to the previous using a &lt;b&gt;StringBuilder&lt;/b&gt; object.&amp;#160; When all chunks are processed, the file is decoded and saved to the chosen location.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;byte&lt;/span&gt;[] DecodeFile(&lt;span style="color: rgb(0,0,255)"&gt;string&lt;/span&gt; data)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// base64 to binary&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;byte&lt;/span&gt;[] buff = Convert.FromBase64String(data);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// decompress&lt;/span&gt;&lt;br /&gt;    MemoryStream ms = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; MemoryStream(buff);&lt;br /&gt;    GZipStream gs = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; GZipStream(ms, CompressionMode.Decompress, &lt;span style="color: rgb(0,0,255)"&gt;false&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;// original&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;byte&lt;/span&gt;[] decompressed = ReadAllBytes(gs);&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;return&lt;/span&gt; decompressed;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; DecodeFile(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; data &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Byte&lt;/span&gt;()&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' base64 to binary&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; buff() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Byte&lt;/span&gt; = Convert.FromBase64String(data)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' decompress&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; ms &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; MemoryStream(buff)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; gs &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; GZipStream(ms, CompressionMode.Decompress, &lt;span style="color: rgb(0,0,255)"&gt;False&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,128,0)"&gt;' original&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; decompressed() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Byte&lt;/span&gt; = ReadAllBytes(gs)&lt;br /&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; decompressed&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;To decode the file, we do the opposite of what we did before: the file is converted to bytes from the base64 encoded string, a &lt;b&gt;GZipStream&lt;/b&gt; is used to decompress the data, and the final, uncompressed file contents are returned to the caller to be saved to the disk.&lt;/p&gt;

&lt;p&gt;Be sure to look through the entire &lt;b&gt;&lt;a class="linkification-ext" title="Linkification: http://TwitterDrive.cs/vb" href="http://TwitterDrive.cs/vb"&gt;TwitterDrive.cs/vb&lt;/a&gt;&lt;/b&gt; file for the full picture, but these are the important parts.&lt;/p&gt;

&lt;h4&gt;User Interface&lt;/h4&gt;

&lt;p&gt;The final piece is the user interface.&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="4-1-2009 4-01-42 AM" border="0" alt="4-1-2009 4-01-42 AM" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TwitterDrive_36DE/4-1-2009%204-01-42%20AM_3.png" width="289" height="350" /&gt; &lt;/p&gt;

&lt;p&gt;A very simple UI for uploading, downloading and deleting files.&amp;#160; At the start of the application, the three TwitterDrive events are hooked: &lt;b&gt;ChunkUpload&lt;/b&gt;, &lt;b&gt;ChunkDownload&lt;/b&gt;, and &lt;b&gt;TransferComplete&lt;/b&gt;.&amp;#160; These three event handlers are used to update the progress bar on a dialog box that pops up during the file transfer.&lt;/p&gt;

&lt;p&gt;When upload or download is selected, the file is selected, and a new thread is created to start the actual process.&amp;#160; Here is what the download process looks like:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,128,0)"&gt;// start a new thread to grab the file&lt;/span&gt;&lt;br /&gt;Thread t = &lt;span style="color: rgb(0,0,255)"&gt;new&lt;/span&gt; Thread(() =&amp;gt; _twitterDrive.DownloadFile(fe, fbd.SelectedPath));&lt;br /&gt;t.Start();&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt;(_progress.ShowDialog() == DialogResult.Cancel)&lt;br /&gt;    t.Abort();&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;else&lt;/span&gt;&lt;br /&gt;    MessageBox.Show(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;File download complete.&amp;quot;&lt;/span&gt;, &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;TwitterDrive&amp;quot;&lt;/span&gt;, MessageBoxButtons.OK, MessageBoxIcon.Information);&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: rgb(0,128,0)"&gt;' start a new thread to grab the file&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; t &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; Thread(&lt;span style="color: rgb(0,0,255)"&gt;CType&lt;/span&gt;(&lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt;() _twitterDrive.DownloadFile(fe, fbd.SelectedPath), ThreadStart))&lt;br /&gt;t.Start()&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; _progress.ShowDialog() = System.Windows.Forms.DialogResult.Cancel &lt;span style="color: rgb(0,0,255)"&gt;Then&lt;/span&gt;&lt;br /&gt;    t.Abort()&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;Else&lt;/span&gt;&lt;br /&gt;    MessageBox.Show(&lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;File download complete.&amp;quot;&lt;/span&gt;, &lt;span style="color: rgb(0,96,128)"&gt;&amp;quot;TwitterDrive&amp;quot;&lt;/span&gt;, MessageBoxButtons.OK, MessageBoxIcon.Information)&lt;br /&gt;&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;A new thread is created, whose &lt;b&gt;ThreadStart&lt;/b&gt; parameter is the &lt;b&gt;DownloadFile&lt;/b&gt; method of the &lt;b&gt;TwitterDrive&lt;/b&gt; class.&amp;#160; The thread is started, and the progress dialog box is shown.&amp;#160; If the progress box is cancelled, the thread is aborted, otherwise the dialog box is closed in response to the &lt;b&gt;TransferComplete&lt;/b&gt; event sent by the &lt;b&gt;TwitterDrive&lt;/b&gt; class.&lt;/p&gt;

&lt;h4&gt;Using the Application&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;Create a new Twitter account for use in TwitterDrive. &lt;/li&gt;

  &lt;li&gt;Enter the credentials for this new account in the provided textboxes and click Refresh.&amp;#160; Or, if you want to download files from someone else, enter just the username and click Refresh. &lt;/li&gt;

  &lt;li&gt;Upload and download data at will. &lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;And there we have it.&amp;#160; A functionally useless application that actually works.&amp;#160; Give it a try and find out what the limitations are.&amp;#160; Just be sure to use a Twitter account that isn’t your main feed otherwise you’ll have some pretty angry followers.&lt;/p&gt;

&lt;h4&gt;Thanks&lt;/h4&gt;

&lt;p&gt;A special thanks to &lt;a href="http://www.markzaugg.com/" target="_blank"&gt;Mark Zaugg&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/danielfe" target="_blank"&gt;Dan Fernandez&lt;/a&gt;, and &lt;a href="http://www.gmontrone.com/" target="_blank"&gt;Giovanni Montrone&lt;/a&gt; for helping me test this application.&amp;#160; Giovanni is also partly responsible for this horrible idea after joking that I should Twitter him a file.&amp;#160; So blame him.&lt;/p&gt;

&lt;p&gt;Also thanks to &lt;a href="http://www.betterthaneveryone.com/" target="_blank"&gt;Clint Rutkas&lt;/a&gt; for throwing together the icon (it’s a combo of the SkyDrive icon + the Twitter icon).&lt;/p&gt;

&lt;h4&gt;Bio&lt;/h4&gt;

&lt;p&gt;Brian is a &lt;a href="https://mvp.support.microsoft.com/profile/Brian.Peek"&gt;Microsoft C# MVP&lt;/a&gt; who has been actively developing in .NET since its early betas in 2000, and who has been developing solutions using Microsoft technologies and platforms for even longer. Along with .NET, Brian is particularly skilled in the languages of C, C++ and assembly language for a variety of CPUs. He is also well-versed in a wide variety of technologies including web development, document imaging, GIS, graphics, game development, and hardware interfacing. Brian has a strong background in developing applications for the health-care industry, as well as developing solutions for portable devices, such as tablet PCs and PDAs. Additionally, Brian has co-authored the book &amp;quot;&lt;a href="http://www.amazon.com/exec/obidos/ASIN/0596520743/brianpcom-20"&gt;Coding4Fun: 10 .NET Programming Projects for Wiimote, YouTube, World of Warcraft, and More&lt;/a&gt;&amp;quot; published &lt;a href="http://www.oreilly.com/"&gt;O'Reilly&lt;/a&gt;. He previously co-authored the book &amp;quot;&lt;a href="http://www.amazon.com/dp/0735711410/"&gt;Debugging ASP.NET&lt;/a&gt;&amp;quot; published by New Riders.&amp;#160; Brian is also an author for MSDN's &lt;a href="http://blogs.msdn.com/coding4fun/"&gt;Coding4Fun&lt;/a&gt; website.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9525376" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/utility/default.aspx">utility</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/productivity/default.aspx">productivity</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/web/default.aspx">web</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/april+fools+day/default.aspx">april fools day</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/holiday/default.aspx">holiday</category></item><item><title>WiiEarthVR – A Fully Immersive 3D Experience with Virtual Earth 3D</title><link>http://blogs.msdn.com/coding4fun/archive/2008/11/14/9068804.aspx</link><pubDate>Fri, 14 Nov 2008 11:57:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9068804</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9068804.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9068804</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9068804</wfw:comment><description>&lt;table border="0" cellspacing="0" cellpadding="1" width="100%"&gt;&lt;tbody&gt;     &lt;tr class="entry_overview"&gt;       &lt;td width="50"&gt;&lt;a href="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/globe4.png"&gt;&lt;img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="globe4" border="0" alt="globe4" src="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/globe4_thumb.png" width="54" height="53" mce_src="http://www.coding4fun.net/images/WiiEarthWiimoteInterfaceforVirtualEarth_4B93/globe.png" /&gt;&lt;/a&gt; &lt;/td&gt;        &lt;td&gt;&lt;span class="entry_description"&gt;In this article, Brian Peek will demonstrate how to use a Nintendo Wii Remote (Wiimote), a Wii Fit Balance Board, and Vuzix VR920 glasses as input devices for Microsoft Virtual Earth 3D, providing a fully immersive, 3D experience.&lt;/span&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td colspan="2"&gt;         &lt;div class="entry_author"&gt;&lt;a href="http://www.brianpeek.com/" target="_blank" mce_href="http://www.brianpeek.com/"&gt;Brian Peek&lt;/a&gt;&lt;/div&gt;          &lt;div class="entry_company"&gt;&lt;a href="http://www.aspsoft.com/" mce_href="http://www.aspsoft.com/"&gt;ASPSOFT, Inc.&lt;/a&gt;&lt;/div&gt;          &lt;br /&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Difficulty: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Intermediate&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Time Required:&lt;/b&gt; 2&lt;span class="entry_details_input"&gt;-3 hours&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Cost: &lt;/b&gt;&lt;span class="entry_details_input"&gt;$60 for Wiimote and Nunchuk, $90 for Wii Fit (which includes Balance Board), $400 for &lt;a href="http://www.vr920.com/" target="_blank"&gt;Vuzix VR920 glasses&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Software: &lt;/b&gt;&lt;a href="http://www.codeplex.com/WiimoteLib" target="_blank"&gt;Managed Library for Nintendo's Wiimote&lt;/a&gt;, &lt;span class="entry_details_input"&gt;&lt;a href="http://msdn.com/express/" mce_href="http://msdn.com/express/"&gt;Visual Basic or Visual C# Express Editions&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Hardware: &lt;/b&gt;&lt;a href="http://www.nintendo.com/wii/what/accessories"&gt;Nintendo Wii Remote (Wiimote) with Nunchuk&lt;/a&gt;, &lt;a href="http://www.nintendo.com/games/detail/hoiNtus4JvIcPtP8LQPyud4Kyy393oep" target="_blank"&gt;Wii Fit Balance Board&lt;/a&gt;, &lt;a href="http://www.vr920.com/iwear/products_vr920.html" target="_blank"&gt;Vuzix VR920 glasses&lt;/a&gt;, a compatible PC Bluetooth adapter and stack&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Download: &lt;/b&gt;&lt;a href="http://www.brianpeek.com/files/folders/source_code/entry3066.aspx" target="_blank"&gt;Download&lt;/a&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;strong&gt;Discussion Forum: &lt;/strong&gt;&lt;a href="http://www.brianpeek.com/forums/43.aspx" target="_blank"&gt;Forum&lt;/a&gt;&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Introduction&lt;/h3&gt;  &lt;p&gt;Virtual Earth is the 3D interface to &lt;a href="http://maps.live.com" target="_blank"&gt;Microsoft's Live Maps&lt;/a&gt; service.&amp;#160; Normally this control is loaded via the web browser and allows interaction with a keyboard, mouse, and Xbox 360 controller.&amp;#160; In this article, we will take the Virtual Earth 3D control out of the web browser, use it in a WinForms application, and control it with a Nintendo Wii Remote (Wiimote) and a pair of Vuzix VR920 glasses, while also providing a stereoscopic 3D image to the glasses, creating the illusion of a fully three dimensional environment.&amp;#160; Note that use of the Virtual Earth 3D control in this way is undocumented and unsupported at the moment.&amp;#160; Because of this, some of the descriptions in this article are educated guesses and may not be 100% accurate…&lt;/p&gt;  &lt;p&gt;Originally, this project started as a simple Wiimote interface to Virtual Earth 3D as shown in the video below.&amp;#160; Since I wrote that application, I learned of the VR920 glasses and the Wii Fit Balance Board was released, so I’ve decided to create a more immersive experience using all of these controls which was demonstrated at &lt;a href="http://www.microsoftpdc.com/" target="_blank"&gt;PDC2008&lt;/a&gt;, shown here:&lt;/p&gt; &lt;object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="320" height="240"&gt; &lt;param name="source" value="http://channel9.msdn.com/App_Themes/default/VideoPlayer.xap" /&gt; &lt;param name="initParams" value="m=mms://mschnlnine.wmod.llnwd.net/a1809/d1/ch9/3/1/2/1/4/4/WiiEarthVR_s_ch9.wmv,autostart=false,autohide=true,showembed=true, thumbnail=http://mschnlnine.vo.llnwd.net/d1/ch9/3/1/2/1/4/4/WiiEarthVR_large_ch9.jpg" /&gt; &lt;param name="background" value="#00FFFFFF" /&gt; &lt;a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"&gt; &lt;img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /&gt; &lt;/a&gt; &lt;/object&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Setup&lt;/h3&gt;  &lt;p&gt;Before we get started, you will need to install the Virtual Earth 3D control.&amp;#160; If you haven't done this already, browse to &lt;a href="http://maps.live.com/" mce_href="http://maps.live.com/"&gt;http://maps.live.com/&lt;/a&gt; and click on the &lt;b&gt;3D&lt;/b&gt; link to install the control and supporting software.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/captured_Image.png.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="captured_Image.png" border="0" alt="captured_Image.png" src="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/captured_Image.png_thumb.png" width="459" height="107" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Additionally, if you haven't already, please review my &lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" target="_blank" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;Managed Library for Nintendo's Wiimote&lt;/a&gt; article on this site.&amp;#160; We will be using the library in this article, but I will not repeat the basic information that is located in the original article.&amp;#160; You will also need to have the &lt;a href="http://www.vr920.com/" target="_blank"&gt;Vuzix VR920&lt;/a&gt; glasses installed and setup according to its own user manual.&amp;#160; That will also not be covered here.&lt;/p&gt;  &lt;h3&gt;Implementation&lt;/h3&gt;  &lt;h4&gt;The Virtual Earth 3D Control&lt;/h4&gt;  &lt;p&gt;The Virtual Earth 3D (VE3D) control is intended to be used through a well documented JavaScript interface from a web page, however we would not be able to access the Wiimote or VR920 glasses from JavaScript.&amp;#160; Therefore, we will be using the VE3D control through its native, but wholly undocumented interface.&lt;/p&gt;  &lt;p&gt;Start by creating a new Windows Forms application named &lt;strong&gt;WiiEarthVR&lt;/strong&gt; in C# or VB.&amp;#160; As with all controls and 3rd party libraries, a reference needs to be set to the Virtual Earth 3D libraries.&amp;#160; Add references to the following items:&amp;#160; &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Microsoft.MapPoint.Data &lt;/li&gt;    &lt;li&gt;Microsoft.MapPoint.Data.VirtualEarthTileDataSource &lt;/li&gt;    &lt;li&gt;Microsoft.MapPoint.Geometry &lt;/li&gt;    &lt;li&gt;Microsoft.MapPoint.Rendering3D &lt;/li&gt;    &lt;li&gt;Microsoft.MapPoint.Rendering3D.Utility &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If they do not show up in the .NET references, they can be found by selecting the Browse tab and navigating to C:\Program Files\Virtual Earth 3D\ or C:\Program Files (x86)\Virtual Earth 3D\ .&amp;#160; With the references in place, the project file can now be opened and the references will be seen in the References folder in the Solution Explorer as usual.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/captured_Image.png11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="captured_Image.png[11]" border="0" alt="captured_Image.png[11]" src="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/captured_Image.png11_thumb.png" width="376" height="229" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Creating an instance of the control can be done in code just like any other control.&amp;#160; Used in the constructor or load event of the form, the following code will create a VE3D control and add it to the form as fully docked:&lt;/p&gt;  &lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; GlobeControl _globeControl;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; MainForm()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    InitializeComponent();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; GlobeControl();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    SuspendLayout();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Location = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; System.Drawing.Point(0, 0);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Name = &lt;span style="color: #006080"&gt;&amp;quot;_globeControl&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Size = ClientSize;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.TabIndex = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.SendToBack(); &lt;span style="color: #008000"&gt;// we want the button to be on top&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    pnlGlobe.Controls.Add(_globeControl);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    ResumeLayout(&lt;span style="color: #0000ff"&gt;false&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _globeControl &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; GlobeControl&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt;()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    InitializeComponent()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; GlobeControl()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    SuspendLayout()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Location = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; System.Drawing.Point(0, 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Name = &lt;span style="color: #006080"&gt;&amp;quot;_globeControl&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Size = ClientSize&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Anchor = AnchorStyles.Left &lt;span style="color: #0000ff"&gt;Or&lt;/span&gt; AnchorStyles.Right &lt;span style="color: #0000ff"&gt;Or&lt;/span&gt; AnchorStyles.Top &lt;span style="color: #0000ff"&gt;Or&lt;/span&gt; AnchorStyles.Bottom&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.TabIndex = 0&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.SendToBack() &lt;span style="color: #008000"&gt;' we want the button to be on top&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    pnlGlobe.Controls.Add(_globeControl)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    ResumeLayout(&lt;span style="color: #0000ff"&gt;False&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This sets up the VE3D control in its default state.&amp;#160; If you were to run an application with only this code, you would see nothing but the earth.&amp;#160; The navigation controls and other extras would be missing.&lt;/p&gt;

&lt;p&gt;We can start adding items to the VE3D control by listening for the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event of the &lt;strong&gt;GlobeControl&lt;/strong&gt; and then setting the appropriate properties.&amp;#160; Setting these properties prior to this point can lead to some unexpected results.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event handler, if you wish to add the default navigation controls to the screen, the &lt;b&gt;PlugInLoader&lt;/b&gt; object is used.&amp;#160; The &lt;b&gt;PlugInLoader&lt;/b&gt; is created by using the &lt;b&gt;CreateLoader&lt;/b&gt; static method, passing in an instance of the &lt;b&gt;GlobeControl&lt;/b&gt;'s &lt;b&gt;Host&lt;/b&gt; object.&amp;#160; Then, the &lt;b&gt;NavigationPlugIn&lt;/b&gt; can be loaded and activated as shown:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// load all the spiffy UI navigation goodies&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;PlugInLoader loader = PlugInLoader.CreateLoader(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.globeControl.Host);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;loader.LoadPlugIn(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(NavigationPlugIn));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;loader.ActivatePlugIn(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(NavigationPlugIn).GUID, &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' load all the spiffy UI navigation goodies&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; loader &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; PlugInLoader = PlugInLoader.CreateLoader(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.globeControl.Host)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;loader.LoadPlugIn(&lt;span style="color: #0000ff"&gt;GetType&lt;/span&gt;(NavigationPlugIn))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;loader.ActivatePlugIn(&lt;span style="color: #0000ff"&gt;GetType&lt;/span&gt;(NavigationPlugIn).GUID, &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The last thing to be added for basic functionality is the data.&amp;#160; As it stands, the only data that will appear on the globe is the image of the continents.&amp;#160; Zooming in only produces a blurry representation of that base image.&lt;/p&gt;

&lt;p&gt;Data layers are created from specially formatted data sources provided by maps.live.com known as content manifests.&amp;#160; These are XML files which tell the VE3D control how to load the data required for any view.&amp;#160; Content layers can be added by adding them to the &lt;strong&gt;DataSources&lt;/strong&gt; object of the &lt;strong&gt;GlobeControl&lt;/strong&gt;.&amp;#160; We can add any of the following layers (note that there may be other content manifests provided by maps.live.com, but these are the only 5 that I am aware of):&lt;/p&gt;

&lt;table border="1" cellspacing="0" cellpadding="2" width="516"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;
        &lt;p align="center"&gt;&lt;b&gt;URL&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="163"&gt;
        &lt;p align="center"&gt;&lt;b&gt;DataSourceUsage Type&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="107"&gt;
        &lt;p align="center"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;&lt;a title="http://local.live.com/Manifests/HighDemContentManifest.xml" href="http://local.live.com/Manifests/HD.xml" mce_href="http://local.live.com/Manifests/HD.xml"&gt;http://local.live.com/Manifests/HD.xml&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="163"&gt;ElevationMap&lt;/td&gt;

      &lt;td valign="top" width="107"&gt;Terrain data&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;&lt;a title="http://local.live.com/Manifests/ModelContentManifest.xml" href="http://local.live.com/Manifests/MO.xml" mce_href="http://local.live.com/Manifests/MO.xml"&gt;http://local.live.com/Manifests/MO.xml&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="163"&gt;Model&lt;/td&gt;

      &lt;td valign="top" width="107"&gt;3D buildings&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;&lt;a title="http://local.live.com/Manifests/AerialContentManifest.xml" href="http://local.live.com/Manifests/AT.xml" mce_href="http://local.live.com/Manifests/AT.xml"&gt;http://local.live.com/Manifests/AT.xml&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="163"&gt;TextureMap&lt;/td&gt;

      &lt;td valign="top" width="107"&gt;Unlabeled aerial&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;&lt;a title="http://local.live.com/Manifests/HybridContentManifest.xml" href="http://local.live.com/Manifests/HT.xml" mce_href="http://local.live.com/Manifests/HT.xml"&gt;http://local.live.com/Manifests/HT.xml&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="163"&gt;TextureMap&lt;/td&gt;

      &lt;td valign="top" width="107"&gt;Labeled aerial&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;&lt;a title="http://local.live.com/Manifests/RoadContentManifest.xml" href="http://local.live.com/Manifests/RT.xml" mce_href="http://local.live.com/Manifests/RT.xml"&gt;http://local.live.com/Manifests/RT.xml&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="163"&gt;TextureMap&lt;/td&gt;

      &lt;td valign="top" width="107"&gt;Roads only&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;For the best display, add the &lt;b&gt;ElevationMap&lt;/b&gt;, &lt;b&gt;Model&lt;/b&gt; and &lt;b&gt;Aerial&lt;/b&gt; &lt;b&gt;TextureMap&lt;/b&gt; layers as shown:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 81px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// set various data sources, here for elevation data, terrain data, and model data.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Elevation&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Elevation&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;@&amp;quot;http://maps.live.com//Manifests/HD.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.ElevationMap));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Texture&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Texture&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;@&amp;quot;http://maps.live.com//Manifests/AT.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.TextureMap));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Models&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Models&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;@&amp;quot;http://maps.live.com//Manifests/MO.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.Model));&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 83px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' set various data sources, here for elevation data, terrain data, and model data.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Elevation&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Elevation&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;http://maps.live.com//Manifests/HD.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.ElevationMap))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Texture&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Texture&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;http://maps.live.com//Manifests/AT.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.TextureMap))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Models&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Models&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;http://maps.live.com//Manifests/MO.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.Model))&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;By passing the URL of the content manifest, a name for the layer, and what the manifest represents, a new &lt;b&gt;DataSource&lt;/b&gt; is created, which is in turn used to create a &lt;b&gt;DataSourceLayerData&lt;/b&gt; object which is then given to the VE3D control to consume.&amp;#160; This should be done in the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event handler as well.&lt;/p&gt;

&lt;p&gt;We also need to setup VE3D to turn off any UI elements, turn on the atmosphere effects, and ensure we have a full unobstructed view. Again, in the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event handler, we can use the following code to achieve this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 236px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// turn on the nice atmosphere&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.AtmosphereDisplay = Microsoft.MapPoint.Rendering3D.Atmospherics.EnvironmentManager.AtmosphereStyle.Scattering;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// default to all off&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Display3DCursor = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.SetWindowsCursor(&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowNavigationControl = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowCursorLocationInformation = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowScale = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowUI = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.SunPosition = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.LocalWeatherEnabled = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.BaseCopyrightText = &lt;span style="color: #006080"&gt;&amp;quot; &amp;quot;&lt;/span&gt;; // workaround &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; a display issue&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 249px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' turn on the nice atmosphere&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.AtmosphereDisplay = Microsoft.MapPoint.Rendering3D.Atmospherics.EnvironmentManager.AtmosphereStyle.Scattering&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' default to all off&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Display3DCursor = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.SetWindowsCursor(&lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowNavigationControl = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowCursorLocationInformation = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowScale = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowUI = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.SunPosition = &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.LocalWeatherEnabled = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.BaseCopyrightText = &lt;span style="color: #006080"&gt;&amp;quot; &amp;quot;&lt;/span&gt; ' workaround &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; a display issue&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If you were to run the application at this point, you would see a fully functioning Virtual Earth 3D control with proper data and navigation.&lt;/p&gt;

&lt;h4&gt;Control Scheme and Bindings&lt;/h4&gt;

&lt;p&gt;The user will control VE3D with the Wiimote by holding the nunchuk in the left hand, which will move the user forward/back/left/right using the joystick.&amp;#160; The C and Z buttons on the front of the nunchuk will be used to raise and lower the altitude of the camera.&amp;#160; The Wiimote, held in the right hand, will be used to toggle various things on or off and interact with menus.&amp;#160; The user will also stand on the Balance Board which will use their center of gravity to turn them in the environment.&lt;/p&gt;

&lt;p&gt;VE3D bindings allow you to change or create new control schemes for VE3D by placing an XML file in a specific directory as follows:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Vista:&lt;/strong&gt; C:\Users\&amp;lt;username&amp;gt;\AppData\LocalLow\Microsoft\Virtual Earth 3D &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;XP:&lt;/strong&gt; C:\Documents and Settings\&amp;lt;username&amp;gt;\Local Settings\Microsoft\Virtual Earth 3D &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this directory you will find a &lt;b&gt;Bindings.xml &lt;/b&gt;file.&amp;#160; This XML schema defines the default keyboard, mouse, Gamepad and other input device properties.&amp;#160; Open the file to see the schema used to define events and parameters.&lt;/p&gt;

&lt;p&gt;By default, VE3D will load any file named Bindings*.xml from this directory.&amp;#160; For the Wiimote control scheme, create a new file named &lt;b&gt;BindingsWiiEarthVR.xml&lt;/b&gt; in this directory.&amp;#160; Set the contents of the file to the following:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #800000"&gt;xml&lt;/span&gt; &lt;span style="color: #ff0000"&gt;version&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bindings&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;BindingSet&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;WiiEarthVRBindings&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;AutoUse&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Cursor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Drag&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- Nunchuk joystick --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.NunchukX&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.5&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Strafe&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.NunchukY&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Move&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- Nunchuk buttons --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.NunchukC&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.20&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Ascend&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.NunchukZ&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-0.20&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Ascend&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- Balance Board --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.BalanceBoardX&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-0.0009&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Turn&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.BalanceBoardY&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.0009&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Ascend&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- Wiimote buttons --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Home&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ResetOnCenter&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.A&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Locations, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Left&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Locations, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Up&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;LocationsMove, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Down&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;LocationsMove, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- FPS-style keyboard controls in case we don't have a nunchuk --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.W&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;22&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Move&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.S&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-22&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Move&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.D&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;22&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Strafe&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.A&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-22&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Strafe&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.Space&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;20&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Ascend&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.C&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-20&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Ascend&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- Other keys --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.F1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;VR920SetZero, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.F2&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;BalanceBoardSetZero, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.F3&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleVR920Stereo, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Minus&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-0.1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;VR920SetEyeDistance, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Plus&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;VR920SetEyeDistance, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.One&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleBalanceBoard, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Two&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleVR920, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.B&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleBalanceBoard, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.V&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleVR920, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.F&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;FullScreen, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;BindingSet&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bindings&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The &lt;b&gt;&amp;lt;BindingSet&amp;gt;&lt;/b&gt; tags wrap groups of control bindings.&amp;#160; It requires a &lt;b&gt;Name&lt;/b&gt; and optionally a &lt;b&gt;Cursor&lt;/b&gt;.&amp;#160; If the binding set is to be used automatically, as it would be in most cases, set the &lt;b&gt;AutoUse&lt;/b&gt; parameter to &lt;b&gt;True&lt;/b&gt;.&amp;#160; Inside of that are &lt;b&gt;&amp;lt;Bind&amp;gt;&lt;/b&gt; tags.&amp;#160; The tag requires the &lt;strong&gt;Event &lt;/strong&gt;parameter and optionally the &lt;b&gt;Factor&lt;/b&gt; parameter.&amp;#160; The &lt;b&gt;Event &lt;/b&gt;parameter will be used to match the binding to its handler which will be written later.&amp;#160; The syntax is &amp;lt;Handler Name&amp;gt;.&amp;lt;Event Name&amp;gt;.&amp;#160; The &lt;b&gt;Factor&lt;/b&gt; parameter is optional and can be used to scale the data value up or down to increase or decrease sensitivity of the input method.&amp;#160; The &lt;b&gt;Action&lt;/b&gt; tag inside the &lt;strong&gt;Bind&lt;/strong&gt; tag is used to map the specific binding to a particular method.&amp;#160; Once the handler is written, these will make more sense.&lt;/p&gt;

&lt;p&gt;The bindings above create the control scheme described above:&amp;#160; NunchukX/Y describe what happens when the analog joystick is moved, NunchukC/Z describe what happens with the C/Z buttons are pressed, and so on.&lt;/p&gt;

&lt;p&gt;The bindings also allow for several variations.&amp;#160; Bindings are defined for both the IR position (&lt;b&gt;IRX&lt;/b&gt;, &lt;b&gt;IRY&lt;/b&gt;) and accelerometer values (&lt;b&gt;AX&lt;/b&gt;, &lt;b&gt;AY&lt;/b&gt;).&amp;#160; If an IR sensor bar is not available, the accelerometer values of the Wiimote can be used instead.&amp;#160; Additionally, keyboard bindings are created in the style of a first person shooter using WASD.&amp;#160; These can be used if a Nunchuk is not available.&lt;/p&gt;

&lt;p&gt;Note that some bindings append two &lt;b&gt;Event&lt;/b&gt;s together with a + sign.&amp;#160; This allows for button combinations.&amp;#160; In this case, for the accelerometer and/or IR sensor, we only want to register the action if a button is pressed down.&amp;#160; So, those events which require the button to be held down contain &lt;b&gt;Wiimote.B+&lt;/b&gt; and the event it is combined with.&lt;/p&gt;

&lt;p&gt;For those events which require a custom action that will be written separately and not part of the VE3D control, the &lt;b&gt;Action&lt;/b&gt; parameter must contain the action name, followed by a comma, and then the full assembly name:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 83px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.One&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleBalanceBoard, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;br /&gt;You can change any of these button bindings simply by changing this XML file and deploying to the directory above.&lt;/div&gt;

&lt;h4&gt;Event Source&lt;/h4&gt;

&lt;p&gt;An &lt;b&gt;EventSource&lt;/b&gt; is needed which will grab data from the Wiimote and pass it along to VE3D as defined by the bindings file above.&amp;#160; Create a new class named &lt;b&gt;WiimoteEventSource&lt;/b&gt; which derives from &lt;b&gt;Microsoft.MapPoint.Binding.EventSource&lt;/b&gt;&amp;#160; as follows:&lt;/p&gt;

&lt;p&gt;Next, add an enumeration named &lt;b&gt;WiimoteEvent&lt;/b&gt; (the name isn't important) which contains all of the &lt;b&gt;Name&lt;/b&gt; items from the bindings XML file above.&amp;#160; It should look like this:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// all events handled by this event source from XML file&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;enum&lt;/span&gt; WiimoteEvent&lt;br /&gt;{&lt;br /&gt;    IRX,        &lt;span style="color: #008000"&gt;// IR X position&lt;/span&gt;&lt;br /&gt;    IRY,        &lt;span style="color: #008000"&gt;// IR Y position&lt;/span&gt;&lt;br /&gt;    NunchukX,    &lt;span style="color: #008000"&gt;// Nunchuk joystick X position&lt;/span&gt;&lt;br /&gt;    NunchukY,    &lt;span style="color: #008000"&gt;// Nunchuk joystick Y position&lt;/span&gt;&lt;br /&gt;    NunchukC,    &lt;span style="color: #008000"&gt;// Nunchuk C button&lt;/span&gt;&lt;br /&gt;    NunchukZ,    &lt;span style="color: #008000"&gt;// Nunchuk Z button&lt;/span&gt;&lt;br /&gt;    AX,            &lt;span style="color: #008000"&gt;// Wiimote accelerometer X&lt;/span&gt;&lt;br /&gt;    AY,            &lt;span style="color: #008000"&gt;// Wiimote accelerometer Y&lt;/span&gt;&lt;br /&gt;    Up,            &lt;span style="color: #008000"&gt;// Dpad up&lt;/span&gt;&lt;br /&gt;    Down,        &lt;span style="color: #008000"&gt;// Dpad down&lt;/span&gt;&lt;br /&gt;    Left,        &lt;span style="color: #008000"&gt;// Dpad left&lt;/span&gt;&lt;br /&gt;    Right,        &lt;span style="color: #008000"&gt;// Dpad right&lt;/span&gt;&lt;br /&gt;    A,            &lt;span style="color: #008000"&gt;// A button&lt;/span&gt;&lt;br /&gt;    B,            &lt;span style="color: #008000"&gt;// B button&lt;/span&gt;&lt;br /&gt;    Minus,        &lt;span style="color: #008000"&gt;// Minus button&lt;/span&gt;&lt;br /&gt;    Home,        &lt;span style="color: #008000"&gt;// Wiimote Home button&lt;/span&gt;&lt;br /&gt;    Plus,        &lt;span style="color: #008000"&gt;// Plus button&lt;/span&gt;&lt;br /&gt;    One,        &lt;span style="color: #008000"&gt;// Wiimote One button&lt;/span&gt;&lt;br /&gt;    Two,        &lt;span style="color: #008000"&gt;// Wiimote Two button&lt;/span&gt;&lt;br /&gt;    BalanceBoardX,    &lt;span style="color: #008000"&gt;// Balance Board COG X&lt;/span&gt;&lt;br /&gt;    BalanceBoardY    &lt;span style="color: #008000"&gt;// Balance Board COG Y&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;' all events handled by this event source from XML file&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Enum&lt;/span&gt; WiimoteEvent&lt;br /&gt;    IRX &lt;span style="color: #008000"&gt;' IR X position&lt;/span&gt;&lt;br /&gt;    IRY &lt;span style="color: #008000"&gt;' IR Y position&lt;/span&gt;&lt;br /&gt;    NunchukX &lt;span style="color: #008000"&gt;' Nunchuk joystick X position&lt;/span&gt;&lt;br /&gt;    NunchukY &lt;span style="color: #008000"&gt;' Nunchuk joystick Y position&lt;/span&gt;&lt;br /&gt;    NunchukC &lt;span style="color: #008000"&gt;' Nunchuk C button&lt;/span&gt;&lt;br /&gt;    NunchukZ &lt;span style="color: #008000"&gt;' Nunchuk Z button&lt;/span&gt;&lt;br /&gt;    AX &lt;span style="color: #008000"&gt;' Wiimote accelerometer X&lt;/span&gt;&lt;br /&gt;    AY &lt;span style="color: #008000"&gt;' Wiimote accelerometer Y&lt;/span&gt;&lt;br /&gt;    Up &lt;span style="color: #008000"&gt;' Dpad up&lt;/span&gt;&lt;br /&gt;    Down &lt;span style="color: #008000"&gt;' Dpad down&lt;/span&gt;&lt;br /&gt;    Left &lt;span style="color: #008000"&gt;' Dpad left&lt;/span&gt;&lt;br /&gt;    Right &lt;span style="color: #008000"&gt;' Dpad right&lt;/span&gt;&lt;br /&gt;    A &lt;span style="color: #008000"&gt;' A button&lt;/span&gt;&lt;br /&gt;    B &lt;span style="color: #008000"&gt;' B button&lt;/span&gt;&lt;br /&gt;    Minus &lt;span style="color: #008000"&gt;' Minus button&lt;/span&gt;&lt;br /&gt;    Home &lt;span style="color: #008000"&gt;' Wiimote Home button&lt;/span&gt;&lt;br /&gt;    Plus &lt;span style="color: #008000"&gt;' Plus button&lt;/span&gt;&lt;br /&gt;    One &lt;span style="color: #008000"&gt;' Wiimote One button&lt;/span&gt;&lt;br /&gt;    Two &lt;span style="color: #008000"&gt;' Wiimote Two button&lt;/span&gt;&lt;br /&gt;    BalanceBoardX &lt;span style="color: #008000"&gt;' Balance Board COG X&lt;/span&gt;&lt;br /&gt;    BalanceBoardY &lt;span style="color: #008000"&gt;' Balance Board COG Y&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Enum&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Next, several methods from the &lt;b&gt;EventSource&lt;/b&gt; object need to be overridden:&amp;#160; &lt;b&gt;GetEventData&lt;/b&gt;, &lt;b&gt;IsModifier&lt;/b&gt;, &lt;b&gt;CanModify&lt;/b&gt;, &lt;b&gt;TryGetEventId&lt;/b&gt;, &lt;b&gt;TryGetEventName&lt;/b&gt;, &lt;b&gt;Name&lt;/b&gt;.&amp;#160; The methods do the following:&lt;/p&gt;

&lt;table border="1" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;
        &lt;p align="center"&gt;&lt;b&gt;Method/Property&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="200"&gt;
        &lt;p align="center"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;GetEventData&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Unsure at the moment...does not need to be implemented?&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;IsModifier&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Returns a boolean stating whether the passed in event ID is a modifier (such as the Wiimote.B event above)&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;CanModify&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Returns a boolean stating whether the current event is allowed as a modifier&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;TryGetEventID&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Maps a string event name from the bindings file to the integer value in the enumeration above&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;TryGetEventName&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Maps an integer event ID to the string name in the enumeration above&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;Name (property)&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Returns the name of the handler which must match the name in the XML file above (Wiimote in this case)&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;The code for these methods is presented below:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// return out value of the passed enum&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; TryGetEventId(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; eventName, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; eventId)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    eventId = (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)Enum.Parse(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(WiimoteEvent), eventName);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// return out the string name of the passed in enum value&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; TryGetEventName(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; eventId, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; eventName)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    eventName = ((WiimoteEvent)eventId).ToString();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// unknown&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; EventData GetEventData(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; eventId, EventActivateState state)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// can the event be used as a modifier?&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; IsModifier(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; eventId)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// yes to all for now&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// can the supplied event be used as a modifier?&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; CanModify(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; eventId, EventKey other)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// only if it's from us&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (other.Source == &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// this must match the Source name in the bindings XML file&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Name&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    get { &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #006080"&gt;&amp;quot;Wiimote&amp;quot;&lt;/span&gt;; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' return out value of the passed enum&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; TryGetEventId(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventName &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;, &amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: #0000ff"&gt;ByRef&lt;/span&gt; eventId &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    eventId = &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(System.&lt;span style="color: #0000ff"&gt;Enum&lt;/span&gt;.Parse(&lt;span style="color: #0000ff"&gt;GetType&lt;/span&gt;(WiimoteEvent), eventName)))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' return out the string name of the passed in enum value&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; TryGetEventName(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;, &amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: #0000ff"&gt;ByRef&lt;/span&gt; eventName &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    eventName = (&lt;span style="color: #0000ff"&gt;CType&lt;/span&gt;(eventId, WiimoteEvent)).ToString()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' unknown&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; GetEventData(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; state &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EventActivateState) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EventData&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; NotImplementedException()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' can the event be used as a modifier?&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; IsModifier(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;' yes to all for now&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' can the supplied event be used as a modifier?&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; CanModify(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; other &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EventKey) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;' only if it's from us&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; (other.Source &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' this must match the Source name in the bindings XML file&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Property&lt;/span&gt; Name() &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Get&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #006080"&gt;&amp;quot;Wiimote&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Get&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Property&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;With that in place, the constructor can be implemented which will call the base constructor and connect to the Wiimote.&amp;#160; It is assumed you read the Wiimote article above and know how the library works.&lt;/p&gt;

&lt;p&gt;The constructor must take one argument passed from the main from:&amp;#160; an instance of the &lt;b&gt;GlobeControl&lt;/b&gt;'s &lt;b&gt;ActionSystem&lt;/b&gt;.&amp;#160; This just gets passed directly to the parent object's constructor untouched.&amp;#160; The constructor code looks like the following:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; WiimoteEventSource(ActionSystem actionSystem) : &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;(actionSystem)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #008000"&gt;// get all connected Wiimotes&lt;/span&gt;&lt;br /&gt;    WiimoteCollection wc = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; WiimoteCollection();&lt;br /&gt;    wc.FindAllWiimotes();&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// setup wiimotes and event handlers&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt;(Wiimote wm &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; wc)&lt;br /&gt;    {&lt;br /&gt;        wm.WiimoteChanged += &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventHandler&amp;lt;WiimoteChangedEventArgs&amp;gt;(OnWiimoteChanged);&lt;br /&gt;        wm.WiimoteExtensionChanged += &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventHandler&amp;lt;WiimoteExtensionChangedEventArgs&amp;gt;(OnWiimoteExtensionChanged);&lt;br /&gt;        wm.Connect();&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;// if we don't have an extension, set the report type to IR and accel's only&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(!wm.WiimoteState.Extension &amp;amp;&amp;amp; wm.WiimoteState.ExtensionType != ExtensionType.BalanceBoard)&lt;br /&gt;            wm.SetReportType(InputReport.IRAccel, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(wm.WiimoteState.ExtensionType == ExtensionType.BalanceBoard)&lt;br /&gt;            _bb = wm;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;br /&gt;            _wm = wm;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;// turn off all LEDs&lt;/span&gt;&lt;br /&gt;        wm.SetLEDs(0x00);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; actionSystem &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; ActionSystem)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;MyBase&lt;/span&gt;.&lt;span style="color: #0000ff"&gt;New&lt;/span&gt;(actionSystem)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;' get all connected Wiimotes&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; wc &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; WiimoteCollection()&lt;br /&gt;    wc.FindAllWiimotes()&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;' setup wiimotes and event handlers&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;For&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Each&lt;/span&gt; wm &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Wiimote &lt;span style="color: #0000ff"&gt;In&lt;/span&gt; wc&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;AddHandler&lt;/span&gt; wm.WiimoteChanged, &lt;span style="color: #0000ff"&gt;AddressOf&lt;/span&gt; OnWiimoteChanged&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;AddHandler&lt;/span&gt; wm.WiimoteExtensionChanged, &lt;span style="color: #0000ff"&gt;AddressOf&lt;/span&gt; OnWiimoteExtensionChanged&lt;br /&gt;        wm.Connect()&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;' if we don't have an extension, set the report type to IR and accel's only&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; wm.WiimoteState.Extension) &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; wm.WiimoteState.ExtensionType &amp;lt;&amp;gt; ExtensionType.BalanceBoard &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;            wm.SetReportType(InputReport.IRAccel, &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; wm.WiimoteState.ExtensionType = ExtensionType.BalanceBoard &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;            _bb = wm&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;br /&gt;            _wm = wm&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;' turn off all LEDs&lt;/span&gt;&lt;br /&gt;        wm.SetLEDs(&amp;amp;H00)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Next&lt;/span&gt; wm&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The &lt;b&gt;OnWiimoteExtensionChanged&lt;/b&gt; method simply sets the report mode for the Wiimote based on whether or not a Nunchuk is inserted as shown:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; OnWiimoteExtensionChanged(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, WiimoteExtensionChangedEventArgs args)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(_wm == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// if nunchuk inserted, set the report type to return extension data&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(args.ExtensionType == ExtensionType.Nunchuk &amp;amp;&amp;amp; args.Inserted)&lt;br /&gt;        _wm.SetReportType(InputReport.IRExtensionAccel, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #008000"&gt;// in all other cases, set it to the default IR and accel's&lt;/span&gt;&lt;br /&gt;        _wm.SetReportType(InputReport.IRAccel, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; OnWiimoteExtensionChanged(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; args &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; WiimoteExtensionChangedEventArgs)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; _wm &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;' if nunchuk inserted, set the report type to return extension data&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; args.ExtensionType = ExtensionType.Nunchuk &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; args.Inserted &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;        _wm.SetReportType(InputReport.IRExtensionAccel, &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt; &lt;span style="color: #008000"&gt;' in all other cases, set it to the default IR and accel's&lt;/span&gt;&lt;br /&gt;        _wm.SetReportType(InputReport.IRAccel, &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The &lt;b&gt;OnWiimoteChanged&lt;/b&gt; event handler is where the Wiimote data is handled and sent off to the VE3D control to reflect the changes.&amp;#160; First, we handle the Balance Board.&amp;#160; If the Balance Board is the controller reporting data, we take the center of gravity values and pass them to VE3D.&amp;#160; This code looks at the appropriate values, determines if they are beyond the specified thresholds for the dead zones, and, if they are, activates the event for that value using the &lt;b&gt;Execute &lt;/b&gt;method.&amp;#160; &lt;b&gt;Execute &lt;/b&gt;is a method in the base &lt;b&gt;EventSource&lt;/b&gt; class.&amp;#160; This method will activate the event specified from the enumeration (which, remember, is contained in the bindings XML file) with the value associated with that event.&amp;#160; An &lt;b&gt;EventData&lt;/b&gt; object of some type must be created and passed to the &lt;b&gt;Execute&lt;/b&gt; method.&amp;#160; There are two &lt;b&gt;EventData&lt;/b&gt; types to know about:&amp;#160; &lt;b&gt;AxisEventData&lt;/b&gt; and &lt;b&gt;ButtonEventData&lt;/b&gt;.&amp;#160; &lt;b&gt;AxisEventData&lt;/b&gt; should be used when an event is activated that will modify the map position in some way.&amp;#160; That is, if the map is being turned, elevation is changing, etc.&amp;#160; &lt;b&gt;ButtonEventData&lt;/b&gt; should be used if the event is a simple toggle like pressing a button down and releasing it.&lt;/p&gt;

&lt;p&gt;The Balance Board code can be seen below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.ExtensionType == ExtensionType.BalanceBoard &amp;amp;&amp;amp; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.BalanceBoardEnabled)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; x1 = ws.BalanceBoardState.CenterOfGravity.X;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(x1 &amp;gt; Properties.Settings.Default.BBDeadX || x1 &amp;lt; -Properties.Settings.Default.BBDeadX)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.BalanceBoardX), x1 - _zero.X));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; y1 = ws.BalanceBoardState.CenterOfGravity.Y;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(y1 &amp;gt; Properties.Settings.Default.BBDeadY || y1 &amp;lt; -Properties.Settings.Default.BBDeadY)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.BalanceBoardY), y1 - _zero.Y));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.ExtensionType = ExtensionType.BalanceBoard &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.BalanceBoardEnabled &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; x1 &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Single&lt;/span&gt; = ws.BalanceBoardState.CenterOfGravity.X&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; x1 &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.BBDeadX &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; x1 &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.BBDeadX &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.BalanceBoardX))), x1 - _zero.X))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; y1 &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Single&lt;/span&gt; = ws.BalanceBoardState.CenterOfGravity.Y&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; y1 &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.BBDeadY &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; y1 &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.BBDeadY &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.BalanceBoardY))), y1 - _zero.Y))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; If&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Next, let's handle the IR and accelerometer data.&amp;#160; The IR midpoint of the X and Y axes will be used from the &lt;b&gt;WiimoteState&lt;/b&gt; object to activate the &lt;b&gt;IRX&lt;/b&gt; and &lt;b&gt;IRY&lt;/b&gt; events we defined above in the bindings XML file.&amp;#160; The accelerometer X and Y values will be used to activate the &lt;b&gt;AX &lt;/b&gt;and &lt;b&gt;AY&lt;/b&gt; events.&lt;/p&gt;

&lt;p&gt;This snippet assumes that there is a boolean property named &lt;b&gt;UseIR&lt;/b&gt; created in the project to determine whether IR or motion values are used.&amp;#160; Additionally, it assumes there are property settings created which contain values for the X/Y &amp;quot;dead zones&amp;quot; for the IR and accelerometers.&amp;#160; These dead zones are used as a way to only activate the event when the values are pushed beyond the thresholds.&amp;#160; This allows there to be a margin where the user's hand will not be read as movement, allowing the user to not have to worry about keeping a steady hand.&lt;/p&gt;

&lt;p&gt;The application linked above uses the following default values for dead zones:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;NunchukDeadX/Y -&amp;gt; 0.025 &lt;/li&gt;

  &lt;li&gt;WiimoteDeadX/Y -&amp;gt; 0.15 &lt;/li&gt;

  &lt;li&gt;IRDeadX/Y -&amp;gt; 0.1 &lt;/li&gt;

  &lt;li&gt;BBDeadX/Y –&amp;gt; 3 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// if we're using the IR&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(Properties.Settings.Default.UseIR)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// and both LEDs are found&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.IRState.Found1 &amp;amp;&amp;amp; ws.IRState.Found2)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// normalize the midpoints to -0.5 to 0.5 (from 0 to 1.0)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; x = ws.IRState.MidX - 0.5f;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; y = ws.IRState.MidY - 0.5f;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// if we're beyond the thresholds, activate the events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(x &amp;gt; Properties.Settings.Default.IRDeadX || x &amp;lt; -Properties.Settings.Default.IRDeadX)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.IRX), x));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(y &amp;gt; Properties.Settings.Default.IRDeadY || y &amp;lt; -Properties.Settings.Default.IRDeadY)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.IRY), y));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// save the last IR settings...these get used if we go beyond the range of the IRs.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// in that case, the last used positions will be used until the Wiimote comes back in range&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRX = x;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRY = y;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #008000"&gt;// one or both LEDs aren't seen&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// activate events based on the last known positions&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRX &amp;gt; Properties.Settings.Default.IRDeadX || &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRX &amp;lt; -Properties.Settings.Default.IRDeadX)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.IRX), &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRX));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRY &amp;gt; Properties.Settings.Default.IRDeadY || &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRY &amp;lt; -Properties.Settings.Default.IRDeadY)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.IRY), &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRY));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #008000"&gt;// we're using motion controls&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// activate the events based on the accelerometer values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.AccelState.X &amp;gt; Properties.Settings.Default.WiimoteDeadX || ws.AccelState.X &amp;lt; -Properties.Settings.Default.WiimoteDeadX)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.AX), ws.AccelState.X));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.AccelState.Y &amp;gt; Properties.Settings.Default.WiimoteDeadY || ws.AccelState.Y &amp;lt; -Properties.Settings.Default.WiimoteDeadY)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.AY), ws.AccelState.Y));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' if we're using the IR&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;If&lt;/span&gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.UseIR &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;' and both LEDs are found&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.IRState.Found1 &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; ws.IRState.Found2 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;' normalize the midpoints to -0.5 to 0.5 (from 0 to 1.0)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; x &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Single&lt;/span&gt; = ws.IRState.MidX - 0.5f&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; y &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Single&lt;/span&gt; = ws.IRState.MidY - 0.5f&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;' if we're beyond the thresholds, activate the events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; x &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; x &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRX))), x))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; y &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; y &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRY))), y))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;' save the last IR settings...these get used if we go beyond the range of the IRs.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;' in that case, the last used positions will be used until the Wiimote comes back in range&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRX = x&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRY = y&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt; &lt;span style="color: #008000"&gt;' one or both LEDs aren't seen&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;' activate events based on the last known positions&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRX &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRX &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRX))), &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRX))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRY &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRY &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRY))), &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRY))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Else&lt;/span&gt; &lt;span style="color: #008000"&gt;' we're using motion controls&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;' activate the events based on the accelerometer values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.AccelState.X &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.WiimoteDeadX &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; ws.AccelState.X &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.WiimoteDeadX &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.AX))), ws.AccelState.X))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.AccelState.Y &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.WiimoteDeadY &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; ws.AccelState.Y &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.WiimoteDeadY &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.AY))), ws.AccelState.Y))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; If&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Next, the nunchuk values need to be read and the associated events activated.&amp;#160; This is done as follows:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// if the nunchuk is connected&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.Extension &amp;amp;&amp;amp; ws.ExtensionType == ExtensionType.Nunchuk)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// activate the nunchuk-based events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.NunchukState.X &amp;gt; Properties.Settings.Default.NunchukDeadX || ws.NunchukState.X &amp;lt; -Properties.Settings.Default.NunchukDeadX)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukX), ws.NunchukState.X));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.NunchukState.Y &amp;gt; Properties.Settings.Default.NunchukDeadY || ws.NunchukState.Y &amp;lt; -Properties.Settings.Default.NunchukDeadY)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukY), ws.NunchukState.Y));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.NunchukState.C)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukC), 1.0f));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.NunchukState.Z)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukZ), 1.0f));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' if the nunchuk is connected&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.Extension &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; ws.ExtensionType = ExtensionType.Nunchuk &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;' activate the nunchuk-based events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.NunchukState.X &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.NunchukDeadX &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; ws.NunchukState.X &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.NunchukDeadX &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukX))), ws.NunchukState.X))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.NunchukState.Y &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.NunchukDeadY &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; ws.NunchukState.Y &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.NunchukDeadY &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukY))), ws.NunchukState.Y))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.NunchukState.C &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukC))), 1.0f))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.NunchukState.Z &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukZ))), 1.0f))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; If&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Finally, the button events need to be activated.&amp;#160; A helper method which will check the current button state will be used for determining which button of all the Wiimote buttons is pressed.&amp;#160; For those that are, the appropriate event is activated with a call to &lt;b&gt;Execute&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; HandleButton(WiimoteEvent we, &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; buttonState, &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; lastButtonState)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(buttonState == lastButtonState)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(buttonState)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ButtonEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)we), EventActivateState.Activate));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ButtonEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)we), EventActivateState.Deactivate));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// handle all the Wiimote buttons&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Up, ws.ButtonState.Up, _lastBS.Up);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Down, ws.ButtonState.Down, _lastBS.Down);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Left, ws.ButtonState.Left, _lastBS.Left);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Right, ws.ButtonState.Right, _lastBS.Right);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.A, ws.ButtonState.A, _lastBS.A);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.B, ws.ButtonState.B, _lastBS.B);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Minus, ws.ButtonState.Minus, _lastBS.Minus);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Home, ws.ButtonState.Home, _lastBS.Home);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Plus, ws.ButtonState.Plus, _lastBS.Plus);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.One, ws.ButtonState.One, _lastBS.One);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Two, ws.ButtonState.Two, _lastBS.Two);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// save off the current button state for next time&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_lastBS = ws.ButtonState;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_lastNunchuk = ws.NunchukState;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; HandleButton(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; we &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; WiimoteEvent, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; buttonState &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; lastButtonState &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; buttonState = lastButtonState &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; buttonState &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; ButtonEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(we))), EventActivateState.Activate))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; ButtonEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(we))), EventActivateState.Deactivate))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' handle all the Wiimote buttons&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Up, ws.ButtonState.Up, _lastBS.Up)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Down, ws.ButtonState.Down, _lastBS.Down)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Left, ws.ButtonState.Left, _lastBS.Left)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Right, ws.ButtonState.Right, _lastBS.Right)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.A, ws.ButtonState.A, _lastBS.A)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.B, ws.ButtonState.B, _lastBS.B)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Minus, ws.ButtonState.Minus, _lastBS.Minus)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Home, ws.ButtonState.Home, _lastBS.Home)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Plus, ws.ButtonState.Plus, _lastBS.Plus)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.One, ws.ButtonState.One, _lastBS.One)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Two, ws.ButtonState.Two, _lastBS.Two)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' save off the current button state for next time&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_lastBS = ws.ButtonState&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_lastNunchuk = ws.NunchukState&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;And, the current button values are stored away to check on the next event so button events are only fired once.&lt;/p&gt;

&lt;p&gt;Now that the event source object is written, it needs to be hooked up to the &lt;b&gt;GlobeControl&lt;/b&gt; so it can be used.&amp;#160; This can be done by creating an instance of the &lt;b&gt;WiimoteEventSource&lt;/b&gt; object, passing in the VE3D's &lt;b&gt;ActionSystem &lt;/b&gt;from the &lt;b&gt;BindingsManager&lt;/b&gt; object.&amp;#160; Then, the event source instance is passed to the &lt;b&gt;ActionSystem&lt;/b&gt;'s &lt;b&gt;EventSourceManager&lt;/b&gt; and registered using the &lt;b&gt;RegisterEventSource&lt;/b&gt; method.&amp;#160; Event sources should re registered before the control is added to the form.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// wiimote events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; WiimoteEventSource _wiimoteEventSource;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// create a new instance of the Wiimote event handler&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_wiimoteEventSource = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; WiimoteEventSource(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.globeControl.Host.BindingsManager.ActionSystem, &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// register it in the event source list&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.ActionSystem.EventSourceManager.RegisterEventSource(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._wiimoteEventSource);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' wiimote events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _wiimoteEventSource &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; WiimoteEventSource&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' create a new instance of the Wiimote event handler&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_wiimoteEventSource = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; WiimoteEventSource(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.globeControl.Host.BindingsManager.ActionSystem, &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' register it in the event source list&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.ActionSystem.EventSourceManager.RegisterEventSource(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._wiimoteEventSource)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;h4&gt;Actions and the BindingManager&lt;/h4&gt;

&lt;p&gt;Our binding list contains several action types that are not defined by the default VE3D actions.&amp;#160; These actions and their handlers must be registered with the VE3D control.&amp;#160; The actions can be registered as follows in the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event handler:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;BindingsSource bs = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; BindingsSource(&lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.GetType());&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;Locations&amp;quot;&lt;/span&gt;, LocationsHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;LocationsMove&amp;quot;&lt;/span&gt;, LocationsMoveHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleVR920&amp;quot;&lt;/span&gt;, ToggleVR920Handler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;VR920SetZero&amp;quot;&lt;/span&gt;, VR920SetZero);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;BalanceBoardSetZero&amp;quot;&lt;/span&gt;, BalanceBoardSetZero);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleBalanceBoard&amp;quot;&lt;/span&gt;, ToggleBalanceBoardHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;FullScreen&amp;quot;&lt;/span&gt;, FullScreenHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleVR920Stereo&amp;quot;&lt;/span&gt;, ToggleVR920Stereo);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;VR920SetEyeDistance&amp;quot;&lt;/span&gt;, VR920SetEyeDistance);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;BindingsSource bs = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; BindingsSource(base.&lt;span style="color: #0000ff"&gt;GetType&lt;/span&gt;());&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;Locations&amp;quot;&lt;/span&gt;, LocationsHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;LocationsMove&amp;quot;&lt;/span&gt;, LocationsMoveHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleVR920&amp;quot;&lt;/span&gt;, ToggleVR920Handler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;VR920SetZero&amp;quot;&lt;/span&gt;, VR920SetZero);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;BalanceBoardSetZero&amp;quot;&lt;/span&gt;, BalanceBoardSetZero);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleBalanceBoard&amp;quot;&lt;/span&gt;, ToggleBalanceBoardHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;FullScreen&amp;quot;&lt;/span&gt;, FullScreenHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleVR920Stereo&amp;quot;&lt;/span&gt;, ToggleVR920Stereo);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;VR920SetEyeDistance&amp;quot;&lt;/span&gt;, VR920SetEyeDistance);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;With the actions registered and handlers associated with them, the actual handlers need to be implemented.&amp;#160; All event handler methods must be of the following signature:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;bool&lt;/span&gt; EventHandler(EventData cause)&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; EventHandler(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; cause &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; EventData) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Boolean&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Let’s take a look at the &lt;strong&gt;FullScreen &lt;/strong&gt;binding which simply turns the status bar at the bottom of the window on and off:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 146px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; FullScreenHandler(EventData eventData)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(eventData.Activate)&lt;br /&gt;        BeginInvoke(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UIEventHandlerDelegate(FullScreen), eventData);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; FullScreenHandler(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventData &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EventData) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; eventData.Activate &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;        BeginInvoke(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; UIEventHandlerDelegate(&lt;span style="color: #0000ff"&gt;AddressOf&lt;/span&gt; FullScreen), eventData)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; FullScreen(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventData &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EventData)&lt;br /&gt;    statusStrip1.Visible = &lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; statusStrip1.Visible&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Because we are in the VE3D thread when this handler is called, we need to use &lt;strong&gt;BeginInvoke&lt;/strong&gt; to call the real method on the UI thread.&lt;/p&gt;

&lt;p&gt;Be sure to check the source code for the full demo linked above for the location handler methods.&amp;#160; I omitted them here since it is just more of the same type of code above.&lt;/p&gt;

&lt;h3&gt;&lt;/h3&gt;

&lt;h3&gt;&lt;/h3&gt;

&lt;h3&gt;&lt;b&gt;VR920 Head Tracker&lt;/b&gt;&lt;/h3&gt;

&lt;p&gt;Once the VR920 glasses and driver are installed on your PC, getting the data required from the glasses is quite easy.&amp;#160; We are going to create an object named &lt;strong&gt;VR920Tracker&lt;/strong&gt; which will pull data from the device and send it to VE3D.&lt;/p&gt;

&lt;p&gt;First we need to setup a few P/Invoke signatures to talk to the glasses as follows:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;, CharSet = CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; extern int IWROpenTracker();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;, CharSet = CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; extern void IWRZeroSet();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;, CharSet = CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; extern int IWRGetTracking(out int yaw, out int pitch, out int roll);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; int ERROR_SUCCESS  = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError := &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;, CharSet := CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; IWROpenTracker() &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError := &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;, CharSet := CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; IWRZeroSet()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError := &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;, CharSet := CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; IWRGetTracking(&amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: #0000ff"&gt;ByRef&lt;/span&gt; yaw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;, &amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: #0000ff"&gt;ByRef&lt;/span&gt; pitch &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;, &amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: #0000ff"&gt;ByRef&lt;/span&gt; roll &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; int ERROR_SUCCESS  = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;These 3 methods will allows to open access to the glasses, set its zero position, and get the roll, pitch and yaw information from the sensors.&lt;/p&gt;

&lt;p&gt;In the constructor for this object, we will open a handle to the glasses and startup a timer that will poll the glasses at a regular interval to get the sensor data as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; int TimerPeriod = 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; MainForm _mainForm;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; Timer _timer;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; VR920Tracker(MainForm mainForm)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _mainForm = mainForm;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    int openResult = IWROpenTracker();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(openResult != ERROR_SUCCESS)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ApplicationException(&lt;span style="color: #006080"&gt;&amp;quot;Could not connect to VR920: &amp;quot;&lt;/span&gt; + openResult);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _timer = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Timer(VR920Poller, null, Timeout.Infinite, TimerPeriod);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Const&lt;/span&gt; TimerPeriod &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = 1&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _mainForm &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; MainForm&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _timer &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Timer&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; mainForm &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; MainForm)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _mainForm = mainForm&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; openResult &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = IWROpenTracker()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; openResult &amp;lt;&amp;gt; ERROR_SUCCESS &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; ApplicationException(&lt;span style="color: #006080"&gt;&amp;quot;Could not connect to VR920: &amp;quot;&lt;/span&gt; &amp;amp; openResult)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _timer = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; Timer(&lt;span style="color: #0000ff"&gt;AddressOf&lt;/span&gt; VR920Poller, &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;, Timeout.Infinite, TimerPeriod)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The &lt;strong&gt;VR920Poller&lt;/strong&gt; method referenced above will be called at a specific interval and read the values from the glasses as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;// collection of values &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; averaging&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt; _yawValues = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt; _rollValues = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt; _pitchValues = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;// last calculated values&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; _lastYaw;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; _lastPitch;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; _lastRoll;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; void VR920Poller(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; state)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    lock(this)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        int yaw, pitch, roll;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        int result = IWRGetTracking(out yaw, out pitch, out roll);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(result != ERROR_SUCCESS)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ApplicationException(&lt;span style="color: #006080"&gt;&amp;quot;Could not get VR920 tracking information: &amp;quot;&lt;/span&gt; + result);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _yawValues.Add(VR920ToRadians(yaw));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _rollValues.Add(VR920ToRadians(roll));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _pitchValues.Add(VR920ToRadians(pitch));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(_yawValues.Count == 5)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; y = Average(_yawValues, _lastYaw);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(Math.Abs(y - _lastYaw) &amp;gt; 0.026)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _lastYaw = y;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; p = Average(_pitchValues, _lastPitch);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(Math.Abs(p - _lastPitch) &amp;gt; 0.017)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _lastPitch = p;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _lastRoll = Average(_rollValues, _lastRoll);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _yawValues.Clear();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _pitchValues.Clear();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _rollValues.Clear();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            RollPitchYaw rollPitchYaw = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RollPitchYaw(_lastRoll, _lastPitch, _lastYaw);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _mainForm.SetRollPitchYaw(rollPitchYaw);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _mainForm.lblAxes.Text = VR920ToDegrees(yaw) + &lt;span style="color: #006080"&gt;&amp;quot;, &amp;quot;&lt;/span&gt; + VR920ToDegrees(pitch) + &lt;span style="color: #006080"&gt;&amp;quot;, &amp;quot;&lt;/span&gt; + VR920ToDegrees(roll);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; Average(List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt; values, &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; last)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; total = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    foreach(&lt;span style="color: #0000ff"&gt;double&lt;/span&gt; value &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; values)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        total += value;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    total += last;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; total / (values.Count+1);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; VR920ToRadians(int vr920Value)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (vr920Value * .00549) * (Math.PI/180);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; VR920ToDegrees(int vr920Value)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (vr920Value * .00549);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' collection of values for averaging&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _yawValues &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;) = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;)()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _rollValues &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;) = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;)()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _pitchValues &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;) = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;)()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' last calculated values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _lastYaw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _lastPitch &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _lastRoll &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; VR920Poller(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; state &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SyncLock&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; yaw, pitch, roll &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; result &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = IWRGetTracking(yaw, pitch, roll)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; result &amp;lt;&amp;gt; ERROR_SUCCESS &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; ApplicationException(&lt;span style="color: #006080"&gt;&amp;quot;Could not get VR920 tracking information: &amp;quot;&lt;/span&gt; &amp;amp; result)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _yawValues.Add(VR920ToRadians(yaw))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _rollValues.Add(VR920ToRadians(roll))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _pitchValues.Add(VR920ToRadians(pitch))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; _yawValues.Count = 5 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; y &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = Average(_yawValues, _lastYaw)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; Math.Abs(y - _lastYaw) &amp;gt; 0.026 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _lastYaw = y&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; p &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = Average(_pitchValues, _lastPitch)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; Math.Abs(p - _lastPitch) &amp;gt; 0.017 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _lastPitch = p&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _lastRoll = Average(_rollValues, _lastRoll)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _yawValues.Clear()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _pitchValues.Clear()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _rollValues.Clear()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; rollPitchYaw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; RollPitchYaw(_lastRoll, _lastPitch, _lastYaw)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _mainForm.SetRollPitchYaw(rollPitchYaw)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _mainForm.lblAxes.Text = VR920ToDegrees(yaw) &amp;amp; &lt;span style="color: #006080"&gt;&amp;quot;, &amp;quot;&lt;/span&gt; &amp;amp; VR920ToDegrees(pitch) &amp;amp; &lt;span style="color: #006080"&gt;&amp;quot;, &amp;quot;&lt;/span&gt; &amp;amp; VR920ToDegrees(roll)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;SyncLock&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; Average(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; values &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;), &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; last &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; total &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = 0&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;For&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Each&lt;/span&gt; value &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; &lt;span style="color: #0000ff"&gt;In&lt;/span&gt; values&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        total += value&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Next&lt;/span&gt; value&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    total += last&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; total / (values.Count+1)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; VR920ToRadians(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; vr920Value &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; (vr920Value *.00549) * (Math.PI/180)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; VR920ToDegrees(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; vr920Value &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; (vr920Value *.00549)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Function&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This chunk calls the &lt;strong&gt;IWRGetTracking&lt;/strong&gt; method and tosses the results in 3 lists for roll, pitch and yaw.&amp;#160; then, when the list has 5 members in it, the values are averaged and, if that resulting values is past a certain threshold, the values are passed back to the &lt;strong&gt;MainForm&lt;/strong&gt;’s &lt;strong&gt;SetRollPitchYaw&lt;/strong&gt; method as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; _lastYaw;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SetRollPitchYaw(RollPitchYaw rollPitchYaw)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(!_initialized || _globeControl.IsDisposed || (_globeControl.Host) == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; || _globeControl.Host.CameraControllers.Current == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; y = ((_globeControl.Host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.LocalOrientation.Yaw - _lastYaw) + rollPitchYaw.Yaw;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    RollPitchYaw rpw = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RollPitchYaw(rollPitchYaw.Roll, rollPitchYaw.Pitch, y);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    (_globeControl.Host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.LocalOrientation.RollPitchYaw = rpw;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _lastYaw = rollPitchYaw.Yaw;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _lastYaw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; SetRollPitchYaw(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; rollPitchYaw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; RollPitchYaw)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; _initialized) &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; _globeControl.IsDisposed &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; (_globeControl.Host) &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt; &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; _globeControl.Host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; y &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = ((&lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_globeControl.Host.CameraControllers.Current, ActionCameraController)).LastReportedViewpoint.LocalOrientation.Yaw - _lastYaw) + rollPitchYaw.Yaw&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; rpw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; RollPitchYaw(rollPitchYaw.Roll, rollPitchYaw.Pitch, y)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_globeControl.Host.CameraControllers.Current, ActionCameraController).LastReportedViewpoint.LocalOrientation.RollPitchYaw = rpw&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _lastYaw = rollPitchYaw.Yaw&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This method takes the roll, pitch and yaw values provided and applies them to the current &lt;strong&gt;CameraController&lt;/strong&gt; used by VE3D (which, by default, is an &lt;strong&gt;ActionCameraController&lt;/strong&gt;).&lt;/p&gt;

&lt;p&gt;So, this code ultimately takes the roll, yaw and pitch of the user’s head and translates that directly to the roll, yaw and pitch of the camera in VE3D providing an accurate, real-time view into the VE3D world.&lt;/p&gt;

&lt;h3&gt;&lt;/h3&gt;

&lt;h1&gt;&lt;/h1&gt;

&lt;h3&gt;Stereoscopic Images&lt;/h3&gt;

&lt;p&gt;The final piece of the puzzle is drawing frames to the VR920 glasses in such a way that the final view to the user will be three dimensional.&amp;#160; This works similarly to those &lt;a href="http://www.magiceye.com/3dfun/stwkdisp.shtml" target="_blank"&gt;Magic Eye puzzles&lt;/a&gt; you may have seen.&amp;#160; Essentially, for every frame, we want to take the current VE3D camera position and move it several units to the left, render that to the left eye of the glasses, and then move the camera several units to the right and render that to the right eye of the glasses.&amp;#160; To handle this we,&amp;#160; can create an object named &lt;strong&gt;VR920StereoStep&lt;/strong&gt; which derives from the &lt;strong&gt;Step&lt;/strong&gt; class provided by VE3D and add this to the &lt;strong&gt;StepManager&lt;/strong&gt;.&amp;#160; When this is done, the &lt;strong&gt;VR920StereoStep&lt;/strong&gt; will be called at the end of every frame drawn by VE3D.&lt;/p&gt;

&lt;p&gt;As with the &lt;strong&gt;VR920Tracker&lt;/strong&gt; class, we will need to setup a few P/Invoke method signatures to talk to the stereo driver as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint = &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_Open&amp;quot;&lt;/span&gt;, SetLastError=&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; IntPtr OpenStereo();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint = &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_SetStereo&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; Boolean SetStereoEnabled(IntPtr handle, Boolean enabled);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint = &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_SetLR&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; Boolean SetStereoLR(IntPtr handle, Boolean eye);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint = &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_WaitForAck&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; Byte WaitForOpenFrame(IntPtr handle, Boolean eye);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint := &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_Open&amp;quot;&lt;/span&gt;, SetLastError:=&lt;span style="color: #0000ff"&gt;True&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; OpenStereo() &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint := &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_SetLR&amp;quot;&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; SetStereoLR(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; handle &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eye &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint := &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_SetStereo&amp;quot;&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; SetStereoEnabled(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; handle &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; enabled &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint := &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_WaitForAck&amp;quot;&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; WaitForOpenFrame(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; handle &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eye &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Byte&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In the constructor for this object, we will open a handle to the stereo driver and turn on the stereo functionality of the glasses as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;readonly&lt;/span&gt; IntPtr INVALID_FILE_HANDLE = (IntPtr)(-1);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; IntPtr _hStereo = INVALID_FILE_HANDLE;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; Host _host;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; bool _stereoEnabled = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; EyeDistance { &lt;span style="color: #0000ff"&gt;get&lt;/span&gt;; &lt;span style="color: #0000ff"&gt;set&lt;/span&gt;; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; VR920StereoStep(StepManager manager, Host host) : base(manager)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    EyeDistance = 10;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _host = host;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _hStereo = OpenStereo();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(_hStereo != INVALID_FILE_HANDLE)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        SetStereoEnabled(_hStereo, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _stereoEnabled = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ReadOnly&lt;/span&gt; INVALID_FILE_HANDLE &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr = &lt;span style="color: #0000ff"&gt;CType&lt;/span&gt;(-1, IntPtr)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _hStereo &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr = INVALID_FILE_HANDLE&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _host &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Host&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _stereoEnabled &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; privateEyeDistance &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Property&lt;/span&gt; EyeDistance() &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Get&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; privateEyeDistance&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Get&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; value &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        privateEyeDistance = value&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Property&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; manager &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; StepManager, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; host &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Host)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;MyBase&lt;/span&gt;.&lt;span style="color: #0000ff"&gt;New&lt;/span&gt;(manager)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    EyeDistance = 10&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _host = host&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _hStereo = OpenStereo()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; _hStereo &amp;lt;&amp;gt; INVALID_FILE_HANDLE &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        SetStereoEnabled(_hStereo, &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _stereoEnabled = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Next, we need to override the &lt;strong&gt;OnExecute&lt;/strong&gt; method provided by the base &lt;strong&gt;Step &lt;/strong&gt;class as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; _rightEye = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; Vector3D _position;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; OnExecute(SceneState state)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(_hStereo != INVALID_FILE_HANDLE &amp;amp;&amp;amp; _stereoEnabled &amp;amp;&amp;amp; (_host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(!_rightEye)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _position = (_host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.Position.Vector;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            (_host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.Position.Vector = _position + &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Vector3D(-EyeDistance, 0, 0);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _position = (_host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.Position.Vector;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            (_host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.Position.Vector = _position + &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Vector3D(EyeDistance, 0, 0);;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        SetStereoLR(_hStereo, _rightEye);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        WaitForOpenFrame(_hStereo, _rightEye);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _rightEye = !_rightEye;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _rightEye &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _position &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Vector3D&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; OnExecute(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; state &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; SceneState)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; _hStereo &amp;lt;&amp;gt; INVALID_FILE_HANDLE &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; _stereoEnabled &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_host.CameraControllers.Current, ActionCameraController)).LastReportedViewpoint IsNot &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; _rightEye) &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _position = (&lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_host.CameraControllers.Current, ActionCameraController)).LastReportedViewpoint.Position.Vector&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_host.CameraControllers.Current, ActionCameraController).LastReportedViewpoint.Position.Vector = _position + &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; Vector3D(-EyeDistance, 0, 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _position = (&lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_host.CameraControllers.Current, ActionCameraController)).LastReportedViewpoint.Position.Vector&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_host.CameraControllers.Current, ActionCameraController).LastReportedViewpoint.Position.Vector = _position + &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; Vector3D(EyeDistance, 0, 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        SetStereoLR(_hStereo, _rightEye)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        WaitForOpenFrame(_hStereo, _rightEye)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _rightEye = &lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; _rightEye&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;OnExecute&lt;/strong&gt; will be called at the end of each VE3D frame rendered.&amp;#160; In this method, we obtain the current position of the VE3D camera and then set its position several units to the left or right (- or + &lt;strong&gt;EyeDistance&lt;/strong&gt;).&amp;#160; &lt;strong&gt;SetStereoLR&lt;/strong&gt; from the VR920 API is called, setting the appropriate eye to be active (left = false, right = true).&amp;#160; Then &lt;strong&gt;WaitForOpenFrame&lt;/strong&gt; is called which will pause the action long enough for the glasses to draw the entire frame to eye to avoid image tearing.&amp;#160; Essentially, this call “sits and spins” at this location until the glasses report back that the entire frame is drawn in the proper eye and that we can continue on drawing the opposite eye for the next frame.&amp;#160; Finally, the &lt;strong&gt;_rightEye&lt;/strong&gt; member variable is togged to the opposite value, so the next time through this method the opposite eye is drawn.&lt;/p&gt;

&lt;p&gt;With this class in place, back in our &lt;strong&gt;MainForm&lt;/strong&gt; in the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event handler, we can instantiate the object and add it to the &lt;strong&gt;StepManager&lt;/strong&gt; as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; VR920StereoStep _vr920StereoStep;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_vr920StereoStep = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; VR920StereoStep(_globeControl.Host.RenderEngine.StepManager, _globeControl.Host);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.RenderEngine.StepManager.Add(_vr920StereoStep);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _vr920StereoStep &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; VR920StereoStep&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_vr920StereoStep = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; VR920StereoStep(_globeControl.Host.RenderEngine.StepManager, _globeControl.Host)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.RenderEngine.StepManager.Add(_vr920StereoStep)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h3&gt;&lt;b&gt;Running the Application&lt;/b&gt;&lt;/h3&gt;

&lt;p&gt;To run the demo, do the following:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Copy &lt;b&gt;BindingsWiimote.xml&lt;/b&gt; to the appropriate directory listed above &lt;/li&gt;

  &lt;li&gt;Pair the Wiimote and Balance Board to the computer.&amp;#160; See the &lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" target="_blank" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;WiimoteLib article&lt;/a&gt; for more information on how to do that &lt;/li&gt;

  &lt;li&gt;Run the executable &lt;/li&gt;

  &lt;li&gt;Stand on the Balance Board &lt;/li&gt;

  &lt;li&gt;Put on the glasses &lt;/li&gt;

  &lt;li&gt;Zero both the Balance Board and glasses &lt;/li&gt;

  &lt;li&gt;Toggle everything on or off at will &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Controls&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;F1 – Set VR920 glasses to zero position &lt;/li&gt;

  &lt;li&gt;F2 – Set Balance Board to zero position &lt;/li&gt;

  &lt;li&gt;F3 – Toggle stereo mode on and off &lt;/li&gt;

  &lt;li&gt;Wiimote 1 or B – Toggle Balance Board on or off &lt;/li&gt;

  &lt;li&gt;Wiimote 2 or V – Toggle VR920 head tracking on or off &lt;/li&gt;

  &lt;li&gt;F – Toggle full-screen on or off &lt;/li&gt;

  &lt;li&gt;Nunchuk joystick X/Y – Strafe/Move &lt;/li&gt;

  &lt;li&gt;Nunchuk C/Z buttons – Raise/lower altitude &lt;/li&gt;

  &lt;li&gt;Wiimote A – Open location menu/Select location (note that if a new location is selected, the Balance Board is turned off and must be re-enabled after “landing” &lt;/li&gt;

  &lt;li&gt;Wiimote Dpad Up/Down – Move through List &lt;/li&gt;

  &lt;li&gt;Balance Board – Lean your body left or right to turn in the VE3D environment &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/h3&gt;

&lt;p&gt;With the above code, we have created a very interesting interface for Virtual Earth 3D.&amp;#160; The demo and source code linked above contain a few more features and bindings which enhance the application a bit more.&amp;#160; Be sure to give the full demo a try and check out the full source code for a few more implementation details.&lt;/p&gt;

&lt;h3&gt;&lt;/h3&gt;

&lt;h3&gt;Additional Information&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://www.vr920.com/" target="_blank"&gt;Vuzix VR920 Glasses&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" target="_blank" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;Managed Library for Nintendo's Wiimote&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://heptazane.spaces.live.com/default.aspx" target="_blank" mce_href="http://heptazane.spaces.live.com/default.aspx"&gt;Heptazane's Blog&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://virtualearth.spaces.live.com/" target="_blank" mce_href="http://virtualearth.spaces.live.com/"&gt;Virtual Earth Blog&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/virtualearth/" target="_blank" mce_href="http://blogs.msdn.com/virtualearth/"&gt;Virtual Earth Developer's Blog&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Bio&lt;/h3&gt;

&lt;p&gt;Brian is a &lt;a href="https://mvp.support.microsoft.com/profile/Brian.Peek"&gt;Microsoft C# MVP&lt;/a&gt; who has been actively developing in .NET since its early betas in 2000, and who has been developing solutions using Microsoft technologies and platforms for even longer. Along with .NET, Brian is particularly skilled in the languages of C, C++ and assembly language for a variety of CPUs. He is also well-versed in a wide variety of technologies including web development, document imaging, GIS, graphics, game development, and hardware interfacing. Brian has a strong background in developing applications for the health-care industry, as well as developing solutions for portable devices, such as tablet PCs and PDAs. Additionally, Brian has co-authored the book &amp;quot;&lt;a href="http://www.amazon.com/dp/0735711410/"&gt;Debugging ASP.NET&lt;/a&gt;&amp;quot; published by New Riders, and is currently co-authoring a book titled &amp;quot;&lt;a href="http://www.amazon.com/exec/obidos/ASIN/0596520743/brianpcom-20"&gt;Coding4Fun: 10 .NET Programming Projects for Wiimote, YouTube, World of Warcraft, and More&lt;/a&gt;&amp;quot; to be published by &lt;a href="http://www.oreilly.com/"&gt;O'Reilly&lt;/a&gt; in December 2008. Brian is also an author for MSDN's &lt;a href="http://blogs.msdn.com/coding4fun/"&gt;Coding4Fun&lt;/a&gt; website.&amp;#160; You can reach Brian via vis website at &lt;a href="http://www.brianpeek.com/"&gt;http://www.brianpeek.com/&lt;/a&gt; .&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9068804" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/mash+up/default.aspx">mash up</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware+miscellaneous/default.aspx">hardware miscellaneous</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardwarehacks/default.aspx">hardwarehacks</category></item><item><title>BlueBoss - Bluetooth Proximity Detection</title><link>http://blogs.msdn.com/coding4fun/archive/2008/06/26/8658548.aspx</link><pubDate>Fri, 27 Jun 2008 01:09:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8658548</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/8658548.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=8658548</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=8658548</wfw:comment><description>&lt;h3&gt;Summary:&lt;/h3&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt; Bluetooth is now found in a variety of devices and enable the user to use wireless accessories.&amp;#160; The Bluetooth protocol allows a user to “discover” any device that is in proximity to your Bluetooth radio.&amp;#160; Why not see who is in proximity to you?&amp;#160; Why not have the presence of a device execute programs or alert you?&lt;/p&gt;  &lt;p&gt;Andy Konkol – &lt;u&gt;&lt;a href="http://copyandwaste.com/"&gt;http://copyandwaste.com&lt;/a&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Hardware:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Bluetooth radio (USB dongle)&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;SMA Female Jack&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;SMA male to N-male pigtail&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;2.4 GHz antenna (with N-female connector)&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Software:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;u&gt;&lt;a href="http://www.microsoft.com/express/samples/c4fdevkit/default.aspx"&gt;Coding4fun Developer Kit&lt;/a&gt;&lt;/u&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;u&gt;&lt;a href="http://www.codeproject.com/KB/miscctrl/RobMisNotifyWindow.aspx"&gt;Robert Misiak's Notify Window&lt;/a&gt;&lt;/u&gt;&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Download:&lt;/strong&gt; &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;a href="http://www.codeplex.com/blueboss/Release/ProjectReleases.aspx?ReleaseId=14662"&gt;Source / Binary Download&lt;/a&gt;&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;u&gt;&lt;/u&gt;&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Bluetooth and Hardware:&lt;/strong&gt;&lt;/h3&gt;  &lt;br /&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;Bluetooth was designed for devices to communicate wirelessly over short distances.&amp;#160; However, with a very simple hardware modification you can extend the range of your Bluetooth radio with standard 2.4ghz antennas used in wireless networking (802.11 a/b/g). &lt;/p&gt;  &lt;p&gt;Modifying Bluetooth dongles to accept external antennas is documented all over the Internet.&amp;#160; In principle it is very easy: find the antenna lead and solder on a connector/antenna.&amp;#160; I purchased a very cheap Bluetooth USB dongle on eBay and opened the casing.&amp;#160; After finding the antenna trace on the circuit board I soldered on a SMA Female connector to it.&amp;#160; After soldering the antenna jack in place I slipped a 3 inch chunk of heatshrink and heated it to cover the exposed circuit board.&amp;#160; Now I had a Bluetooth radio that accepts external antennas. Adding an antenna simply increases the range of your radio, allowing you to “see” devices from a farther distance. &lt;/p&gt;  &lt;p&gt;To connect an external antenna to the dongle I needed to use a connector converter called a pigtail.&amp;#160; I used a SMA male to N-male pigtail.&amp;#160; I connected one end of the pigtail to my dongle and the other to an omni-directional 9dbi panel antenna that had an N-female connector.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/BlueBoss_F144/IMG_20701.jpg"&gt;&lt;img title="IMG_2070[1]" height="180" alt="IMG_2070[1]" src="http://www.coding4fun.net/images/BlueBoss_F144/IMG_20701_thumb.jpg" width="240" border="0" /&gt;&lt;/a&gt; &lt;a href="http://www.coding4fun.net/images/BlueBoss_F144/IMG_20711.jpg"&gt;&lt;img title="IMG_2071[1]" height="180" alt="IMG_2071[1]" src="http://www.coding4fun.net/images/BlueBoss_F144/IMG_20711_thumb.jpg" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Software:&lt;/strong&gt;&lt;/h3&gt;  &lt;br /&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;To take advantage of my newly modified hardware I needed to download the Coding4Fun Toolkit.&amp;#160; Included in the toolkit is an API for Bluetooth devices.&amp;#160; This API allows you to do a wide variety of things with your Bluetooth radio but I focused on two methods from the ServiceAndDeviceDiscovery library: DiscoverAllDevices and DiscoverDeviceByName. &lt;/p&gt;  &lt;p&gt;DiscoverAllDevices allows you to “scan” the airwaves on the 2.4 GHz band and report back what devices your radio sees. &lt;/p&gt;  &lt;p&gt;DiscoverDeviceByName allows you to scan for a particular device with a specified name and report back if it is present or not.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; DevicePresent()
{
    BluetoothDeviceServicesManager workerBTMgr = &lt;span class="kwrd"&gt;new&lt;/span&gt; BluetoothDeviceServicesManager();
    Device workerDevice = workerBTMgr.DiscoverDeviceByName(_watchItem.DeviceName);

    &lt;span class="kwrd"&gt;return&lt;/span&gt; (workerDevice != &lt;span class="kwrd"&gt;null&lt;/span&gt;);
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Run(String Operation)
{
    &lt;span class="kwrd"&gt;switch&lt;/span&gt; (Operation)
    {
        &lt;span class="kwrd"&gt;case&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;SingleDevice&amp;quot;&lt;/span&gt;:
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (DevicePresent())
            {
                _parentForm.Invoke(_parentForm.AddToDeviceSeenList, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;[] { _watchItem });
            }
            &lt;span class="kwrd"&gt;else&lt;/span&gt;
            {
                _parentForm.Invoke(_parentForm.RemoveFromDeviceSeenList, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;[] { _watchItem });
            }
            &lt;span class="kwrd"&gt;break&lt;/span&gt;;
        &lt;span class="kwrd"&gt;case&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;AllDevices&amp;quot;&lt;/span&gt;:
            BluetoothDeviceServicesManager workerBTMgr = &lt;span class="kwrd"&gt;new&lt;/span&gt; BluetoothDeviceServicesManager();
            List&amp;lt;Device&amp;gt; Devices = workerBTMgr.DiscoverAllDevices();
            _parentForm.Invoke(_parentForm.ThreadUpdateDiscoverBox, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;[] { Devices });
            &lt;span class="kwrd"&gt;break&lt;/span&gt;;
    }
}&lt;/pre&gt;

&lt;p&gt;Both of these methods require that the device you are scanning for is in discoverable mode (which most manufacturers enable by default).&amp;#160; Using the two methods described above I was able to tell if a device is in proximity. And ultimately enabling me create alerts and execute programs based on what device is present. &lt;/p&gt;

&lt;p&gt;To perform device discovery and not have my UI lag I had to create two worker threads.&amp;#160; One worker thread to discover all devices and display it under my devices listbox, and another to discover devices by name specified in the “watchlist.”&amp;#160; I am not an expert at multi-threaded programs but I managed to implement them without any major headaches.&lt;/p&gt;

&lt;h3&gt;User Interface:&lt;/h3&gt;

&lt;p&gt;Since the “Add to watchlist” and “Edit” buttons essentially do the same thing, I decided to overload a windows form.&amp;#160; I also wanted to keep track of the parent form and disable it when the WatchItemForm was shown. &lt;/p&gt;

&lt;p&gt;The second overload allows me to fill in the form control's text based on the data that is already set for the WatchItem that has been selected (the Edit button).&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; WatchItemForm(Form1 f, String DeviceName)
{
    InitializeComponent();
    &lt;span class="kwrd"&gt;this&lt;/span&gt;._parentForm = f;
    lblDeviceName.Text = DeviceName;
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; WatchItemForm(Form1 f, WatchItem item)
{
    InitializeComponent();
    &lt;span class="kwrd"&gt;this&lt;/span&gt;._parentForm = f;

    lblDeviceName.Text = item.DeviceName;
    tbxPicturePath.Text = item.ImagePath;
    tbxProgramPath.Text = item.ProgramPath;
    &lt;span class="kwrd"&gt;this&lt;/span&gt;._parentForm.Enabled = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
}&lt;/pre&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;I wanted to have a pop up notify window similar to outlook and was able to find Robert Misiak's &lt;a href="http://www.codeproject.com/KB/miscctrl/RobMisNotifyWindow.aspx"&gt;NotifyWindow&lt;/a&gt;. This is a very simple library which allows you to create pop up notify windows very easily. I edited &lt;strong&gt;NotifyWindow&lt;/strong&gt; to include a “picturepath” variable as well as picturebox on the form. As you can see creating a &lt;strong&gt;NotifyWindow&lt;/strong&gt; is quite easy:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; NotifyDeviceWindow(WatchItem x)
{
    NotifyWindow nw;
    nw = &lt;span class="kwrd"&gt;new&lt;/span&gt; NotifyWindow();
    &lt;span class="rem"&gt;//validate Alert Message&lt;/span&gt;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (x.AlertMessage == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
    {
        nw.Text = x.DeviceName;
    }
    &lt;span class="kwrd"&gt;else&lt;/span&gt;
    {
        nw.Text = x.AlertMessage;
    }
    &lt;span class="rem"&gt;//validate picture&lt;/span&gt;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (x.ImagePath != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
    {
        FileInfo imgfile = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileInfo(x.ImagePath);
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (imgfile.Exists)
        {
            nw.PicturePath = x.ImagePath;
        }
        &lt;span class="kwrd"&gt;else&lt;/span&gt;
        {
            MessageBox.Show(&lt;span class="str"&gt;&amp;quot;Image does not exist&amp;quot;&lt;/span&gt;);
        }
    }
    nw.Notify();

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (x.ProgramPath != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
    {
        RunProcess(x.ProgramPath);
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Process Flow/Software Operation:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;User clicks the “Discover” button, a thread is spawned which enumerates all Bluetooth devices in proximity &lt;/li&gt;

  &lt;li&gt;Thread finishes and updates the Devices listbox &lt;/li&gt;

  &lt;li&gt;User selects a discovered device and clicks “Add to watchlist” A watch item form is spawned and asks you for an alert message, a picture path, and an executable path &lt;/li&gt;

  &lt;li&gt;User clicks save , a WatchItem object is created and added to the watchList object &lt;/li&gt;

  &lt;li&gt;A timer starts and every 10 seconds a thread is spawned to discover that device by name &lt;/li&gt;

  &lt;li&gt;If the device is discovered, it is added to the “deviceSeenList” and a notify alert is sent and the executable is executed. &lt;/li&gt;

  &lt;li&gt;If that device is still present after the next timer click, no notification is sent, If that device is not present it is removed from the “deviceSeenList” &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Screenshots:&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/BlueBoss_F144/bbmain1.jpg"&gt;&lt;img title="bb-main[1]" height="319" alt="bb-main[1]" src="http://www.coding4fun.net/images/BlueBoss_F144/bbmain1_thumb.jpg" width="470" border="0" /&gt;&lt;/a&gt;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&lt;a href="http://www.coding4fun.net/images/BlueBoss_F144/bbwatchitem1.jpg"&gt;&lt;img title="bb-watchitem[1]" height="210" alt="bb-watchitem[1]" src="http://www.coding4fun.net/images/BlueBoss_F144/bbwatchitem1_thumb.jpg" width="257" border="0" /&gt;&lt;/a&gt; &lt;a href="http://www.coding4fun.net/images/BlueBoss_F144/bbnotify_11.jpg"&gt;&lt;img title="bb-notify_1[1]" height="173" alt="bb-notify_1[1]" src="http://www.coding4fun.net/images/BlueBoss_F144/bbnotify_11_thumb.jpg" width="226" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;ol&gt;&lt;/ol&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8658548" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/utility/default.aspx">utility</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/productivity/default.aspx">productivity</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category></item><item><title>WPF Custom Screen Saver Art</title><link>http://blogs.msdn.com/coding4fun/archive/2008/06/20/8626294.aspx</link><pubDate>Fri, 20 Jun 2008 21:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8626294</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/8626294.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=8626294</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=8626294</wfw:comment><description>&lt;H3&gt;Summary&lt;/H3&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/thum.png" mce_href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/thum.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=thum border=0 alt=thum align=left src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/thum_thumb.png" width=71 height=63 mce_src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/thum_thumb.png"&gt;&lt;/A&gt;Creating custom wallpaper is easy. But what about custom screen savers? This post will detail how to build a custom saver using Windows Presentation Framework (WPF). The posted code also provides some insight on how to create interesting particle effects using WPF’s animation engine, and how to implement multiple monitor support in .Net.&lt;/P&gt;
&lt;P&gt;Erik Klimczak - &lt;A href="http://www.claritycon.com/" mce_href="http://www.claritycon.com/"&gt;Clarity Consulting&lt;/A&gt;&lt;/P&gt;
&lt;H5&gt;Download&lt;/H5&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;A href="http://wpfscreensaverart.codeplex.com/"&gt;&lt;FONT color=#0000ff&gt;http://wpfscreensaverart.codeplex.com/&lt;/FONT&gt;&lt;/A&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;
&lt;H4&gt;&lt;/H4&gt;
&lt;H4&gt;Introduction&lt;/H4&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/uc/default.mspx" mce_href="http://www.microsoft.com/uc/default.mspx"&gt;Microsoft Unified Communications&lt;/A&gt; (UC) is a new technology that has been getting a lot of hype in the past couple of months. UC is essentially the integration of messaging, voice, and video across the applications and devices that people use every day. More information about UC can be found &lt;A href="http://www.microsoft.com/uc/default.mspx" mce_href="http://www.microsoft.com/uc/default.mspx"&gt;here&lt;/A&gt;. One of the coolest things about UC is the concept of “presence” (see below). The Presence indicator effectively allows the user to reflect his/her status in other Office Communicator Server friendly applications (i.e. Outlook, Office communicator, Live Meeting, etc.)&lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image002.jpg" mce_href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image002.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image002 border=0 alt=clip_image002 src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image002_thumb.jpg" width=240 height=151 mce_src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image002_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;While building out some communicator functionality on another project I found myself recreating the presence “bubbles” in xaml so that they could scale without losing quality (see below). I used Expression Design to re-create the presence bubbles and export then to xaml.&lt;/P&gt;
&lt;P&gt;In doing so it occurred to me that the presence “bubbles” would make for some excellent art sprites. &lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image004.jpg" mce_href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image004.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image004 border=0 alt=clip_image004 src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image004_thumb.jpg" width=470 height=342 mce_src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image004_thumb.jpg"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So after a hop-skip-and a jump to Photoshop I found myself with a shiny new “presence art” wallpaper.&lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image006.jpg" mce_href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image006.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image006 border=0 alt=clip_image006 src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image006_thumb.jpg" width=496 height=312 mce_src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image006_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Immediately after creating the wallpaper I thought to myself, “this would also make a great screen saver”. This article will attempt to show how to build a custom WPF screen saver that implements a simple physics particle effect using the WPF animation engine.&lt;/P&gt;
&lt;H4&gt;Particle Animation&lt;/H4&gt;
&lt;P&gt;With my graphic designer hat on I knew that I wanted to create a floating particle effect. Particle effects can be used to simulate anything from rain, snow, fire to bubbles and clouds. Then by varying the presence “bubbles” in size and opacity the illusion of depth and space can be created. After some research I found the CompositionTarget.Rendering event handler in WPF. Essentially, this event is a timer that ticks all the time and fires once each time WPF decides to render a frame. Inside the event handler you have complete freedom to do whatever you want to any object.&amp;nbsp; In other words, hooking CompositionTarget.Rendering is very much a "do it yourself" animation system. This event is especially good for physics-based animations and is very similar to the way Flash’s rendering engine works. The MSDN entry for this event handler can be found &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.media.compositiontarget.rendering.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.media.compositiontarget.rendering.aspx"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Once I had found the appropriate animation hook I created the particle user control. This control holds the various particle attributes that will be animated. The code below shows the various properties that can be used to create very interesting physics-based effects. These properties can be used to calculate collision detection, gravitational pull and other kinetics-related effects.&lt;/P&gt;
&lt;P&gt;C#&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;partial&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt; Particle : UserControl&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt;    {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; Particle()&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt;            InitializeComponent();&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   8:&lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   9:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  10:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;readonly&lt;/SPAN&gt; DependencyProperty StatusProperty = DependencyProperty.Register(&lt;SPAN style="COLOR: #006080"&gt;"Status"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #0000ff"&gt;typeof&lt;/SPAN&gt;(Status), &lt;SPAN style="COLOR: #0000ff"&gt;typeof&lt;/SPAN&gt;(Particle), &lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt; UIPropertyMetadata(Particle.StatusValueChanged));&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  11:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; Status Status&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  12:&lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  13:&lt;/SPAN&gt;            get { &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; (Status)GetValue(StatusProperty); }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  14:&lt;/SPAN&gt;            set { SetValue(StatusProperty, &lt;SPAN style="COLOR: #0000ff"&gt;value&lt;/SPAN&gt;); }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  15:&lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  16:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  17:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; StatusValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  18:&lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  19:&lt;/SPAN&gt;            Particle myclass = (Particle)d;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  20:&lt;/SPAN&gt;            myclass.imgStatus.Source = Application.Current.FindResource(((Status)e.NewValue).ToString() + &lt;SPAN style="COLOR: #006080"&gt;"Png"&lt;/SPAN&gt;) &lt;SPAN style="COLOR: #0000ff"&gt;as&lt;/SPAN&gt; BitmapImage;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  21:&lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  22:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  23:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; Radius&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  24:&lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  25:&lt;/SPAN&gt;            get { &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.imgStatus.Height / 2; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  26:&lt;/SPAN&gt;            set { &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.imgStatus.Height = &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.imgStatus.Width = &lt;SPAN style="COLOR: #0000ff"&gt;value&lt;/SPAN&gt; * 2; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  27:&lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  28:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  29:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; vy;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  30:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; VY&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  31:&lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  32:&lt;/SPAN&gt;            get { &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.vy; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  33:&lt;/SPAN&gt;            set { &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.vy = &lt;SPAN style="COLOR: #0000ff"&gt;value&lt;/SPAN&gt;; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  34:&lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  35:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  36:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; vx;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  37:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; VX&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  38:&lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  39:&lt;/SPAN&gt;            get { &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.vx; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  40:&lt;/SPAN&gt;            set { &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.vx = &lt;SPAN style="COLOR: #0000ff"&gt;value&lt;/SPAN&gt;; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  41:&lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  42:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  43:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; mass;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  44:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; Mass&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  45:&lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  46:&lt;/SPAN&gt;            get { &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.mass; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  47:&lt;/SPAN&gt;            set { &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.mass = &lt;SPAN style="COLOR: #0000ff"&gt;value&lt;/SPAN&gt;; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  48:&lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  49:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; x;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  50:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; X&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  51:&lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  52:&lt;/SPAN&gt;            get { &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.x; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  53:&lt;/SPAN&gt;            set { &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.x = &lt;SPAN style="COLOR: #0000ff"&gt;value&lt;/SPAN&gt;; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  54:&lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  55:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  56:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; y;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  57:&lt;/SPAN&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; Y&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  58:&lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  59:&lt;/SPAN&gt;            get { &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.y; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  60:&lt;/SPAN&gt;            set { &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.y = &lt;SPAN style="COLOR: #0000ff"&gt;value&lt;/SPAN&gt;; }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  61:&lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  62:&lt;/SPAN&gt;    }&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;PRE class=csharpcode&gt;VB&lt;/PRE&gt;
&lt;DIV style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; Partial &lt;SPAN style="COLOR: #0000ff"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Class&lt;/SPAN&gt; Particle&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Inherits&lt;/SPAN&gt; UserControl&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Sub&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;New&lt;/SPAN&gt;()&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt;         InitializeComponent()&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   8:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   9:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Shared&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;ReadOnly&lt;/SPAN&gt; StatusProperty &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; DependencyProperty = DependencyProperty.Register(&lt;SPAN style="COLOR: #006080"&gt;"Status"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #0000ff"&gt;GetType&lt;/SPAN&gt;(Status), &lt;SPAN style="COLOR: #0000ff"&gt;GetType&lt;/SPAN&gt;(Particle), &lt;SPAN style="COLOR: #0000ff"&gt;New&lt;/SPAN&gt; PropertyMetadata(&lt;SPAN style="COLOR: #0000ff"&gt;AddressOf&lt;/SPAN&gt; Particle.StatusValueChanged))&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  10:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt; Status() &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; Status&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  11:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  12:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;CType&lt;/SPAN&gt;(GetValue(StatusProperty), Status)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  13:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  14:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; value &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; Status)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  15:&lt;/SPAN&gt;             SetValue(StatusProperty, value)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  16:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  17:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  18:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  19:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Shared&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Sub&lt;/SPAN&gt; StatusValueChanged(&lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; d &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; DependencyObject, &lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; DependencyPropertyChangedEventArgs)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  20:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Dim&lt;/SPAN&gt; [&lt;SPAN style="COLOR: #0000ff"&gt;myclass&lt;/SPAN&gt;] &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; Particle = &lt;SPAN style="COLOR: #0000ff"&gt;CType&lt;/SPAN&gt;(d, Particle)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  21:&lt;/SPAN&gt;         [&lt;SPAN style="COLOR: #0000ff"&gt;myclass&lt;/SPAN&gt;].imgStatus.Source = &lt;SPAN style="COLOR: #0000ff"&gt;TryCast&lt;/SPAN&gt;(Application.Current.FindResource((&lt;SPAN style="COLOR: #0000ff"&gt;CType&lt;/SPAN&gt;(e.NewValue, Status)).ToString() &amp;amp; &lt;SPAN style="COLOR: #006080"&gt;"Png"&lt;/SPAN&gt;), BitmapImage)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  22:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  23:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  24:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt; Radius() &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  25:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  26:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;.imgStatus.Height / 2&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  27:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  28:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; value &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  29:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;.imgStatus.Width = value * 2&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  30:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;.imgStatus.Height = &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;.imgStatus.Width&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  31:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  32:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  33:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  34:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Private&lt;/SPAN&gt; _vy &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  35:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt; VY() &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  36:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  37:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;._vy&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  38:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  39:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; value &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  40:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;._vy = value&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  41:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  42:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  43:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  44:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Private&lt;/SPAN&gt; _vx &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  45:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt; VX() &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  46:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  47:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;._vx&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  48:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  49:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; value &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  50:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;._vx = value&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  51:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  52:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  53:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  54:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Private&lt;/SPAN&gt; _mass &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  55:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt; Mass() &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  56:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  57:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;._mass&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  58:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  59:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; value &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  60:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;._mass = value&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  61:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  62:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  63:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  64:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Private&lt;/SPAN&gt; _x &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  65:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt; X() &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  66:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  67:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;._x&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  68:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  69:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; value &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  70:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;._x = value&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  71:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  72:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  73:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  74:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Private&lt;/SPAN&gt; _y &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  75:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt; Y() &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  76:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  77:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;._y&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  78:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Get&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  79:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; value &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Double&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  80:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;._y = value&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  81:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Set&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  82:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Property&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  83:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  84:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Class&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  85:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  86:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Once I had the particle class created, I decided to use a variation of a spring physics equation to get the desired float animation. The spring equation forces the particles toward each other and then springs them past each other similar to how a ball on the end of a rubber band would act when pulling it and letting it spring back and forth. Then by tweaking the force and velocity applied to each particle I successfully simulated a floating effect (I am by no means a physicist and I am sure there is a better way of implementing this equation). By combining the CompositionTarget.Rendering event and the positioning logic we can effectively scatter and animate the particles on our Canvas. The math involved looks something like this:&lt;/P&gt;
&lt;H6&gt;&lt;/H6&gt;C# 
&lt;DIV style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; Spring(Particle a, Particle b)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt;         {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; dx = b.X - a.X;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; dy = b.Y - a.Y;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; dist = Math.Sqrt(dx * dx + dy * dy);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (dist &amp;lt; _minDist)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   8:&lt;/SPAN&gt;             {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   9:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; ax = dx * _spring;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  10:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt; ay = dy * _spring;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  11:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  12:&lt;/SPAN&gt;                 a.VX += ax;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  13:&lt;/SPAN&gt;                 a.VY += ay;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  14:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  15:&lt;/SPAN&gt;                 b.VX -= ax;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  16:&lt;/SPAN&gt;                 b.VY -= ay;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  17:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  18:&lt;/SPAN&gt; Canvas.SetLeft(a, a.X);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  19:&lt;/SPAN&gt; Canvas.SetTop(a, a.Y);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  20:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  21:&lt;/SPAN&gt; Canvas.SetLeft(b, b.X);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  22:&lt;/SPAN&gt; Canvas.SetTop(b, b.Y);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  23:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  24:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  25:&lt;/SPAN&gt;             }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  26:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  27:&lt;/SPAN&gt; Canvas.SetLeft(a, a.X);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  28:&lt;/SPAN&gt; Canvas.SetTop(a, a.Y);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  29:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  30:&lt;/SPAN&gt; Canvas.SetLeft(b, b.X);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  31:&lt;/SPAN&gt; Canvas.SetTop(b, b.Y);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  32:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  33:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  34:&lt;/SPAN&gt;         }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  35:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  36:&lt;/SPAN&gt; VB:&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  37:&lt;/SPAN&gt; PrivateSub Spring(ByVal a As Particle, ByVal b As Particle)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  38:&lt;/SPAN&gt; Dim dx AsDouble = b.X - a.X&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  39:&lt;/SPAN&gt; Dim dy AsDouble = b.Y - a.Y&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  40:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  41:&lt;/SPAN&gt; Dim dist AsDouble = Math.Sqrt(dx * dx + dy * dy)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  42:&lt;/SPAN&gt; If dist &amp;lt; _minDist Then&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  43:&lt;/SPAN&gt; Dim ax AsDouble = dx * _spring&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  44:&lt;/SPAN&gt; Dim ay AsDouble = dy * _spring&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  45:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  46:&lt;/SPAN&gt;             a.VX += ax&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  47:&lt;/SPAN&gt;             a.VY += ay&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  48:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  49:&lt;/SPAN&gt;             b.VX -= ax&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  50:&lt;/SPAN&gt;             b.VY -= ay&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  51:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  52:&lt;/SPAN&gt;             Canvas.SetLeft(a, a.X)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  53:&lt;/SPAN&gt;             Canvas.SetTop(a, a.Y)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  54:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  55:&lt;/SPAN&gt;             Canvas.SetLeft(b, b.X)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  56:&lt;/SPAN&gt;             Canvas.SetTop(b, b.Y)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  57:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  58:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  59:&lt;/SPAN&gt; EndIf&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  60:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  61:&lt;/SPAN&gt;         Canvas.SetLeft(a, a.X)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  62:&lt;/SPAN&gt;         Canvas.SetTop(a, a.Y)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  63:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  64:&lt;/SPAN&gt;         Canvas.SetLeft(b, b.X)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  65:&lt;/SPAN&gt;         Canvas.SetTop(b, b.Y)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  66:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  67:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  68:&lt;/SPAN&gt; EndSub&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  69:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  70:&lt;/SPAN&gt; And the main animation loop looks like &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  71:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  72:&lt;/SPAN&gt; C#:&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  73:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; CompositionTarget_Rendering(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; sender, EventArgs e)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  74:&lt;/SPAN&gt;         {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  75:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;for&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt; i = 0; i &amp;lt; _numParticles; i++)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  76:&lt;/SPAN&gt;             {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  77:&lt;/SPAN&gt;                 _particles[i].X += _particles[i].VX;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  78:&lt;/SPAN&gt;                 _particles[i].Y += _particles[i].VY;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  79:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  80:&lt;/SPAN&gt; Particle p = _particles[i];&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  81:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  82:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (p.X &amp;gt;&lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.Width)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  83:&lt;/SPAN&gt;                 {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  84:&lt;/SPAN&gt;                     p.X = 0;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  85:&lt;/SPAN&gt;                 }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  86:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  87:&lt;/SPAN&gt; elseif (p.X &amp;lt; 0)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  88:&lt;/SPAN&gt;                 {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  89:&lt;/SPAN&gt;                     p.X = &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.Width;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  90:&lt;/SPAN&gt;                 }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  91:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  92:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (p.Y &amp;gt;&lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.Height)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  93:&lt;/SPAN&gt;                 {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  94:&lt;/SPAN&gt;                     p.Y = 0;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  95:&lt;/SPAN&gt;                 }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  96:&lt;/SPAN&gt; elseif (p.Y &amp;lt; 0)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  97:&lt;/SPAN&gt;                 {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  98:&lt;/SPAN&gt;                     p.Y = &lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;.Height;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  99:&lt;/SPAN&gt;                 }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 100:&lt;/SPAN&gt;             }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 101:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 102:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 103:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;for&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt; i = 0; i &amp;lt; _numParticles - 1; i++)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 104:&lt;/SPAN&gt;             {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 105:&lt;/SPAN&gt; var partA = _particles[i];&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 106:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;for&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt; j = i + 1; j &amp;lt; _numParticles; j++)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 107:&lt;/SPAN&gt;                 {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 108:&lt;/SPAN&gt; var partB = _particles[j];&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 109:&lt;/SPAN&gt;                     Spring(partA, partB);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 110:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 111:&lt;/SPAN&gt;                 }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 112:&lt;/SPAN&gt;             }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt; 113:&lt;/SPAN&gt;         }&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;VB&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; Sub CompositionTarget_Rendering(ByVal sender As System.Object, ByVal e As System.EventArgs)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt; For i AsInteger = 0 To _numParticles - 1&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt;             _particles(i).X += _particles(i).VX&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt;             _particles(i).Y += _particles(i).VY&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt; Dim p As Particle = _particles(i)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   8:&lt;/SPAN&gt; If p.X &amp;gt;Me.Width Then&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   9:&lt;/SPAN&gt;                 p.X = 0&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  10:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  11:&lt;/SPAN&gt; ElseIf p.X &amp;lt; 0 Then&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  12:&lt;/SPAN&gt;                 p.X = Me.Width&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  13:&lt;/SPAN&gt; EndIf&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  14:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  15:&lt;/SPAN&gt; If p.Y &amp;gt;Me.Height Then&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  16:&lt;/SPAN&gt;                 p.Y = 0&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  17:&lt;/SPAN&gt; ElseIf p.Y &amp;lt; 0 Then&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  18:&lt;/SPAN&gt;                 p.Y = Me.Height&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  19:&lt;/SPAN&gt; EndIf&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  20:&lt;/SPAN&gt; Next i&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  21:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  22:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  23:&lt;/SPAN&gt; For i AsInteger = 0 To _numParticles - 2&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  24:&lt;/SPAN&gt; Dim partA = _particles(i)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  25:&lt;/SPAN&gt; For j AsInteger = i + 1 To _numParticles - 1&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  26:&lt;/SPAN&gt; Dim partB = _particles(j)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  27:&lt;/SPAN&gt;                 Spring(partA, partB)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  28:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  29:&lt;/SPAN&gt; Next j&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  30:&lt;/SPAN&gt; Next&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  31:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  32:&lt;/SPAN&gt; EndSub&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  33:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4&gt;Supporting Multiple Monitors&lt;/H4&gt;
&lt;P&gt;After the animation was rendering correctly the next step was getting it to run on multiple monitors. To make this happen I wrote some code in the application entry point to get a handle to the active screens. The System.Windows.Forms namespace has a Screen class which contains a collection of screens and their attributes including working area, width, and height. By looping through the screen collection I measure the screen boundaries and set the window size dynamically based on the available screen real estate.&lt;/P&gt;
&lt;P&gt;C#&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; Application_Startup(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; sender, StartupEventArgs e)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt;         {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt; Window1 _window = &lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt;             System.Windows.Forms.Cursor.Hide();&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   8:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;foreach&lt;/SPAN&gt; (Screen screen inScreen.AllScreens)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   9:&lt;/SPAN&gt;             {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  10:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (screen.Primary)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  11:&lt;/SPAN&gt;                 {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  12:&lt;/SPAN&gt; Rectangle location = screen.Bounds;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  13:&lt;/SPAN&gt;                     _window = newWindow1(location.Height, location.Width);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  14:&lt;/SPAN&gt;                     _window.Width = location.Width;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  15:&lt;/SPAN&gt;                     _window.Height = location.Height;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  16:&lt;/SPAN&gt;                     _window.Left = 0;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  17:&lt;/SPAN&gt;                     _window.Top = 0;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  18:&lt;/SPAN&gt;                     _window.WindowState = WindowState.Maximized;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  19:&lt;/SPAN&gt;                     _window.Show();&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  20:&lt;/SPAN&gt;                 }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  21:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  22:&lt;/SPAN&gt; elseif (!screen.Primary)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  23:&lt;/SPAN&gt;                 {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  24:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  25:&lt;/SPAN&gt; Rectangle location = screen.Bounds;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  26:&lt;/SPAN&gt;                     _window = newWindow1(location.Height, location.Width);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  27:&lt;/SPAN&gt;                     _window.Left = screen.WorkingArea.Left;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  28:&lt;/SPAN&gt;                     _window.Top = screen.WorkingArea.Top;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  29:&lt;/SPAN&gt;                     _window.Width = location.Width;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  30:&lt;/SPAN&gt;                     _window.Height = location.Height;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  31:&lt;/SPAN&gt;                     _window.Show();&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  32:&lt;/SPAN&gt;                 }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  33:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  34:&lt;/SPAN&gt;             }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  35:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  36:&lt;/SPAN&gt;         }&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;VB&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt; void Application_Startup(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; sender, StartupEventArgs e)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt;         {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt; Window1 _window = null;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt;             System.Windows.Forms.Cursor.Hide();&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   8:&lt;/SPAN&gt; foreach (Screen screen inScreen.AllScreens)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   9:&lt;/SPAN&gt;             {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  10:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (screen.Primary)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  11:&lt;/SPAN&gt;                 {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  12:&lt;/SPAN&gt; Rectangle location = screen.Bounds;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  13:&lt;/SPAN&gt;                     _window = newWindow1(location.Height, location.Width);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  14:&lt;/SPAN&gt;                     _window.Width = location.Width;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  15:&lt;/SPAN&gt;                     _window.Height = location.Height;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  16:&lt;/SPAN&gt;                     _window.Left = 0;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  17:&lt;/SPAN&gt;                     _window.Top = 0;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  18:&lt;/SPAN&gt;                     _window.WindowState = WindowState.Maximized;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  19:&lt;/SPAN&gt;                     _window.Show();&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  20:&lt;/SPAN&gt;                 }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  21:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  22:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;elseif&lt;/SPAN&gt; (!screen.Primary)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  23:&lt;/SPAN&gt;                 {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  24:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  25:&lt;/SPAN&gt; Rectangle location = screen.Bounds;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  26:&lt;/SPAN&gt;                     _window = newWindow1(location.Height, location.Width);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  27:&lt;/SPAN&gt;                     _window.Left = screen.WorkingArea.Left;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  28:&lt;/SPAN&gt;                     _window.Top = screen.WorkingArea.Top;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  29:&lt;/SPAN&gt;                     _window.Width = location.Width;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  30:&lt;/SPAN&gt;                     _window.Height = location.Height;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  31:&lt;/SPAN&gt;                     _window.Show();&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  32:&lt;/SPAN&gt;                 }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  33:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  34:&lt;/SPAN&gt;             }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  35:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  36:&lt;/SPAN&gt;         }&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;H4&gt;&lt;/H4&gt;
&lt;H4&gt;&lt;/H4&gt;
&lt;H4&gt;Making it a Screen Saver&lt;/H4&gt;
&lt;P&gt;The last step to this application is making it a screen saver. By implementing mouse and keyboard event handlers to shut down the application we essentially can mimic the interaction of a screen saver. &lt;/P&gt;
&lt;P&gt;C#&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; MouseMove += newMouseEventHandler(Window2_MouseMove);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt;   MouseDown += newMouseButtonEventHandler(Window2_MouseDown);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt;   KeyDown += newKeyEventHandler(Window2_KeyDown);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; Window2_KeyDown(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; sender, KeyEventArgs e)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt;         {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt; Application.Current.Shutdown();&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt;         }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   8:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   9:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; Window2_MouseDown(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; sender, MouseButtonEventArgs e)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  10:&lt;/SPAN&gt;         {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  11:&lt;/SPAN&gt; Application.Current.Shutdown();&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  12:&lt;/SPAN&gt;         }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  13:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  14:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; Window2_MouseMove(&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt; sender, MouseEventArgs e)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  15:&lt;/SPAN&gt;         {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  16:&lt;/SPAN&gt; Point currentPosition = e.MouseDevice.GetPosition(&lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  17:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  18:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (!isActive)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  19:&lt;/SPAN&gt;             {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  20:&lt;/SPAN&gt;                 mousePosition = currentPosition;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  21:&lt;/SPAN&gt;                 isActive = &lt;SPAN style="COLOR: #0000ff"&gt;true&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  22:&lt;/SPAN&gt;             }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  23:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;else&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  24:&lt;/SPAN&gt;             {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  25:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  26:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; ((Math.Abs(mousePosition.X - currentPosition.X) &amp;gt; 10) ||&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  27:&lt;/SPAN&gt;                     (Math.Abs(mousePosition.Y - currentPosition.Y) &amp;gt; 10))&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  28:&lt;/SPAN&gt;                 {&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  29:&lt;/SPAN&gt; Application.Current.Shutdown();&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  30:&lt;/SPAN&gt;                 }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  31:&lt;/SPAN&gt;             }&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  32:&lt;/SPAN&gt;         }&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;VB&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: gray 1px solid; BORDER-LEFT: gray 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: gray 1px solid; CURSOR: text; BORDER-RIGHT: gray 1px solid; PADDING-TOP: 4px"&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   1:&lt;/SPAN&gt; AddHandlerMe.MouseMove, &lt;SPAN style="COLOR: #0000ff"&gt;AddressOf&lt;/SPAN&gt; Window_MouseMove&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   2:&lt;/SPAN&gt; AddHandlerMe.MouseDown, &lt;SPAN style="COLOR: #0000ff"&gt;AddressOf&lt;/SPAN&gt; Window_MouseDown&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   3:&lt;/SPAN&gt; AddHandlerMe.KeyDown, &lt;SPAN style="COLOR: #0000ff"&gt;AddressOf&lt;/SPAN&gt; Window_KeyDown&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   4:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   5:&lt;/SPAN&gt; PrivateSub Window_KeyDown(&lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; sender AsObject, &lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; KeyEventArgs)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   6:&lt;/SPAN&gt;         Application.Current.Shutdown()&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   7:&lt;/SPAN&gt; EndSub&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   8:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;   9:&lt;/SPAN&gt; PrivateSub Window_MouseDown(&lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; sender AsObject, &lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; MouseButtonEventArgs)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  10:&lt;/SPAN&gt;         Application.Current.Shutdown()&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  11:&lt;/SPAN&gt; EndSub&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  12:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  13:&lt;/SPAN&gt; PrivateSub Window_MouseMove(&lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; sender AsObject, &lt;SPAN style="COLOR: #0000ff"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; MouseEventArgs)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  14:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Dim&lt;/SPAN&gt; currentPosition &lt;SPAN style="COLOR: #0000ff"&gt;As&lt;/SPAN&gt; Point = e.MouseDevice.GetPosition(&lt;SPAN style="COLOR: #0000ff"&gt;Me&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  15:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;If&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #0000ff"&gt;Not&lt;/SPAN&gt; isActive) &lt;SPAN style="COLOR: #0000ff"&gt;Then&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  16:&lt;/SPAN&gt;             mousePosition = currentPosition&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  17:&lt;/SPAN&gt;             isActive = &lt;SPAN style="COLOR: #0000ff"&gt;True&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  18:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Else&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  19:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;If&lt;/SPAN&gt; (Math.Abs(mousePosition.X - currentPosition.X) &amp;gt; 10) &lt;SPAN style="COLOR: #0000ff"&gt;OrElse&lt;/SPAN&gt; (Math.Abs(mousePosition.Y - currentPosition.Y) &amp;gt; 10) &lt;SPAN style="COLOR: #0000ff"&gt;Then&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  20:&lt;/SPAN&gt;                 Application.Current.Shutdown()&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  21:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;EndIf&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  22:&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;EndIf&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  23:&lt;/SPAN&gt; EndSub&lt;/PRE&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #606060"&gt;  24:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Lastly, simply set the build configuration to Release mode and build it. In the output bin-&amp;gt;Release directory find the built executable. Rename the file extension from .exe to .scr then right click and choose &lt;B&gt;Install&lt;/B&gt; from the context menu.&lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image008.jpg" mce_href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image008.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image008 border=0 alt=clip_image008 src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image008_thumb.jpg" width=423 height=319 mce_src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image008_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image010.jpg" mce_href="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image010.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image010 border=0 alt=clip_image010 src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image010_thumb.jpg" width=413 height=217 mce_src="http://www.coding4fun.net/images/WPFCustomScreenSaverArt_B511/clip_image010_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;That’s it! &lt;/P&gt;
&lt;H4&gt;Challenges to You&lt;/H4&gt;
&lt;P&gt;One of the interesting things about Office Communicator Server is that it comes with an SDK to build your own custom Unified Communications applications.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I would love to see the presence bubbles actually hooked up to real users’ status, and maybe a cool animation to indicate when a users’ status is changed. &lt;/LI&gt;
&lt;LI&gt;Create a config file to let the user specify his/her own images and tweak other settings like speed and velocity.&amp;nbsp; &lt;/LI&gt;&lt;/UL&gt;
&lt;H4&gt;Conclusion&lt;/H4&gt;
&lt;P&gt;This was a great opportunity to brush up on my physics skills and play with some of the animation possibilities in WPF. This application is also a great example of alternative data visualization. Sometimes I get tired of seeing everything in tabular form and I think that “presence art” is a great example of Art + Code (aesthetically pleasing and functional). I hope you enjoy it.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8626294" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows+miscellaneous/default.aspx">windows miscellaneous</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category></item><item><title>A Better Startup Experience</title><link>http://blogs.msdn.com/coding4fun/archive/2008/03/17/8290797.aspx</link><pubDate>Mon, 17 Mar 2008 18:55:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8290797</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>16</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/8290797.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=8290797</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=8290797</wfw:comment><description>&lt;span id="c4fmetadata"&gt;   &lt;table cellspacing="0" cellpadding="1" width="100%" border="0"&gt;&lt;tbody&gt;       &lt;tr class="entry_overview"&gt;         &lt;td width="50"&gt;&lt;a href="http://www.coding4fun.net/images/ABetterStartupExperience_D7BC/flag.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="52" alt="flag" src="http://www.coding4fun.net/images/ABetterStartupExperience_D7BC/flag_thumb.png" width="52" border="0" /&gt;&lt;/a&gt; &lt;/td&gt;          &lt;td&gt;&lt;span class="entry_description"&gt;Does Windows take too long starting up before you can get to work?&amp;#160; Wouldn't it better if things could startup at a lower priority?&amp;#160; Learn how to launch processes, use performance counters, monitor files, and run tasks in the background.&lt;/span&gt;&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td colspan="2"&gt;           &lt;div class="entry_author"&gt;Arian Kulp&lt;/div&gt;            &lt;div class="entry_company"&gt;&lt;a href="http://www.ariankulp.com"&gt;Arian's Blog&lt;/a&gt;&lt;/div&gt;            &lt;br /&gt;            &lt;div class="entry_details"&gt;&lt;b&gt;Difficulty: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Intermediate&lt;/span&gt;&lt;/div&gt;            &lt;div class="entry_details"&gt;&lt;b&gt;Time Required:&lt;/b&gt; &lt;span class="entry_details_input"&gt;1-3 hours&lt;/span&gt;&lt;/div&gt;            &lt;div class="entry_details"&gt;&lt;b&gt;Cost: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Free&lt;/span&gt;&lt;/div&gt;            &lt;div class="entry_details"&gt;&lt;b&gt;Software: &lt;/b&gt;&lt;span class="entry_details_input"&gt;&lt;a href="http://msdn.com/express/"&gt;Visual Basic or Visual C# Express Editions&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;            &lt;div class="entry_details"&gt;&lt;span class="entry_details_input"&gt;&lt;b&gt;Hardware: &lt;/b&gt;None&lt;/span&gt;&lt;/div&gt;            &lt;div class="entry_details"&gt;&lt;b&gt;Download: &lt;/b&gt;              &lt;ul&gt;               &lt;li&gt;&lt;a href="http://channel9.msdn.com/ShowPost.aspx?PostID=390525"&gt;C# Download&lt;/a&gt; &lt;/li&gt;                &lt;li&gt;&lt;a href="http://channel9.msdn.com/ShowPost.aspx?PostID=390526"&gt;VB Download&lt;/a&gt; &lt;/li&gt;             &lt;/ul&gt;           &lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/span&gt;  &lt;p&gt;&lt;a href="http://www.peacelovecode.com/code/silverlight/puzzle/1.0.0.0/surfacePuzzleDemoVB.zip"&gt;&lt;/a&gt;&lt;/p&gt; &lt;style type="text/css"&gt;










.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
	overflow: auto;
}
.csharpcode pre { margin: 0em;  }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;h2&gt;Introduction&lt;/h2&gt;  &lt;p&gt;Starting up Windows usually takes longer than I'd like it to.&amp;#160; It seems like the system is churning away for ages.&amp;#160; I've often thought that it would make more sense to wait as each item starts up before starting the next item.&amp;#160; The problem is Windows has no idea how long an application takes to initialize itself.&amp;#160; After launching it, it's just another running process.&amp;#160; It would be nice to be able to configure a delay after each application so it can perform its potentially expensive startup before another application starts.&amp;#160; I decided to put this idea into action.&lt;/p&gt;  &lt;p&gt;This application requires Visual Studio 2005 Express Editions (C# or Visual Basic) or higher.&amp;#160; This will be my last Coding 4 Fun article targeting Visual Studio 2005.&amp;#160; If you haven't downloaded a Visual Studio 2008 Express Edition yet, definitely check them out.&amp;#160; The upgrade is very much worth it!&lt;/p&gt;  &lt;h2&gt;Starting Up&lt;/h2&gt;  &lt;p&gt;The basic idea of the program is very simple: launch each startup item with a configurable delay between each one.&amp;#160; Beyond a simple delay though, it might be good to see how active the system is.&amp;#160; If the CPU is working hard, maybe it would be good to wait until it settles down before launching something else.&lt;/p&gt;  &lt;p&gt;In case you've never looked closely, there are a few ways that Windows knows what to startup with the system.&amp;#160; The three most common ways to start things are by using the Registry, the Startup folder, or by configuring services.&amp;#160; The Registry and Startup folder methods are pretty similar.&amp;#160; Of course Services are background processes that run even if a user isn't logged in.&lt;/p&gt;  &lt;p&gt;Once a user logs in, the Registry and Startup folders take effect.&amp;#160; The system Registry is a collection of keys, values, and data that applications (and Windows itself) use for configuration.&amp;#160; One such use is to contain a list of programs to launch with Windows.&amp;#160; There is a system-level and user-level list.&amp;#160; System-level programs are started up for every user that logs in, while user-level programs are started only for the specific user.&lt;/p&gt;  &lt;p&gt;The Startup folder works the same way.&amp;#160; As part of each user's profile folder there is a Startup folder.&amp;#160; There is also one at the Default User level.&amp;#160; These folders contain shortcuts to applications.&amp;#160; Whenever a user logs in, all of these shortcuts are launched.&amp;#160; We just need to take over this process.&amp;#160; To do this though, we'll need to take the shortcuts out of the system Startup folders.&lt;/p&gt;  &lt;h2&gt;The Basics&lt;/h2&gt;  &lt;p&gt;The Startup Optimizer works by scanning the user's &lt;strong&gt;Startup &lt;/strong&gt;folder looking for shortcuts.&amp;#160; As a new shortcut is found, a &lt;strong&gt;StartupEntry &lt;/strong&gt;object is created.&amp;#160; This object holds the filename, a display name and a few flags.&amp;#160; The key flag is &lt;strong&gt;Managed&lt;/strong&gt;.&amp;#160; An object with &lt;strong&gt;Managed &lt;/strong&gt;set to &lt;strong&gt;True&lt;/strong&gt; is launched by the application and moved to a new &lt;strong&gt;ManagedStartup &lt;/strong&gt;folder in the user's profile.&lt;/p&gt;  &lt;p&gt;When a file or shortcut is detected in the &lt;strong&gt;Startup &lt;/strong&gt;folder, a popup will occur to let a user decide if the program should manage it or not.&amp;#160; If so, it moves the shortcut to its &lt;strong&gt;ManagedStartup &lt;/strong&gt;folder.&amp;#160; If not, it leaves it alone but sets the &lt;strong&gt;Managed &lt;/strong&gt;flag to &lt;strong&gt;False&lt;/strong&gt;.&amp;#160; Next time it notices the same shortcut, it will just now to ignore it and let Windows handle it.&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://www.coding4fun.net/images/ABetterStartupExperience_D7BC/image.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="160" alt="Startup Item Encountered" src="http://www.coding4fun.net/images/ABetterStartupExperience_D7BC/image_thumb.png" width="385" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="center"&gt;&lt;em&gt;Figure 1: The dialog shown when a startup item is found&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;If you click the button to show the advanced options, you can specify a display name, the low CPU flag, and how to long to wait before launching the next application.&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://www.coding4fun.net/images/ABetterStartupExperience_D7BC/image_3.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="256" alt="Startup Item Encountered - Advanced Settings" src="http://www.coding4fun.net/images/ABetterStartupExperience_D7BC/image_thumb_3.png" width="385" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="center"&gt;&lt;em&gt;Figure 2: The dialog with advanced settings shown&lt;/em&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Notice the icon.&amp;#160; There's no included support for extracting the icon from a file, but you can use the Win32 &lt;strong&gt;SHGetFileInfo&lt;/strong&gt; function in the &lt;strong&gt;shell32.dll&lt;/strong&gt; library like so:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Visual Basic&lt;/strong&gt;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&amp;lt;DllImport(&lt;span class="str"&gt;&amp;quot;shell32.dll&amp;quot;&lt;/span&gt;)&amp;gt; _
&lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Shared&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; SHGetFileInfo(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; pszPath &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; dwFileAttributes &lt;span class="kwrd"&gt;As&lt;/span&gt; UInteger, &lt;span class="kwrd"&gt;ByRef&lt;/span&gt; psfi &lt;span class="kwrd"&gt;As&lt;/span&gt; SHFILEINFO, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; cbSizeFileInfo &lt;span class="kwrd"&gt;As&lt;/span&gt; UInteger, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; uFlags &lt;span class="kwrd"&gt;As&lt;/span&gt; UInteger) &lt;span class="kwrd"&gt;As&lt;/span&gt; IntPtr
&lt;span class="kwrd"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Visual C#&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[DllImport(&lt;span class="str"&gt;&amp;quot;shell32.dll&amp;quot;&lt;/span&gt;)] 
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; IntPtr SHGetFileInfo(&lt;span class="kwrd"&gt;string&lt;/span&gt; pszPath, &lt;span class="kwrd"&gt;uint&lt;/span&gt; dwFileAttributes,
       &lt;span class="kwrd"&gt;ref&lt;/span&gt; SHFILEINFO psfi, &lt;span class="kwrd"&gt;uint&lt;/span&gt; cbSizeFileInfo, &lt;span class="kwrd"&gt;uint&lt;/span&gt; uFlags);&lt;/pre&gt;

&lt;p&gt;All &lt;strong&gt;StartupEntry&lt;/strong&gt; objects are added to the &lt;strong&gt;StartupEntryList&lt;/strong&gt; collection which is a subclass of &lt;strong&gt;List&amp;lt;StartupEntry&amp;gt;&lt;/strong&gt;.&amp;#160; Creating a subclass like this allows you to add helper methods for finding or removing objects or other useful functions.&amp;#160; This collection is what is saved to disk to retain the properties of each item.&amp;#160; The basic .NET binary serialization method is used due to its simplicity in code.&amp;#160; Note that any class to be serialized must be decorated with the &lt;strong&gt;Serializable &lt;/strong&gt;attribute.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Visual Basic&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Shared&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; FromDisk() &lt;span class="kwrd"&gt;As&lt;/span&gt; StartupEntryList
    &lt;span class="kwrd"&gt;If&lt;/span&gt; &lt;span class="kwrd"&gt;Not&lt;/span&gt; File.Exists(&lt;span class="str"&gt;&amp;quot;StartupEntryList.ser&amp;quot;&lt;/span&gt;) &lt;span class="kwrd"&gt;Then&lt;/span&gt;
        &lt;span class="kwrd"&gt;Return&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; StartupEntryList()
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;

    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; c &lt;span class="kwrd"&gt;As&lt;/span&gt; StartupEntryList
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; s &lt;span class="kwrd"&gt;As&lt;/span&gt; Stream = File.Open(&lt;span class="str"&gt;&amp;quot;StartupEntryList.ser&amp;quot;&lt;/span&gt;, FileMode.Open)
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; b &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; BinaryFormatter()
    c = &lt;span class="kwrd"&gt;DirectCast&lt;/span&gt;(b.Deserialize(s), StartupEntryList)

    s.Close()

    &lt;span class="kwrd"&gt;Return&lt;/span&gt; c
&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt;

&lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; SaveToDisk()
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; s &lt;span class="kwrd"&gt;As&lt;/span&gt; Stream = File.Open(&lt;span class="str"&gt;&amp;quot;StartupEntryList.ser&amp;quot;&lt;/span&gt;, FileMode.Create)
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; b &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; BinaryFormatter()
    b.Serialize(s, &lt;span class="kwrd"&gt;Me&lt;/span&gt;)
    s.Close()
&lt;span class="kwrd"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Visual C#&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; StartupEntryList FromDisk() 
{ 
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!File.Exists(&lt;span class="str"&gt;&amp;quot;StartupEntryList.ser&amp;quot;&lt;/span&gt;)) &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; StartupEntryList(); 

    StartupEntryList c; 
    Stream s = File.Open(&lt;span class="str"&gt;&amp;quot;StartupEntryList.ser&amp;quot;&lt;/span&gt;, FileMode.Open); 
    BinaryFormatter b = &lt;span class="kwrd"&gt;new&lt;/span&gt; BinaryFormatter(); 
    c = (StartupEntryList)b.Deserialize(s); 

    s.Close(); 

    &lt;span class="kwrd"&gt;return&lt;/span&gt; c; 
} 

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SaveToDisk() 
{ 
    Stream s = File.Open(&lt;span class="str"&gt;&amp;quot;StartupEntryList.ser&amp;quot;&lt;/span&gt;, FileMode.Create); 
    BinaryFormatter b = &lt;span class="kwrd"&gt;new&lt;/span&gt; BinaryFormatter(); 
    b.Serialize(s, &lt;span class="kwrd"&gt;this&lt;/span&gt;); 
    s.Close(); 
} &lt;/pre&gt;

&lt;p&gt;Notice how the &lt;strong&gt;FromDisk()&lt;/strong&gt; method is static.&amp;#160; This works as a factory method on the &lt;strong&gt;StartupEntryList &lt;/strong&gt;class itself.&amp;#160; Subclassing that simple generic list has made it easy to encapsulate all related functionality into the same place.&lt;/p&gt;

&lt;h2&gt;Working in the Background&lt;/h2&gt;

&lt;h2&gt;&lt;/h2&gt;

&lt;h2&gt;&lt;/h2&gt;

&lt;p&gt;Of course at some point the application needs to perform its startup magic.&amp;#160; Obviously the main work is just launching each shortcut.&amp;#160; This is done using the &lt;strong&gt;Process.Start()&lt;/strong&gt; method in the &lt;strong&gt;System.Diagnostics&lt;/strong&gt; namespace.&amp;#160; If we were just launching the shortcuts one after another, it would be over quickly, but it would defeat the purpose of the program!&amp;#160; With delays and waiting for the CPU to go idle, this startup process could potentially take a few minutes.&amp;#160; This is important because it means that we can't just start the sequence in the &lt;strong&gt;Form_Load &lt;/strong&gt;event handler on startup.&amp;#160; The application would be unresponsive and there would be no way to abort.&lt;/p&gt;

&lt;p&gt;Enter the &lt;strong&gt;BackgroundWorker &lt;/strong&gt;class.&amp;#160; I've used this in articles before and they make it really easy to run things in the background.&amp;#160; It's much easier than creating threads -- especially if you need to update the user interface.&amp;#160; You get to avoid the &lt;strong&gt;Invoke&lt;/strong&gt; calls that are otherwise required and you even get Form Designer support.&lt;/p&gt;

&lt;p&gt;Similar to the &lt;strong&gt;StartupEntryList&lt;/strong&gt;, subclassing is a good idea in order to keep things nicely encapsulated.&amp;#160; There's actually only one method that matters in this case: the event handler for the &lt;strong&gt;DoWork &lt;/strong&gt;event.&amp;#160; This is where work is done.&amp;#160; You never call it directly (it's marked &lt;strong&gt;private&lt;/strong&gt;) -- it's invoked when the &lt;strong&gt;RunWorkerAsync &lt;/strong&gt;method is called.&amp;#160; Anything that happens in the event handler is automatically on a thread other than the UI thread.&amp;#160; It couldn't be simpler!&amp;#160; In order to cause the UI to be updated (you can't ever directly reference it due to cross-threading concerns) call the &lt;strong&gt;ReportProgress &lt;/strong&gt;method.&amp;#160; Periodically check the &lt;strong&gt;CancellationPending &lt;/strong&gt;flag to see if you need to exit.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;StartupBackgroundWorker_DoWork &lt;/strong&gt;event handler method basically just iterates over the entries that have &lt;strong&gt;Managed &lt;/strong&gt;set to true, waits for an idle CPU if necessary, and waits the specified delay time if set before moving to the next one.&amp;#160; At several points it checks to see if a cancellation has been requested.&amp;#160; The best thing though, is regardless of how long the sequence takes the UI will run smoothly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Visual Basic&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;    Private Sub StartupBackgroundWorker_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
        Dim entries As List(Of StartupEntry) = TryCast(e.Argument, List(Of StartupEntry))

        If entries Is Nothing OrElse entries.Count = 0 Then
            e.Cancel = True
            Throw New Exception(&lt;span class="str"&gt;&amp;quot;No entries passed in&amp;quot;&lt;/span&gt;)
        End If

        Try
            &lt;span class="str"&gt;' Don'&lt;/span&gt;t bother &lt;span class="kwrd"&gt;if&lt;/span&gt; there aren&lt;span class="str"&gt;'t any entries!
            If entries.Count &amp;gt; 0 Then
                Me.ReportProgress(0, &amp;quot;Startup Optimizer will begin in five seconds.  Click to cancel.&amp;quot;)
                Dim i As Integer = 0
                While i &amp;lt; 5 AndAlso Not Me.CancellationPending
                    Thread.Sleep(1000)
                    i += 1
                End While

                If Me.CancellationPending Then
                    e.Cancel = True
                    Return
                End If
            End If

            systemIdleComponent1.Enabled = True

            '&lt;/span&gt; Process entries to perform startup
            For Each entry As StartupEntry In entries
                If entry.Managed Then
                    If entry.WaitForLowCPU Then
                        Me.ReportProgress(0, &lt;span class="str"&gt;&amp;quot;Waiting for idle CPU to launch: &amp;quot;&lt;/span&gt; + entry.DisplayName)

                        &lt;span class="str"&gt;' CPU wait routine...
                        '&lt;/span&gt; TODO: Give up &lt;span class="kwrd"&gt;if&lt;/span&gt; we never go idle?  This would be the place..!
                        While Not systemIdleComponent1.WaitForIdle(1000)
                            If Me.CancellationPending Then
                                e.Cancel = True
                                Return
                            End If
                        End While
                    End If

                    Me.ReportProgress(0, &lt;span class="str"&gt;&amp;quot;Starting: &amp;quot;&lt;/span&gt; + entry.DisplayName)

                    &lt;span class="str"&gt;' Don'&lt;/span&gt;t actually start &lt;span class="kwrd"&gt;if&lt;/span&gt; we are debugging
                    If Not Debugger.IsAttached Then
                        Process.Start(Path.Combine(My.Settings.ManagedStartupPath, entry.FileName))
                    Else
                        &lt;span class="str"&gt;'SIMULATE STARTUP DELAY
                        Thread.Sleep(2000)
                    End If

                    Me.ReportProgress(0, &amp;quot;Started: &amp;quot; + entry.DisplayName)

                    If entry.DelayTime &amp;gt; 0 Then
                        Me.ReportProgress(0, &amp;quot;Waiting: &amp;quot; + entry.DelayTime + &amp;quot; seconds until next item&amp;quot;)
                        For x As Integer = 0 To entry.DelayTime - 1

                            '&lt;/span&gt; Wait the number of seconds but check &lt;span class="kwrd"&gt;for&lt;/span&gt; cancel flag each second
                            If Me.CancellationPending Then
                                e.Cancel = True
                                Return
                            End If

                            Thread.Sleep(1000)
                        Next
                    End If
                End If
            Next
        Catch
            e.Cancel = True
        Finally
            systemIdleComponent1.Enabled = False
        End Try

    End Sub&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Visual C#&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; StartupBackgroundWorker_DoWork(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, DoWorkEventArgs e)
{
    List&amp;lt;StartupEntry&amp;gt; entries = e.Argument &lt;span class="kwrd"&gt;as&lt;/span&gt; List&amp;lt;StartupEntry&amp;gt;;

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (entries == &lt;span class="kwrd"&gt;null&lt;/span&gt; || entries.Count == 0 )
    {
        e.Cancel = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
        &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Exception(&lt;span class="str"&gt;&amp;quot;No entries passed in&amp;quot;&lt;/span&gt;);
    }

    &lt;span class="kwrd"&gt;try&lt;/span&gt;
    {
        &lt;span class="rem"&gt;// Don't bother if there aren't any entries!&lt;/span&gt;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (entries.Count &amp;gt; 0)
        {
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.ReportProgress(0, &lt;span class="str"&gt;&amp;quot;Startup Optimizer will begin in five seconds.  Click to cancel.&amp;quot;&lt;/span&gt;);
            &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 5 &amp;amp;&amp;amp; !&lt;span class="kwrd"&gt;this&lt;/span&gt;.CancellationPending; i++)
                Thread.Sleep(1000);

            &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;.CancellationPending)
            {
                e.Cancel = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
                &lt;span class="kwrd"&gt;return&lt;/span&gt;;
            }
        }

        systemIdleComponent1.Enabled = &lt;span class="kwrd"&gt;true&lt;/span&gt;;

        &lt;span class="rem"&gt;// Process entries to perform startup&lt;/span&gt;
        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (StartupEntry entry &lt;span class="kwrd"&gt;in&lt;/span&gt; entries)
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (entry.Managed)
            {
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (entry.WaitForLowCPU)
                {
                    &lt;span class="kwrd"&gt;this&lt;/span&gt;.ReportProgress(0, &lt;span class="str"&gt;&amp;quot;Waiting for idle CPU to launch: &amp;quot;&lt;/span&gt; + entry.DisplayName);

                    &lt;span class="rem"&gt;// CPU wait routine...&lt;/span&gt;
                    &lt;span class="rem"&gt;// TODO: Give up if we never go idle?  This would be the place..!&lt;/span&gt;
                    &lt;span class="kwrd"&gt;while&lt;/span&gt;( !systemIdleComponent1.WaitForIdle(1000) )
                    {
                        &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;.CancellationPending)
                        {
                            e.Cancel = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
                            &lt;span class="kwrd"&gt;return&lt;/span&gt;;
                        }
                    }
                }

                &lt;span class="kwrd"&gt;this&lt;/span&gt;.ReportProgress(0, &lt;span class="str"&gt;&amp;quot;Starting: &amp;quot;&lt;/span&gt; + entry.DisplayName);

                &lt;span class="rem"&gt;// Don't actually start if we are debugging&lt;/span&gt;
                &lt;span class="kwrd"&gt;if&lt;/span&gt;( !Debugger.IsAttached)
                    Process.Start(Path.Combine(Properties.Settings.Default.ManagedStartupPath, entry.FileName));
                &lt;span class="kwrd"&gt;else&lt;/span&gt;
                    Thread.Sleep(2000); &lt;span class="rem"&gt;//SIMULATE STARTUP DELAY&lt;/span&gt;

                &lt;span class="kwrd"&gt;this&lt;/span&gt;.ReportProgress(0, &lt;span class="str"&gt;&amp;quot;Started: &amp;quot;&lt;/span&gt; + entry.DisplayName);

                &lt;span class="kwrd"&gt;if&lt;/span&gt; (entry.DelayTime &amp;gt; 0)
                {
                    &lt;span class="kwrd"&gt;this&lt;/span&gt;.ReportProgress(0, &lt;span class="str"&gt;&amp;quot;Waiting: &amp;quot;&lt;/span&gt; + entry.DelayTime + &lt;span class="str"&gt;&amp;quot; seconds until next item&amp;quot;&lt;/span&gt;);

                    &lt;span class="rem"&gt;// Wait the number of seconds but check for cancel flag each second&lt;/span&gt;
                    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; x = 0; x &amp;lt; entry.DelayTime; x++)
                    {
                        &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;.CancellationPending)
                        {
                            e.Cancel = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
                            &lt;span class="kwrd"&gt;return&lt;/span&gt;;
                        }

                        Thread.Sleep(1000);
                    }
                }
            }
        }
    }
    &lt;span class="kwrd"&gt;catch&lt;/span&gt;
    {
        e.Cancel = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
    }
    &lt;span class="kwrd"&gt;finally&lt;/span&gt;
    {
        systemIdleComponent1.Enabled = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
    }

}&lt;/pre&gt;

&lt;p&gt;There are a few things to callout in this block.&amp;#160; I have a few sanity checks in there to be sure that the list isn't NULL or empty.&amp;#160; Defensive programming is always a good idea!&amp;#160; Notice also that I have pauses built in with the &lt;strong&gt;Thread.Sleep() &lt;/strong&gt;command.&amp;#160; Where it would be convenient to pause for several seconds, it would render the thread unresponsive if a cancellation was requested.&amp;#160; Note that cancellation is completely passive.&amp;#160; The framework doesn't ever abort your &lt;strong&gt;BackgroundWorker&lt;/strong&gt;.&amp;#160; It's up to your code to catch it if cancellation is requested.&amp;#160; So for pauses, I wait a second, check the flag, and repeat for the number of seconds.&amp;#160; The code is slightly bulky but it works well.&lt;/p&gt;

&lt;p&gt;Notice also how I don't launch the startup applications if &lt;strong&gt;System.Diagnostics.Debugger.IsAttached &lt;/strong&gt;is true.&amp;#160; When I'm troubleshooting/testing, I don't really want the applications launching every time!&amp;#160; It's a simple check to see if the application is currently being debugged (as in Visual Studio).&lt;/p&gt;

&lt;h2&gt;Detecting Idleness&lt;/h2&gt;

&lt;p&gt;In addition to the simple time-based delays, I also wanted the option to wait for the system to be idle before launching applications.&amp;#160; There's no direct way to see this though, so I created the &lt;strong&gt;SystemIdleComponent&lt;/strong&gt;.&amp;#160; This is completely modular and could be plugged into other applications easily.&amp;#160; It all comes down to system Performance Counters.&amp;#160; If you've never worked with these before, don't let them intimidate you.&amp;#160; They're actually very easy to work with.&amp;#160; From the Visual Studio Toolbox you can easily drag a counter and set its properties (category, counter,and instance), but unfortunately there's no support for events when the value changes.&amp;#160; A pretty big deal I think!&lt;/p&gt;

&lt;p&gt;My component builds on the &lt;strong&gt;PerformanceCounter &lt;/strong&gt;object and creates a &lt;strong&gt;System.Threading.Timer &lt;/strong&gt;object behind the scenes to monitor the state of the counter periodically.&amp;#160; If a change is measured and it falls outside of the tolerance limits, it raises an event.&amp;#160; It also raises an event when it returns to the tolerance.&amp;#160; This allows you to receive an event both when the system becomes idle and when it returns to non-idle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Visual Basic&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; timerCpu_Tick(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; state &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;)
        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; currentValue &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt; = 100 - &lt;span class="kwrd"&gt;CInt&lt;/span&gt;(performanceCounterProcessorIdle.NextValue())

        &lt;span class="rem"&gt;' If we are below the threshold, start counting...&lt;/span&gt;
        &lt;span class="kwrd"&gt;If&lt;/span&gt; currentValue &amp;lt;= _thresholdIdlePercent &lt;span class="kwrd"&gt;Then&lt;/span&gt;
            idleTimer.Start()
        &lt;span class="kwrd"&gt;Else&lt;/span&gt;
            idleTimer.[&lt;span class="kwrd"&gt;Stop&lt;/span&gt;]()
            idleTimer.Reset()
        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;


        &lt;span class="rem"&gt;' See if we've been idle long enough&lt;/span&gt;
        &lt;span class="kwrd"&gt;If&lt;/span&gt; idleTimer.ElapsedMilliseconds / 1000 &amp;gt; _thresholdIdleTime &lt;span class="kwrd"&gt;Then&lt;/span&gt;
            &lt;span class="rem"&gt;' We've just gone idle&lt;/span&gt;
            RaiseIdleEvent()
        &lt;span class="kwrd"&gt;Else&lt;/span&gt;
            &lt;span class="rem"&gt;' We are not idle&lt;/span&gt;
            LowerIdleEvent()
        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;

        _lastCpuValue = &lt;span class="kwrd"&gt;CInt&lt;/span&gt;(currentValue)
    &lt;span class="kwrd"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Visual C#&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; timerCpu_Tick(&lt;span class="kwrd"&gt;object&lt;/span&gt; state)
{
    &lt;span class="kwrd"&gt;int&lt;/span&gt; currentValue = 100 - (&lt;span class="kwrd"&gt;int&lt;/span&gt;)performanceCounterProcessorIdle.NextValue();

    &lt;span class="rem"&gt;// If we are below the threshold, start counting...&lt;/span&gt;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (currentValue &amp;lt;= _thresholdIdlePercent)
        idleTimer.Start();
    &lt;span class="kwrd"&gt;else&lt;/span&gt;
    {
        idleTimer.Stop();
        idleTimer.Reset();
    };

    &lt;span class="rem"&gt;// See if we've been idle long enough&lt;/span&gt;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (idleTimer.ElapsedMilliseconds / 1000 &amp;gt; _thresholdIdleTime)
    {
        &lt;span class="rem"&gt;// We've just gone idle&lt;/span&gt;
        RaiseIdleEvent();
    }
    &lt;span class="kwrd"&gt;else&lt;/span&gt;
    {
        &lt;span class="rem"&gt;// We are not idle&lt;/span&gt;
        LowerIdleEvent();
    }

    _lastCpuValue = (&lt;span class="kwrd"&gt;int&lt;/span&gt;)currentValue;
}&lt;/pre&gt;

&lt;p&gt;What is idle?&amp;#160; This is defined by properties &lt;strong&gt;ThresholdIdlePercent &lt;/strong&gt;and &lt;strong&gt;ThresholdIdleTime&lt;/strong&gt;.&amp;#160; The statement is &amp;quot;the system is idle when it has been at {ThresholdIdlePercent}% for {ThresholdIdleTime} seconds.&amp;quot;&amp;#160; A consuming application just sets the properties and subscribes to events.&amp;#160; Alternately, you can check the &lt;strong&gt;SystemIdle &lt;/strong&gt;property when you need to.&amp;#160; A final way is to call &lt;strong&gt;WaitForIdle &lt;/strong&gt;with our without a timeout value.&amp;#160; The call will not return until the system is idle.&lt;/p&gt;

&lt;p&gt;This works by using an &lt;strong&gt;System.Threading.EventWaitHandle &lt;/strong&gt;object.&amp;#160; This very cool construct (system-based, not just .NET) lets two threads coordinate via a shared semaphore.&amp;#160; The &lt;strong&gt;BackgroundWorker &lt;/strong&gt;thread goes to sleep until the &lt;strong&gt;SystemIdleComponent&lt;/strong&gt;'s timer fires and detects an idle state.&amp;#160; It can be dangerous to wait too long locked like this, so the worker will only call it for a second at a time in-between checking for a cancellation request.&amp;#160; I've added additional attributes to this object to make it easier to reuse and for a good design-time experience.&amp;#160; Drag it to your form and work with it like any other object.&lt;/p&gt;

&lt;h2&gt;Usage&lt;/h2&gt;

&lt;p&gt;It currently reads the user's &lt;strong&gt;Startup&lt;/strong&gt; folder upon startup and shows the dialog to take action.&amp;#160; There's no &lt;strong&gt;Cancel &lt;/strong&gt;button since it wouldn't make sense.&amp;#160; If you want to cancel, chances are you really just don't want the application to manage that shortcut.&amp;#160; It won't know that next time unless it creates an entry for it though.&lt;/p&gt;

&lt;p&gt;Something to think about is that some applications are going to check the Startup folder every time they launch and add their shortcut if it isn't there.&amp;#160; Once that &lt;strong&gt;StartupEntry &lt;/strong&gt;is in the &lt;strong&gt;StartupEntryList &lt;/strong&gt;collection, the application will know what to do with it and you won't be prompted again.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;FileSystemWatcher &lt;/strong&gt;object enables the application to see new shortcuts added.&amp;#160; It then takes action only on shortcuts for which no &lt;strong&gt;StartupEntry &lt;/strong&gt;is found.&amp;#160; You can modify the display name, delay, wait-for-idle flag, or the managed property at any time.&amp;#160; Unless you're debugging, you won't have any way to execute the launch sequence except when it's initially started with the &amp;quot;/startup&amp;quot; command line flag.&amp;#160; If you launch it without the flag it won't launch anything so it's safer that way.&lt;/p&gt;

&lt;p&gt;There's not much else to worry about.&amp;#160; Tell it which startup entries to manage, then let it do it's thing upon restarts.&amp;#160; It could really exit after the list is complete, except that it wouldn't see new entries that way.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;The application ended up taking considerably longer than I ever imagined it would!&amp;#160; I tried to create a good experience while demonstrating some good concepts.&amp;#160; I was surprised at some of the subtleties I ran into to make this work as well as it does.&amp;#160; It's not perfect by any means, but it's a good start and it should be useable as-is.&lt;/p&gt;

&lt;p&gt;I tried to keep things out of &lt;strong&gt;MainForm &lt;/strong&gt;where it made sense, though there is still room for more encapsulation.&amp;#160; Individual classes should always be fairly light-weight.&amp;#160; It's the way that they interact with each other that provides their power.&lt;/p&gt;

&lt;h2&gt;Next Steps&lt;/h2&gt;

&lt;p&gt;For this article, you can use Visual Studio 2005 Express, or make the upgrade to Visual Studio 2008 Express.&amp;#160; As I mentioned at the beginning, I'll be upgrading to VS2008 for future articles, and with the Express products being free, there's no reason not to upgrade today at &lt;a title="http://www.microsoft.com/express/" href="http://www.microsoft.com/express/"&gt;http://www.microsoft.com/express/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I left a number of &lt;strong&gt;TODO &lt;/strong&gt;comments in the code.&amp;#160; These were cool things that I just didn't have time to implement.&amp;#160; For one thing, it would be good to be able to just drag an application to the main window to add it to the Managed Startup list.&amp;#160; Even more useful would be scanning the Registry Current User (HKCU) Run list.&amp;#160; Probably more entries end up there than the Startup folder.&amp;#160; I'd also like to extend my &lt;strong&gt;SystemIdleComponent &lt;/strong&gt;to be a generalized &lt;strong&gt;PerformanceCounter&lt;/strong&gt; event broker.&amp;#160; That would make it easy to add code to wait for low disk I/O in addition to CPU load.&amp;#160; Finally, I really wanted to add entry reordering to specify which applications should have the higher priority of starting first.&amp;#160; Not difficult, so give it a try!&amp;#160; If you end up adding any interesting features, let me know.&amp;#160; I'd love to see where it goes!&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/ABetterStartupExperience_D7BC/Avatar80.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="84" alt="Arian Kulp" src="http://www.coding4fun.net/images/ABetterStartupExperience_D7BC/Avatar80_thumb.jpg" width="74" align="left" border="0" /&gt;&lt;/a&gt; 

  &lt;br /&gt;Arian Kulp is an independent software developer and writer working in the Midwest.&amp;#160; He has been coding since the fifth grade on various platforms, and also enjoys photography, nature, and spending time with his family.&amp;#160; Arian can be reached through his web site at &lt;a href="http://www.ariankulp.com"&gt;http://www.ariankulp.com&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8290797" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/utility/default.aspx">utility</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/productivity/default.aspx">productivity</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category></item><item><title>Animated Musical Holiday Light Show - Version 2.0</title><link>http://blogs.msdn.com/coding4fun/archive/2007/12/23/1230660.aspx</link><pubDate>Mon, 24 Dec 2007 01:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1230660</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>27</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/1230660.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=1230660</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=1230660</wfw:comment><description>&lt;span id="c4fmetadata"&gt;
&lt;table border="0" cellpadding="1" cellspacing="0" width="100%"&gt;
&lt;tbody&gt;
&lt;tr class="entry_overview"&gt;
&lt;td width="50"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;span class="entry_description"&gt;Create an animated holiday light show for indoor or outdoor use using some &lt;a href="http://www.phidgets.com/" target="_blank" mce_href="http://www.phidgets.com/"&gt;Phidget Interface Kits&lt;/a&gt;, extension cords, and .NET.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;
&lt;div class="entry_author"&gt;&lt;a href="http://www.brianpeek.com/" target="_blank" mce_href="http://www.brianpeek.com/"&gt;Brian Peek&lt;/a&gt;&lt;/div&gt;
&lt;div class="entry_company"&gt;&lt;a href="http://www.aspsoft.com" target="_blank" mce_href="http://www.aspsoft.com"&gt;ASPSOFT, Inc.&lt;/a&gt;&lt;/div&gt;&lt;br&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Difficulty: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Intermediate&lt;/span&gt;&lt;/div&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Time Required:&lt;/b&gt; &lt;span class="entry_details_input"&gt;3-6 hours&lt;/span&gt;&lt;/div&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Cost: &lt;/b&gt;&lt;span class="entry_details_input"&gt;$100-$200&lt;/span&gt;&lt;/div&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Software: &lt;/b&gt;&lt;span class="entry_details_input"&gt;&lt;a href="http://msdn.microsoft.com/express/" target="_blank" mce_href="http://msdn.microsoft.com/express/"&gt;Visual Basic or Visual C# 2008 Express Editions&lt;/a&gt;, &lt;a href="http://www.phidgets.com/downloads.php?os_id=1" target="_blank" mce_href="http://www.phidgets.com/downloads.php?os_id=1"&gt;Phidgets .NET libraries&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Hardware: &lt;/b&gt;&lt;span class="entry_details_input"&gt;&lt;a href="http://www.trossenrobotics.com/store/p/3203-InterfaceKit-0-0-4.aspx" target="_blank" mce_href="http://www.trossenrobotics.com/store/p/3203-InterfaceKit-0-0-4.aspx"&gt;Phidget Interface Kit 0/0/4&lt;/a&gt;, extension cords, wire nuts, spare wire&lt;/span&gt;&lt;/div&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Download:&amp;nbsp;&lt;/b&gt;&lt;b&gt; &lt;/b&gt;&lt;a href="http://www.c4fbook.com/media/p/42.aspx" target="_blank" mce_href="http://www.c4fbook.com/media/p/42.aspx"&gt;Download&lt;/a&gt;&lt;/div&gt;&lt;div class="entry_details"&gt;&lt;b&gt;Discussion Forum: &lt;/b&gt;&lt;a href="http://www.c4fbook.com/forums/30.aspx" mce_href="http://www.c4fbook.com/forums/30.aspx"&gt;Forum&lt;/a&gt; &lt;br&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;
&lt;p&gt;Welcome to version 2.0 of the software and article!&amp;nbsp; I have rewritten the key points of this article to address the new features in the latest version of the software.&amp;nbsp; Read on for a full explanation...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New Features for 2.0&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;MIDI support 
&lt;ul&gt;
&lt;li&gt;Load a MIDI file and a sequence will be automatically created based on the data contained in the file.&amp;nbsp; You can automatically create your own show with barely any effort at all! &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Playlists 
&lt;ul&gt;
&lt;li&gt;Load up several sequences and have them play in order to create a multi-song show! &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;More accurate timing 
&lt;ul&gt;
&lt;li&gt;The timing algorithm used in the last version was very imprecise...it worked, but it wasn't perfect.&amp;nbsp; The new version uses a method which gives millisecond precision timing &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Cut/Copy/Paste 
&lt;ul&gt;
&lt;li&gt;One can now cut/copy/paste cells on the grid...makes it easy to repeat chunks of sequences without having to tap out the rhythm by hand over and over again &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Edit existing sequences 
&lt;ul&gt;
&lt;li&gt;After loading a sequence created by someone else (or yourself), you can now re-assign Phidget boards, serial numbers, output ports, etc. to get them to run on your setup. &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Note that any sequences created with the old version will continue to play just fine, but editing them could be troublesome due to the new timing method.&lt;/p&gt;
&lt;p&gt;And now back to the article with updates.&amp;nbsp; The hardware section remains the same, but the &lt;a href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=4539&amp;amp;postid=1230660#software" mce_href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=4539&amp;amp;postid=1230660#software"&gt;software&lt;/a&gt; discussion below is updated with new information. &lt;/p&gt;
&lt;hr&gt;

&lt;p&gt;I'm sure by now everyone with a computer has seen the videos of holiday light shows timed to holiday music such as &lt;a href="http://www.youtube.com/watch?v=nD8_7c36yfw" target="_blank" mce_href="http://www.youtube.com/watch?v=nD8_7c36yfw"&gt;this one&lt;/a&gt;.&amp;nbsp; For this holiday season, I decided to create my own indoor show using some off-the-shelf components and .NET.&lt;/p&gt;
&lt;h3&gt;&lt;embed src="http://www.youtube.com/v/B83uajiZHo4" type="application/x-shockwave-flash" mce_src="http://www.youtube.com/v/B83uajiZHo4" height="350" width="600"&gt;&lt;/h3&gt;
&lt;p&gt;&lt;b&gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;WARNING:&amp;nbsp; The hardware portion of this project uses standard 120V AC current.&amp;nbsp; As you are likely aware, this is enough voltage to seriously hurt or kill you.&amp;nbsp; Please be careful and follow the instructions closely.&lt;/b&gt;&lt;/p&gt;
&lt;h3&gt;What You Will Need&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.trossenrobotics.com/store/p/3203-InterfaceKit-0-0-4.aspx" mce_href="http://www.trossenrobotics.com/store/p/3203-InterfaceKit-0-0-4.aspx"&gt;Phidget Interface Kit&lt;/a&gt; 0/0/4 – a USB-controlled board with 4 relays.&amp;nbsp; I used 2 kits for a total of 8 channels.&amp;nbsp; Any number can be used. &lt;/li&gt;
&lt;li&gt;5 6' (or longer/shorter for your needs) indoor or outdoor 2-prong extension cords for each Phidget board used.&amp;nbsp; I was able to find these at the local home improvement store for about $1 each.&amp;nbsp; If you will be creating an outdoor show, be sure to purchase extension cords that are meant for outdoor use. &lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/extension_cord14.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/extension_cord14.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/extension_cord_thumb12.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/extension_cord_thumb12.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Some 14-16 gauge wire.&amp;nbsp; If in doubt, simply buy one additional extension cord to use for the additional wire. &lt;/li&gt;
&lt;li&gt;2 wire nuts that can handle the wire gauge selected above for each Phidget board used. &lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wirenuts1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wirenuts1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wirenuts.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wirenuts.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;A project box large enough to hold one or many Phidget boards and associated wiring.&amp;nbsp; I chose a 7"L x 5"W x 3"H enclosure from Radio Shack which provides ample room to hold 2 Phidget Interface Kits and wiring. &lt;/li&gt;
&lt;li&gt;Some holiday lights &lt;/li&gt;
&lt;li&gt;External speakers (or possibly an FM transmitter for an outdoor show) &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.phidgets.com/downloads.php?os_id=1" target="_blank" mce_href="http://www.phidgets.com/downloads.php?os_id=1"&gt;Phidgets .NET libraries&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://msdn.com/express/" mce_href="http://msdn.com/express/"&gt;Microsoft Visual Basic or Visual C# Express Editions&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;
&lt;h3&gt;Building the Hardware&lt;/h3&gt;
&lt;p&gt;The hardware we are going to build will allow for one Phidget board to be plugged into a single AC outlet and provide 4 output outlets that can be switched off and on by the Phidget board's relays.&amp;nbsp; By building two of these and placing them in a project box, I have a neat and tidy control box with 2 USB inputs, 2 AC male plugs for the wall, and 8 AC female plugs for my lights.&amp;nbsp; The following description will be for building a single unit.&lt;/p&gt;
&lt;p&gt;Let's start by preparing the extension cords.&amp;nbsp; Cut the female end off of one extension cord.&amp;nbsp; Split the cord up the center and strip the insulation off each of the wires to expose the ends.&amp;nbsp; Twist the ends with your fingers to create a neat, twisted wire as shown:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/male_end1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/male_end1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/male_end.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/male_end.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Next, take the remaining four extension cords and cut the male ends off each.&amp;nbsp; As before, split the cord up the center a small bit, strip off some insulation, and twist the exposed ends as shown:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/female_end1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/female_end1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/female_end.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/female_end.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now, cut 4 equal lengths of your 14-16 gauge wire.&amp;nbsp; These should be no longer than 2-4 inches in length.&amp;nbsp; Strip some insulation off each end and twist up any loose wires.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wire1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wire1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wire.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wire.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;For the next part, you will need to pay close attention.&amp;nbsp; Each extension cord &lt;b&gt;should&lt;/b&gt; have two different types of insulation around the wires.&amp;nbsp; One side should have a ribbed edge, and one side should have a smooth edge shown below:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/smooth5.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/smooth5.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/smooth_thumb3.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/smooth_thumb3.jpg" border="0" height="337" width="450"&gt;&lt;/a&gt; &lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/ribbed2.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/ribbed2.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/ribbed_thumb.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/ribbed_thumb.jpg" border="0" height="337" width="450"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The ribbed side should be in line with the "fat" prong/receptacle (the neutral side) and the smooth side should be in line with the smaller prong/receptacle (the active/"hot" side).&amp;nbsp; It is important that the next steps be followed carefully, noting which wires I am referring to.&amp;nbsp; Using the wrong wire can lead to a short, blown fuses, kicked circuit breakers, or even worse things.&lt;/p&gt;
&lt;p&gt;Take the 4 short wires you cut earlier and twist them all together along with the ribbed/neutral wire from the extension cord with the male end still attached.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/twisted_wires1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/twisted_wires1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/twisted_wires.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/twisted_wires.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Twist a wire nut over the exposed ends to keep them together and covered.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wires_nut1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wires_nut1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wires_nut.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wires_nut.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Next, twist together the smooth/"hot" wire from the four extension cords with the female ends still attached along with the smooth/"hot" wire from the extension cord with the male end attached (i.e. the other wire from the male cord used above).&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_twisted1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_twisted1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_twisted.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_twisted.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Again, twist on a wire nut to keep things covered and safe.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_nut1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_nut1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_nut.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_nut.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;You should now be left with the opposite ends of the 4 cut wires exposed, and the 4 ribbed/neutral wires of the female extension exposed.&amp;nbsp; These will all be put into the screw terminals of the Phidget Interface Kit.&lt;/p&gt;
&lt;p&gt;The Phidget Interface Kit board has 4 groups of screw terminals.&amp;nbsp; Each group contains 3 items:&amp;nbsp; NO, XC, and NC, where X is the relay number in question.&amp;nbsp; These stand for "Normally Open", "Common", and "Normally Closed".&amp;nbsp; For this project, the lights should normally be off and switched on via the software, so the NO (Normally Open) and XC (Common) ports will be used.&lt;/p&gt;
&lt;p&gt;Place one wire from each exposed bundle into each NO and XC port.&amp;nbsp; Note that it does not matter which wire you plug into which terminal of each group, just that each group has only one short wire and only one extension cord wire.&lt;/p&gt;
&lt;p&gt;In the end, there will be one each of the 4 short wires in each group on the board, and one each of the extension cord wires in each group on the board as pictured:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/phidget_done1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/phidget_done1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/phidget_done.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/phidget_done.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Below is a very simple schematic of the wiring of a single board:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/Schematic8.png" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/Schematic8.png"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/Schematic_thumb4.png" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/Schematic_thumb4.png" border="0" height="124" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;I decided to keep things neat and tidy and mount the Phidget boards into a project box.&amp;nbsp; Since I have 2 boards to manage, I placed both inside a single, large box.&amp;nbsp; I drilled holes in the short sides to expose the boards' USB ports.&amp;nbsp; I then notched out some spaces on the top edge and lid for the extension cords to pass through.&amp;nbsp; I mounted the boards inside the box with some carefully placed two-sided foam tape.&lt;/p&gt;
&lt;p&gt;The finished product can be seen below:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/internals1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/internals1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/internals.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/internals.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt;&amp;nbsp;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/finished1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/finished1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/finished.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/finished.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;And that's it!&amp;nbsp; If this box will be placed outside, take the time to properly weatherproof the box so the elements cannot damage anything inside.&lt;/p&gt;
&lt;h3&gt;A Word on Amperages&lt;/h3&gt;
&lt;p&gt;Your individual light strings will be plugged into each extension cord outlet.&amp;nbsp; An average strand of mini-lights draws about .3 amps. An average string of larger bulbs will draw 1-2 amps.&amp;nbsp; The relays on the Phidget board are rated at 10 amps.&amp;nbsp; Additionally, a standard house circuit will allow up to 15-20 amps before overloading.&amp;nbsp; Check the circuit breaker in your home on which the outlet you'll be using lives for the allowed amperage.&amp;nbsp; Also, keep in mind that any other devices that are plugged into that circuit elsewhere in the house will be drawing power, so you may not be able to draw a full 15 amps from it.&amp;nbsp; So, be sure to not draw more than 10A per channel, nor more than 15-20A in total, &lt;b&gt;including&lt;/b&gt; all additional devices plugged into that circuit.&amp;nbsp; Keep this in mind as you string your lights together on each channel.&lt;/p&gt;&lt;a class="" title="software" name="software"&gt;&lt;/a&gt;
&lt;h3&gt;Writing the Software&lt;/h3&gt;
&lt;p&gt;Ensure the &lt;a href="http://www.phidgets.com" target="_blank" mce_href="http://www.phidgets.com"&gt;Phidgets libraries for .NET&lt;/a&gt; are installed on the development machine.&amp;nbsp; To compile the source code, &lt;a href="http://msdn.microsoft.com/express/" target="_blank" mce_href="http://msdn.microsoft.com/express/"&gt;Visual Basic and/or Visual C# Express 2005&lt;/a&gt; will also be need to be installed and working.&lt;/p&gt;
&lt;p&gt;The &lt;b&gt;Light Sequencer&lt;/b&gt; application uses a grid-style interface to show the list of channels and when each channel is switched on and off.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/image.png" mce_href="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/image.png"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/image_thumb.png" style="border: 0px none ;" alt="image" mce_src="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/ima