<?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 : mash up</title><link>http://blogs.msdn.com/coding4fun/archive/tags/mash+up/default.aspx</link><description>Tags: mash up</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Popfly game engine – open source</title><link>http://blogs.msdn.com/coding4fun/archive/2009/08/27/9887173.aspx</link><pubDate>Thu, 27 Aug 2009 21:01:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9887173</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9887173.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9887173</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9887173</wfw:comment><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Popflygameengineopensource_B726/codeplex_2%5B1%5D_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 5px; display: inline; border-top: 0px; border-right: 0px" title="codeplex_2[1]" border="0" alt="codeplex_2[1]" align="right" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Popflygameengineopensource_B726/codeplex_2%5B1%5D_thumb.jpg" width="240" height="181" /&gt;&lt;/a&gt; As popfly is getting shut down August 31st, they released the game engine under the Ms-Pl.&amp;#160; If you used the &lt;a href="http://blogs.msdn.com/coding4fun/archive/2009/07/22/9845135.aspx"&gt;Popfly Game Downloader&lt;/a&gt; we released a few weeks back to grab your games, there’s also instructions on how to crack them open and grab the data files.&amp;#160; Which means you may be able to recreate the actual GUI for creating games!&lt;/p&gt;  &lt;p&gt;Check it out over at &lt;a title="Codeplex" href="http://popflygameengine.codeplex.com/"&gt;Codeplex&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;[via &lt;a href="http://blogs.msdn.com/ben_anderson/archive/2009/08/26/popfly-parting-present.aspx"&gt;Ben Anderson&lt;/a&gt;]&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9887173" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/c4fnews/default.aspx">c4fnews</category><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/gaming/default.aspx">gaming</category></item><item><title>TweetCraft - An in-game Twitter client for World of Warcraft</title><link>http://blogs.msdn.com/coding4fun/archive/2009/07/02/9813390.aspx</link><pubDate>Thu, 02 Jul 2009 11:18:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9813390</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9813390.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9813390</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9813390</wfw:comment><description>&lt;p&gt;&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/vp09_06_22.xap" /&gt; &lt;param name="initParams" value="m=mms://mschnlnine.wmod.llnwd.net/a1809/d1/ch9/8/0/6/6/7/4/TweetCraftTrailer_s_ch9.wmv,autostart=false,autohide=true,showembed=true, thumbnail=http://mschnlnine.vo.llnwd.net/d1/ch9/8/0/6/6/7/4/TweetCraftTrailer_large_ch9.png, postid=476608" /&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;p&gt;&lt;a href="http://ch9.ms/tweetcraft"&gt;TweetCraft&lt;/a&gt; is a World of Warcraft add-on that enables you to send and receive tweets using &lt;a href="http://twitter.com/"&gt;Twitter&lt;/a&gt; without leaving the game, automatically upload and post screenshots using &lt;a href="http://twitpic.com/"&gt;TwitPic&lt;/a&gt; and automatically tweet certain in-game events such as achievements and moving around in the world of Azeroth. TweetCraft customizes your World of Warcraft user interface by adding its own frame similar to the built-in ones (such as the Quest Log) and provides easy access to it through a button near the minimap, slash commands or your favorite launcher (e.g. ChocolateBar).&lt;/p&gt;  &lt;li&gt;&lt;b&gt;Compiled version: &lt;/b&gt;&lt;a href="http://tweetcraft.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29622#DownloadId=73735"&gt;Download&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;b&gt;Source Code:&lt;/b&gt; &lt;a href="http://tweetcraft.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29622"&gt;Download&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; 3-5 hours &lt;/li&gt;  &lt;li&gt;&lt;b&gt;Cost:&lt;/b&gt; $19.99 for World of Warcraft; $14.99 for monthly fee &lt;/li&gt;  &lt;li&gt;&lt;b&gt;Software Needed:&lt;/b&gt; &lt;a href="http://addonstudio.codeplex.com/"&gt;AddOn Studio for World of Warcraft&lt;/a&gt;, Visual Studio Standard (or higher), although possible to use Visual C# Express as well, &lt;/li&gt;  &lt;li&gt;&lt;b&gt;Hardware:&lt;/b&gt; none     &lt;h3&gt;How TweetCraft works&lt;/h3&gt;    &lt;p&gt;Let&amp;#8217;s quickly walk through the different things that TweetCraft does to bring Twitter into World of Warcraft.&lt;/p&gt;    &lt;h4&gt;Overview&lt;/h4&gt;    &lt;p&gt;World of Warcraft&amp;#8217;s user interface is highly customizable and enables add-on developers to do almost anything in the game they can dream of. Add-ons can interact with the world, listen to events that happen in the game, alter the look of the default user interface or create brand new ones, but add-ons are seriously limited when it comes to talking to the world outside World of Warcraft. They cannot read or write files, call web services or do anything that could be potentially harmful. This is why TweetCraft comes with a Windows application that sits in the Notification Area (also known as the tray) and does the bulk of the work, giving the TweetCraft add-on only the data that it needs to display, such as tweets, replies and user pictures. All the Twitter web service calls, uploading of screenshots and housekeeping is done by this application. Let&amp;#8217;s see how!&lt;/p&gt;    &lt;h4&gt;The TweetCraft Tray application&lt;/h4&gt;    &lt;p&gt;The TweetCraft Tray application is a WPF application that periodically checks for new tweets, dowloads and converts the user pictures of the tweets&amp;#8217; authors and writes it out to a file that World of Warcraft picks up and the add-on can use. It also picks up all outgoing tweets queued up for sending and sends them using Twitter one-by-one. It watches for screenshots taken by World of Warcraft and uploads them using TwitPic immediately.&lt;/p&gt;    &lt;p&gt;To do all this, it has a couple of settings that need to be configured before it can work. For starters, it needs your Twitter credentials to be able to send tweets and post pictures on your behalf. It also needs to know which World of Warcraft account you are going to use to play and send and receive tweets with. Finally, you can opt out of automatically uploading screenshots you take during game. Figure 1 shows the TweetCraft Settings window that shows up when you first start TweetCraft after installation and is also available by right clicking the tray icon (Figure 2).&lt;/p&gt;    &lt;p&gt;&lt;img border="0" alt="Figure1_TweetCraftSettingsWindow" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TweetCraftAningameTwitterclientforWorldo_1236/Figure1_TweetCraftSettingsWindow_96f280c9-cef7-47db-a5a8-1b3ae3da5d13.png" width="415" height="544" /&gt;       &lt;br /&gt;&lt;strong&gt;Figure 1. TweetCraft Settings Window&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&lt;img border="0" alt="Figure2_TweetCraftTrayIcon" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TweetCraftAningameTwitterclientforWorldo_1236/Figure2_TweetCraftTrayIcon_647e915d-5ae9-41ab-9f6a-85ffbf94c0cc.png" width="418" height="172" /&gt;       &lt;br /&gt;&lt;strong&gt;Figure 2. TweetCraft tray icon in the notification area&lt;/strong&gt;&lt;/p&gt;    &lt;h4&gt;Getting data from Twitter&lt;/h4&gt;    &lt;p&gt;TweetCraft uses an open-source library called &lt;strong&gt;TwitterLib&lt;/strong&gt; to send and receive tweets using Twitter&amp;#8217;s API. TwitterLib is part of the open-source WPF Twitter Client &lt;a href="http://code.google.com/p/wittytwitter/"&gt;WittyTwitter&lt;/a&gt; and wraps the web services provided by Twitter into an easy to use .NET class library. TweetCraft wraps this library into a simple class called &lt;strong&gt;TwitterClient&lt;/strong&gt; that all the services in TweetCraft rely on. One of those services is the &lt;strong&gt;TwitterBackgroundService&lt;/strong&gt; which polls Twitter periodically to check for new tweets. By default, this is set to five minutes. If new tweets or replies are available, an event is raised that other components of TweetCraft can handle and work with the new tweets, download user pictures, etc. Figure 3 shows the three classes that take part in downloading new tweets and replies and notifying other classes.&lt;/p&gt;    &lt;p&gt;&lt;img border="0" alt="Figure3_TwitterBackgroundService" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TweetCraftAningameTwitterclientforWorldo_1236/Figure3_TwitterBackgroundService_2c37e43e-7c00-4a0b-8357-f821fc443b79.png" width="715" height="333" /&gt;       &lt;br /&gt;&lt;strong&gt;Figure 3. TwitterBackgroundService, TwitterClient and TwitterNet (TwitterLib)&lt;/strong&gt;&lt;/p&gt;    &lt;h4&gt;&amp;#160;&lt;/h4&gt;    &lt;h4&gt;Dynamically building TGA images&lt;/h4&gt;    &lt;p&gt;When it comes to visualizing images (or textures, in WoW parlance), World of Warcraft poses quite a few restrictions on what files can be used and where does files should be. First of all, World of Warcraft only supports the TGA and BLP file formats. TGA stands for the Truevision Targa format, whereas BLP is Blizzard&amp;#8217;s own image format. The images must also have dimensions of two (32&amp;#215;32, 64&amp;#215;64 pixels and so on&amp;#8230;), otherwise they won&amp;#8217;t show up. On the other hand, Twitter user pictures are available as 48&amp;#215;48 or 75&amp;#215;75 pixels and in various well-known formats, such as JPG, PNG or even GIF. TweetCraft needs to convert these pictures to 64&amp;#215;64 TGA files if it wants to play nice with World of Warcraft. This is done for each tweet&amp;#8217;s authors user picture that will show up in World of Warcraft. The converted pictures must be placed in the &lt;em&gt;Interface&lt;/em&gt; folder of World of Warcraft where the add-ons themselves also reside. The &lt;strong&gt;TwitterUserPictureService&lt;/strong&gt; can retrieve the user picture and convert it to a 64&amp;#215;64 TGA file that contains the 48&amp;#215;48 user picture in the middle and puts that file into the same directory where the TweetCraft add-on is installed. The files are named after each user&amp;#8217;s screen name and if &lt;strong&gt;TwitterUserPictureService&lt;/strong&gt; sees that a file is already there, it won&amp;#8217;t convert it again, saving some time and computing power.&lt;/p&gt;    &lt;p&gt;Figure 4 shows &lt;strong&gt;TwitterUserPictureService&lt;/strong&gt; and two helper classes that take care of downloading and the actual conversion. The &lt;code&gt;GetUserPicturePath&lt;/code&gt; method returns the path of the resulting World of Warcraft compatible TGA file for a single user.&lt;/p&gt;    &lt;p&gt;&lt;img border="0" alt="Figure4_TwitterUserPictureService" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TweetCraftAningameTwitterclientforWorldo_1236/Figure4_TwitterUserPictureService_abf4a52c-8e97-4458-b620-dc62d0be314d.png" width="475" height="313" /&gt;       &lt;br /&gt;&lt;strong&gt;Figure 4. TwitterUserPictureService and its helper classes&lt;/strong&gt;&lt;/p&gt;    &lt;h4&gt;Serializing tweets into Lua&lt;/h4&gt;    &lt;p&gt;Until now, we were quite secretive about how we can avoid World of Warcraft&amp;#8217;s restrictions and let TweetCraft be able to read the data and show it. We&amp;#8217;ve said that add-ons cannot read or write files and that still hasn&amp;#8217;t changed during the last few minutes, but add-ons must have a way somehow to save their settings and other information when I log out of the game and load that when I log back in, you sincerely ask and you&amp;#8217;re right! Although add-ons cannot read or write to files, they can ask World of Warcraft to save and load some of their global variables whenever the user reloads the UI (by entering an instance or hearthing), logs in or logs out. These files are called the SavedVariables files. When TweetCraft finishes downloading tweets, converting user pictures and everything else, it saves them using the very same format and to the very same file World of Warcraft uses on behalf of the TweetCraft add-on. Neat, huh? Just wait a little bit more&amp;#8230; :)&lt;/p&gt;    &lt;p&gt;Those variables that an add-on asks to be saved between sessions are saved into a Lua file, which is the same programming language add-on developers can use to write their add-ons. So basically, World of Warcraft creates a file that contains code full of assignment statements (think &lt;code&gt;a = 5&lt;/code&gt;) that it will just run whenever those values need to be set again. More complex data structures can also be expressed this way using Lua tables, the swiss army-knife of Lua.&lt;/p&gt;    &lt;p&gt;It sounds like a great idea to put all the data we would like for TweetCraft to use, but all we have is .NET objects, arrays and dictionaries. Fortunately, all these data structures can be expressed with simple Lua types and tables and TweetCraft comes with a class called &lt;strong&gt;LuaSerializer&lt;/strong&gt; that produces Lua code from any .NET object (with a few restrictions, of course), very similar to how &lt;strong&gt;XmlSerializer&lt;/strong&gt; works.&lt;/p&gt;    &lt;p&gt;To make this even more simple, TweetCraft contains the concept of a &lt;strong&gt;SavedVariablesChannel&lt;/strong&gt; that you can just drop objects in, flush it and those object show up on the other side. In our case, as Lua variables. What&amp;#8217;s even better, it works the other way around as well. The TweetCraft add-on stores all the tweets queued up and ready to be sent in a variable and triggers World of Warcraft to save them to the SavedVariables file. The &lt;strong&gt;SavedVariablesChannel&lt;/strong&gt; detects this by watching for changes made to the SavedVariables file using &lt;strong&gt;FileSystemWatcher&lt;/strong&gt; and notifies other components of the TweetCraft application that can pull out the information and send the tweets.&lt;/p&gt;    &lt;p&gt;Figure 5 shows &lt;strong&gt;SavedVariablesChannel&lt;/strong&gt; and its base class, &lt;strong&gt;ValueChannelBase&lt;/strong&gt; which keeps track of all objects thrown into it until it is flushed.&lt;/p&gt;    &lt;p&gt;&lt;img border="0" alt="Figure5_SavedVariablesChannel" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TweetCraftAningameTwitterclientforWorldo_1236/Figure5_SavedVariablesChannel_d3bf3853-d03e-43a6-b8e4-899708f431dd.png" width="475" height="325" /&gt;       &lt;br /&gt;&lt;strong&gt;Figure 5. SavedVariablesChannel and ValueChannelBase&lt;/strong&gt;&lt;/p&gt;    &lt;h4&gt;Refreshing the data in World of Warcraft&lt;/h4&gt;    &lt;p&gt;There&amp;#8217;s one last problem we face when trying to achieve this two-way communication between the TweetCraft add-on and the application. If World of Warcraft is running, we cannot just overwrite the SavedVariables file and expect World of Warcraft to pick it up as it does not watch for changes made to the file. If we were to overwrite the file and subsequently the user logs out, World of Warcraft will happily overwrite the information we placed there. There&amp;#8217;s another trick we have to resort to: the TweetCraft add-on can trigger the reloading of the UI which will unload all add-ons, save their variables and then load them again. There&amp;#8217;s a a little bit of time between the saving and loading of a particular add-ons SavedVariables file and that&amp;#8217;s when TweetCraft can safely read the file for queued up tweets and overwrite it with the new data. This is what happens when the user clicks the Refresh button in TweetCraft&amp;#8217;s frame.&lt;/p&gt;    &lt;h4&gt;Sending tweets and uploading screenshots&lt;/h4&gt;    &lt;p&gt;Whenever the user queues up tweets for sending, they are not immediately sent but kept in a data structure that will be saved out to the SavedVariables file by World of Warcraft. We&amp;#8217;ve seen that his happens when either the user logs out or presses the Refresh button. The updated SavedVariables file gets detected by &lt;strong&gt;SavedVariablesChannel&lt;/strong&gt; and the &lt;code&gt;ChannelUpdated&lt;/code&gt; event is raised. When the TweetCraft application handles this event, it cannot immediately send the tweets as that would take a couple seconds and if you remember from the last section, we only have a tiny little window of time to process the values and save back all the data we would like to send back. For this reason, the tweets that are picked up from the SavedVariables file using the &lt;strong&gt;SavedVariablesChannel&lt;/strong&gt; get quickly queued up in the &lt;strong&gt;TwitterDispatcherService&lt;/strong&gt; that then goes ahead and starts sending them one by one in the background. To make sure that all the values we prepared to save into the file get flushed, the &lt;strong&gt;SavedVariablesChannel&lt;/strong&gt; has a property called &lt;code&gt;AutoFlush&lt;/code&gt; that is enabled by default.&lt;/p&gt;    &lt;p&gt;One thing we have not mentioned is that &lt;strong&gt;TwitterDispatcherService&lt;/strong&gt; can also upload and post pictures using TwitPic. It watches the &lt;em&gt;Screenshots&lt;/em&gt; folder of World of Warcraft for new files and if AutoTweeting of screenshots is enabled, immediately queues up the picture for uploading and posting it. This also means that you don&amp;#8217;t need to press the Refresh button or wait until you log off for screenshots to be posted. They will show up immediately in your Twitter feed.&lt;/p&gt;    &lt;p&gt;The &lt;strong&gt;TwitterDispatcherService&lt;/strong&gt; uses &lt;strong&gt;TwitterClient&lt;/strong&gt; (and &lt;strong&gt;TwitterLib&lt;/strong&gt;) to send the tweets but it does not interfere with the quick reading and writing of the SavedVariables file we discussed previously. It also uses &lt;strong&gt;TwitPicClient&lt;/strong&gt; to upload and post pictures. Figure 6 shows &lt;strong&gt;TwitterDispatcherService&lt;/strong&gt;, &lt;strong&gt;TwitterClient&lt;/strong&gt; and &lt;strong&gt;TwitPicClient&lt;/strong&gt;.&lt;/p&gt;    &lt;p&gt;&lt;img border="0" alt="Figure6_TwitterDispatcherService" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TweetCraftAningameTwitterclientforWorldo_1236/Figure6_TwitterDispatcherService_575f8576-4afc-4191-b41e-e45084b19ae6.png" width="691" height="348" /&gt;       &lt;br /&gt;&lt;strong&gt;Figure 6. TwitterDispatcherService, TwitterClient and TwitPicClient&lt;/strong&gt;&lt;/p&gt;    &lt;h4&gt;Bringing it all together&lt;/h4&gt;    &lt;p&gt;So far, we&amp;#8217;ve looked at components of TweetCraft that implemented a particular part of the application. Retrieving and sending tweets, converting user pictures and making all this information available for the TweetCraft add-on, but there&amp;#8217;s an important class that brings all this together and contains all the logic of how these components interact with each other. We also need to be able to detect World of Warcraft installations, figure out what accounts are available and where to look for files like the SavedVariables files and put the converted user pictures. The &lt;strong&gt;TweetCraft&lt;/strong&gt; class implements the logic required and relies on the &lt;strong&gt;WorldOfWarcraft&lt;/strong&gt; class for everything World of Warcraft related.&lt;/p&gt;    &lt;p&gt;Figure 7 shows the &lt;strong&gt;TweetCraft&lt;/strong&gt; and &lt;strong&gt;WorldOfWarcraft&lt;/strong&gt; side by side.&lt;/p&gt;    &lt;p&gt;&lt;img border="0" alt="Figure7_TweetCraft" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/TweetCraftAningameTwitterclientforWorldo_1236/Figure7_TweetCraft_6bf95ca8-d5c2-4d54-8169-c02de469ecb3.png" width="523" height="463" /&gt;       &lt;br /&gt;&lt;strong&gt;Figure 7. TweetCraft and WorldOfWarcraft&lt;/strong&gt;&lt;/p&gt;    &lt;h3&gt;Summary&lt;/h3&gt;    &lt;p&gt;While this is a high-level overview of TweetCraft only, it gives you a good idea of how it enables World of Warcraft players to use Twitter to send and receive tweets, upload the screenshots and share their achievements right inside the game. Make sure you try out TweetCraft if you have World of Warcraft installed and if you&amp;#8217;re curious, &lt;a href="http://tweetcraft.codeplex.com/SourceControl/ListDownloadableCommits.aspx"&gt;download the source code&lt;/a&gt; and take a deeper look.&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;p&gt;&lt;img src="http://blogs.msdn.com/blogfiles/danielfe/WindowsLiveWriter/Coding4FunBookThepeopleandtheprojects_99D7/gaborratky_762a3823-615d-45f0-84f7-bb5c1d0a2707.png" /&gt;       &lt;br /&gt;Gabor Ratky (&lt;a href="http://rgabostyle.com/"&gt;Blog&lt;/a&gt;, &lt;a href="http://twitter.com/rgabostyle"&gt;Twitter&lt;/a&gt;), Senior Software Engineer and Coding4Fun Ninja at &lt;a href="http://www.epam.com"&gt;EPAM Systems&lt;/a&gt;&amp;#160;&lt;/p&gt;    &lt;p&gt;Gabor is the developer behind TweetCraft and has been working on Coding4Fun projects for almost two years. He also leads the development of &lt;a href="http://addonstudio.codeplex.com/"&gt;AddOn Studio for World of Warcraft&lt;/a&gt;, a Visual Studio-based IDE for building World of Warcraft add-ons and he co-authored the chapter in the &lt;a href="http://www.amazon.com/Coding4Fun-Programming-Projects-Wiimote-Warcraft/dp/0596520743/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1246522615&amp;amp;sr=8-1"&gt;Coding4Fun&lt;/a&gt; book about it. He is a VSX Insider and was invited to speak at various events about Visual Studio Extensibility. When not working on Coding4Fun projects, Gabor works on large scale, enterprise solutions using exciting Microsoft technologies. He lives in Budapest, Hungary and loves traveling, good wine and Channel9 videos.&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;p&gt;&lt;/p&gt; &lt;/li&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9813390" 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/web+services/default.aspx">web services</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/gaming/default.aspx">gaming</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Skype Voice Changer</title><link>http://blogs.msdn.com/coding4fun/archive/2009/02/02/9391048.aspx</link><pubDate>Mon, 02 Feb 2009 21:19:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9391048</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>26</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9391048.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9391048</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9391048</wfw:comment><description>&lt;p&gt;In this article I demonstrate how you can create your own audio effects in .NET to manipulate digital audio at the sample level. These effects are used to process MP3 files while they are being played back, and to process the real-time microphone input allowing you to change your voice during a Skype conversation.&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&gt;Mark Heath, &lt;a href="http://mark-dot-net.blogspot.com"&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://www.codeplex.com/skypefx"&gt;Download&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; 8 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/naudio"&gt;NAudio&lt;/a&gt;, &lt;a href="https://developer.skype.com/Docs/Skype4COM"&gt;Skype4COM&lt;/a&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;&lt;a href="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_15.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_thumb_12.png" width="500" height="204" /&gt;&lt;/a&gt; &lt;/h3&gt;  &lt;h3&gt;Audio and the .NET Framework&lt;/h3&gt;  &lt;p&gt;Playing back audio in a .NET application is not quite as easy as you might hope it would be. The .NET 2.0 Framework introduced the &lt;a href="http://msdn.microsoft.com/en-us/library/system.media.soundplayer.aspx"&gt;SoundPlayer&lt;/a&gt; component, which allows you to play back an existing WAV file. While this may be fine for many scenarios, as soon as you want to do things even slightly more advanced, such as changing the volume, or playing back from a different file-format, or pausing and repositioning, you must resort to writing P/Invoke wrappers for various Windows APIs.&lt;/p&gt;  &lt;p&gt;Back in 2002, as I was getting started learning .NET, I create some audio-related classes of my own to compensate for the lack of audio support in the .NET Framework. I focused initially on reading and writing WAV and MIDI files, as well as playing back audio in a way that allowed real-time mixing and manipulation of the audio at a sample level. As time went by, I made this growing collection of audio classes available as an open source project, called &lt;a href="http://www.codeplex.com/naudio"&gt;NAudio&lt;/a&gt;, now hosted at CodePlex.&lt;/p&gt;  &lt;h4&gt;Audio Playback in NAudio&lt;/h4&gt;  &lt;p&gt;NAudio works by constructing an audio playback graph. Audio comes in “streams” which can be connected together and modified before eventually they go to a renderer. This might be your soundcard if you are listening to the audio, or it might be to a file on the hard disk.&lt;/p&gt;  &lt;p&gt;In NAudio, all streams derive from &lt;b&gt;WaveStream&lt;/b&gt;. NAudio comes with a collection of useful &lt;b&gt;WaveStream&lt;/b&gt; derived classes such as &lt;b&gt;WaveFileReader&lt;/b&gt; to read from WAV files or &lt;b&gt;WaveStreamMixer&lt;/b&gt; to sum together multiple audio streams. &lt;/p&gt;  &lt;p&gt;Audio mixing and effects are almost always performed with floating point numbers (32 bit is most common), so one of the first steps after reading audio out of a WAV file is to convert it from 16 bit to 32 bit. NAudio includes the &lt;b&gt;Wave16To32ConversionStream &lt;/b&gt;class to do this. If the audio wasn’t in PCM in the first place, for example it is MP3, then we make use of a combination of the &lt;b&gt;Mp3FileReaderStream&lt;/b&gt;, &lt;b&gt;WaveFormatConversionStream&lt;/b&gt; and &lt;b&gt;BlockAlignmentReductionStream&lt;/b&gt; to read the audio out and get it into just the format we want. Here’s an example showing how to create a &lt;b&gt;WaveStream&lt;/b&gt; ready for playback.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;WaveStream outStream;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (fileName.EndsWith(&lt;span class="str"&gt;&amp;quot;.mp3&amp;quot;&lt;/span&gt;))
{
   outStream = &lt;span class="kwrd"&gt;new&lt;/span&gt; Mp3FileReader(fileName);
}
&lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(fileName.EndsWith(&lt;span class="str"&gt;&amp;quot;.wav&amp;quot;&lt;/span&gt;))
{
   outStream = &lt;span class="kwrd"&gt;new&lt;/span&gt; WaveFileReader(fileName);
}
&lt;span class="kwrd"&gt;else&lt;/span&gt;
{
   &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; InvalidOperationException(&lt;span class="str"&gt;&amp;quot;Can't open this type of file&amp;quot;&lt;/span&gt;);
}                
&lt;span class="kwrd"&gt;if&lt;/span&gt; (outStream.WaveFormat.Encoding != WaveFormatEncoding.Pcm)
{
   outStream = WaveFormatConversionStream.CreatePcmStream(outStream);
   outStream = &lt;span class="kwrd"&gt;new&lt;/span&gt; BlockAlignReductionStream(outStream); &lt;span class="rem"&gt;// reduces choppiness&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;If we simply want to play back the audio without any extra processing, we would use one of the audio output classes provided by NAudio to create an object that implements &lt;b&gt;IWavePlayer&lt;/b&gt;. The options are &lt;b&gt;WaveOut&lt;/b&gt;, &lt;b&gt;DirectSoundOut&lt;/b&gt;, &lt;b&gt;AsioOut&lt;/b&gt; and &lt;b&gt;WasapiOut&lt;/b&gt;, each representing a different technology for audio playback in Windows. We will use &lt;b&gt;WaveOut&lt;/b&gt;, which is the most universally supported. Here we are opening the default output device with a latency of 300ms, and instructing it to use windowed callbacks.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;IWavePlayer player = &lt;span class="kwrd"&gt;new&lt;/span&gt; WaveOut(0, 300, &lt;span class="kwrd"&gt;true&lt;/span&gt;);
player.Init(outStream);
player.Play();&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;WaveOut&lt;/b&gt; will now repeatedly call the &lt;b&gt;Read&lt;/b&gt; method of the output stream to get the next batch of audio samples to play. All we need to do now is to insert our audio effects into the playback chain.&lt;/p&gt;

&lt;h4&gt;An Audio Effects Framework&lt;/h4&gt;

&lt;p&gt;To allow us to process sample level audio more simply, I have create a new &lt;b&gt;WaveStream&lt;/b&gt; derived class called &lt;b&gt;EffectStream&lt;/b&gt;. &lt;b&gt;EffectStream&lt;/b&gt; will simply pass each audio sample to one or more audio effects before returning the modified audio in its &lt;b&gt;Read&lt;/b&gt; method. The reason I have chosen to host all the effects in a single &lt;b&gt;EffectSteam&lt;/b&gt; rather than creating one &lt;b&gt;WaveStream&lt;/b&gt; derived class is that I want to avoid the performance penalty of converting between arrays of bytes and arrays of floating point numbers at every step. Some types of effect, particularly those involving Fourier transforms can be processor intensive, so anything we can do to speed up performance will help.&lt;/p&gt;

&lt;p&gt;As well as the &lt;b&gt;EffectStream &lt;/b&gt;class, we need a base &lt;b&gt;Effect&lt;/b&gt; class, from which all of our effects can derive. Here’s a simplified version of the base Effect class (minus a whole load of helper mathematical functions):&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;abstract&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Effect
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; List&amp;lt;Slider&amp;gt; sliders;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; SampleRate { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; Tempo { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; Enabled { get; set; }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; Effect()
    {
        sliders = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;Slider&amp;gt;();
        Enabled = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
        Tempo = 120;
        SampleRate = 44100;
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; IList&amp;lt;Slider&amp;gt; Sliders { get { &lt;span class="kwrd"&gt;return&lt;/span&gt; sliders; } }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; Slider AddSlider(&lt;span class="kwrd"&gt;float&lt;/span&gt; defaultValue, &lt;span class="kwrd"&gt;float&lt;/span&gt; minimum, 
            &lt;span class="kwrd"&gt;float&lt;/span&gt; maximum, &lt;span class="kwrd"&gt;float&lt;/span&gt; increment, &lt;span class="kwrd"&gt;string&lt;/span&gt; description)
    {
        Slider slider = &lt;span class="kwrd"&gt;new&lt;/span&gt; Slider(defaultValue, minimum, 
            maximum, increment, description);
        sliders.Add(slider);
        &lt;span class="kwrd"&gt;return&lt;/span&gt; slider;
    }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// Should be called on effect load, &lt;/span&gt;
    &lt;span class="rem"&gt;/// sample rate changes, and start of playback&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Init()
    {}

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// will be called when a slider value has been changed&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;abstract&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Slider();

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// called before each block is processed&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Block()
    { }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// called for each sample&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;abstract&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Sample(&lt;span class="kwrd"&gt;ref&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; spl0, &lt;span class="kwrd"&gt;ref&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; spl1);
}&lt;/pre&gt;

&lt;p&gt;The bulk of the work of the effect should be done in the overridden &lt;b&gt;Sample&lt;/b&gt; method. The &lt;b&gt;spl0&lt;/b&gt; and &lt;b&gt;spl1&lt;/b&gt; parameters contain the current sample values to be modified for the left and right channels respectively. For example, to lower the volume we could halve the amplitude of every sample with the following code:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Sample(&lt;span class="kwrd"&gt;ref&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; spl0, &lt;span class="kwrd"&gt;ref&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; spl1)
{
    spl0 *= 0.5f;
    spl1 *= 0.5f;
}&lt;/pre&gt;

&lt;p&gt;The &lt;b&gt;Effect&lt;/b&gt; class contains &lt;b&gt;Tempo&lt;/b&gt; and &lt;b&gt;SampleRate&lt;/b&gt; values which are useful for certain types of effect. It also contains a concept of ‘Sliders’ for each effect. These are the effect parameters, which allow real-time modification of the effect. So if we wanted to control the volume using a slider, we could write the following code (although bear in mind that normally volume sliders should be logarithmic not linear – see the &lt;b&gt;Volume&lt;/b&gt; effect in the sample code for an example of how to do this):&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Sample(&lt;span class="kwrd"&gt;ref&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; spl0, &lt;span class="kwrd"&gt;ref&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; spl1)
{
    spl0 *= slider1;
    spl1 *= slider1;
}&lt;/pre&gt;

&lt;p&gt;To simplify the task of adding, removing and re-ordering effects, I created an &lt;b&gt;EffectChain&lt;/b&gt; class, which is a simple wrapper around a &lt;b&gt;List&amp;lt;Effect&amp;gt;&lt;/b&gt;. The &lt;b&gt;EffectStream&lt;/b&gt; class has an &lt;b&gt;EffectChain&lt;/b&gt; that contains all the effects it needs to run. Here is the code for the &lt;b&gt;EffectStream&lt;/b&gt;:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; EffectStream : WaveStream
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; EffectChain effects;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; WaveStream source;
    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; effectLock = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;();
    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; sourceLock = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;();

    &lt;span class="kwrd"&gt;public&lt;/span&gt; EffectStream(EffectChain effects, WaveStream sourceStream)
    {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.effects = effects;
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.source = sourceStream;
        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Effect effect &lt;span class="kwrd"&gt;in&lt;/span&gt; effects)
        {
            InitialiseEffect(effect);
        }

    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; EffectStream(WaveStream sourceStream)
        : &lt;span class="kwrd"&gt;this&lt;/span&gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; EffectChain(), sourceStream)
    {        
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; EffectStream(Effect effect, WaveStream sourceStream)
        : &lt;span class="kwrd"&gt;this&lt;/span&gt;(sourceStream)
    {
        AddEffect(effect);
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; WaveFormat WaveFormat
    {
        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; source.WaveFormat; }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;long&lt;/span&gt; Length
    {
        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; source.Length; }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;long&lt;/span&gt; Position
    {
        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; source.Position; }
        set { &lt;span class="kwrd"&gt;lock&lt;/span&gt; (sourceLock) { source.Position = &lt;span class="kwrd"&gt;value&lt;/span&gt;; } }
    }        

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Read(&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buffer, &lt;span class="kwrd"&gt;int&lt;/span&gt; offset, &lt;span class="kwrd"&gt;int&lt;/span&gt; count)
    {
        &lt;span class="kwrd"&gt;int&lt;/span&gt; read;
        &lt;span class="kwrd"&gt;lock&lt;/span&gt;(sourceLock)
        {
            read = source.Read(buffer, offset, count);
        }
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (WaveFormat.BitsPerSample == 16)
        {
            &lt;span class="kwrd"&gt;lock&lt;/span&gt; (effectLock)
            {
                Process16Bit(buffer, offset, read);
            }
        }
        &lt;span class="kwrd"&gt;return&lt;/span&gt; read;
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Process16Bit(&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buffer, &lt;span class="kwrd"&gt;int&lt;/span&gt; offset, &lt;span class="kwrd"&gt;int&lt;/span&gt; count)
    {
        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Effect effect &lt;span class="kwrd"&gt;in&lt;/span&gt; effects)
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (effect.Enabled)
            {
                effect.Block();
            }
        }

        &lt;span class="kwrd"&gt;for&lt;/span&gt;(&lt;span class="kwrd"&gt;int&lt;/span&gt; sample = 0; sample &amp;lt; count/2; sample++)
        {
            &lt;span class="rem"&gt;// get the sample(s)&lt;/span&gt;
            &lt;span class="kwrd"&gt;int&lt;/span&gt; x = offset + sample * 2;
            &lt;span class="kwrd"&gt;short&lt;/span&gt; sample16Left = BitConverter.ToInt16(buffer, x);
            &lt;span class="kwrd"&gt;short&lt;/span&gt; sample16Right = sample16Left;
            &lt;span class="kwrd"&gt;if&lt;/span&gt;(WaveFormat.Channels == 2)
            {                    
                sample16Right = BitConverter.ToInt16(buffer, x + 2);
                sample++;
            }
           
            &lt;span class="rem"&gt;// run these samples through the effects&lt;/span&gt;
            &lt;span class="kwrd"&gt;float&lt;/span&gt; sample64Left = sample16Left / 32768.0f;
            &lt;span class="kwrd"&gt;float&lt;/span&gt; sample64Right = sample16Right / 32768.0f;
            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Effect effect &lt;span class="kwrd"&gt;in&lt;/span&gt; effects)
            {
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (effect.Enabled)
                {
                    effect.Sample(&lt;span class="kwrd"&gt;ref&lt;/span&gt; sample64Left, &lt;span class="kwrd"&gt;ref&lt;/span&gt; sample64Right);
                }
            }

            sample16Left = (&lt;span class="kwrd"&gt;short&lt;/span&gt;)(sample64Left * 32768.0f);
            sample16Right = (&lt;span class="kwrd"&gt;short&lt;/span&gt;)(sample64Right * 32768.0f);

            &lt;span class="rem"&gt;// put them back&lt;/span&gt;
            buffer[x] = (&lt;span class="kwrd"&gt;byte&lt;/span&gt;)(sample16Left &amp;amp; 0xFF);
            buffer[x + 1] = (&lt;span class="kwrd"&gt;byte&lt;/span&gt;)((sample16Left &amp;gt;&amp;gt; 8) &amp;amp; 0xFF); 

            &lt;span class="kwrd"&gt;if&lt;/span&gt;(WaveFormat.Channels == 2)    
            {
                buffer[x + 2] = (&lt;span class="kwrd"&gt;byte&lt;/span&gt;)(sample16Right &amp;amp; 0xFF);
                buffer[x + 3] = (&lt;span class="kwrd"&gt;byte&lt;/span&gt;)((sample16Right &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
            }
        }
    }


    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; MoveUp(Effect effect)
    {
        &lt;span class="kwrd"&gt;lock&lt;/span&gt; (effectLock)
        {
            &lt;span class="kwrd"&gt;return&lt;/span&gt; effects.MoveUp(effect);
        }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; MoveDown(Effect effect)
    {
        &lt;span class="kwrd"&gt;lock&lt;/span&gt; (effectLock)
        {
            &lt;span class="kwrd"&gt;return&lt;/span&gt; effects.MoveDown(effect);
        }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddEffect(Effect effect)
    {
        InitialiseEffect(effect);
        &lt;span class="kwrd"&gt;lock&lt;/span&gt; (effectLock)
        {
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.effects.Add(effect);
        }
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; InitialiseEffect(Effect effect)
    {
        effect.SampleRate = WaveFormat.SampleRate;
        effect.Init();
        effect.Slider();
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; RemoveEffect(Effect effect)
    {
        &lt;span class="kwrd"&gt;lock&lt;/span&gt; (effectLock)
        {
            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.effects.Remove(effect);
        }
    }
}&lt;/pre&gt;

&lt;p&gt;When the &lt;b&gt;Read&lt;/b&gt; method on &lt;b&gt;EffectStream&lt;/b&gt; is called, we first read the requested number of bytes from our source &lt;b&gt;WaveStream&lt;/b&gt;. This might be from a WAV or MP3 file, or from a microphone. Then, we convert it from 16 bit to 32 bit floating point audio. 16 bit audio is stored as integers going from -32,768 to 32,767, and 32 bit audio uses the range -1.0 to 1.0 to represent this range. This means we have plenty of headroom to mix together multiple signals without distorting. It is important though to remember that no samples should be greater than 1.0 before converting back to 16 bit.&lt;/p&gt;

&lt;h3&gt;Porting Effects to .NET&lt;/h3&gt;

&lt;p&gt;Now we have a basic effect framework, it is time to create some real effects to use. There are many sources of algorithms for digital signal processing (DSP) (try &lt;a href="http://www.musicdsp.org/"&gt;musicdsp.org&lt;/a&gt; for a good starting point), but I have chosen to base my effects model on that provided by the &lt;a href="http://www.reaper.fm/"&gt;REAPER digital audio workstation&lt;/a&gt; (DAW). This impressive application, masterminded by legendary software developer &lt;a href="http://en.wikipedia.org/wiki/Justin_Frankel"&gt;Justin Frankel&lt;/a&gt;, includes a text-based effects framework. These effects, known as &lt;a href="http://www.reaper.fm/sdk/js/"&gt;JS effects&lt;/a&gt;, allow the use of a C-like syntax to quickly write your own effects. I have modelled my &lt;b&gt;Effect&lt;/b&gt; class on the JS syntax, allowing me to quickly port effects across.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Tremolo : Effect
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; Tremolo()
    {
        AddSlider(4,0,100,1,&lt;span class="str"&gt;&amp;quot;frequency (Hz)&amp;quot;&lt;/span&gt;);
        AddSlider(-6,-60,0,1,&lt;span class="str"&gt;&amp;quot;amount (dB)&amp;quot;&lt;/span&gt;);
        AddSlider(0, 0, 1, 0.1f, &lt;span class="str"&gt;&amp;quot;stereo separation (0..1)&amp;quot;&lt;/span&gt;);
    }

    &lt;span class="kwrd"&gt;float&lt;/span&gt; adv, sep, amount, sc, pos;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Slider()
    {
        adv=PI*2*slider1/SampleRate;
        sep=slider3*PI;
        amount=pow(2,slider2/6);
        sc=0.5f*amount; amount=1-amount;
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Sample(&lt;span class="kwrd"&gt;ref&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; spl0, &lt;span class="kwrd"&gt;ref&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; spl1)
    {
        spl0 = spl0 * ((cos(pos) + 1) * sc + amount);
        spl1 = spl1 * ((cos(pos + sep) + 1) * sc + amount);
        pos += adv;
    }
}&lt;/pre&gt;

&lt;p&gt;Some members in the &lt;b&gt;Effect&lt;/b&gt; base class such as &lt;b&gt;cos&lt;/b&gt; and &lt;b&gt;slider1&lt;/b&gt; allow me to keep the ported syntax as similar to the original JS script as possible.&lt;/p&gt;

&lt;p&gt;REAPER ships with well over 100 of these JS Effects, so I chose about 15 of them and ported them to .NET. They are available in the download that accompanies this article. With some of them, for example pitch shifting effects, you will immediately notice the effect on the sound, while others, such as compressors, require some knowledge of how to adjust the parameters to get good results.&lt;/p&gt;

&lt;h4&gt;The Test Harness&lt;/h4&gt;

&lt;p&gt;Obviously we need a way to pass audio through our effects, so our next task is to create a test harness that will allow us to load in audio files and listen to them with the effects applied. For this purpose I created a simple Windows Forms application that allows you to select a WAV or MP3 file to play back. After being converted into PCM using various classes from the NAudio library, the resulting &lt;b&gt;WaveStream&lt;/b&gt; is passed through an &lt;b&gt;EffectStream &lt;/b&gt;before being passed to the soundcard for playback. The use of an &lt;b&gt;EffectChain &lt;/b&gt;allows us to modify the effects loaded, and their order during playback.&lt;/p&gt;

&lt;p&gt;To make the loading of effects simpler, I used the &lt;a&gt;&lt;/a&gt;&lt;a href="http://www.codeplex.com/MEF"&gt;Managed Extensibility Framework&lt;/a&gt; (MEF), to &lt;a href="#_msocom_1" name="_msoanchor_1"&gt;[DF1]&lt;/a&gt; make each effect a “plugin” to the test harness. Each effect is decorated with an &lt;b&gt;Export&lt;/b&gt; attribute to indicate that it is a plugin:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[Export(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Effect))]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SuperPitch : Effect&lt;/pre&gt;

&lt;p&gt;Then I can request that MEF auto-populates a property with all the exported effects it can find:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[Import]
&lt;span class="kwrd"&gt;public&lt;/span&gt; ICollection&amp;lt;Effect&amp;gt; Effects { get; set; }&lt;/pre&gt;

&lt;p&gt;When the user selects an effect from the list of available effects, we create a new instance of it. This is because you might want to put the same effect into the effect chain more than once:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;EffectSelectorForm effectSelectorForm = &lt;span class="kwrd"&gt;new&lt;/span&gt; EffectSelectorForm(Effects);
&lt;span class="kwrd"&gt;if&lt;/span&gt; (effectSelectorForm.ShowDialog(&lt;span class="kwrd"&gt;this&lt;/span&gt;) == DialogResult.OK)
{
    &lt;span class="rem"&gt;// create a new instance of the selected effect &lt;/span&gt;
    &lt;span class="rem"&gt;// as we may want multiple copies of one effect&lt;/span&gt;
    Effect effect = (Effect)Activator.CreateInstance(
       effectSelectorForm.SelectedEffect.GetType());
    audioGraph.AddEffect(effect);
    checkedListBox1.Items.Add(effect, &lt;span class="kwrd"&gt;true&lt;/span&gt;);
}&lt;/pre&gt;

&lt;p&gt;To allow real-time modification of the effect parameters, I created two user controls. The first, &lt;b&gt;EffectSliderPanel&lt;/b&gt; allows you to hook up a Windows Forms &lt;b&gt;TrackBar&lt;/b&gt; to one of our effect’s sliders and manages the minimum, maximum and granularity settings. The second user control, &lt;b&gt;EffectPanel&lt;/b&gt; takes an &lt;b&gt;Effect&lt;/b&gt; and creates one &lt;b&gt;EffectSliderPanel&lt;/b&gt; for each slider in that effect. It also is responsible for calling the &lt;b&gt;Slider&lt;/b&gt; method on the &lt;b&gt;Effect&lt;/b&gt; whenever the user moves one of the sliders. Here’s an example of what it looks like:&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="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image.png" width="488" height="164" /&gt; &lt;/p&gt;

&lt;p&gt;Now we are able to test our effects by listening to WAV files and playing them with real-time control over their parameters.&lt;/p&gt;

&lt;h3&gt;Intercepting Skype Audio&lt;/h3&gt;

&lt;p&gt;There are many interesting uses for audio effects, but it was suggested to me that I create a “voice changer” for Skype as the example program for this article. At first I didn’t think that this would be possible, as you would need access to the audio samples from the microphone &lt;i&gt;before&lt;/i&gt; Skype transmitted them over the network.&lt;/p&gt;

&lt;p&gt;However, it turns out that Skype has a full featured SDK to allow all kinds of third-party add-ons and enhancements. The Skype API can be used in .NET via a COM object, called &lt;a href="https://developer.skype.com/"&gt;Skype4Com&lt;/a&gt;. Skype plugins are not loaded directly by the Skype application but attach to it via network sockets. The Skype4Com COM object hides much of this complexity from the user.&lt;/p&gt;

&lt;p&gt;Having added Skype4Com as a reference to our application, we then need to connect to Skype. This is achieved by using the following code:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Protocol = 8;
skype = &lt;span class="kwrd"&gt;new&lt;/span&gt; Skype();
_ISkypeEvents_Event events = (_ISkypeEvents_Event)skype;
events.AttachmentStatus += OnSkypeAttachmentStatus;            
skype.CallStatus += OnSkypeCallStatus;
skype.Attach(Protocol, &lt;span class="kwrd"&gt;false&lt;/span&gt;);&lt;/pre&gt;

&lt;p&gt;In the &lt;b&gt;CallStatus&lt;/b&gt; event handler, we tell Skype that we wish to ‘capture’ the microphone. This will cause it to send us the raw audio data from the microphone via a TCP socket. Then we tell it that we will send the audio to be transmitted using another TCP socket.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;void&lt;/span&gt; OnSkypeCallStatus(Call call, TCallStatus status)
{
    log.Info(&lt;span class="str"&gt;&amp;quot;SkypeCallStatus: {0}&amp;quot;&lt;/span&gt;, status);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (status == TCallStatus.clsInProgress)
    {
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.call = call;                  
        call.set_CaptureMicDevice(
        TCallIoDeviceType.callIoDeviceTypePort, MicPort.ToString());
        call.set_InputDevice(
        TCallIoDeviceType.callIoDeviceTypeSoundcard, &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);
        call.set_InputDevice(
        TCallIoDeviceType.callIoDeviceTypePort, OutPort.ToString());
    }
    &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (status == TCallStatus.clsFinished)
    {
        call = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
        packetSize = 0;
    }
}&lt;/pre&gt;

&lt;p&gt;I found an example Delphi application on the Skype developer website which shows how to intercept the microphone signal to &lt;a href="https://developer.skype.com/Docs/Skype4COM/Example/MicBooster_pas"&gt;boost the signal level&lt;/a&gt;. I used this sample as the starting point for creating my own application to intercept audio samples in Skype. The Delphi application made use of an object called &lt;a href="http://www.indyproject.org/docsite/html/frames.html?frmname=topic&amp;amp;frmfile=TIdTCPServer.html"&gt;TIdTCPServer&lt;/a&gt;, which is a multi-threaded socket server. I created a very simple .NET implementation of this class (without the multi-threading as we will only have one connection at a time):&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; TcpServer : IDisposable
{
    TcpListener listener;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler&amp;lt;ConnectedEventArgs&amp;gt; Connect;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler Disconnect;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler&amp;lt;DataReceivedEventArgs&amp;gt; DataReceived;
    
    &lt;span class="kwrd"&gt;public&lt;/span&gt; TcpServer(&lt;span class="kwrd"&gt;int&lt;/span&gt; port)
    {
        listener = &lt;span class="kwrd"&gt;new&lt;/span&gt; TcpListener(IPAddress.Loopback, port);
        listener.Start();
        ThreadPool.QueueUserWorkItem(Listen);
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Listen(&lt;span class="kwrd"&gt;object&lt;/span&gt; state)
    {
        &lt;span class="kwrd"&gt;while&lt;/span&gt; (&lt;span class="kwrd"&gt;true&lt;/span&gt;)
        {
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (TcpClient client = listener.AcceptTcpClient())
            {
                AcceptClient(client);
            }
        }
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AcceptClient(TcpClient client)
    {
        &lt;span class="kwrd"&gt;using&lt;/span&gt; (NetworkStream inStream = client.GetStream())
        {
            OnConnect(inStream);
            &lt;span class="kwrd"&gt;while&lt;/span&gt; (client.Connected)
            {
                &lt;span class="kwrd"&gt;int&lt;/span&gt; available = client.Available;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (available &amp;gt; 0)
                {
                    &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buffer = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[available];
                    &lt;span class="kwrd"&gt;int&lt;/span&gt; read = inStream.Read(buffer, 0, available);
                    Debug.Assert(read == available);
                    OnDataReceived(buffer);
                }
                &lt;span class="kwrd"&gt;else&lt;/span&gt;
                {
                    Thread.Sleep(50);
                }
            }
        }
        OnDisconnect();
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnConnect(NetworkStream stream)
    {
        var connect = Connect;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (connect != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        {
            connect(&lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; ConnectedEventArgs() { Stream = stream });
        }
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnDisconnect()
    {
        var disconnect = Disconnect;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (disconnect != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        {
            disconnect(&lt;span class="kwrd"&gt;this&lt;/span&gt;, EventArgs.Empty);
        }
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnDataReceived(&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buffer)
    {
        var execute = DataReceived;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (execute != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        {
            execute(&lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; DataReceivedEventArgs() { Buffer = buffer });
        }
    }

    &lt;span class="preproc"&gt;#region&lt;/span&gt; IDisposable Members

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Dispose()
    {
        listener.Stop();
    }

    &lt;span class="preproc"&gt;#endregion&lt;/span&gt;
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; DataReceivedEventArgs : EventArgs
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] Buffer { get; set; }
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ConnectedEventArgs : EventArgs
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; NetworkStream Stream { get; set; }
}&lt;/pre&gt;

&lt;p&gt;Once Skype has been told the port numbers on which to connect, it will attempt to open sockets to our &lt;b&gt;TcpListener&lt;/b&gt; classes (one for audio in, and one for audio out). We now simply need to pass the audio through our effect chain. But &lt;b&gt;EffectStream &lt;/b&gt;needs a &lt;b&gt;WaveStream&lt;/b&gt; derived class for its input, so I created &lt;b&gt;SkypeBufferStream&lt;/b&gt; to which we pass the raw data received on the microphone in socket, and it returns it in its &lt;b&gt;Read&lt;/b&gt; method. One difficulty I encountered was that Skype offers no way of querying what the sample rate of the incoming data is. On my PC it seems to be 44.1kHz, but I do not know if this is guaranteed on all computers.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; SkypeBufferStream : WaveStream
{
    &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] latestInBuffer;
    WaveFormat waveFormat;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; SkypeBufferStream(&lt;span class="kwrd"&gt;int&lt;/span&gt; sampleRate)
    {
        waveFormat = &lt;span class="kwrd"&gt;new&lt;/span&gt; WaveFormat(sampleRate, 16, 1);
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; WaveFormat WaveFormat
    {
        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; waveFormat; }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;long&lt;/span&gt; Length
    {
        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; 0; }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;long&lt;/span&gt; Position
    {
        get
        {
            &lt;span class="kwrd"&gt;return&lt;/span&gt; 0;
        }
        set
        {
            &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; NotImplementedException();
        }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetLatestInBuffer(&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buffer)
    {
        latestInBuffer = buffer;
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Read(&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buffer, &lt;span class="kwrd"&gt;int&lt;/span&gt; offset, &lt;span class="kwrd"&gt;int&lt;/span&gt; count)
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (offset != 0)
            &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ArgumentOutOfRangeException(&lt;span class="str"&gt;&amp;quot;offset&amp;quot;&lt;/span&gt;);
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (buffer != latestInBuffer)
            Array.Copy(latestInBuffer, buffer, count);
        &lt;span class="kwrd"&gt;return&lt;/span&gt; count;
    }
}&lt;/pre&gt;

&lt;p&gt;Now when we receive any data from the microphone socket, we pass it through the &lt;b&gt;SkypeBufferStream&lt;/b&gt; which in turn passes it through the &lt;b&gt;EffectStream&lt;/b&gt; and finally out on the output socket’s data stream. Here’s the relevant code (found in the &lt;b&gt;MicInterceptor&lt;/b&gt; class):&lt;/p&gt;

&lt;pre class="csharpcode"&gt;NetworkStream outStream;
SkypeBufferStream bufferStream;
WaveStream outputStream;

&lt;span class="kwrd"&gt;void&lt;/span&gt; OnOutServerConnect(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, ConnectedEventArgs e)
{
    log.Info(&lt;span class="str"&gt;&amp;quot;OutServer Connected&amp;quot;&lt;/span&gt;);
    outStream = e.Stream;
}

&lt;span class="kwrd"&gt;void&lt;/span&gt; OnMicServerExecute(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, DataReceivedEventArgs args)
{
    &lt;span class="rem"&gt;// log.Info(&amp;quot;Got {0} bytes&amp;quot;, args.Buffer.Length);&lt;/span&gt;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (outStream != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
    {
        &lt;span class="rem"&gt;// give the input audio to the beginning of our audio graph&lt;/span&gt;
        bufferStream.SetLatestInBuffer(args.Buffer);
        &lt;span class="rem"&gt;// process it out through the effects&lt;/span&gt;
        outputStream.Read(args.Buffer, 0, args.Buffer.Length);
        &lt;span class="rem"&gt;// play it back&lt;/span&gt;
        outStream.Write(args.Buffer, 0, args.Buffer.Length);
    }
}&lt;/pre&gt;

&lt;p&gt;When you run your application for the first time, you will need to grant it permission from within Skype:&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="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_3.png" width="203" height="133" /&gt; &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="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_4.png" width="500" height="371" /&gt; &lt;/p&gt;

&lt;p&gt;To test that the effects are working in Skype is a little tricky as you will not hear the effected sound on your end of the conversation. One good way of checking the effects are working as expected is to use the Skype test call service. This is a number you can dial and it will record what you say and play it back to you. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_thumb.png" width="240" height="20" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;It is a good idea to test your effect first using a local audio file, as you will not easily be able to determine whether glitches and other audio artifacts were caused by your effect, or simply due to poor network conditions.&lt;/p&gt;

&lt;p&gt;There are a few things you should be aware of when selecting effects for use with Skype. First, the audio is mono, so there is no point using any effects such as stereo delay. Second, the audio is almost certainly down-sampled to a much lower sample rate before being transmitted to save on network bandwidth. This means any high frequency components of your sound will be lost. Third, internet telephony applications often have built in echo-suppression, so using delay-based effects might not work quite as well as you were hoping. &lt;/p&gt;

&lt;p&gt;For silly voice effects, the most effective is pitch shifting (try the &lt;b&gt;SuperPitch&lt;/b&gt; effect and shift either up or down about five semitones). &lt;b&gt;FlangeBaby&lt;/b&gt; or &lt;b&gt;Chorus&lt;/b&gt; can be used for more subtle voice changing effects. Or if you just want to be annoying, load up a &lt;b&gt;Delay&lt;/b&gt;. Feel free to experiment with the other included effects, but bear in mind that many of them are designed with more musical uses in mind, so may not be relevant for internet telephony.&lt;/p&gt;

&lt;h3&gt;The Sample Code&lt;/h3&gt;

&lt;p&gt;The source code for all the effects, the &lt;b&gt;EffectStream&lt;/b&gt; and the Skype connection code described in this article is available in the provided download. It uses a recent unreleased build of NAudio, so you will also need to visit the NAudio CodePlex site if you want to get access to the full source code. The &lt;b&gt;EffectStream&lt;/b&gt; and &lt;b&gt;Effect&lt;/b&gt; classes will eventually be made part of the NAudio framework, once I have refined their design a bit.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_thumb_3.png" width="500" height="227" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;How to use Effect Tester sample app: 
  &lt;table border="1" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" width="57"&gt;&lt;a href="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_7.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_thumb_4.png" width="45" height="41" /&gt;&lt;/a&gt; &lt;/td&gt;

        &lt;td valign="top" width="559"&gt;
          &lt;p&gt;Click this icon to attach to Skype and await a call. Click it again to disconnect, allowing you to test your effects using audio files instead. The textbox in the top right corner keeps you updated with the status of the connection to Skype&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="57"&gt;&lt;a href="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_thumb_5.png" width="39" height="43" /&gt;&lt;/a&gt; &lt;/td&gt;

        &lt;td valign="top" width="559"&gt;
          &lt;p&gt;Click this icon to load a WAV or MP3 file for playback. Files at 44.1kHz work best.&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="57"&gt;&lt;a href="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_9.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_thumb_6.png" width="147" height="40" /&gt;&lt;/a&gt; &lt;/td&gt;

        &lt;td valign="top" width="559"&gt;
          &lt;p&gt;Rewind, Play, Pause or Stop the current WAV or MP3 file.&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="57"&gt;&lt;a href="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_thumb_7.png" width="38" height="42" /&gt;&lt;/a&gt; &lt;/td&gt;

        &lt;td valign="top" width="559"&gt;
          &lt;p&gt;Brings up the effect selector dialog to add a new instance of an effect to the current Effect chain. Loaded effects appear in the CheckedListBox on the left.&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="57"&gt;&lt;a href="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_thumb_8.png" width="42" height="41" /&gt;&lt;/a&gt; &lt;/td&gt;

        &lt;td valign="top" width="559"&gt;
          &lt;p&gt;Removes the currently selected effect from the effect chain&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="57"&gt;&lt;a href="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_12.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_thumb_9.png" width="74" height="40" /&gt;&lt;/a&gt; &lt;/td&gt;

        &lt;td valign="top" width="559"&gt;
          &lt;p&gt;Move the currently selected effects up or down in the signal chain&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="57"&gt;&lt;a href="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_13.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_thumb_10.png" width="96" height="42" /&gt;&lt;/a&gt; &lt;/td&gt;

        &lt;td valign="top" width="559"&gt;
          &lt;p&gt;Use the checkboxes to enable or disable effects in the effect chain on the fly.&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td valign="top" width="57"&gt;&lt;a href="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.coding4fun.net/images/SkypeVoiceChanger_A7CE/image_thumb_11.png" width="228" height="44" /&gt;&lt;/a&gt; &lt;/td&gt;

        &lt;td valign="top" width="559"&gt;
          &lt;p&gt;Use the sliders to adjust the effect parameters in real-time&lt;/p&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;h3&gt;About the Author&lt;/h3&gt;

&lt;p&gt;Mark&lt;b&gt; &lt;/b&gt;Heath is a .NET developer based in Southampton, UK. When he’s not writing .NET audio applications for fun, he enjoys home studio recording, playing football, reading theology books and sword fighting with his four small children. His development blog can be found at &lt;a href="http://mark-dot-net.blogspot.com"&gt;http://mark-dot-net.blogspot.com&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9391048" 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/Audio/default.aspx">Audio</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>Silverlight Dynamic Video Puzzle</title><link>http://blogs.msdn.com/coding4fun/archive/2008/01/22/7163484.aspx</link><pubDate>Tue, 22 Jan 2008 22:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7163484</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/7163484.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=7163484</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=7163484</wfw:comment><description>&lt;P&gt;My blog title says it all, &lt;A href="http://www.betterthaneveryone.com/" mce_href="http://www.betterthaneveryone.com/"&gt;Monkey see, Monkey Build&lt;/A&gt;.&amp;nbsp; I saw Microsoft Surface's video puzzle and I needed to build it.&amp;nbsp; I took this opportunity to play with Microsoft's new technology, &lt;A href="http://silverlight.net/" mce_href="http://silverlight.net"&gt;Silverlight&lt;/A&gt; and build my own puzzle game.&amp;nbsp; I couldn't find anything out on the Internet regarding dynamic video creation with Silverlight so I took it upon myself to do this.&amp;nbsp; The screen shots in this demo will be in c#, however, everything should hold true for VB.&lt;/P&gt;
&lt;P&gt;Clint Rutkas - Academic Developer Evangelist - Microsoft &lt;BR&gt;&lt;A href="http://www.betterthaneveryone.com/" mce_href="http://www.betterthaneveryone.com/"&gt;Monkey see, Monkey Build&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; 6-10 hours &lt;BR&gt;&lt;B&gt;Cost: &lt;/B&gt;Free &lt;BR&gt;&lt;B&gt;Software: &lt;/B&gt;&lt;B&gt;&lt;A href="http://www.microsoft.com/express/" mce_href="http://www.microsoft.com/express/"&gt;Visual Studio Express&lt;/A&gt;, &lt;A href="http://silverlight.net/GetStarted/" mce_href="http://silverlight.net/GetStarted/"&gt;Silverlight SDK and Runtime for &lt;STRIKE&gt;1.1&lt;/STRIKE&gt; 2.0 beta2&lt;/A&gt;&lt;/B&gt; &lt;BR&gt;&lt;B&gt;Download: &lt;/B&gt;&lt;A href="http://www.peacelovecode.com/code/silverlight/puzzle/1.0.0.0/surfacePuzzleDemo.zip" mce_href="http://www.peacelovecode.com/code/silverlight/puzzle/1.0.0.0/surfacePuzzleDemo.zip"&gt;&lt;STRIKE&gt;Download c#&lt;/STRIKE&gt;&lt;/A&gt;&lt;STRIKE&gt; - &lt;/STRIKE&gt;&lt;A href="http://www.peacelovecode.com/code/silverlight/puzzle/1.0.0.0/surfacePuzzleDemoVB.zip" mce_href="http://www.peacelovecode.com/code/silverlight/puzzle/1.0.0.0/surfacePuzzleDemoVB.zip"&gt;&lt;STRIKE&gt;Download VB&lt;/STRIKE&gt;&lt;/A&gt; Updated to Silverlight 2.0 Beta - &lt;A href="http://www.peacelovecode.com/code/silverlight/puzzle/2.0.0.0/VideoRealTimeBreakUp.zip"&gt;Download c#&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Updates: &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Fixed the Silverlight.Js, used the new version that is included with the 1.1 Refresh SDK so the proper installer will prompt now.&amp;nbsp; Downloads are corrected also too. &lt;/LI&gt;
&lt;LI&gt;6/20/2008&amp;nbsp;- Verified the solution works with Silverlight 2.0beta2.&lt;/LI&gt;&lt;/UL&gt;
&lt;H2&gt;Spec's, Requirements and headaches&lt;/H2&gt;
&lt;P&gt;So I had a few mental requirements for the application to "entertain" myself.&amp;nbsp; &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Be able to rotate the video blocks &lt;/LI&gt;
&lt;LI&gt;Be able to translate &lt;/LI&gt;
&lt;LI&gt;Be able to increase the difficulty of the puzzle on the fly. &lt;/LI&gt;
&lt;LI&gt;Zero interaction with the keyboard&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Simple, right?&amp;nbsp; You want to see a demo too see some awesomeness?&amp;nbsp; No problem, &lt;A href="http://www.betterthaneveryone.com/archive/2008/01/06/silverlight-ms-surface-puzzle-like-demo.aspx" mce_href="http://www.betterthaneveryone.com/archive/2008/01/06/silverlight-ms-surface-puzzle-like-demo.aspx"&gt;head over to my site&lt;/A&gt; and see it in person.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Microsoft Surface Video Puzzle&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="MARGIN: 0px 0px 0px 5px" height=180 alt=sl_9[1] src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/sl_91.jpg" width=240 border=0 mce_src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/sl_91.jpg"&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Clint's Silverlight Video Puzzle&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image1.png" mce_href="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image1.png"&gt;&lt;IMG style="MARGIN: 0px 0px 0px 5px" height=219 alt=image[1] src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image1_thumb.png" width=240 border=0 mce_src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image1_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;H2&gt;To the Internet Batman!&lt;/H2&gt;
&lt;P&gt;To help save time building this, I first when out and attempting to see if anything has been done anything close to this before.&amp;nbsp; I found&lt;/P&gt;
&lt;P&gt;Also I need 2 small controls which I found out are in the Silverlight SDK.&amp;nbsp; I needed horizontal slider controls for this app.&amp;nbsp; While I know a text box control would have worked just as well, see requirement 4.&lt;/P&gt;
&lt;P&gt;On the Silverlight community site, there is also a very nice demo showing the &lt;A href="http://silverlight.net/samples/1.1/SilverlightSurface/Run/default.html" mce_href="http://silverlight.net/samples/1.1/SilverlightSurface/Run/default.html"&gt;photo application in Surface with source code&lt;/A&gt;.&amp;nbsp; This is where I learned the majority of what I needed.&amp;nbsp; This application was very close to where I needed to go with mine.&amp;nbsp; However, while it was close, it wasn't perfect.&amp;nbsp; Parts of the photo application code are pretty much copied.&amp;nbsp; This isn't the best way of doing this, but it is one way of doing it.&lt;/P&gt;
&lt;H2&gt;Toolbelt: check, Keyboard: check, Band-aids: check&lt;/H2&gt;
&lt;P&gt;So on to building it.&amp;nbsp; I first started off with a new project and some XAML.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_6.png" mce_href="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_6.png"&gt;&lt;IMG style="MARGIN: 0px 0px 0px 5px" height=269 alt=image src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image.png" width=400 border=0 mce_src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;After clicking "OK", I get a very nice blank project.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;A href="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_7.png" mce_href="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_7.png"&gt;&lt;IMG style="MARGIN: 0px 0px 0px 5px" height=367 alt=image src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_3.png" width=400 border=0 mce_src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;We'll want to add an additional XAML object for the video blocks.&amp;nbsp; Go to "&lt;STRONG&gt;Project -&amp;gt; Add New Item&lt;/STRONG&gt;", select Silverlight Page, name it "VideoBlock.xaml" and click "OK".&lt;/P&gt;
&lt;P&gt;So now we have everything we need for the most part, grab any video you have, if you don't have one, go to a site like &lt;A href="http://teamxbox.com/" mce_href="http://teamxbox.com"&gt;TeamXbox&lt;/A&gt; and grab one from there.&amp;nbsp; I used Windows Movie Maker and grabbed a snippet from The Office (best show ever).&lt;/P&gt;
&lt;P&gt;In addition to all these files, we need to add in a reference to the Silverlight SDK to get a hold of the Slider controls. Go to "&lt;STRONG&gt;Project -&amp;gt; Add Reference&lt;/STRONG&gt;", and add in the &lt;STRONG&gt;Silverlight.Samples.Controls.dll&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;While we have a reference in the application, we still need the XAML to know about this also.&amp;nbsp; So we'll add a line to link this in.&amp;nbsp; It is the xmlns line that I bolded, XML name space, real clever, eh?&amp;nbsp; We'll also&amp;nbsp; change the background color to a gray so we can see it more easy.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Canvas&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="parentCanvas"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/client/2007"&lt;/SPAN&gt; 
        &lt;SPAN class=attr&gt;xmlns:x&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/SPAN&gt; 
        &lt;SPAN class=attr&gt;Loaded&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Page_Loaded"&lt;/SPAN&gt; 
        &lt;SPAN class=attr&gt;x:Class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="c4f_SilverlightVideoDemo.VideoBlock;assembly=ClientBin/c4f_SilverlightVideoDemo.dll"&lt;/SPAN&gt;
        &lt;STRONG&gt;&lt;SPAN class=attr&gt;xmlns:uicontrol&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="clr-namespace:Silverlight.Samples.Controls;assembly=ClientBin/Silverlight.Samples.Controls.dll"&lt;/SPAN&gt;&lt;/STRONG&gt;
        &lt;SPAN class=attr&gt;Background&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="#CCCCCC" &lt;SPAN class=attr&gt;Width&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="640"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Height&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="480"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Canvas&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&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;*/
	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;Silverlight 101&lt;/H2&gt;
&lt;P&gt;So in Silverlight, you have brushes which can "painted" onto objects.&amp;nbsp; One of these brushes is called the VideoBrush which I'll talk about later on.&amp;nbsp; For playing videos, one would use the &lt;STRONG&gt;MediaElement&lt;/STRONG&gt;.&amp;nbsp; Lets add this to our canvas.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;MediaElement&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="media"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Source&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="theOffice.wmv"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&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;Now if we run the application at this point, we'll get the video playing.&amp;nbsp; Lets sit back with some popcorn and enjoy this victory for a second or two.&amp;nbsp; Now that we have this, lets hide it since this isn't what we want.&amp;nbsp; We do that by adding in an XML attribute &lt;STRONG&gt;Opacity&lt;/STRONG&gt; and setting it to 0.&lt;/P&gt;
&lt;P&gt;On top of that element, lets add on some TextBlock elements and the sliders.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Canvas&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="parentCanvas"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/client/2007"&lt;/SPAN&gt; 
        &lt;SPAN class=attr&gt;xmlns:x&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/SPAN&gt; 
        &lt;SPAN class=attr&gt;Loaded&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Page_Loaded"&lt;/SPAN&gt; 
        &lt;SPAN class=attr&gt;x:Class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="VideoCreatedObjectTest.Page;assembly=ClientBin/VideoCreatedObjectTest.dll"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;xmlns:uicontrol&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="clr-namespace:Silverlight.Samples.Controls;assembly=ClientBin/Silverlight.Samples.Controls.dll"&lt;/SPAN&gt; 
        &lt;SPAN class=attr&gt;Background&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="#CCCCCC"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;MediaElement&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="media"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Source&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="theOffice.wmv"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Opacity&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="0"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TextBlock&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="sliderX"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Top&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="5"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Left&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="5"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Text&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="X (01):"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TextBlock&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="sliderY"&lt;/SPAN&gt;  &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Top&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="21"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Left&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="5"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Text&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Y (01):"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;uicontrol:Slider&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="hSliderX"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Top&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="8"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Left&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="55"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;uicontrol:Slider&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="hSliderY"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Top&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="25"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Left&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="55"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Canvas&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&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;So now when we run the application, we get a blank screen but we can hear the audio from the video.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_8.png" mce_href="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_8.png"&gt;&lt;IMG style="MARGIN: 0px 0px 0px 5px" height=345 alt=image src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_4.png" width=400 border=0 mce_src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_4.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Super exciting I know.&amp;nbsp; Now if you resize the browser, you'll notice also the canvas isn't resizing automatically.&amp;nbsp; Lets fix that.&lt;/P&gt;
&lt;P&gt;So in the code behind lets add in a new event on the BrowserHost object with the Resize event.&amp;nbsp; We'll attach the Browser_Resize event to it.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;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; BrowserHost_Resize(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, EventArgs e)
{
    &lt;SPAN class=rem&gt;// Set size to host size&lt;/SPAN&gt;
    Width = BrowserHost.ActualWidth;
    Height = BrowserHost.ActualHeight;
}&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;VB.Net&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; BrowserHost_Resize(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Object&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; EventArgs)
    &lt;SPAN class=rem&gt;' Set size to host size&lt;/SPAN&gt;
    Width = BrowserHost.ActualWidth
    Height = BrowserHost.ActualHeight
&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; Sub&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;H2&gt;Video as Paint?&lt;/H2&gt;
&lt;P&gt;So now that we have that small part done, lets get into more of the nitty gritty with video.&amp;nbsp; As I said earlier, you'll use a &lt;STRONG&gt;VideoBrush&lt;/STRONG&gt; to paint on the video.&lt;/P&gt;
&lt;P&gt;We'll use the brush as the Fill for the rectangle we'll be using to show off the clip of the video we want.&lt;/P&gt;
&lt;H3&gt;Still not moving?&amp;nbsp; Try explosives?&lt;/H3&gt;
&lt;P&gt;While doing this project, I discovered an interesting thing when using the VideoBrush and dynamically appending items on.&amp;nbsp; Having items in the XAML rather than programmatically creating everything caused it not to work properly.&amp;nbsp; Nothing would appear.&lt;/P&gt;
&lt;H3&gt;Throwback to how UI's use to be done&lt;/H3&gt;
&lt;P&gt;The XAML for this is a simplified version of the Surface demo Photo.XAML.&amp;nbsp; You have a 3 Rectangles, 1 for the video, 1 for translation and 1 for rotation.&amp;nbsp; Simple, no?&amp;nbsp; Doing all this by hand gets a bit annoying since you need to nest everything properly.&lt;/P&gt;
&lt;P&gt;Here is the more interesting &lt;STRONG&gt;VideoBrush&lt;/STRONG&gt; code.&amp;nbsp; You need the name from the &lt;STRONG&gt;MediaElement &lt;/STRONG&gt;along with the how much of an offset you want the video.&amp;nbsp; Since your moving the "camera" in, this value needs to be negative.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_10.png" mce_href="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_10.png"&gt;&lt;IMG style="MARGIN: 0px 0px 0px 5px" height=395 alt=image src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_5.png" width=654 border=0 mce_src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/image_5.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;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;delegate&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; SetActiveVideo(VideoBlock videoBlock, ActionType actionType, Point photoCenter, Point lastPosition);
&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; VideoBlock(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; mediaName, &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; offsetX, &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; offsetY, &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; rectWidth, &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; rectHeight, SetActiveVideo functionPointer)
{
    &lt;SPAN class=rem&gt;// additional code here&lt;/SPAN&gt;
    Rectangle video = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Rectangle();
    VideoBrush vb = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; VideoBrush();
    TranslateTransform videoTransform = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; TranslateTransform();
    videoTransform.X = -1 * offsetX;
    videoTransform.Y = -1 * offsetY;

    vb.SourceName = mediaName;
    vb.Transform = videoTransform;
    vb.Stretch = Stretch.None;
    vb.AlignmentX = AlignmentX.Left;
    vb.AlignmentY = AlignmentY.Top;

    video.Width = Width;
    video.Height = Height;
    video.Fill = vb;
    &lt;SPAN class=rem&gt;// additional code here&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;&lt;STRONG&gt;VB.Net&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;Delegate&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; SetActiveVideo(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; videoBlock &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; VideoBlock, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; actionType &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; ActionType, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; photoCenter &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; Point, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; lastPosition &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; Point)
&lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; VideoBlock(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; mediaName &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; offsetX &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; offsetY &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; rectWidth &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; rectHeight &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; functionPointer &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; SetActiveVideo)
      &lt;SPAN class=rem&gt;' additional code here&lt;/SPAN&gt;
      &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; video &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; Rectangle = &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; Rectangle
      &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; vb &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; VideoBrush = &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; VideoBrush
      &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; videoTransform &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; TranslateTransform = &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; TranslateTransform
      videoTransform.X = ((1 * offsetX)  * -1)
      videoTransform.Y = ((1 * offsetY)  * -1)
      vb.SourceName = mediaName
      vb.Transform = videoTransform
      vb.Stretch = Stretch.None
      vb.AlignmentX = AlignmentX.Left
      vb.AlignmentY = AlignmentY.Top
      video.Width = Width
      video.Height = Height
      video.Fill = vb
      &lt;SPAN class=rem&gt;' additional code here&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; Sub&lt;/PRE&gt;
&lt;H3&gt;There is a mouse on my object!&lt;/H3&gt;
&lt;P&gt;So now we have our video block element prepped and ready.&amp;nbsp; There are additional events added in, but they are fairly boiler plate.&amp;nbsp; When looking at this code, you see I pass in a delegate, a function pointer if you will.&amp;nbsp; Why do I do this?&amp;nbsp; This is how the mouse position is calculated.&amp;nbsp; I bet this could be redone better, but this is how I did it.&amp;nbsp; The parent element, the canvas, has the mouse position I need to calculate proper translation and rotation, however, mouse events on the VideoBlock object will give me the mouse position only on that element.&amp;nbsp; So I may be at point 150, 150 on the screen, on the VideoBlock object, I'm actually at 10,15.&lt;/P&gt;
&lt;P&gt;Additionally, this approach allows me to move the VideoBlock to the top of the objects.&amp;nbsp; Once again, this could be done other ways, this is how I chose to do it.&lt;/P&gt;
&lt;P&gt;So on all my mouse related all boils down to doing the exact same function.&amp;nbsp; Since events are bubbled, a mouse movement on a VideoBlock is also a mouse movement on the root canvas.&lt;/P&gt;
&lt;P&gt;C#&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; root_MouseLeftButtonDown(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, MouseEventArgs e)
{
    HandleMouseLeftButtonDown(ActionType.Selecting, e);
}

&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; translateControls_MouseLeftButtonDown(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, MouseEventArgs e)
{
    HandleMouseLeftButtonDown(ActionType.Moving, e);
}

&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; rotateScaleControls_MouseLeftButtonDown(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, MouseEventArgs e)
{
    HandleMouseLeftButtonDown(ActionType.RotatingScaling, e);
}

&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; HandleMouseLeftButtonDown(ActionType actionType, MouseEventArgs e)
{
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (functionPointer != &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;)
        functionPointer(&lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;, actionType,
            &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Point(translateTransform.X + rotateTransform.CenterX,
                  translateTransform.Y + rotateTransform.CenterY), e.GetPosition(&lt;SPAN class=kwrd&gt;null&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;VB.Net&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; root_MouseLeftButtonDown(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Object&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; MouseEventArgs)
        HandleMouseLeftButtonDown(ActionType.Selecting, e)
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;Private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; translateControls_MouseLeftButtonDown(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Object&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; MouseEventArgs)
        HandleMouseLeftButtonDown(ActionType.Moving, e)
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;Private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; rotateScaleControls_MouseLeftButtonDown(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Object&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; MouseEventArgs)
        HandleMouseLeftButtonDown(ActionType.RotatingScaling, e)
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;Private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; HandleMouseLeftButtonDown(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; actionType &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; ActionType, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; MouseEventArgs)
        &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;Not&lt;/SPAN&gt; (functionPointer) &lt;SPAN class=kwrd&gt;Is&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Nothing&lt;/SPAN&gt;) &lt;SPAN class=kwrd&gt;Then&lt;/SPAN&gt;
            functionPointer(&lt;SPAN class=kwrd&gt;Me&lt;/SPAN&gt;, actionType, &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; Point((translateTransform.X + rotateTransform.CenterX), &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (translateTransform.Y + rotateTransform.CenterY)), e.GetPosition(&lt;SPAN class=kwrd&gt;Nothing&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;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;H2&gt;You built a car out of all these parts?&lt;/H2&gt;
&lt;P&gt;So we move back from VideoBlock.xaml.cs to Page.xaml.cs&lt;/P&gt;
&lt;P&gt;We've created our primary object for painting video, lets populate it.&amp;nbsp; First, how do we know how big the media file is?&amp;nbsp; With the &lt;STRONG&gt;MediaOpened&lt;/STRONG&gt; event!&amp;nbsp; And we'll restart the video with the &lt;STRONG&gt;MediaEnded&lt;/STRONG&gt; event.&lt;/P&gt;
&lt;P&gt;So here is the full Page_Load event from Page.xaml.cs&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;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;void&lt;/SPAN&gt; Page_Loaded(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; o, EventArgs e)
{
    &lt;SPAN class=rem&gt;// Required to initialize variables&lt;/SPAN&gt;
    InitializeComponent();

    BrowserHost.Resize +=&lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler(BrowserHost_Resize);
    media.MediaOpened += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler(media_MediaOpened);
    media.MediaEnded += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler(media_MediaEnded);
    MouseLeftButtonUp += Page_MouseLeftButtonUpOrLeave;
    MouseLeave += Page_MouseLeftButtonUpOrLeave;
    MouseMove += Page_MouseMove;

    hSliderX.Range = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; ValueRange(1, 20);
    hSliderY.Range = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; ValueRange(1, 20);
    hSliderX.ValueChanged += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler(slider_ValueChanged);
    hSliderY.ValueChanged += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler(slider_ValueChanged);

    hSliderX.SetValue(ZIndexProperty, 500);
    hSliderY.SetValue(ZIndexProperty, 500);
    sliderX.SetValue(ZIndexProperty, 500);
    sliderY.SetValue(ZIndexProperty, 500);
}&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;VB.Net&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; Page_Loaded(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; o &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Object&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; EventArgs)
        &lt;SPAN class=rem&gt;' Required to initialize variables&lt;/SPAN&gt;
        InitializeComponent
        &lt;SPAN class=kwrd&gt;AddHandler&lt;/SPAN&gt; BrowserHost.Resize, &lt;SPAN class=kwrd&gt;AddressOf&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Me&lt;/SPAN&gt;.BrowserHost_Resize
        &lt;SPAN class=kwrd&gt;AddHandler&lt;/SPAN&gt; media.MediaOpened, &lt;SPAN class=kwrd&gt;AddressOf&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Me&lt;/SPAN&gt;.media_MediaOpened
        &lt;SPAN class=kwrd&gt;AddHandler&lt;/SPAN&gt; media.MediaEnded, &lt;SPAN class=kwrd&gt;AddressOf&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Me&lt;/SPAN&gt;.media_MediaEnded
        MouseLeftButtonUp = (MouseLeftButtonUp + Page_MouseLeftButtonUpOrLeave)
        MouseLeave = (MouseLeave + Page_MouseLeftButtonUpOrLeave)
        MouseMove = (MouseMove + Page_MouseMove)
        hSliderX.Range = &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; ValueRange(1, 20)
        hSliderY.Range = &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; ValueRange(1, 20)
        &lt;SPAN class=kwrd&gt;AddHandler&lt;/SPAN&gt; hSliderX.ValueChanged, &lt;SPAN class=kwrd&gt;AddressOf&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Me&lt;/SPAN&gt;.slider_ValueChanged
        &lt;SPAN class=kwrd&gt;AddHandler&lt;/SPAN&gt; hSliderY.ValueChanged, &lt;SPAN class=kwrd&gt;AddressOf&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Me&lt;/SPAN&gt;.slider_ValueChanged
        hSliderX.SetValue(ZIndexProperty, 500)
        hSliderY.SetValue(ZIndexProperty, 500)
        sliderX.SetValue(ZIndexProperty, 500)
        sliderY.SetValue(ZIndexProperty, 500)
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; Sub&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;So now that we have the media loaded, we can use the media.NaturalVideoWidth and media.NaturalVideoHeight properties to find out exactly how big the video is!&amp;nbsp; I have a function that is fired off when the page is first loaded or a slider value has changed.&amp;nbsp; This is how we chop it up.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="MARGIN: 0px 0px 0px 5px" height=180 alt=mince_garlic[1] src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/mince_garlic1.jpg" width=240 border=0 mce_src="http://www.coding4fun.net/images/SilverlightsVideoPuzzle_E3FF/mince_garlic1.jpg"&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;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; prepVideoObjects()
{
    &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; totalPhotosX = (&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt;)hSliderX.Value;
    &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; totalPhotosY = (&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt;)hSliderY.Value;

    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (lastX != totalPhotosX || lastY != totalPhotosY)
    {
        lastX = totalPhotosX;
        lastY = totalPhotosY;

        sliderX.Text = &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;.Format(&lt;SPAN class=str&gt;"X ({0}):"&lt;/SPAN&gt;, totalPhotosX.ToString(&lt;SPAN class=str&gt;"D2"&lt;/SPAN&gt;));
        sliderY.Text = &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;.Format(&lt;SPAN class=str&gt;"Y ({0}):"&lt;/SPAN&gt;, totalPhotosY.ToString(&lt;SPAN class=str&gt;"D2"&lt;/SPAN&gt;));

        &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; rectWidth = (&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt;)Math.Floor(media.NaturalVideoWidth / totalPhotosX);
        &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; rectHeight = (&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt;)Math.Floor(media.NaturalVideoHeight / totalPhotosY);
        Random random = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Random();

        &lt;SPAN class=rem&gt;// remove all old videoblocks&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;for&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; i = Children.Count - 1; i &amp;gt; 0; i--)
        {
            &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (Children[i].GetType() == &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(VideoBlock))
                Children.RemoveAt(i);
        }

        &lt;SPAN class=kwrd&gt;for&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; x = 0; x &amp;lt; totalPhotosX; x++)
        {
            &lt;SPAN class=kwrd&gt;for&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; y = 0; y &amp;lt; totalPhotosY; y++)
            {
                VideoBlock vb = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; VideoBlock(media.Name, x * rectWidth, y * rectHeight, rectWidth, rectHeight, SetActivePhoto);
                shuffle(vb, random);
                Children.Add(vb);
            }
        }
    }
}&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;VB.Net&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; prepVideoObjects()
        &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; totalPhotosX &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt; = &lt;SPAN class=kwrd&gt;CType&lt;/SPAN&gt;(hSliderX.Value,&lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;)
        &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; totalPhotosY &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt; = &lt;SPAN class=kwrd&gt;CType&lt;/SPAN&gt;(hSliderY.Value,&lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;)
        &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt; ((lastX &amp;lt;&amp;gt; totalPhotosX)  _
                    &lt;SPAN class=kwrd&gt;OrElse&lt;/SPAN&gt; (lastY &amp;lt;&amp;gt; totalPhotosY)) &lt;SPAN class=kwrd&gt;Then&lt;/SPAN&gt;
            lastX = totalPhotosX
            lastY = totalPhotosY
            sliderX.Text = &lt;SPAN class=kwrd&gt;String&lt;/SPAN&gt;.Format(&lt;SPAN class=str&gt;"X ({0}):"&lt;/SPAN&gt;, totalPhotosX.ToString(&lt;SPAN class=str&gt;"D2"&lt;/SPAN&gt;))
            sliderY.Text = &lt;SPAN class=kwrd&gt;String&lt;/SPAN&gt;.Format(&lt;SPAN class=str&gt;"Y ({0}):"&lt;/SPAN&gt;, totalPhotosY.ToString(&lt;SPAN class=str&gt;"D2"&lt;/SPAN&gt;))
            &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; rectWidth &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt; = &lt;SPAN class=kwrd&gt;CType&lt;/SPAN&gt;(Math.Floor((media.NaturalVideoWidth / totalPhotosX)),&lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;)
            &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; rectHeight &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt; = &lt;SPAN class=kwrd&gt;CType&lt;/SPAN&gt;(Math.Floor((media.NaturalVideoHeight / totalPhotosY)),&lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;)
            &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; random &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; Random = &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; Random
            &lt;SPAN class=rem&gt;' remove all old videoblocks&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; i &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt; = (Children.Count - 1)
            &lt;SPAN class=kwrd&gt;Do&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;While&lt;/SPAN&gt; (i &amp;gt; 0)
                &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt; (Children(i).&lt;SPAN class=kwrd&gt;GetType&lt;/SPAN&gt; = &lt;SPAN class=kwrd&gt;GetType&lt;/SPAN&gt;(VideoBlock)) &lt;SPAN class=kwrd&gt;Then&lt;/SPAN&gt;
                    Children.RemoveAt(i)
                &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt;
                i = (i - 1)
            &lt;SPAN class=kwrd&gt;Loop&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; x &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt; = 0
            &lt;SPAN class=kwrd&gt;Do&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;While&lt;/SPAN&gt; (x &amp;lt; totalPhotosX)
                &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; y &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt; = 0
                &lt;SPAN class=kwrd&gt;Do&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;While&lt;/SPAN&gt; (y &amp;lt; totalPhotosY)
                    &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; vb &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; VideoBlock = &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; VideoBlock(media.Name, (x * rectWidth), (y * rectHeight), rectWidth, rectHeight, SetActivePhoto)
                    shuffle(vb, random)
                    Children.Add(vb)
                    y = (y + 1)
                &lt;SPAN class=kwrd&gt;Loop&lt;/SPAN&gt;
                x = (x + 1)
            &lt;SPAN class=kwrd&gt;Loop&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; &lt;SPAN class=kwrd&gt;Sub&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;Last but not least, lets see how the mouse movements are handled on the page.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;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; Page_MouseMove(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, MouseEventArgs e)
{
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt; != activeVideoBlock)
    {
        &lt;SPAN class=rem&gt;// Perform the appropriate transform on the active photo&lt;/SPAN&gt;
        Point position = e.GetPosition(&lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);
        &lt;SPAN class=kwrd&gt;switch&lt;/SPAN&gt; (currentActionType)
        {
            &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; VideoBlock.ActionType.Moving:
                &lt;SPAN class=rem&gt;// Move it by the amount of the mouse move&lt;/SPAN&gt;
                activeVideoBlock.Translate(position.X - currentLastPosition.X, position.Y - currentLastPosition.Y);
                &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
            &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; VideoBlock.ActionType.RotatingScaling:
                &lt;SPAN class=rem&gt;// Rotate it according to the angle the mouse moved around the photo's center&lt;/SPAN&gt;
                &lt;SPAN class=kwrd&gt;double&lt;/SPAN&gt; radiansToDegrees = 360 / (2 * Math.PI);
                &lt;SPAN class=kwrd&gt;double&lt;/SPAN&gt; lastAngle = Math.Atan2(currentLastPosition.Y - currentVideoCenter.Y, currentLastPosition.X - currentVideoCenter.X) * radiansToDegrees;
                &lt;SPAN class=kwrd&gt;double&lt;/SPAN&gt; currentAngle = Math.Atan2(position.Y - currentVideoCenter.Y, position.X - currentVideoCenter.X) * radiansToDegrees;
                activeVideoBlock.Rotate(currentAngle - lastAngle);

                &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
        }
        currentLastPosition = position;
    }
}&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;VB.Net&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; Page_MouseMove(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Object&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; MouseEventArgs)
        &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;Not&lt;/SPAN&gt; (activeVideoBlock) &lt;SPAN class=kwrd&gt;Is&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Nothing&lt;/SPAN&gt;) &lt;SPAN class=kwrd&gt;Then&lt;/SPAN&gt;
            &lt;SPAN class=rem&gt;' Perform the appropriate transform on the active photo&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; position &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; Point = e.GetPosition(&lt;SPAN class=kwrd&gt;Nothing&lt;/SPAN&gt;)
            &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; (currentActionType)
                &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; VideoBlock.ActionType.Moving
                    &lt;SPAN class=rem&gt;' Move it by the amount of the mouse move&lt;/SPAN&gt;
                    activeVideoBlock.Translate((position.X - currentLastPosition.X), (position.Y - currentLastPosition.Y))
                &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; VideoBlock.ActionType.RotatingScaling
                    &lt;SPAN class=rem&gt;' Rotate it according to the angle the mouse moved around the photo's center&lt;/SPAN&gt;
                    &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; radiansToDegrees &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Double&lt;/SPAN&gt; = (360 / (2 * Math.PI))
                    &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; lastAngle &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Double&lt;/SPAN&gt; = (Math.Atan2((currentLastPosition.Y - currentVideoCenter.Y), (currentLastPosition.X - currentVideoCenter.X)) * radiansToDegrees)
                    &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; currentAngle &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Double&lt;/SPAN&gt; = (Math.Atan2((position.Y - currentVideoCenter.Y), (position.X - currentVideoCenter.X)) * radiansToDegrees)
                    activeVideoBlock.Rotate((currentAngle - lastAngle))
            &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;
            currentLastPosition = position
        &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;H2&gt;Wrapping it up&lt;/H2&gt;
&lt;P&gt;So as you can see, Silverlight is pretty powerful once you figure out how to tame it.&amp;nbsp; I used example base code and modified it to suit my own needs to dynamically alter a video in real time.&amp;nbsp; There are a few code tweaks that could happen to improve this code and I'm betting with some additional effort, one could remove the delegate.&amp;nbsp; In addition, you could add in edge detection code and a timer to make this into a true video puzzle game.&amp;nbsp; This was a pet project I worked on while I was at the airport.&amp;nbsp; This demo can be downgraded to Silverlight 1.0 also.&amp;nbsp; I don't believe anything I did was really Silverlight 1.1 (now 2.0) only.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Clint's Bio:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Clint is an academic developer evangelist for Microsoft.&amp;nbsp; His two primary development languages are C# and JavaScript. He has built a &lt;A href="http://msdn.microsoft.com/coding4fun/coolapplications/disco/default.aspx" mce_href="http://msdn.microsoft.com/coding4fun/coolapplications/disco/default.aspx"&gt;Disco Dance Floor&lt;/A&gt; too! In his off time, he whips up other random weird projects and does twenty something activities with his friends.&amp;nbsp; His next two big projects are an automated bartender and a skateboard segway.&amp;nbsp; Clint’s blog is &lt;A href="http://betterthaneveryone.com/" mce_href="http://betterthaneveryone.com/"&gt;betterthaneveryone.com&lt;/A&gt; and can be emailed at &lt;A href="mailto:crutkas@microsoft.com" mce_href="mailto:crutkas@microsoft.com"&gt;crutkas@microsoft.com&lt;/A&gt; if you have any question.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7163484" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/media/default.aspx">media</category><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/web+miscellaneous/default.aspx">web miscellaneous</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/puzzle/default.aspx">puzzle</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/web/default.aspx">web</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Facebook Developer Toolkit</title><link>http://blogs.msdn.com/coding4fun/archive/2007/05/24/2854939.aspx</link><pubDate>Fri, 25 May 2007 00:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2854939</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>28</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/2854939.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=2854939</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=2854939</wfw:comment><description>&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/wpF%5B2%5D.jpg" atomicselection="true" mce_href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/wpF%5B2%5D.jpg"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; BORDER-TOP: 0px; BORDER-RIGHT: 0px" border=0 align=left src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/wpF_thumb.jpg" width=240 height=179 mce_src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/wpF_thumb.jpg"&gt;&lt;/A&gt; Do you have a Facebook account and want to do more with it? Start creating cool, fun Windows applications and Web sites with the Facebook Developer Toolkit. This toolkit offers you a huge amount of easy-to-use components and controls, plus ready-to-run samples and detailed documentation to get you started. With Visual Studio Express Editions and the Facebook Developer Toolkit, you'll have the tools you need to get going today! &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/AddFacebook%5B2%5D.jpg" atomicselection="true" mce_href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/AddFacebook%5B2%5D.jpg"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; BORDER-TOP: 0px; BORDER-RIGHT: 0px" border=0 align=right src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/AddFacebook_thumb.jpg" width=240 height=228 mce_src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/AddFacebook_thumb.jpg"&gt;&lt;/A&gt; The Facebook Developer Toolkit is a full complement of components, controls and samples for developing applications using the Facebook Platform. The kit also includes Visual C# and Visual Basic wrappers for the Facebook API to make application development simple, fun and quick. You can use the Facebook Developer Toolkit to build applications using Windows Forms, ASP.NET or WPF. You can even use the toolkit to take advantage of LINQ. &lt;/P&gt;
&lt;H5&gt;See How Easy It Is&lt;/H5&gt;
&lt;P&gt;Explore the &lt;A href="http://msdn.microsoft.com/vstudio/express/showcase/quickstarts"&gt;QuickStarts&lt;/A&gt; to see just how easy it is to develop using the Facebook Developer Toolkit and Visual Studio Express Editions. Watch the &lt;A href="http://msdn.microsoft.com/vstudio/express/showcase/default.aspx#walkthrough"&gt;walkthrough videos&lt;/A&gt; to see how easy it is to build Facebook-enabled applications. You can have an &lt;A href="http://msdn.microsoft.com/vstudio/express/showcase/quickstarts/default.aspx#Win"&gt;application&lt;/A&gt; or &lt;A href="http://msdn.microsoft.com/vstudio/express/showcase/quickstarts/default.aspx#web"&gt;website&lt;/A&gt; up and running in only a few minutes. &lt;/P&gt;
&lt;P&gt;The Facebook Development Toolkit allows you to create applications that you can share with your Facebook friends. &lt;A href="http://facebooktoolkit.codeplex.com/Release/ProjectReleases.aspx" mce_href="http://facebooktoolkit.codeplex.com/Release/ProjectReleases.aspx"&gt;Download the toolkit today&lt;/A&gt;! &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/FlitterImageS%5B2%5D.jpg" atomicselection="true" mce_href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/FlitterImageS%5B2%5D.jpg"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; BORDER-TOP: 0px; BORDER-RIGHT: 0px" border=0 align=left src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/FlitterImageS_thumb.jpg" width=205 height=240 mce_src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/FacebookDeveloperToolkit_F357/FlitterImageS_thumb.jpg"&gt;&lt;/A&gt; Want to see the Facebook Developer Toolkit in action? Download &lt;A href="http://blogs.msdn.com/coding4fun/attachment/2854939.ashx" target=_blank mce_href="http://blogs.msdn.com/coding4fun/attachment/2854939.ashx"&gt;this sample application&lt;/A&gt; that uses the Facebook Developer Toolkit to build a dynamic screensaver with Visual C# Express Edition. Explore the &lt;A href="http://wiki.f8.facebook.com/" mce_href="http://wiki.f8.facebook.com/"&gt;Facebook Developer Toolkit wiki&lt;/A&gt; for more details on the toolkit.&lt;/P&gt;&lt;BR clear=all&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2854939" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/coding4fun/attachment/2854939.ashx" length="283010" type="application/x-zip-compressed" /><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/web+services/default.aspx">web services</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/web/default.aspx">web</category></item><item><title>Creating a Vanity Search Page</title><link>http://blogs.msdn.com/coding4fun/archive/2007/03/10/1855817.aspx</link><pubDate>Sun, 11 Mar 2007 02:09:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1855817</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/1855817.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=1855817</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=1855817</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;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;span class="entry_description"&gt;It's all about you. Learn how to call the Windows Live Search service to create a vanity page that displays images, news articles, and websites about you.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;div class="entry_author"&gt;Stephen Walther&lt;/div&gt; &lt;div class="entry_company"&gt;&lt;a href="http://www.superexpert.com"&gt;Superexpert 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;Easy&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;Less than 1 hour&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.microsoft.com/vstudio/express/vwd/"&gt;Visual Web Developer 2005 Express Edition&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;ul&gt;&lt;/ul&gt; &lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;This month, we create a vanity search page. The vanity search page displays any images, news or website entries about a particular person (for example, you). To create this page, we take advantage of the Windows Live Search API. This free API enables you to retrieve search results by calling a web service that Microsoft exposes on the web.  &lt;p&gt;I decided to write this article because I wanted an excuse to play with the Windows Live SDK (see &lt;a href="http://dev.live.com/"&gt;http://dev.live.com&lt;/a&gt;). The SDK includes documentation and samples for accessing all of the Windows Live web services including the Windows Live Search Web Service, Virtual Earth, and Windows Live Alerts.  &lt;p&gt;I fully admit that I&amp;nbsp;was&amp;nbsp;actively avoiding writing this article because I dreaded the thought of needing to learn yet another Application Programming Interface. I was pleasantly surprised to discover that the API for Windows Live Search is both logical and painlessly simple to understand. I wrote the code for this article in less than an hour.  &lt;p&gt;Before you can access the Windows Live services, you need to get an Application ID. You pass this ID to the Windows Live services to identify yourself. You get an Application ID by signing an agreement at the following URL: &lt;a href="http://search.msn.com/developer/appids.aspx"&gt;http://search.msn.com/developer/appids.aspx&lt;/a&gt;.  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/CreatingaVanitySearchPage_CBFD/image08.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="178" src="http://www.coding4fun.net/images/CreatingaVanitySearchPage_CBFD/image0_thumb4.png" width="240" border="0"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Figure 1 - Adding a Web Reference for Windows&amp;nbsp;Live Search&lt;/strong&gt;  &lt;p&gt;After you have an Application ID, you are ready to start calling Windows Live web services. Here are the steps for creating the vanity search page:  &lt;p&gt;1. Launch Visual Web Developer and create a new Web Site  &lt;p&gt;2. Select the menu option Website, Add Web Reference to add a Web Reference to the Windows Live Search web service (see Figure 1). Enter the following address into the URL field: &lt;a href="http://soap.search.msn.com/webservices.asmx?wsdl"&gt;http://soap.search.msn.com/webservices.asmx?wsdl&lt;/a&gt;. When you click OK, a new Web reference named com.msn.search.soap is created.  &lt;p&gt;3. Create a new Web Form Page by selecting the menu option Website, Add New Item. When you create the new Web Form Page, give it the name Vanity.aspx. Also, make sure that the checkbox labeled &lt;b&gt;Place code in separate file&lt;/b&gt; is not checked.  &lt;p&gt;4. Replace the contents of the page with the following code:  &lt;p&gt;&lt;b&gt;VB.NET Code&lt;/b&gt;&amp;nbsp; &lt;/p&gt; &lt;div style="overflow: scroll; width: 500px; height: 500px; background-color: #eeeeee"&gt;&lt;pre class="csharpcode"&gt;&amp;lt;%@ Page Language=&lt;span class="str"&gt;"VB"&lt;/span&gt; %&amp;gt;

&amp;lt;%@ Import &lt;span class="kwrd"&gt;Namespace&lt;/span&gt;=&lt;span class="str"&gt;"com.msn.search.soap"&lt;/span&gt; %&amp;gt;

&amp;lt;%@ Import &lt;span class="kwrd"&gt;Namespace&lt;/span&gt;=&lt;span class="str"&gt;"System.Text.RegularExpressions"&lt;/span&gt; %&amp;gt;

&amp;lt;!DOCTYPE html &lt;span class="kwrd"&gt;PUBLIC&lt;/span&gt; &lt;span class="str"&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/span&gt; &lt;span class="str"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/span&gt;&amp;gt;

&amp;lt;script runat=&lt;span class="str"&gt;"server"&lt;/span&gt;&amp;gt;

&lt;span class="kwrd"&gt;Const&lt;/span&gt; appId &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = &lt;span class="str"&gt;""&lt;/span&gt;

&lt;span class="kwrd"&gt;Const&lt;/span&gt; query &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = &lt;span class="str"&gt;""&lt;/span&gt;&lt;span class="str"&gt;"Bill Gates"&lt;/span&gt;&lt;span class="str"&gt;""&lt;/span&gt;

&lt;span class="kwrd"&gt;Const&lt;/span&gt; startMark &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = &lt;span class="str"&gt;"\uE000"&lt;/span&gt;

&lt;span class="kwrd"&gt;Const&lt;/span&gt; endMark &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = &lt;span class="str"&gt;"\uE001"&lt;/span&gt;

&lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; Page_Load()

&lt;span class="rem"&gt;' Create instance of MSN Search Services&lt;/span&gt;

&lt;span class="kwrd"&gt;Dim&lt;/span&gt; search &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; MSNSearchService()

&lt;span class="rem"&gt;' Build Source Request&lt;/span&gt;

&lt;span class="kwrd"&gt;Dim&lt;/span&gt; NewsSource &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; SourceRequest()

NewsSource.Source = SourceType.News

&lt;span class="kwrd"&gt;Dim&lt;/span&gt; webSource &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; SourceRequest()

webSource.Source = SourceType.Web

&lt;span class="kwrd"&gt;Dim&lt;/span&gt; imageSource &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; SourceRequest()

imageSource.Source = SourceType.Image

imageSource.ResultFields = ResultFieldMask.Image &lt;span class="kwrd"&gt;Or&lt;/span&gt; ResultFieldMask.Url

&lt;span class="rem"&gt;' Build the Search Request&lt;/span&gt;

&lt;span class="kwrd"&gt;Dim&lt;/span&gt; request &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; SearchRequest()

request.AppID = appId

request.Requests = &lt;span class="kwrd"&gt;New&lt;/span&gt; SourceRequest() {imageSource, NewsSource, webSource}

request.Query = query

request.CultureInfo = &lt;span class="str"&gt;"en-US"&lt;/span&gt;

request.Flags = SearchFlags.MarkQueryWords

&lt;span class="rem"&gt;' Execute Search&lt;/span&gt;

&lt;span class="kwrd"&gt;Dim&lt;/span&gt; response &lt;span class="kwrd"&gt;As&lt;/span&gt; SearchResponse = search.Search(request)

lstResponses.DataSource = response.Responses

lstResponses.DataBind()

&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;

&lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; hiLite(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; item &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;) &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; item &lt;span class="kwrd"&gt;Is&lt;/span&gt; &lt;span class="kwrd"&gt;Nothing&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;String&lt;/span&gt;.Empty

&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; text &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = item.ToString()

text = Regex.Replace(text, startMark, &lt;span class="str"&gt;"&amp;lt;span class='hiLite'&amp;gt;"&lt;/span&gt;)

text = Regex.Replace(text, endMark, &lt;span class="str"&gt;"&amp;lt;/span&amp;gt;"&lt;/span&gt;)

&lt;span class="kwrd"&gt;Return&lt;/span&gt; text

&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt;

&lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; toImage(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; objImage &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;) &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; &lt;span class="kwrd"&gt;Not&lt;/span&gt; objImage &lt;span class="kwrd"&gt;Is&lt;/span&gt; &lt;span class="kwrd"&gt;Nothing&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;

&lt;span class="kwrd"&gt;Dim&lt;/span&gt; image &lt;span class="kwrd"&gt;As&lt;/span&gt; com.msn.search.soap.Image = &lt;span class="kwrd"&gt;CType&lt;/span&gt;(objImage, com.msn.search.soap.Image)

&lt;span class="kwrd"&gt;Return&lt;/span&gt; image.ImageURL

&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;

&lt;span class="kwrd"&gt;Return&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;.Empty

&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt;

&amp;lt;/script&amp;gt;

&amp;lt;html xmlns=&lt;span class="str"&gt;"http://www.w3.org/1999/xhtml"&lt;/span&gt; &amp;gt;

&amp;lt;head runat=&lt;span class="str"&gt;"server"&lt;/span&gt;&amp;gt;

&amp;lt;title&amp;gt;Untitled Page&amp;lt;/title&amp;gt;

&amp;lt;style type=&lt;span class="str"&gt;"text/css"&lt;/span&gt;&amp;gt;

html 

{

font:12px Verdana;

}

a {text-decoration:none}

.hiLite {background-color:yellow}

&amp;lt;/style&amp;gt;

&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;

&amp;lt;form id=&lt;span class="str"&gt;"form1"&lt;/span&gt; runat=&lt;span class="str"&gt;"server"&lt;/span&gt;&amp;gt;

&amp;lt;div&amp;gt;

&amp;lt;asp:DataList

id=&lt;span class="str"&gt;"lstResponses"&lt;/span&gt;

Runat=&lt;span class="str"&gt;"server"&lt;/span&gt;&amp;gt;

&amp;lt;ItemTemplate&amp;gt;

&amp;lt;h1&amp;gt;&amp;lt;%# Eval(&lt;span class="str"&gt;"Source"&lt;/span&gt;) %&amp;gt; (&amp;lt;%# Eval(&lt;span class="str"&gt;"Total"&lt;/span&gt;) %&amp;gt; Results)&amp;lt;/h1&amp;gt;

&amp;lt;asp:Repeater

id=&lt;span class="str"&gt;"grdResults"&lt;/span&gt;

DataSource=&lt;span class="rem"&gt;'&amp;lt;%# Eval("Results") %&amp;gt;'&lt;/span&gt;

Runat=&lt;span class="str"&gt;"server"&lt;/span&gt;&amp;gt;

&amp;lt;HeaderTemplate&amp;gt;

&amp;lt;ul&amp;gt;

&amp;lt;/HeaderTemplate&amp;gt;

&amp;lt;ItemTemplate&amp;gt;

&amp;lt;li&amp;gt;

&amp;lt;asp:HyperLink 

id=&lt;span class="str"&gt;"lnkResult"&lt;/span&gt;

ImageUrl=&lt;span class="rem"&gt;'&amp;lt;%# toImage( Eval("Image")) %&amp;gt;'&lt;/span&gt;

Text=&lt;span class="rem"&gt;'&amp;lt;%# hiLite( Eval("Title") ) %&amp;gt;'&lt;/span&gt;

NavigateUrl=&lt;span class="rem"&gt;'&amp;lt;%# Eval("Url") %&amp;gt;'&lt;/span&gt;

Runat=&lt;span class="str"&gt;"server"&lt;/span&gt; /&amp;gt;

&amp;lt;p&amp;gt;

&amp;lt;%# hiLite( Eval(&lt;span class="str"&gt;"Description"&lt;/span&gt;) ) %&amp;gt;

&amp;lt;/p&amp;gt;

&amp;lt;/li&amp;gt;

&amp;lt;/ItemTemplate&amp;gt;

&amp;lt;FooterTemplate&amp;gt;

&amp;lt;/ul&amp;gt;

&amp;lt;/FooterTemplate&amp;gt;

&amp;lt;/asp:Repeater&amp;gt;

&amp;lt;/ItemTemplate&amp;gt;

&amp;lt;/asp:DataList&amp;gt;

&amp;lt;/div&amp;gt;

&amp;lt;/form&amp;gt;

&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;

&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	/*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;b&gt;C# Code&lt;/b&gt; 
&lt;p&gt;&amp;nbsp; &lt;/p&gt;
&lt;div style="overflow: scroll; width: 500px; height: 500px; background-color: #eeeeee"&gt;&lt;pre class="csharpcode"&gt;&amp;lt;%@ Page Language=&lt;span class="str"&gt;"C#"&lt;/span&gt; %&amp;gt;

&amp;lt;%@ Import Namespace=&lt;span class="str"&gt;"com.msn.search.soap"&lt;/span&gt; %&amp;gt;

&amp;lt;%@ Import Namespace=&lt;span class="str"&gt;"System.Text.RegularExpressions"&lt;/span&gt; %&amp;gt;

&amp;lt;!DOCTYPE html PUBLIC &lt;span class="str"&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/span&gt; &lt;span class="str"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/span&gt;&amp;gt;

&amp;lt;script runat=&lt;span class="str"&gt;"server"&lt;/span&gt;&amp;gt;

&lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; appId = &lt;span class="str"&gt;""&lt;/span&gt;;

&lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; query = &lt;span class="str"&gt;"\"Bill Gates\""&lt;/span&gt;;

&lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; startMark = &lt;span class="str"&gt;"\uE000"&lt;/span&gt;;

&lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; endMark = &lt;span class="str"&gt;"\uE001"&lt;/span&gt;;

&lt;span class="kwrd"&gt;void&lt;/span&gt; Page_Load()

{

&lt;span class="rem"&gt;// Create instance of MSN Search Services&lt;/span&gt;

MSNSearchService search = &lt;span class="kwrd"&gt;new&lt;/span&gt; MSNSearchService();

&lt;span class="rem"&gt;// Build Source Request&lt;/span&gt;

SourceRequest newsSource = &lt;span class="kwrd"&gt;new&lt;/span&gt; SourceRequest();

newsSource.Source = SourceType.News;

SourceRequest webSource = &lt;span class="kwrd"&gt;new&lt;/span&gt; SourceRequest();

webSource.Source = SourceType.Web;

SourceRequest imageSource = &lt;span class="kwrd"&gt;new&lt;/span&gt; SourceRequest();

imageSource.Source = SourceType.Image;

imageSource.ResultFields = ResultFieldMask.Image | ResultFieldMask.Url;

&lt;span class="rem"&gt;// Build the Search Request&lt;/span&gt;

SearchRequest request = &lt;span class="kwrd"&gt;new&lt;/span&gt; SearchRequest();

request.AppID = appId;

request.Requests = &lt;span class="kwrd"&gt;new&lt;/span&gt; SourceRequest[] {imageSource, newsSource, webSource};

request.Query = query;

request.CultureInfo = &lt;span class="str"&gt;"en-US"&lt;/span&gt;;

request.Flags = SearchFlags.MarkQueryWords;

&lt;span class="rem"&gt;// Execute Search&lt;/span&gt;

SearchResponse response = search.Search(request);

lstResponses.DataSource = response.Responses;

lstResponses.DataBind();

}

&lt;span class="kwrd"&gt;string&lt;/span&gt; hiLite(&lt;span class="kwrd"&gt;object&lt;/span&gt; item)

{

&lt;span class="kwrd"&gt;if&lt;/span&gt; (item == &lt;span class="kwrd"&gt;null&lt;/span&gt;)

&lt;span class="kwrd"&gt;return&lt;/span&gt; String.Empty;

&lt;span class="kwrd"&gt;string&lt;/span&gt; text = item.ToString();

text = Regex.Replace(text, startMark, &lt;span class="str"&gt;"&amp;lt;span class='hiLite'&amp;gt;"&lt;/span&gt;);

text = Regex.Replace(text, endMark, &lt;span class="str"&gt;"&amp;lt;/span&amp;gt;"&lt;/span&gt;);

&lt;span class="kwrd"&gt;return&lt;/span&gt; text;

}

&lt;span class="kwrd"&gt;string&lt;/span&gt; toImage(&lt;span class="kwrd"&gt;object&lt;/span&gt; objImage)

{

&lt;span class="kwrd"&gt;if&lt;/span&gt; (objImage != &lt;span class="kwrd"&gt;null&lt;/span&gt;)

{

com.msn.search.soap.Image image = (com.msn.search.soap.Image)objImage;

&lt;span class="kwrd"&gt;return&lt;/span&gt; image.ImageURL;

}

&lt;span class="kwrd"&gt;return&lt;/span&gt; String.Empty;

}

&amp;lt;/script&amp;gt;

&amp;lt;html xmlns=&lt;span class="str"&gt;"http://www.w3.org/1999/xhtml"&lt;/span&gt; &amp;gt;

&amp;lt;head runat=&lt;span class="str"&gt;"server"&lt;/span&gt;&amp;gt;

&amp;lt;title&amp;gt;Vanity Search&amp;lt;/title&amp;gt;

&amp;lt;style type=&lt;span class="str"&gt;"text/css"&lt;/span&gt;&amp;gt;

html 

{

font:12px Verdana;

}

a {text-decoration:none}

.hiLite {background-color:yellow}

&amp;lt;/style&amp;gt;

&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;

&amp;lt;form id=&lt;span class="str"&gt;"form1"&lt;/span&gt; runat=&lt;span class="str"&gt;"server"&lt;/span&gt;&amp;gt;

&amp;lt;div&amp;gt;

&amp;lt;asp:DataList

id=&lt;span class="str"&gt;"lstResponses"&lt;/span&gt;

Runat=&lt;span class="str"&gt;"server"&lt;/span&gt;&amp;gt;

&amp;lt;ItemTemplate&amp;gt;

&amp;lt;h1&amp;gt;&amp;lt;%# Eval(&lt;span class="str"&gt;"Source"&lt;/span&gt;) %&amp;gt; (&amp;lt;%# Eval(&lt;span class="str"&gt;"Total"&lt;/span&gt;) %&amp;gt; Results)&amp;lt;/h1&amp;gt;

&amp;lt;asp:Repeater

id=&lt;span class="str"&gt;"grdResults"&lt;/span&gt;

DataSource=&lt;span class="str"&gt;'&amp;lt;%# Eval("Results") %&amp;gt;'&lt;/span&gt;

Runat=&lt;span class="str"&gt;"server"&lt;/span&gt;&amp;gt;

&amp;lt;HeaderTemplate&amp;gt;

&amp;lt;ul&amp;gt;

&amp;lt;/HeaderTemplate&amp;gt;

&amp;lt;ItemTemplate&amp;gt;

&amp;lt;li&amp;gt;

&amp;lt;asp:HyperLink 

id=&lt;span class="str"&gt;"lnkResult"&lt;/span&gt;

ImageUrl=&lt;span class="str"&gt;'&amp;lt;%# toImage( Eval("Image")) %&amp;gt;'&lt;/span&gt;

Text=&lt;span class="str"&gt;'&amp;lt;%# hiLite( Eval("Title") ) %&amp;gt;'&lt;/span&gt;

NavigateUrl=&lt;span class="str"&gt;'&amp;lt;%# Eval("Url") %&amp;gt;'&lt;/span&gt;

Runat=&lt;span class="str"&gt;"server"&lt;/span&gt; /&amp;gt;

&amp;lt;p&amp;gt;

&amp;lt;%# hiLite( Eval(&lt;span class="str"&gt;"Description"&lt;/span&gt;) ) %&amp;gt;

&amp;lt;/p&amp;gt;

&amp;lt;/li&amp;gt;

&amp;lt;/ItemTemplate&amp;gt;

&amp;lt;FooterTemplate&amp;gt;

&amp;lt;/ul&amp;gt;

&amp;lt;/FooterTemplate&amp;gt;

&amp;lt;/asp:Repeater&amp;gt;

&amp;lt;/ItemTemplate&amp;gt;

&amp;lt;/asp:DataList&amp;gt;

&amp;lt;/div&amp;gt;

&amp;lt;/form&amp;gt;

&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;

&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;

	/*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;Before you use the vanity search page, you should modify two of the constants that appear at the top of the page: the appId and query constants. Assign the App ID that you get from visiting the following URL to the appId constant: &lt;a href="http://search.msn.com/developer/appids.aspx"&gt;http://search.msn.com/developer/appids.aspx&lt;/a&gt;. Enter anything you want for the query constant. In the page above, the name Bill Gates (enclosed in quotes) is assigned to the query constant. When you open the page in a web browser, you should see a page similar to Figure 2. 
&lt;p&gt;&amp;nbsp; 
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/CreatingaVanitySearchPage_CBFD/image07.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" src="http://www.coding4fun.net/images/CreatingaVanitySearchPage_CBFD/image06.png" width="228" border="0"&gt;&lt;/a&gt; 
&lt;p&gt;&lt;strong&gt;Figure 2 - Image results for Bill Gates vanity search page&lt;/strong&gt;
&lt;p&gt;The page displays three different groups of results. First, the page displays a list of images that match the search query. Next, the page displays a list of news articles. Finally, the page displays a list of websites (see Figure 3). 
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/CreatingaVanitySearchPage_CBFD/image010.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" src="http://www.coding4fun.net/images/CreatingaVanitySearchPage_CBFD/image09.png" width="228" border="0"&gt;&lt;/a&gt; 
&lt;p&gt;&lt;strong&gt;Figure 3 - Web results&amp;nbsp;for Bill Gates vanity search page&lt;/strong&gt;
&lt;p&gt;&amp;nbsp; 
&lt;p&gt;The Windows Live Search web service currently supports the following types of searches: 
&lt;p&gt;&amp;nbsp; 
&lt;ul&gt;
&lt;li&gt;Image - Returns a list of images that match the search query. 
&lt;li&gt;Inline Answers - Only available for commercial use. This type of search returns information from Encarta, Finance, Weather, and Movie show times. 
&lt;li&gt;News - Returns results from online news sources. 
&lt;li&gt;Phone Book - Returns results from white and yellow page phone books. 
&lt;li&gt;Query Location - Returns latitude and longitude information associated with a query. 
&lt;li&gt;Spelling - Returns a list of spelling suggestions. 
&lt;li&gt;Web - Returns a list of websites that match the search query.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp; 
&lt;p&gt;You perform a search by creating an instance of the SearchRequest class. You assign the text of your search query to the SearchRequest class’s Query property. This class also includes a Requests collection. You add one or more SourceRequest objects to this collection that represent different types of searches (Image, Web, News, and so on). After you get all of the objects ready, you call the MSNSearchService.Search() method to actually perform the search.
&lt;p&gt;The search results are displayed with the help of a DataList and Repeater control. The DataList displays the source of the search and the number of results for each source returned. The Repeater control is nested in the DataList and it displays the actual search results.&amp;nbsp;&amp;nbsp;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;As I mentioned before, I wrote this article as an excuse to play with the Windows Live SDK. I am very happy that I got the chance to experiment with this SDK since I discovered that it is very easy to work with. I’m looking forward to trying out some of the other Windows Live services such as the Virtual Earth and Alerts services over the coming months. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1855817" 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/web+services/default.aspx">web services</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/web/default.aspx">web</category></item><item><title>Windows Clipboard Sharing Through Web Services</title><link>http://blogs.msdn.com/coding4fun/archive/2007/03/09/1848530.aspx</link><pubDate>Sat, 10 Mar 2007 03:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1848530</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>16</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/1848530.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=1848530</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=1848530</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;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;span class="entry_description"&gt;This application transfers the contents of a machine's clipboard to another machine through the user of ASP .NET Web Services.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;div class="entry_author"&gt;Brian Trautman&lt;/div&gt; &lt;div class="entry_company"&gt;&lt;a href=""&gt;&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;Easy&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;b&gt;Hardware: &lt;/b&gt;&lt;span class="entry_details_input"&gt;None&lt;/span&gt;&lt;/div&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Download: &lt;/b&gt;&lt;a href="http://coding4fun.personifydesign.com/clipboard.zip"&gt;Download&lt;/a&gt;  &lt;ul&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt; &lt;h3&gt;Background&lt;/h3&gt; &lt;p&gt;Have you ever worked on multiple machines and wished you could copy the clipboard contents from one machine to the other? I’ve often found myself wishing that there was a quick and easy way to move text snippets, screenshots, or even files to another machine with a simple copy and paste. If this sounds interesting to you then read on.  &lt;p&gt;I wanted this to work regardless of whether both machines were online at the same time, and not be halted by firewalls, NAT’s, etc. so I opted for a server based rather than a peer to peer architecture. The architecture involved a client application to transfer the clipboard contents to the server via a web services call, a web service to cache the clipboard contents, and another client component to retrieve the clipboard contents from the server and place them on the local machine’s clipboard.  &lt;p&gt;To tackle this problem we need programmatic access to the clipboard on both the machine to copy from and also the machine we want to copy to. Luckily .NET provides a managed wrapper around the native Windows Clipboard API that gives us access to this. The relevant namespaces are Clipboard for C# and my.Computer.Clipboard. Since we’re interested in moving clipboard objects from one machine to another we first need to determine what type of objects get placed onto the clipboard for our various actions (copy text, images, and files). Writing a quick code snippet with the Clipboard namespace allows us to iterate through all objects on the clipboard for various types of actions to see what we’re dealing with.  &lt;p&gt;&amp;nbsp;&lt;pre class="csharpcode"&gt;C#&lt;/pre&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;        IDataObject clipData = Clipboard.GetDataObject();&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;//retrieve an array of strings for all the formats available on the clipboard.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;string&lt;/span&gt;[] formats = clipData.GetFormats();&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;//iterate through the list of formats on the clipboard&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt; format &lt;span class="kwrd"&gt;in&lt;/span&gt; formats)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;//add each objeoct to an arraylist so we can inspect the object types&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;object&lt;/span&gt; dataObject = clipData.GetData(format);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;/div&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;pre class="csharpcode"&gt;VB&lt;/pre&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; clipData &lt;span class="kwrd"&gt;As&lt;/span&gt; IDataObject = Clipboard.GetDataObject&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; formats() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = clipData.GetFormats&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;'iterate through the list of formats on the clipboard&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;For&lt;/span&gt; &lt;span class="kwrd"&gt;Each&lt;/span&gt; format &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; &lt;span class="kwrd"&gt;In&lt;/span&gt; formats&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;'add each objeoct to an arraylist so we can inspect the object types&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;          &lt;span class="kwrd"&gt;Dim&lt;/span&gt; dataObject &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt; = clipData.GetData(Format)&lt;/pre&gt;&lt;pre class="alt"&gt;    Next&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The screenshot below shows the results for having some text from Word copied onto the clipboard. Each format in the string array is a representation of the data on the clipboard. Since the target application (where you’re going to paste to) is unknown the clipboard has multiple formats each containing the same data. The objective with this project is to replicate all these formats on the target machine’s clipboard.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/WindowsClipboardSharingThroughWebService_E4B8/image02.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="212" src="http://www.coding4fun.net/images/WindowsClipboardSharingThroughWebService_E4B8/image0_thumb.png" width="717" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;After inspection of the objects on the Clipboard for text, images, and file objects it was easy to determine that the primary object types we need to be concerned with. These are "System.IO.MemoryStream", “System.IO.FileStream”, "System.Drawing.Bitmap", and "System.String" . Since all this information would be transferred to the server via web services it’s simple to serialize all objects to bytes for transmission. This is necessary for a number of reasons including the fact that complex objects such as MemoryStreams cannot be simply serialized and sent over the web service call as Strings can. In addition, some of the objects are larger than the web service call allows, and would need to be broken up into smaller pieces for transmission and then reassembled on the server side in the correct order. Again, when the client requests the clipboard items we’ll need to disassemble each object, send it over the web service return result to the client, and then reassemble it.&lt;/p&gt;
&lt;p&gt;The first item to build is a base function that handles the breaking up of these large streams into more manageable byte arrays for transmission to the web service. The function below performs this task by sending chunks of the MemoryStream limited in size by the “byteCount” constant. Once this limit is reached the buffer is sent over the web service call for storage and assembly on the server. Once we have either 0 bytes left to send, or a number less than “byteCount” we send the remaining elements of the buffer and signal the web service that this particular object is complete with the “isFinalTransaction” flag. &lt;/p&gt;
&lt;p&gt;C#&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; UploadStreamBlock(&lt;span class="kwrd"&gt;string&lt;/span&gt; format, &lt;span class="kwrd"&gt;string&lt;/span&gt; objectType, MemoryStream memStream)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;//each time we enter this function we have a new transaction beginning.  &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;//  A transaction represents a comlete&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;//object on the clipboard and we'll use this on the server side to know &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;//  how to put the stream back together&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; transactionGuid = System.Guid.NewGuid().ToString();&lt;/pre&gt;&lt;pre&gt;            memStream.Position = 0;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buffer = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[byteCount];&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;bool&lt;/span&gt; isFinalTransaction = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;//while the current stream position plus our byte count is less than the &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;//  length of the stream continue sending as much as we can.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;while&lt;/span&gt; ((memStream.Position + byteCount) &amp;lt;= memStream.Length)&lt;/pre&gt;&lt;pre&gt;            {&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;//if we happen to be on the last byte of the stream set the final &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="rem"&gt;// transaction flag to true so the server will know that this is the &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;//  last bit of this transaction to expect.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (memStream.Position + byteCount == memStream.Length)&lt;/pre&gt;&lt;pre class="alt"&gt;                {&lt;/pre&gt;&lt;pre&gt;                    isFinalTransaction = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                }&lt;/pre&gt;&lt;pre&gt;                &lt;span class="rem"&gt;//read the stream into our buffer for transmission over the web service.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                memStream.Read(buffer, 0, byteCount);&lt;/pre&gt;&lt;pre&gt;                ws.InsertMessageStream(buffer, format, objectType, transactionGuid, &lt;/pre&gt;&lt;pre class="alt"&gt;                    isFinalTransaction, clipBoardGUID);&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;long&lt;/span&gt; remainingBytes = memStream.Length - memStream.Position;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;//if we still have remaining bytes left figure out how many and transmit the &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;//  last bit of this ojbect over the web service.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; ((&lt;span class="kwrd"&gt;int&lt;/span&gt;)remainingBytes &amp;gt; 0)&lt;/pre&gt;&lt;pre&gt;            {&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] remainingBuffer = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[(&lt;span class="kwrd"&gt;int&lt;/span&gt;)remainingBytes];&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                memStream.Read(remainingBuffer, 0, (&lt;span class="kwrd"&gt;int&lt;/span&gt;)remainingBytes);&lt;/pre&gt;&lt;pre&gt;                ws.InsertMessageStream(remainingBuffer, format, objectType, &lt;/pre&gt;&lt;pre class="alt"&gt;                    transactionGuid, &lt;span class="kwrd"&gt;true&lt;/span&gt;, clipBoardGUID);&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;VB&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; UploadStreamBlock(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; format &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; objectType &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;, _&lt;/pre&gt;&lt;pre&gt;                                  &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; memStream &lt;span class="kwrd"&gt;As&lt;/span&gt; MemoryStream)&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;'each time we enter this function we have a new transaction beginning. &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;' A transaction represents a comlete&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;'object on the clipboard and we'll use this on the server side to know how &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;' to put the stream back together&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; transactionGuid &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = System.Guid.NewGuid.ToString&lt;/pre&gt;&lt;pre&gt;        memStream.Position = 0&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; buffer() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Byte&lt;/span&gt; = &lt;span class="kwrd"&gt;New&lt;/span&gt; &lt;span class="kwrd"&gt;Byte&lt;/span&gt;((byteCount) - 1) {}&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; isFinalTransaction &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt; = &lt;span class="kwrd"&gt;False&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;'while the current stream position plus our byte count is less than the &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;' length of the stream continue sending as much as we can.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;While&lt;/span&gt; ((memStream.Position + byteCount) _&lt;/pre&gt;&lt;pre class="alt"&gt;                    &amp;lt;= memStream.Length)&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;'if we happen to be on the last byte of the stream set the final &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;' transaction flag to true so the server will know that this is the &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;' last bit of this transaction to expect.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;If&lt;/span&gt; ((memStream.Position + byteCount) _&lt;/pre&gt;&lt;pre&gt;                        = memStream.Length) &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                isFinalTransaction = &lt;span class="kwrd"&gt;True&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;'ream the stream into our buffer for transmission over the web service.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            memStream.Read(buffer, 0, byteCount)&lt;/pre&gt;&lt;pre class="alt"&gt;            clipService.InsertMessageStream(buffer, format, objectType, transactionGuid, _&lt;/pre&gt;&lt;pre&gt;                                            isFinalTransaction, clipBoardGUID)&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;While&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; remainingBytes &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt; = (memStream.Length - memStream.Position)&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;'if we still have remaining bytes left figure out how many and &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;' transmit the last bit of this ojbect over the web service.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;If&lt;/span&gt; (&lt;span class="kwrd"&gt;CType&lt;/span&gt;(remainingBytes, &lt;span class="kwrd"&gt;Integer&lt;/span&gt;) &amp;gt; 0) &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;Dim&lt;/span&gt; remainingBuffer() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Byte&lt;/span&gt; = &lt;span class="kwrd"&gt;New&lt;/span&gt; &lt;span class="kwrd"&gt;Byte&lt;/span&gt;((&lt;span class="kwrd"&gt;CType&lt;/span&gt;(remainingBytes, &lt;span class="kwrd"&gt;Integer&lt;/span&gt;)) - 1) {}&lt;/pre&gt;&lt;pre&gt;            memStream.Read(remainingBuffer, 0, &lt;span class="kwrd"&gt;CType&lt;/span&gt;(remainingBytes, &lt;span class="kwrd"&gt;Integer&lt;/span&gt;))&lt;/pre&gt;&lt;pre class="alt"&gt;            clipService.InsertMessageStream(remainingBuffer, format, objectType, _&lt;/pre&gt;&lt;pre&gt;                                            transactionGuid, &lt;span class="kwrd"&gt;True&lt;/span&gt;, clipBoardGUID)&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The Server side of the web service needs to put the whole clipboard back together from a number of byte arrays so it’s important that all the objects, their types, and formats be preserved for the clipboard to work properly on the target machine. We use the clipBoardGuid to determine if we are on a new clipboard posting or adding objects to an already existing instance. We use the isFinalTranaction flag to know if this byte array should be part of an existing transaction, or is the first in a new transaction. All clipboard items are saved to disk for later retrieval by any client requesting them. The code for this is below. 
&lt;p&gt;C# 
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;    [WebMethod]&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; InsertMessageStream(&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buffer, &lt;span class="kwrd"&gt;string&lt;/span&gt; format, &lt;span class="kwrd"&gt;string&lt;/span&gt; objectType, &lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;string&lt;/span&gt; transactionGuid, &lt;span class="kwrd"&gt;bool&lt;/span&gt; isFinalTransaction, &lt;span class="kwrd"&gt;string&lt;/span&gt; clipBoardGUID)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;//always base the current directory on the clipboard that we're sending now.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;string&lt;/span&gt; clipBoardGUIDDirectory = &lt;/pre&gt;&lt;pre class="alt"&gt;            System.Web.HttpContext.Current.Request.PhysicalApplicationPath + clipBoardGUID;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;//if the directory does not exist then delete all the other directories &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;// (clipboard instances) and create a new directory if the directory already &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;// exists then this particular transaction is part of the same clipboard so &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;// don't do anything. this works because othe clipboardDirectory is based &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;// off of the GUID sent from the client.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!Directory.Exists(clipBoardGUIDDirectory))&lt;/pre&gt;&lt;pre class="alt"&gt;            {&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;string&lt;/span&gt;[] dirs = Directory.GetDirectories(&lt;/pre&gt;&lt;pre class="alt"&gt;                    System.Web.HttpContext.Current.Request.PhysicalApplicationPath);&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt; dir &lt;span class="kwrd"&gt;in&lt;/span&gt; dirs)&lt;/pre&gt;&lt;pre class="alt"&gt;                {&lt;/pre&gt;&lt;pre&gt;                    Directory.Delete(dir, &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;                }&lt;/pre&gt;&lt;pre&gt;                Directory.CreateDirectory(clipBoardGUIDDirectory);&lt;/pre&gt;&lt;pre class="alt"&gt;            }&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;catch&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;//create the filename based on the current transaction, format, and object type.  &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// We will parse this out later so we know how to add this back to the target clipboard.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;string&lt;/span&gt; fileName = clipBoardGUIDDirectory + &lt;span class="str"&gt;"\\" + transactionGuid &lt;/pre&gt;&lt;pre class="alt"&gt;            + "&lt;/span&gt;_&lt;span class="str"&gt;" + format + "&lt;/span&gt;_" + objectType;&lt;/pre&gt;&lt;pre&gt;        FileStream fs = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileStream(fileName, FileMode.Append, FileAccess.Write);&lt;/pre&gt;&lt;pre class="alt"&gt;        fs.Position = fs.Length;&lt;/pre&gt;&lt;pre&gt;        fs.Write(buffer, 0, buffer.Length);&lt;/pre&gt;&lt;pre class="alt"&gt;        fs.Close();&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;/div&gt;&lt;pre class="csharpcode"&gt;VB&lt;/pre&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;    &amp;lt;WebMethod()&amp;gt; &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; InsertMessageStream(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; buffer() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Byte&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; _&lt;/pre&gt;&lt;pre&gt;            format &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; objectType &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; transactionGuid _&lt;/pre&gt;&lt;pre class="alt"&gt;            &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; isFinalTransaction &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; clipBoardGUID &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;'always base the current directory on the clipboard that we're sending now.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; clipBoardDataDirectory &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = _&lt;/pre&gt;&lt;pre&gt;        (System.Web.HttpContext.Current.Request.PhysicalApplicationPath _&lt;/pre&gt;&lt;pre class="alt"&gt;         + &lt;span class="str"&gt;"\\Clipboard_Data"&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; clipBoardGUIDDirectory &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = (clipBoardDataDirectory + _&lt;/pre&gt;&lt;pre class="alt"&gt;                                                (&lt;span class="str"&gt;"\\"&lt;/span&gt; + clipBoardGUID))&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Try&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;'if the directory does not exist then delete all the other directories (clipboard &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;' instances) and create a new directory if the directory already exists then this &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;' particular transaction is part of the same clipboard so don't do anything. this &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;' works because othe clipboardDirectory is based off of the GUID sent from the client.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;If&lt;/span&gt; &lt;span class="kwrd"&gt;Not&lt;/span&gt; Directory.Exists(clipBoardGUIDDirectory) &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;Dim&lt;/span&gt; dirs() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = Directory.GetDirectories(clipBoardDataDirectory)&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;For&lt;/span&gt; &lt;span class="kwrd"&gt;Each&lt;/span&gt; dir &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; &lt;span class="kwrd"&gt;In&lt;/span&gt; dirs&lt;/pre&gt;&lt;pre&gt;                    Directory.Delete(dir, &lt;span class="kwrd"&gt;True&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;Next&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                Directory.CreateDirectory(clipBoardGUIDDirectory)&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Catch&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Try&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;'create the filename based on the current transaction, format, and object type.  We &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;' will parse this out later so we know how to add this back to the target clipboard.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; fileName &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = (clipBoardGUIDDirectory + (&lt;span class="str"&gt;"\\"&lt;/span&gt; _&lt;/pre&gt;&lt;pre&gt;                    + (transactionGuid + (&lt;span class="str"&gt;"_"&lt;/span&gt; _&lt;/pre&gt;&lt;pre class="alt"&gt;                    + (format + (&lt;span class="str"&gt;"_"&lt;/span&gt; + objectType))))))&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; fs &lt;span class="kwrd"&gt;As&lt;/span&gt; FileStream = &lt;span class="kwrd"&gt;New&lt;/span&gt; FileStream(fileName, FileMode.Append, FileAccess.Write)&lt;/pre&gt;&lt;pre class="alt"&gt;        fs.Position = fs.Length&lt;/pre&gt;&lt;pre&gt;        fs.Write(buffer, 0, buffer.Length)&lt;/pre&gt;&lt;pre class="alt"&gt;        fs.Close()&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Each clipgoard format object is stored on disk for later retrievel by the client. Note in the screenshot below how the filename is used to store the unique transactionID for the object, the object type and also the clipboard format. All these pieces of information are necessary to reassemble the items correctly and place onto the target clipboard. 
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/WindowsClipboardSharingThroughWebService_E4B8/image05.png" atomicselection="true"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="198" src="http://www.coding4fun.net/images/WindowsClipboardSharingThroughWebService_E4B8/image0_thumb1.png" width="728" border="0"&gt;&lt;/a&gt; 
&lt;p&gt;Now that we have a representation of each clipboard format object on the server we need a way to get each item back onto the target clipboard. The following web service method provides a return result of type “ClipboardStream”. The ClipboardStream object contains all relevant information necessary to reassemble each item onto the target clipboard. Since a web service is a request-response type relationship the web service expects the client to continue to call the web service until the all the clipboard items have been successfully received. In addition, further complexity is introduced because each individual clipboard item may be split into multiple items if they exceed the maximum length set by our contstant “byteCount”, therefore the target machine must keep track of each request and tell the server where the last transaction left off via the variable named “currentByte”. The web service code is shown below. 
&lt;p&gt;C# 
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;    [WebMethod]&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; ClipboardStream GetMessageStream(&lt;span class="kwrd"&gt;string&lt;/span&gt; transactionGUID, &lt;span class="kwrd"&gt;string&lt;/span&gt;[] &lt;/pre&gt;&lt;pre class="alt"&gt;        previousTransactionGUIDs, &lt;span class="kwrd"&gt;string&lt;/span&gt; clipBoardGUID, &lt;span class="kwrd"&gt;long&lt;/span&gt; currentByte)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;string&lt;/span&gt; clipBoardDataDirectory = &lt;/pre&gt;&lt;pre&gt;            System.Web.HttpContext.Current.Request.PhysicalApplicationPath + &lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="str"&gt;"Clipboard_Data"&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;string&lt;/span&gt; clipBoardGUIDDirectory = clipBoardDataDirectory + &lt;span class="str"&gt;"\\" + &lt;/pre&gt;&lt;pre class="alt"&gt;            clipBoardGUID;&lt;/pre&gt;&lt;pre&gt;        string currentTransaction = "&lt;/span&gt;&lt;span class="str"&gt;";&lt;/pre&gt;&lt;pre class="alt"&gt;        bool isLastTransaction = false;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        //if the clipBoardGUID is not empty then we only need to make sure &lt;/pre&gt;&lt;pre class="alt"&gt;        // that the directory still exists.&lt;/pre&gt;&lt;pre&gt;        if (clipBoardGUID != "&lt;/span&gt;&lt;span class="str"&gt;")&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            //if the directory does not exist throw an exception, it must &lt;/pre&gt;&lt;pre class="alt"&gt;            // have already been deleted.&lt;/pre&gt;&lt;pre&gt;            if (!Directory.Exists(clipBoardGUIDDirectory))&lt;/pre&gt;&lt;pre class="alt"&gt;            {&lt;/pre&gt;&lt;pre&gt;                throw new Exception("&lt;/span&gt;Requested clipboard does not exist.&lt;span class="str"&gt;" +&lt;/pre&gt;&lt;pre class="alt"&gt;                        "&lt;/span&gt;It must have been deleted.");&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;//if the clipboardGUID is empty then this is the client's first contact &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// with the server and we need&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;//to select the available clipboard GUID to return to the user.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt;[] availableClipBoard = &lt;/pre&gt;&lt;pre&gt;                Directory.GetDirectories(clipBoardDataDirectory)[0].Split(&lt;span class="str"&gt;'\\');&lt;/pre&gt;&lt;pre class="alt"&gt;            clipBoardGUID = availableClipBoard[availableClipBoard.Length - 1];&lt;/pre&gt;&lt;pre&gt;            clipBoardGUIDDirectory += clipBoardGUID;&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        //we need to get the next transaction.  Each time we finish a transaction &lt;/pre&gt;&lt;pre&gt;        // we add it to previousTransactionGUIDs at the client end so we know not &lt;/pre&gt;&lt;pre class="alt"&gt;        // to send it again.&lt;/pre&gt;&lt;pre&gt;        currentTransaction = GetCurrentTransaction(clipBoardGUIDDirectory, &lt;/pre&gt;&lt;pre class="alt"&gt;            previousTransactionGUIDs);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        //if the current transaction is null then we'&lt;/span&gt;re done and there are no &lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;// more to send to the client&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (currentTransaction == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;//open the filestream and set it to the position requested by the client.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        FileStream fs = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileStream(currentTransaction, FileMode.Open);&lt;/pre&gt;&lt;pre&gt;        fs.Position = currentByte;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;//determind if this is the last transaction or not for this object &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;// so we can let the client know.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;long&lt;/span&gt; numBytesToRead = fs.Length - currentByte;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (numBytesToRead &amp;gt; byteCount)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            numBytesToRead = byteCount;&lt;/pre&gt;&lt;pre&gt;            isLastTransaction = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        {&lt;/pre&gt;&lt;pre&gt;            isLastTransaction = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;//read the filestream bytes to the buffer and populate the object to &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;// return to the client.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buffer = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[numBytesToRead];&lt;/pre&gt;&lt;pre&gt;        fs.Read(buffer, 0, (&lt;span class="kwrd"&gt;int&lt;/span&gt;)numBytesToRead);&lt;/pre&gt;&lt;pre class="alt"&gt;        fs.Close();&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        FileInfo fi = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileInfo(currentTransaction);&lt;/pre&gt;&lt;pre class="alt"&gt;        ClipboardStream clipboardStream = &lt;span class="kwrd"&gt;new&lt;/span&gt; ClipboardStream();&lt;/pre&gt;&lt;pre&gt;        clipboardStream.Buffer = buffer;&lt;/pre&gt;&lt;pre class="alt"&gt;        clipboardStream.ClipBoardID = clipBoardGUID;&lt;/pre&gt;&lt;pre&gt;        clipboardStream.Format = fi.Name.Split(&lt;span class="str"&gt;'_'&lt;/span&gt;)[1];&lt;/pre&gt;&lt;pre class="alt"&gt;        clipboardStream.ObjectType = fi.Name.Split(&lt;span class="str"&gt;'_'&lt;/span&gt;)[2];&lt;/pre&gt;&lt;pre&gt;        clipboardStream.IsLastTransaction = isLastTransaction;&lt;/pre&gt;&lt;pre class="alt"&gt;        clipboardStream.TransactionID = currentTransaction;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; clipboardStream;&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;/div&gt;&lt;pre class="csharpcode"&gt;VB&lt;/pre&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;    &amp;lt;WebMethod()&amp;gt; &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; GetMessageStream(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; transactionGUID &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;, _&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; previousTransactionGUIDs() &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; clipBoardGUID &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;, _&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; currentByte &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;) &lt;span class="kwrd"&gt;As&lt;/span&gt; ClipboardStream&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; clipBoardDataDirectory &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = _&lt;/pre&gt;&lt;pre class="alt"&gt;            (System.Web.HttpContext.Current.Request.PhysicalApplicationPath + &lt;span class="str"&gt;"Clipboard_Data"&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; clipBoardGUIDDirectory &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = clipBoardDataDirectory&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; currentTransaction &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = &lt;span class="str"&gt;""&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; isLastTransaction &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt; = &lt;span class="kwrd"&gt;False&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;'if the clipBoardGUID is not empty then we only need to make sure that &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;' the directory still exists.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;If&lt;/span&gt; (clipBoardGUID &amp;lt;&amp;gt; &lt;span class="str"&gt;""&lt;/span&gt;) &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;'if the directory does not exist throw an exception, it must have &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;' already been deleted.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;If&lt;/span&gt; &lt;span class="kwrd"&gt;Not&lt;/span&gt; Directory.Exists(clipBoardGUIDDirectory) &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&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;"Requested clipboard does not exist."&lt;/span&gt; + _&lt;/pre&gt;&lt;pre&gt;                                    &lt;span class="str"&gt;"It must have been deleted."&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;'if the clipboardGUID is empty then this is the client's first contact &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;' with the server and we need&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;'to select the available clipboard GUID to return to the user.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; availableClipBoard() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = Directory.GetDirectories _&lt;/pre&gt;&lt;pre class="alt"&gt;            (clipBoardDataDirectory)(0).Split(Microsoft.VisualBasic.ChrW(92))&lt;/pre&gt;&lt;pre&gt;        clipBoardGUID = availableClipBoard((availableClipBoard.Length - 1))&lt;/pre&gt;&lt;pre class="alt"&gt;        clipBoardGUIDDirectory = (clipBoardGUIDDirectory + &lt;span class="str"&gt;"\"&lt;/span&gt; + clipBoardGUID)&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;'we need to get the next transaction.  Each time we finish a transaction &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;' we add it to previousTransactionGUIDs&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;'at the client end so we know not to send it again.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        currentTransaction = GetCurrentTransaction(clipBoardGUIDDirectory, _&lt;/pre&gt;&lt;pre&gt;                                                   previousTransactionGUIDs)&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;'if the current transaction is null then we're done and there are no &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;' more to send to the client&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;If&lt;/span&gt; (currentTransaction &lt;span class="kwrd"&gt;Is&lt;/span&gt; &lt;span class="kwrd"&gt;Nothing&lt;/span&gt;) &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;Return&lt;/span&gt; &lt;span class="kwrd"&gt;Nothing&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;'open the filestream and set it to the position requested by the client.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; fs &lt;span class="kwrd"&gt;As&lt;/span&gt; FileStream = &lt;span class="kwrd"&gt;New&lt;/span&gt; FileStream(currentTransaction, FileMode.Open)&lt;/pre&gt;&lt;pre&gt;        fs.Position = currentByte&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;'determind if this is the last transaction or not for this object so &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;' we can let the client know.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; numBytesToRead &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt; = (fs.Length - currentByte)&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;If&lt;/span&gt; (numBytesToRead &amp;gt; byteCount) &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            numBytesToRead = byteCount&lt;/pre&gt;&lt;pre&gt;            isLastTransaction = &lt;span class="kwrd"&gt;False&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;Else&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            isLastTransaction = &lt;span class="kwrd"&gt;True&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;'read the filestream bytes to the buffer and populate the object to &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;' return to the client.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; buffer() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Byte&lt;/span&gt; = &lt;span class="kwrd"&gt;New&lt;/span&gt; &lt;span class="kwrd"&gt;Byte&lt;/span&gt;((numBytesToRead) - 1) {}&lt;/pre&gt;&lt;pre class="alt"&gt;        fs.Read(buffer, 0, &lt;span class="kwrd"&gt;CType&lt;/span&gt;(numBytesToRead, &lt;span class="kwrd"&gt;Integer&lt;/span&gt;))&lt;/pre&gt;&lt;pre&gt;        fs.Close()&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; fi &lt;span class="kwrd"&gt;As&lt;/span&gt; FileInfo = &lt;span class="kwrd"&gt;New&lt;/span&gt; FileInfo(currentTransaction)&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; clipboardStream &lt;span class="kwrd"&gt;As&lt;/span&gt; ClipboardStream = &lt;span class="kwrd"&gt;New&lt;/span&gt; ClipboardStream&lt;/pre&gt;&lt;pre&gt;        clipboardStream.Buffer = buffer&lt;/pre&gt;&lt;pre class="alt"&gt;        clipboardStream.ClipBoardID = clipBoardGUID&lt;/pre&gt;&lt;pre&gt;        clipboardStream.Format = fi.Name.Split(Microsoft.VisualBasic.ChrW(95))(1)&lt;/pre&gt;&lt;pre class="alt"&gt;        clipboardStream.ObjectType = fi.Name.Split(Microsoft.VisualBasic.ChrW(95))(2)&lt;/pre&gt;&lt;pre&gt;        clipboardStream.IsLastTransaction = isLastTransaction&lt;/pre&gt;&lt;pre class="alt"&gt;        clipboardStream.TransactionID = currentTransaction&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Return&lt;/span&gt; clipboardStream&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;End&lt;/span&gt; Function&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The last remaining piece for our project to function correctly is the client code that receives the clipboard contents from the server and reassembles each item in the correct order, adding it to the clipboard with the correct format as each is completed. The client code for this is shown below.&amp;nbsp;&amp;nbsp;&lt;pre class="csharpcode"&gt;C#&lt;/pre&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;string&lt;/span&gt;[] transactionGuids = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        ClipboardService.ClipboardStream clipBoardStream = &lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;new&lt;/span&gt; WindowsApplication1.ClipboardService.ClipboardStream();&lt;/pre&gt;&lt;pre class="alt"&gt;        DataObject dataObject = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataObject();&lt;/pre&gt;&lt;pre&gt;        clipBoardStream.ClipBoardID = &lt;span class="str"&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;        clipBoardStream.IsLastTransaction = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;        clipBoardStream.TransactionID = &lt;span class="str"&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;long&lt;/span&gt; currentByte = 0;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        Clipboard.Clear();&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;//while we don't get null back keep on contacting the web service &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;// to get the next ojbect.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;while&lt;/span&gt; (clipBoardStream != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            MemoryStream memStream = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream();&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;//while this is not the last transaction keep on contacting &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;// the web service to get the rest of this particular object.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;while&lt;/span&gt; (clipBoardStream.IsLastTransaction == &lt;span class="kwrd"&gt;false&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;            {&lt;/pre&gt;&lt;pre&gt;                &lt;span class="rem"&gt;//contact the web service to get the next transaction&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                clipBoardStream = clipService.GetMessageStream(&lt;/pre&gt;&lt;pre&gt;                    clipBoardStream.TransactionID, transactionGuids, &lt;/pre&gt;&lt;pre class="alt"&gt;                    clipBoardStream.ClipBoardID, currentByte);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (clipBoardStream != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;                {&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="rem"&gt;//write the results to the memory stream&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    memStream.Write(clipBoardStream.Buffer, 0, &lt;/pre&gt;&lt;pre class="alt"&gt;                        clipBoardStream.Buffer.Length);&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="rem"&gt;//increment the current byte so next time we contact &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="rem"&gt;// the webservice we'll pick up where we left off&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    currentByte = memStream.Position;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="rem"&gt;//if it is the last transaction then we need to place &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="rem"&gt;// this item onto the clipboard.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (clipBoardStream.IsLastTransaction)&lt;/pre&gt;&lt;pre class="alt"&gt;                    {&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="rem"&gt;//handle the clipBoardStream appropriately and add it &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="rem"&gt;// to the dataObject for posting to the clipblard.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        HandleFinalTransaction(clipBoardStream, memStream, &lt;span class="kwrd"&gt;ref&lt;/span&gt; dataObject);&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="rem"&gt;//resize the transactionGuids array as necessary and &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="rem"&gt;// add the current transaction so next time we contact &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="rem"&gt;// the web service we won't get this one again.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;if&lt;/span&gt; (transactionGuids == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;                        {&lt;/pre&gt;&lt;pre class="alt"&gt;                            Array.Resize(&lt;span class="kwrd"&gt;ref&lt;/span&gt; transactionGuids, 1);&lt;/pre&gt;&lt;pre&gt;                        }&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        {&lt;/pre&gt;&lt;pre class="alt"&gt;                            Array.Resize(&lt;span class="kwrd"&gt;ref&lt;/span&gt; transactionGuids, &lt;/pre&gt;&lt;pre&gt;                                transactionGuids.Length + 1);&lt;/pre&gt;&lt;pre class="alt"&gt;                        }&lt;/pre&gt;&lt;pre&gt;                        transactionGuids[transactionGuids.Length - 1] = &lt;/pre&gt;&lt;pre class="alt"&gt;                            clipBoardStream.TransactionID;&lt;/pre&gt;&lt;pre&gt;                    }&lt;/pre&gt;&lt;pre class="alt"&gt;                }&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                {&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                }&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (clipBoardStream != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;            {&lt;/pre&gt;&lt;pre&gt;                clipBoardStream.IsLastTransaction = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;                currentByte = 0;&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class="alt"&gt;        }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        Clipboard.SetDataObject(dataObject, &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;/div&gt;&lt;pre class="csharpcode"&gt;VB&lt;/pre&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; transactionGuids() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt; = &lt;span class="kwrd"&gt;Nothing&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; clipBoardStream &lt;span class="kwrd"&gt;As&lt;/span&gt; ClipboardService.ClipboardStream = _&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;New&lt;/span&gt; ClipboardVB.ClipboardService.ClipboardStream&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; dataObject &lt;span class="kwrd"&gt;As&lt;/span&gt; DataObject = &lt;span class="kwrd"&gt;New&lt;/span&gt; DataObject&lt;/pre&gt;&lt;pre class="alt"&gt;        clipBoardStream.ClipBoardID = &lt;span class="str"&gt;""&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        clipBoardStream.IsLastTransaction = &lt;span class="kwrd"&gt;False&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        clipBoardStream.TransactionID = &lt;span class="str"&gt;""&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;Dim&lt;/span&gt; currentByte &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt; = 0&lt;/pre&gt;&lt;pre class="alt"&gt;        Clipboard.Clear()&lt;/pre&gt;&lt;pre&gt;        &lt;span class="rem"&gt;'while we don't get null back keep on contacting the web service &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="rem"&gt;' to get the next ojbect.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;While&lt;/span&gt; (&lt;span class="kwrd"&gt;Not&lt;/span&gt; (clipBoardStream) &lt;span class="kwrd"&gt;Is&lt;/span&gt; &lt;span class="kwrd"&gt;Nothing&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;Dim&lt;/span&gt; memStream &lt;span class="kwrd"&gt;As&lt;/span&gt; MemoryStream = &lt;span class="kwrd"&gt;New&lt;/span&gt; MemoryStream&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="rem"&gt;'while this is not the last transaction keep on contacting the&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="rem"&gt;' web service to get the rest of this particular object.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;While&lt;/span&gt; (clipBoardStream.IsLastTransaction = &lt;span class="kwrd"&gt;False&lt;/span&gt;)&lt;/pre&gt;&lt;pre class="alt"&gt;                &lt;span class="rem"&gt;'contact the web service to get the next transaction&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;                clipBoardStream = clipService.GetMessageStream( _&lt;/pre&gt;&lt;pre&gt;                    clipBoardStream.TransactionID, transactionGuids, _&lt;/pre&gt;&lt;pre class="alt"&gt;                    clipBoardStream.ClipBoardID, currentByte)&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;If&lt;/span&gt; (&lt;span class="kwrd"&gt;Not&lt;/span&gt; (clipBoardStream) &lt;span class="kwrd"&gt;Is&lt;/span&gt; &lt;span class="kwrd"&gt;Nothing&lt;/span&gt;) &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="rem"&gt;'write the results to the memory stream&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    memStream.Write(clipBoardStream.Buffer, 0, _&lt;/pre&gt;&lt;pre class="alt"&gt;                                    clipBoardStream.Buffer.Length)&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="rem"&gt;'increment the current byte so next time we contact &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="rem"&gt;' the webservice we'll pick up where we left off&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    currentByte = memStream.Position&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="rem"&gt;'if it is the last transaction then we need to place &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                    &lt;span class="rem"&gt;' this item onto the clipboard.&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;If&lt;/span&gt; clipBoardStream.IsLastTransaction &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="rem"&gt;'handle the clipBoardStream appropriately and add &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="rem"&gt;' it to the dataObject for posting to the clipblard.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        HandleFinalTransaction(clipBoardStream, memStream, dataObject)&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="rem"&gt;'resize the transactionGuids array as necessary and &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="rem"&gt;' add the current transaction so next time we contact&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        &lt;span class="rem"&gt;' the web service we won't get this one again.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;If&lt;/span&gt; (transactionGuids &lt;span class="kwrd"&gt;Is&lt;/span&gt; &lt;span class="kwrd"&gt;Nothing&lt;/span&gt;) &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                            Array.Resize(transactionGuids, 1)&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;Else&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                            Array.Resize(transactionGuids, (transactionGuids.Length + 1))&lt;/pre&gt;&lt;pre&gt;                        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                        transactionGuids((transactionGuids.Length - 1)) = _&lt;/pre&gt;&lt;pre&gt;                            clipBoardStream.TransactionID&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;Else&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;Exit&lt;/span&gt; &lt;span class="kwrd"&gt;While&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;While&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;If&lt;/span&gt; (&lt;span class="kwrd"&gt;Not&lt;/span&gt; (clipBoardStream) &lt;span class="kwrd"&gt;Is&lt;/span&gt; &lt;span class="kwrd"&gt;Nothing&lt;/span&gt;) &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;                clipBoardStream.IsLastTransaction = &lt;span class="kwrd"&gt;False&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;                currentByte = 0&lt;/pre&gt;&lt;pre&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;While&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        Clipboard.SetDataObject(dataObject, &lt;span class="kwrd"&gt;True&lt;/span&gt;)&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;In this project we’ve shown how any object (string, bitmap, or file) from the Clipboard can be serialized to an array of bytes for transmission over a web service call. We’ve also show how to store these clipboard items on disk on the server, and then retrieve them later on for assembly onto the target clipboard. I’ve often thought that this would be an interesting idea for a hosted ASP (Application Service Provider) service, where a hosting company would host the web service of this project for customer use. Look out for an upcoming article on how to add ASP .NET membership class functionality providing authentication and allowing multiple users to use the same instance of the web service. 
&lt;p&gt;For working samples of the client application and web service in both C# and VB check out the&amp;nbsp;&lt;a href="http://CODING4fun.personifydesign.com/clipboard.zip"&gt;DOWNLOAD&lt;/a&gt;. 
&lt;h3&gt;Bio&lt;/h3&gt;
&lt;p&gt;As President and principal founder of Personify Design Brian oversees the operations of the design and development businesses. Brian has more than 10 years experience in the technology industry. In his current role Brian’s expertise lies in developing and architecting end to end customer solutions involving web application technologies such as SQL Server and ASP .NET. When not writing code Brian enjoys sailing in the Puget Sound on Far Niente, a 36 foot Catalina MKII cutter.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1848530" 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/web+services/default.aspx">web services</category></item><item><title>iAccelerate</title><link>http://blogs.msdn.com/coding4fun/archive/2007/02/18/1709215.aspx</link><pubDate>Mon, 19 Feb 2007 03:13:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1709215</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/1709215.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=1709215</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=1709215</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;img height="50" src="http://www.coding4fun.net/images/iAccelerate/rx8.PNG" width="50"&gt;&lt;/td&gt; &lt;td&gt;&lt;span class="entry_description"&gt;This article shows how to build a .NET application using an accelerometer to measure the performance of a vehicle. An accelerometer is an instrument that is used for measuring acceleration. By using basic physics equations, we can derive a vehicle’s current speed, distance traveled, horsepower, and other performance metrics from the acceleration of the vehicle. iAccelerate is solely for use in a vehicle on a closed course or on private property while under the supervision of a certified emergency care provider. As a reminder, please always wear your safety belt.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;div class="entry_author"&gt;Mike Harkabus&lt;/div&gt; &lt;div class="entry_company"&gt;&lt;a href="http://blogs.claritycon.com/blogs/mike_harkabus/default.aspx"&gt;Clarity Consulting&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;6-10 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;$50-$100&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/vstudio/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;span class="entry_details_input"&gt;Analog Devices ADXL320&lt;/span&gt;&lt;/div&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Download: &lt;/b&gt;&lt;a href="http://channel9.msdn.com/ShowPost.aspx?PostID=283953"&gt;Download&lt;/a&gt;  &lt;ul&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt; &lt;h1&gt;&lt;/h1&gt; &lt;h3&gt;Introduction&lt;/h3&gt; &lt;p&gt;I have had a passion for computers and cars for as long as I can remember. Ever since I was little, I have been able to name the make and model of almost any car on the road. I have been around computers since I was young, and can still remember the day I wrote (read: “copied out of a book”) my first program in BASIC for IBM’s PCjr. Twenty years later, these same interests coupled with an accelerometer played a role in the development of iAccelerate. iAccelerate displays accurate vehicle performance data from calculations performed 20-30 times per second. The data that is provided can be used to check if your car actually does benefit from a higher octane fuel, or to check if a new exhaust system has increased the horsepower as much as the manufacturer claims (or just makes a lot more noise). The article will first give you some background on what an accelerometer is, and show how you can use it to calculate performance data. An explanation of the development of iAccelerate will follow, describing the calculations and formulas used in code and the factors considered during development. Finally, I will demonstrate how iAccelerate works by walking you through a typical test scenario and comparing the results of the test to the results gathered from reputable sources to determine the accuracy of the data.&lt;/p&gt; &lt;h3&gt;&lt;/h3&gt; &lt;h3&gt;Background&lt;/h3&gt; &lt;p&gt;In the abstract, I explained that an accelerometer is an instrument that is used to measure acceleration. Accelerometers are commonly used in many different types of applications. For example, they are used to determine if an airbag should be deployed during a crash, or to detect when your laptop has been dropped to prevent hard drive damage. Also, both the Nintendo Wii and PlayStation 3 controllers use accelerometers to calculate how you are holding or moving the controller. If you took physics class in high school or college, you may remember studying kinematics or dynamics. Together, these two areas of mechanics make up the foundation for iAccelerate. By using a few simple physics equations and an accelerometer, you can determine both the velocity (mph) and distance traveled (miles) of a car, assuming it is at a complete stop when the measurements are started. This assumption is important because acceleration is the rate of change of velocity with respect to time. For example, if we are sitting at 0 mph and we measure a change in acceleration with our accelerometer then we must be moving now since acceleration cannot occur without a change in velocity. We can determine the exact value of the car’s velocity and distance traveled by using derivations of the following two equations: &lt;/p&gt; &lt;blockquote&gt; &lt;p&gt; &lt;p&gt;Velocity&lt;sub&gt;final&lt;/sub&gt; = Velocity&lt;sub&gt;initial&lt;/sub&gt; + Acceleration × Time&lt;/p&gt; &lt;p&gt;Distance = 1/2 (Velocity&lt;sub&gt;final&lt;/sub&gt; + Velocity&lt;sub&gt;initial&lt;/sub&gt; ) × Time&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Once we obtain these values, we can use a computer to calculate virtually any metric relating to a car’s performance. The following must hold true for iAccelerate to provide accurate data: the accelerometer provides both the direction and magnitude of the acceleration; we are able to calculate the time spent accelerating; we were not moving when we started timing. Using iAccelerate, we can measure 0-60 mph (acceleration), 60-0 mph (braking distance), lateral acceleration (handling), ¼-mile time (acceleration), and much more. For example, if we provide the vehicle’s weight, other measurements such as horsepower and torque can be calculated. The accuracy of the measurements for horsepower and torque can be improved significantly by using the vehicle’s coefficient of drag to account for the air resistance incurred on the vehicle. The accuracy of the other measurements should theoretically be identical to a measurement taken with a radar gun, or from the use of a 5th wheel. In practice, however, factors such as the earth’s gravity will introduce some margin of error. You will obtain the most accurate measurements by testing on a flat surface.  &lt;h3&gt;Development&lt;/h3&gt; &lt;p&gt;This application was developed using the 2005 Express Editions of VB.NET and Visual C#, which are available free of charge from the link provided at the beginning of this article. I created the project with each class being as loosely coupled from one another as possible. The project has a class called CarCalculator that is responsible for all of the necessary physics calculations and handles the conversion of the calculated results to U.S. customary units. This class is instantiated by calling the constructor with the gross weight (in pounds) of the car tested as its parameter. Most properties of this class return their value in U.S. customary units but are set internally using the metric system of units, as these are the native units the class uses in the calculations. The following code is an example of how the CarCalculator stores weight privately (in kilograms) and how the class exposes this value publically (in pounds). &lt;/p&gt; &lt;p&gt;The constructor:  &lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; CarCalculator(&lt;span class="kwrd"&gt;double&lt;/span&gt; weight)
{
     &lt;span class="kwrd"&gt;this&lt;/span&gt;.Weight = weight;
     &lt;span class="kwrd"&gt;this&lt;/span&gt;.reset();
}&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;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;VB.NET&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&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;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; weight &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Double&lt;/span&gt;)
    &lt;span class="kwrd"&gt;Me&lt;/span&gt;.Weight = weight
    &lt;span class="kwrd"&gt;Me&lt;/span&gt;.reset()
&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&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;The Weight property of the class:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; Weight
{
    get     
    {
         &lt;span class="kwrd"&gt;return&lt;/span&gt; _weight;
    }
    set
    {
         _weight = (&lt;span class="kwrd"&gt;value&lt;/span&gt; / POUNDS_PER_KG);
    }
}&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;div class="csharpcode"&gt;&lt;strong&gt;VB.NET&lt;/strong&gt;&lt;/div&gt;
&lt;div class="csharpcode"&gt;&amp;nbsp;&lt;/div&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; Weight() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Double&lt;/span&gt;
    &lt;span class="kwrd"&gt;Get&lt;/span&gt;
        &lt;span class="kwrd"&gt;Return&lt;/span&gt; _weight
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Get&lt;/span&gt;
    &lt;span class="kwrd"&gt;Set&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; Value &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Double&lt;/span&gt;)
        _weight = Value / POUNDS_PER_KG
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Set&lt;/span&gt;
&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Property&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;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;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The CarCalculator uses an event model to notify consumers during a test. The SpeedReachedCheckpoint events are fired when the CurrentSpeed property reaches one of the speeds (e.g. 60 mph) added by the user in the Setup form. This functionality is shown in the following code snippets.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;/div&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (_checkPoints != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
{
    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;double&lt;/span&gt; speed &lt;span class="kwrd"&gt;in&lt;/span&gt; _checkPoints)
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (_lastCheckpoint != Math.Floor(speed)
             &amp;amp;&amp;amp;  (Math.Floor(CurrentSpeed) == Math.Floor(speed)))
        {
            SpeedReachedCheckpoint(_totalTime, CurrentSpeed);
            _lastCheckpoint = Math.Floor(CurrentSpeed);
        }
     }
 }&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;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;VB.NET&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;If&lt;/span&gt; &lt;span class="kwrd"&gt;Not&lt;/span&gt; _checkPoints &lt;span class="kwrd"&gt;Is&lt;/span&gt; &lt;span class="kwrd"&gt;Nothing&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;
    &lt;span class="kwrd"&gt;For&lt;/span&gt; &lt;span class="kwrd"&gt;Each&lt;/span&gt; speed &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Double&lt;/span&gt; &lt;span class="kwrd"&gt;In&lt;/span&gt; _checkPoints
        &lt;span class="kwrd"&gt;If&lt;/span&gt; lastCheckpoint &amp;lt;&amp;gt; Math.Floor(speed) &lt;span class="kwrd"&gt;AndAlso&lt;/span&gt; Math.Floor(CurrentSpeed) = Math.Floor(speed) &lt;span class="kwrd"&gt;Then&lt;/span&gt;
            &lt;span class="kwrd"&gt;RaiseEvent&lt;/span&gt; SpeedReachedCheckpoint(_totalTime, CurrentSpeed)
            lastCheckpoint = Math.Floor(CurrentSpeed)
        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;
    &lt;span class="kwrd"&gt;Next&lt;/span&gt;
&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&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;The next class I will discuss, called Setup, is instantiated only when the application first loads. It is solely responsible for handling all of the data that is user configurable and validating input for any user-supplied settings, such as ”speed reached checkpoints”, vehicle and passenger weights, and the car’s coefficient of drag (if horsepower is being measured). &lt;/p&gt;
&lt;p&gt;Figure 1 (below) shows the Setup form. 
&lt;p&gt;The next class, called Main, is responsible for handling all of the input and output to and from the CarCalculator class. The accelerometer raises an event providing the current acceleration value to the wired event handler 20-30 times per second. This value, along with the amount of time that has elapsed since the last time the event was raised, is passed into a public method in the CarCalculator class. This method uses these two values to perform all of the calculations, and sets the results of the calculations to properties in the CarCalculator class. Since this event is fired so frequently, the Main class/form only displays these results on the screen four times per second. The user can also configure the application to write the results to a CSV file for further analysis. In this case, a row is added to a file every time this event is fired. Consequently, the resulting file will contain the results of every calculation made by the CarCalculator. This file can be opened with Excel to create charts and graphs so the data can be easily interpreted. 
&lt;p&gt;This event handler is very hard to test or debug because all of the calculations performed are based on time. For instance, if you set a breakpoint in the event handler so you can evaluate an expression, the Stopwatch object responsible for measuring the elapsed time will continue to tick away when the debugger reaches the breakpoint – rendering it nearly impossible to evaluate the expression the next time the event is fired. The elapsed time value that the CarCalculator relies on will now also include the time that it took to debug, ultimately resulting in inaccurate output. 
&lt;p&gt;&amp;nbsp; 
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; accel_AccelerationChange(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, AccelerationChangeEventArgs e)&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;{&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;// pseudo code&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    time = SetElapsedTimeSinceLastCalculation;&lt;/pre&gt;&lt;pre&gt;    &lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;// when a breakpoint is set to check the results of the following&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;// statement, the time value will be increasing, causing inaccurate&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;// data the next time this code is executed&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    CalculateVehiclePerformance(time, e.Acceleration);&lt;/pre&gt;&lt;pre&gt;    &lt;span class="rem"&gt;// example calculation (used in the above method): &lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="rem"&gt;// currentSpeed = lastSpeed + (((e.Acceleration + _lastAcceleration) * time) / 2);&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;    DisplayResults;&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/div&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;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;&amp;nbsp; 
&lt;p&gt;There is too much code to cover here, and I have already outlined the location and functionality of the methods that are pertinent to accurate data output. I highly recommend reading through the source code to fully understand the program. I will now demonstrate the application using the data from my RX-8’s test run. 
&lt;h3&gt;Final Product&lt;/h3&gt;
&lt;p&gt;To use this application, you will need a vehicle to test, a notebook computer, and an accelerometer. You can purchase a USB accelerometer from &lt;a href="http://www.trossenrobotics.com/"&gt;http://www.trossenrobotics.com/&lt;/a&gt; for less than $70. A .NET assembly is also available for download from this site so you can start coding without having to write your own interface for the accelerometer. Most, if not all, RS232 accelerometers that I found would work just as well but would require much more development time. In addition, since you would be using the accelerometer from within the confines of a car, being able to quickly plug and unplug the device is essential. From information gathered from various forums, a tri-axis USB model is currently in development, which you could use to negate the error caused by the acceleration due to gravity that was mentioned earlier. I will now walk you through a scenario where the 0 to 60 mph time of my RX-8 is tested. &lt;/p&gt;
&lt;p&gt;Setting the weight, output types, and checkpoints: 
&lt;p&gt;&lt;img src="http://www.coding4fun.net/images/iAccelerate/figure1.png"&gt; &lt;/p&gt;
&lt;p&gt;Figure 1 – Setting up the calculator&lt;br&gt;&lt;/p&gt;
&lt;p&gt;The frontal area of your car can be found by having a friend park behind you with their lights on (park your car’s nose 5 feet or so from a wall or building) and then trace the shadow. Measure the shadow’s area using a metric ruler. The current default setting is for an older RX-7 that I found data for. I am sure my car is a little bigger, so this probably has an effect on the resulting horsepower value. Since horsepower is the only calculation that uses this setting, all other data will be accurate – so in other words, you can leave this setting as the default if you do not know your car’s frontal area. The other defaulted setting is the coefficient of drag, which is defaulted to the average value found for about ten sports cars. If you would like to use your car’s specific value, you can find it by running your car’s name through a search engine with the word “drag” next to it. &lt;/p&gt;
&lt;p&gt;&amp;nbsp; 
&lt;p&gt;Main output screen (after start has been clicked): 
&lt;p&gt;&lt;img src="http://www.coding4fun.net/images/iAccelerate/figure2.png"&gt; &lt;/p&gt;
&lt;p&gt;Figure 2 – The application is waiting for the change of acceleration to exceed the value entered during the setup stage (.09g) before timing will begin.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Main output screen results (10 seconds elapsed – timing over):&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.coding4fun.net/images/iAccelerate/figure3.png"&gt; &lt;/p&gt;
&lt;p&gt;Figure 3 – The results of a 0-60 test on a 2004 Mazda RX-8 (6-speed)&lt;br&gt;&lt;/p&gt;
&lt;p&gt;If you noticed, the 0-60 time arrived in 5.871x seconds. Two magazines quoted it right around 5.8 s while another quoted it at 6.5 s. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;Excel output (every calculation from the 10 second run is in this file – much more detailed than the screen’s output):&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;
&lt;h1&gt;&lt;/h1&gt;
&lt;p&gt;&lt;img src="http://www.coding4fun.net/images/iAccelerate/figure4.png"&gt; &lt;/p&gt;
&lt;p&gt;Figure 4 – A CSV file opened with Excel allowing for analysis of all of the calculated data (e.g. horsepower graph)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;I have tried to make this project as easy to modify as possible by keeping the data calculations separate from the display of calculated data to the user. This allows for greater flexibility when developing iAccelerate on other platforms. For example, rewriting this application for use on a Windows Mobile Smartphone would be cool, as you would not have to worry about breaking your laptop when you try to beat your cornering record. The processing power required to perform the needed calculations and output the results fast enough was unknown during design, so the decision to build a standard WinForm application was predisposed. If anyone redesigns this for use on a cell phone (or redesigns it at all), please provide some feedback on how it turns out. The use or modification of this software for educational or testing purposes is strongly encouraged. The developer prohibits the use of this source code and/or assembly for monetary and/or personal gain. If errors are discovered in any of the code or the calculations that were used within iAccelerate, please feel free to contact me at the following email address:&amp;nbsp;&lt;a title="" href="mailto:mharkabus@claritycon.com?subject=Accelerometer"&gt;mharkabus@claritycon.com&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1709215" 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/mash+up/default.aspx">mash up</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category></item><item><title>Flickr-ing about with .NET</title><link>http://blogs.msdn.com/coding4fun/archive/2006/11/22/1126978.aspx</link><pubDate>Thu, 23 Nov 2006 07:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1126978</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>32</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/1126978.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=1126978</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=1126978</wfw:comment><description>&lt;SPAN id=c4fmetadata&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=1 width="100%" border=0&gt;
&lt;TBODY&gt;
&lt;TR class=entry_overview&gt;
&lt;TD class="" width=50&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;SPAN class=entry_description&gt;This blog details about the flickering in .net&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" colSpan=2&gt;
&lt;DIV class=entry_author&gt;Sam Judson&lt;/DIV&gt;
&lt;DIV class=entry_company&gt;&lt;A href="http://www.wackylabs.net/"&gt;Wackylabs.Net&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/" mce_href="http://msdn.com/express/"&gt;Visual Basic or Visual C# Express Editions&lt;/A&gt;,&lt;A class="" href="http://www.codeplex.com/FlickrNet" mce_href="http://www.codeplex.com/FlickrNet"&gt;FlickrNET API&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;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class=entry_details&gt;&lt;B&gt;Download: &lt;/B&gt;&lt;A href="http://channel9.msdn.com/ShowPost.aspx?PostID=211711#211711"&gt;Download&lt;/A&gt; &lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/SPAN&gt;
&lt;P&gt;Everyone who is anyone seems to be messing about with Flickr these days, one of the newest waves of "Web 2.0" Web-based applications. With its now much imitated style, social networking orientated layout, and use of the newest AJAX technologies to provide the user with a truly interactive experience, Flickr sets the bar for the future of applications on the Internet. Also one of the key benchmarks of a "Web 2.0" application (sorry, that’s the last time I'll use that word, honestly) is the public API that has been delivered and can be used by you and me to provide new and interesting ways of displaying and manipulating photos.&lt;/P&gt;
&lt;H2&gt;Getting Started&lt;/H2&gt;
&lt;P&gt;The first thing I will mention is that this article is aimed at .NET 2.0, but the Flickr.Net API library works just as well in .NET 1.1, so don't let that stop you. I'm also assuming that you know how to write applications in .NET, either using Visual Studio 2005 or one of the free Visual Studio 2005 Express editions. I will be focusing mainly on Windows Forms applications, but again the Flickr.Net API library can be used just as well for Web applications, including those hosted in a Medium Trust environment (see my &lt;A href="http://www.wackylabs.net/category/flickr-api/" mce_href="http://www.wackylabs.net/category/flickr-api/"&gt;Web site&lt;/A&gt; for more details on Medium Trust).&lt;/P&gt;
&lt;P&gt;I'm also assuming you are familiar with how to use Flickr and have an account there. If not, go GET ONE!&lt;/P&gt;
&lt;H3&gt;Get an API Key&lt;/H3&gt;
&lt;P&gt;To get started you will need to get an &lt;B&gt;API Key&lt;/B&gt; for use with Flickr. You apply for new keys and manage your keys from the &lt;B&gt;Your Keys&lt;/B&gt; section of the Flickr Services Web site at &lt;A href="http://www.flickr.com/services/api/keys" mce_href="http://www.flickr.com/services/api/keys"&gt;http://www.flickr.com/services/api/keys&lt;/A&gt;. Applying for a new key should be a pretty instantaneous affair. Once you get your API Key, you can return to the same page and click the &lt;B&gt;Edit Configuration&lt;/B&gt; link. This will allow you to edit the description of the use of your API Key and show you your &lt;B&gt;Shared Secret&lt;/B&gt;, which you will need if you want to perform authenticated requests to Flickr.&lt;/P&gt;
&lt;P&gt;When running the examples below, you will have to replace the example API key with your own.&lt;/P&gt;
&lt;H3&gt;Get the Flickr.Net API Library&lt;/H3&gt;
&lt;P&gt;The Flickr.Net API Library can be downloaded from the Flickr.Net Web site. There is also a forum for posting your Flickr.Net specific questions (if they relate to the Flickr API in general you are better posting them on the Flickr API mailing list).&lt;/P&gt;
&lt;P&gt;The download contains the source code for the library, as well as debug and release compiled DLLs. For the purposes of this article, we will use the release DLL, but you are free to add the source code project to your solution directly.&lt;/P&gt;
&lt;H2&gt;Flickr API Concepts&lt;/H2&gt;
&lt;P&gt;The Flickr API has a number of concepts and naming conventions that it would be useful to go over at this point.&lt;/P&gt;
&lt;H3&gt;Users&lt;/H3&gt;
&lt;P&gt;A user is uniquely identified by their &lt;B&gt;User ID&lt;/B&gt;. This will look something like "40123132@N01." Where the &lt;B&gt;Username&lt;/B&gt; is referred to, this is the same as your &lt;B&gt;Screen name &lt;/B&gt;—&lt;B&gt; &lt;/B&gt;the name that is displayed on your home page and which you can change at will. This should never be cached by your application because it can be changed at any time.&lt;/P&gt;
&lt;P&gt;The final term is your &lt;B&gt;Alias&lt;/B&gt; or the part of your Flickr URL that identified you. When you create an account this will be the same as your User ID (this URL will always work); you can specify a more user-friendly format for this URL once only.&lt;/P&gt;
&lt;H3&gt;Authentication&lt;/H3&gt;
&lt;P&gt;When you authenticate a user, Flickr gives you a &lt;B&gt;Token&lt;/B&gt;. This token is unique for your API key, the user who you have authenticated, and the permissions they have given you (for example, read only or write access). This token will remain valid as long as the user does not revoke your authentication, and you should ideally cache this within your application.&lt;/P&gt;
&lt;P&gt;Once authenticated, calls to Flickr will respond as if sent by that user and will show photos they have permission to see that others may not, such as private photos or their friends' and family's photos that have been marked for their eyes only. You will also be able to modify their photos, and upload new photos into their account.&lt;/P&gt;
&lt;P&gt;Without authentication you can still do quite a lot of things, such as view all public photos, search for photos for users or by tag, and browse public groups.&lt;/P&gt;
&lt;H3&gt;Lists of Photos&lt;/H3&gt;
&lt;P&gt;When you perform a search on Flickr it often will not return all the photos in one go, but page the results. For example, if a search would usually return 1000 photos, it will return the details of the first 100 photos, then the next 100, and so on, for 10 pages. You can often specify the size of the page (the number of photos to return each time) and the page number to return; for example, if you set the page size (or PerPage property) to 500 you will only get 2 pages returned. In most cases 500 is the maximum, but check the Flickr API documentation for whatever the given method supports.&lt;/P&gt;
&lt;H2&gt;Go Flickr, Go&lt;/H2&gt;
&lt;H3&gt;Create an Instance of Flickr&lt;/H3&gt;
&lt;P&gt;First, let's create a simple Flickr object, passing in your API key obtained above.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; apikey = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"1234abcd1234abcd"&lt;/FONT&gt;;&lt;BR&gt;Flickr flickr = &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;new&lt;/FONT&gt; Flickr(apikey);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; apikey &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = &lt;FONT color=#800000 family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;"1234abcd1234abcd"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; f &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Flickr = &lt;FONT color=#0000ff family="Microsoft &amp;#13;&amp;#10;Sans Serif"&gt;New&lt;/FONT&gt; Flickr(apikey)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;From this instance of the &lt;B&gt;Flickr&lt;/B&gt; object you can perform searches, browse groups, find users, and perform the steps required to authenticate a user (provided you provide the &lt;B&gt;Shared Secret&lt;/B&gt; as well).&lt;/P&gt;
&lt;H3&gt;Find Those Photos&lt;/H3&gt;
&lt;P&gt;The following line of code searches all Flickr photos for photos with the tag "microsoft":&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PhotoSearchOptions searchOptions = &lt;FONT color=#0000ff family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;new&lt;/FONT&gt; PhotoSearchOptions();&lt;BR&gt;searchOptions.Tags = &lt;FONT color=#800000 family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;"microsoft"&lt;/FONT&gt;;&lt;BR&gt;Photos microsoftPhotos = flickr.PhotosSearch(searchOptions);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; searchOptions &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; PhotoSearchOptions = &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;New&lt;/FONT&gt; PhotoSearchOptions()&lt;BR&gt;searchOptions.Tags = &lt;FONT color=#800000 family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;"microsoft"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; microsoftPhotos &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Photos = f.PhotosSearch(searchOptions)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;B&gt;PhotoSearchOptions&lt;/B&gt; class is the easiest and most flexible way to search for photos. Many of its properties are optional, but it covers all the options available to the complex search function, including &lt;B&gt;UserId&lt;/B&gt;, &lt;B&gt;Tags&lt;/B&gt;, and &lt;B&gt;SortOrder&lt;/B&gt;.&lt;/P&gt;
&lt;P&gt;The &lt;B&gt;Photos&lt;/B&gt; class contains a selection of properties, some of which may not be immediately obvious. As previously mentioned, when you perform a search on Flickr the result are paged. By default a page will be 100 photos big, and the above search will return the first 100 photos (or less if there are fewer than that) for the specified search. &lt;B&gt;Photos.TotalPhotos&lt;/B&gt; will give you the total number of photos available on the current search, while &lt;B&gt;Photos.TotalPages&lt;/B&gt; will give you the number of &lt;I&gt;pages&lt;/I&gt; that you need to return to get all the available photos. By modifying the Page property of the PhotoSearchOptions class, you can return more pages from Flickr.&lt;/P&gt;
&lt;P&gt;The following code returns the second and then the third page of results from Flickr for the above search:&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;searchOptions.Page = 2;&lt;BR&gt;Photos microsoftPhotos2 = flickr.PhotosSearch(searchOptions);&lt;BR&gt;searchOptions.Page = 3;&lt;BR&gt;Photos microsoftPhotos3 = flickr.PhotosSearch(searchOptions);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;searchOptions.Page = 2&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; microsoftPhotos2 &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Photos = f.PhotosSearch(searchOptions)&lt;BR&gt;searchOptions.Page = 3&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; microsoftPhotos3 &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Photos = f.PhotosSearch(searchOptions)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;B&gt;Photos&lt;/B&gt; class also contains a PhotoCollection property, which is where the actual photos lie. You can add PhotoCollection objects together to collect together one or more page of results. You can also use the &lt;B&gt;foreach&lt;/B&gt; statement to loop through all the photos in the collection.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PhotoCollection allPhotos = microsoftPhotos.PhotoCollection;&lt;BR&gt;allPhotos.AddRange(microsoftPhotos2.PhotoCollection);&lt;BR&gt;allPhotos.AddRange(microsoftPhotos3.PhotoCollection);&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;foreach&lt;/FONT&gt; (Photo photo &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;in&lt;/FONT&gt; allPhotos)&lt;BR&gt;{&lt;BR&gt;    Console.Write(&lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"Photos title is "&lt;/FONT&gt; + photo.Title);&lt;BR&gt;}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; allPhotos &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; PhotoCollection = microsoftPhotos.PhotoCollection&lt;BR&gt;allPhotos.AddRange(microsoftPhotos2.PhotoCollection)&lt;BR&gt;allPhotos.AddRange(microsoftPhotos3.PhotoCollection)&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;For&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Each&lt;/FONT&gt; p &lt;FONT color=#0000ff family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;As&lt;/FONT&gt; Photo &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;In&lt;/FONT&gt; allPhotos&lt;BR&gt;    Console.&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Write&lt;/FONT&gt;(&lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"Photos title is "&lt;/FONT&gt; &amp;amp; p.Title)&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Next&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;For&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;H3&gt;Find a User and Their Photos&lt;/H3&gt;
&lt;P&gt;To find a user you either have to search on their screen name or the URL of their home page (or use authentication, which we will get to later). If you have the screen name of a user (say "Sam Judson"), then the following will give you the &lt;B&gt;User ID&lt;/B&gt; of that user.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; screenName = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"Sam Judson"&lt;/FONT&gt;;&lt;BR&gt;FoundUser user = flickr.PeopleFindByUsername(screenName);&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; userId = user.UserId;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; screenName &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = &lt;FONT color=#800000 family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;"Sam Judson"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; user &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; FoundUser = f.PeopleFindByUsername(screenName)&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; userId &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;String&lt;/FONT&gt; = user.UserId&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This user ID can then be used to search that user's photos, favorites, groups, contacts, and so on. (Apologies to my British fans at the use of the American spelling of &lt;I&gt;favorite&lt;/I&gt; throughout the API, but blame Flickr not me :-)&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// First page of the users photos&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Sorted by interestingness&lt;/FONT&gt;&lt;BR&gt;PhotoSearchOptions userSearch = &lt;FONT color=#0000ff family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;new&lt;/FONT&gt; PhotoSearchOptions ();&lt;BR&gt;userSearch.UserId = userId;&lt;BR&gt;userSearch.Sort = SortOrder.InterestingnessAsc;&lt;BR&gt;Photos usersPhotos = flickr.PhotosSearch(userSearch);&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Get users contacts&lt;/FONT&gt;&lt;BR&gt;Contacts contacts = flickr.ContactsGetPublicList(userId);&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Get first page of a users favorites&lt;/FONT&gt;&lt;BR&gt;Photos usersFavoritePhotos = flickr.FavoritesGetPublicList(userId);&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Get a list of the users groups&lt;/FONT&gt;&lt;BR&gt;PublicGroupInfo[] usersGroups = flickr.PeopleGetPublicGroups(userId);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' First page of the users photos&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Sorted by interestingness&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; userSearch &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; PhotoSearchOptions = &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;New&lt;/FONT&gt; PhotoSearchOptions()&lt;BR&gt;userSearch.UserId = userId&lt;BR&gt;userSearch.Sort = SortOrder.InterestingnessAsc&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; usersPhotos &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Photos = flickr.PhotosSearch(userSearch)&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Get users contacts&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; contacts &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Contacts = flickr.ContactsGetPublicList(userId)&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Get first page of a users favorites&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; usersFavoritePhotos &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Photos = flickr.FavoritesGetPublicList(userId)&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Get a list of the users groups&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; usersGroups &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; PublicGroupInfo() = flickr.PeopleGetPublicGroups(userId)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I could sit here all day and list every method in the API, but basically if it's in the Flickr API, it's in the .Net library, and the method name will be the same as the Flickr method — but without the full stops and the &lt;I&gt;flickr&lt;/I&gt; bit at the beginning. For example, "flickr.people.getPublicGroups" is "PeopleGetPublicGroups" in the Flickr.Net API Library.&lt;/P&gt;
&lt;H2&gt;Authentication&lt;/H2&gt;
&lt;P&gt;This perhaps is the most complex part of any application (at least in terms of interaction with Flickr), so we will cover it step-by-step. The example application provided at the end will have a complete implementation of desktop authentication in it. Web-based authentication is slightly different and is covered at the end.&lt;/P&gt;
&lt;H3&gt;Get the Frob&lt;/H3&gt;
&lt;P&gt;Frob? What the heck? I'm not quite sure what the word &lt;I&gt;Frob&lt;/I&gt; means, but basically it's a temporary key that you can pass to Flickr, which will then ask the user to authenticate your application. Once it has been authenticated, you can use that same Frob to get the &lt;B&gt;Authentication Token&lt;/B&gt; as well as the User ID of the authenticated user (see, told you we'd get back to that).&lt;/P&gt;
&lt;H3&gt;Tell the User Where to Go&lt;/H3&gt;
&lt;P&gt;After you have the Frob, you must pass this, along with your API Key and the permissions you need to Flickr, in a signed URL. Fortunately, the library has a method that does the signing for you and returns the URL to redirect the user to. You will however need to know your &lt;B&gt;Shared Secret&lt;/B&gt; (see "Get an API Key" above if you haven't got your shared secret yet) to calculate this URL.&lt;/P&gt;
&lt;H3&gt;Example Code&lt;/H3&gt;
&lt;P&gt;Imagine you have two buttons on a form. The first reads &lt;B&gt;Authenticate Me&lt;/B&gt; and the second reads &lt;B&gt;Complete Authentication&lt;/B&gt;. The following code illustrates the code behind the form for the two buttons to authenticate a user for read/write permissions.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;using&lt;/FONT&gt; FlickrNet;&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Store the Frob in a private variable&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; tempFrob;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; ApiKey = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"1234abcd1234abcd1234"&lt;/FONT&gt;;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; SharedSecret = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"abcd1234abcd"&lt;/FONT&gt;;&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;protected&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;void&lt;/FONT&gt; AuthMeButton_Click(&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;object&lt;/FONT&gt; sender, EventArgs e)&lt;BR&gt;{&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Create Flickr instance&lt;/FONT&gt;&lt;BR&gt;    Flickr flickr = &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;new&lt;/FONT&gt; Flickr(ApiKey, SharedSecret);&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Get Frob    &lt;/FONT&gt;&lt;BR&gt;    tempFrob = flickr.AuthGetFrob();&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Calculate the URL at Flickr to redirect the user to&lt;/FONT&gt;&lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; flickrUrl = flckr.AuthCalcUrl(tempFrob, AuthLevel.Write);&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// The following line will load the URL in the users default browser.&lt;/FONT&gt;&lt;BR&gt;    System.Diagnostics.Process.Start(flickrUrl);&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;protected&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;void&lt;/FONT&gt; CompleteAuthButton_Click(&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;object&lt;/FONT&gt; sender, EventArgs e)&lt;BR&gt;{&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Create Flickr instance&lt;/FONT&gt;&lt;BR&gt;    Flickr flickr = &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;new&lt;/FONT&gt; Flickr(ApiKey, SharedSecret);&lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;try&lt;/FONT&gt; &lt;BR&gt;    {&lt;BR&gt;        &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// use the temporary Frob to get the authentication&lt;/FONT&gt;&lt;BR&gt;        Auth auth = flickr.AuthGetToken(tempFrob);&lt;BR&gt;        &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Store this Token for later usage, &lt;/FONT&gt;&lt;BR&gt;        &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// or set your Flickr instance to use it.&lt;/FONT&gt;&lt;BR&gt;        Console.WriteLine(&lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"User authenticated successfully"&lt;/FONT&gt;);&lt;BR&gt;        Console.WriteLine(&lt;FONT color=#800000 family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;"Authentication token is "&lt;/FONT&gt; + auth.Token); &lt;BR&gt;        flickr.ApiToken = auth.Token;&lt;BR&gt;Console.WriteLine(&lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"User id is "&lt;/FONT&gt; + auth.UserId);&lt;BR&gt;    }&lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;catch&lt;/FONT&gt;(FlickrException ex)&lt;BR&gt;    {&lt;BR&gt;        &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// If user did not authenticat your application &lt;/FONT&gt;&lt;BR&gt;        &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// then a FlickrException will be thrown.&lt;/FONT&gt;&lt;BR&gt;        Console.WriteLine(&lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"User did not authenticate you"&lt;/FONT&gt;);&lt;BR&gt;        Console.WriteLine(ex.ToString());&lt;BR&gt;    }&lt;BR&gt;}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Imports&lt;/FONT&gt; FlickrNet&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Store the Frob in a private variable&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Private&lt;/FONT&gt; tempFrob &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Private&lt;/FONT&gt; ApiKey &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"1234abcd1234abcd1234"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Private&lt;/FONT&gt; SharedSecret &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = &lt;FONT color=#800000 family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;"abcd1234abcd"&lt;/FONT&gt;&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Private&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Sub&lt;/FONT&gt; AuthMeButton_Click(&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;ByVal&lt;/FONT&gt; sender &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Object&lt;/FONT&gt;, &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;ByVal&lt;/FONT&gt; e &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; EventArgs)&lt;BR&gt;&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Create Flickr instance&lt;/FONT&gt;&lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; f &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Flickr = &lt;FONT color=#0000ff family="Microsoft &amp;#13;&amp;#10;Sans Serif"&gt;New&lt;/FONT&gt; Flickr(ApiKey, SharedSecret)&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Get Frob    &lt;/FONT&gt;&lt;BR&gt;    tempFrob = f.AuthGetFrob()&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Calculate the URL at Flickr to redirect the user to&lt;/FONT&gt;&lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; flickrUrl &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = f.AuthCalcUrl(tempFrob, AuthLevel.&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Write&lt;/FONT&gt;)&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' The following line will load the URL in the users default browser.&lt;/FONT&gt;&lt;BR&gt;    System.Diagnostics.Process.Start(flickrUrl)&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;End&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Sub&lt;/FONT&gt;&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Private&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Sub&lt;/FONT&gt; CompleteAuthButton_Click(&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;ByVal&lt;/FONT&gt; sender &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Object&lt;/FONT&gt;, &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;ByVal&lt;/FONT&gt; e &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; EventArgs)&lt;BR&gt;&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Create Flickr instance&lt;/FONT&gt;&lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; f &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Flickr = &lt;FONT color=#0000ff family="Microsoft &amp;#13;&amp;#10;Sans Serif"&gt;New&lt;/FONT&gt; Flickr(ApiKey, SharedSecret)    &lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Try&lt;/FONT&gt;&lt;BR&gt;        &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' use the temporary Frob to get the authentication&lt;/FONT&gt;&lt;BR&gt;        Auth a = f.AuthGetToken(tempFrob)&lt;BR&gt;        &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Store this Token for later usage, &lt;/FONT&gt;&lt;BR&gt;        &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' or set your Flickr instance to use it.&lt;/FONT&gt;&lt;BR&gt;        Console.WriteLine(&lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"User authenticated successfully"&lt;/FONT&gt;)&lt;BR&gt;        Console.WriteLine(&lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"Authentication token is "&lt;/FONT&gt; &amp;amp; a.Token)&lt;BR&gt;        f.ApiToken = a.Token&lt;BR&gt;Console.WriteLine(&lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"User id is "&lt;/FONT&gt; &amp;amp; a.UserId)&lt;BR&gt;    &lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Catch&lt;/FONT&gt; ex &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; FlickrException&lt;BR&gt;&lt;BR&gt;        &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' If user did not authenticat your application &lt;/FONT&gt;&lt;BR&gt;        &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' then a FlickrException will be thrown.&lt;/FONT&gt;&lt;BR&gt;        Console.WriteLine(&lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"User did not authenticate you"&lt;/FONT&gt;)&lt;BR&gt;        Console.WriteLine(ex.ToString())&lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;End&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Try&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;End&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Sub&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see, if the user does not authenticate you, then the &lt;B&gt;AuthGetToken&lt;/B&gt; method throws an exception which can be caught to handle this situation.&lt;/P&gt;
&lt;H3&gt;Now You're Authenticated&lt;/H3&gt;
&lt;P&gt;Once you have authenticated and have the user's &lt;B&gt;Token&lt;/B&gt;, two things can happen. Firstly, you can now call new methods that are only available when authenticated, such as Flickr.PhotosSetTags(), which sets the tags for a given photo of the authenticated user. You can also now upload photos to that user's account. &lt;/P&gt;
&lt;P&gt;Secondly though, some methods will now perform slightly differently. For example, the above search for photos with the "microsoft" tag will now return any of that user's private photos that have that tag, as well as their public and other users' public photos with the tag. &lt;/P&gt;
&lt;P&gt;Setting the token can also be done at the constructor stage, or later.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Flickr flickr = &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;new&lt;/FONT&gt; Flickr(ApiKey, SharedSecret, AuthToken); &lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// or &lt;/FONT&gt;&lt;BR&gt;flickr.ApiToken = newToken;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; f &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Flickr = &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;New&lt;/FONT&gt; Flickr(ApiKey, SharedSecret, AuthToken)&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' or &lt;/FONT&gt;&lt;BR&gt;f.ApiToken = newToken&lt;/CODE&gt;&lt;/PRE&gt;
&lt;H3&gt;Web Authentication? Different How?&lt;/H3&gt;
&lt;P&gt;For Web-based authentication you must specify in the &lt;B&gt;Edit Configuration&lt;/B&gt; page of your API key the page to redirect users to after they have authenticated your application. It's called the &lt;B&gt;Callback URL&lt;/B&gt;. You also do not need to create a Frob when using Web-based authentication.&lt;/P&gt;
&lt;P&gt;You can use the &lt;B&gt;Flickr.AuthCalcWebUrl&lt;/B&gt; method to generate a URL to redirect the user to.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; url = flickr.AuthCalcWebUrl(AuthLevel.Write);&lt;BR&gt;Response.Redirect(url);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; url &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = f.AuthCalcWebUrl(AuthLevel.&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Write&lt;/FONT&gt;)&lt;BR&gt;Response.Redirect(url)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the page specified by the Callback URL above you get passed the Frob in the query string; for example, if your callback URL is http://example.com/flickr.aspx, then the user will be redirected to http://example.com/flickr.aspx?frob=1234abcd1234abcd.&lt;/P&gt;
&lt;P&gt;Then you can use the Frob to get the authentication token as in the example above:&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;protected&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;void&lt;/FONT&gt; Page_OnLoad(&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;object&lt;/FONT&gt; sender, EventArgs e)&lt;BR&gt;{&lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; frob = Request.QueryString[&lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"frob"&lt;/FONT&gt;];&lt;BR&gt;    Flickr flickr = &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;new&lt;/FONT&gt; Flickr(ApiKey, SharedSecret);&lt;BR&gt;    Auth auth = flickr.AuthGetToken(frob);&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Store the token somewhere for later calls&lt;/FONT&gt;&lt;BR&gt;}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Protected&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Sub&lt;/FONT&gt; Page_Load(&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;ByVal&lt;/FONT&gt; sender &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Object&lt;/FONT&gt;, &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;ByVal&lt;/FONT&gt; e &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; System.EventArgs) &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Handles&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Me&lt;/FONT&gt;.Load&lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; frob &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = Request.QueryString(&lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"frob"&lt;/FONT&gt;)&lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; f &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Flickr = &lt;FONT color=#0000ff family="Microsoft &amp;#13;&amp;#10;Sans Serif"&gt;New&lt;/FONT&gt; Flickr(ApiKey, SharedSecret)&lt;BR&gt;    &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; a &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Auth = f.AuthGetToken(frob)&lt;BR&gt;    &lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Store the token somewhere for later calls&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;End&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Sub&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;H2&gt;Uploading Photos&lt;/H2&gt;
&lt;P&gt;Once you have authenticated a user, you can upload a photo to their account.&lt;/P&gt;
&lt;P&gt;This is actually really simple to do. It can either be done directly from a file on the hard drive or from a &lt;B&gt;Stream&lt;/B&gt; object.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; file = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"test.jpg"&lt;/FONT&gt;;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; title = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"Test Photo"&lt;/FONT&gt;;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; descripton = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"This is the description of the photo"&lt;/FONT&gt;;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; tags = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"tag1,tag2,tag3"&lt;/FONT&gt;;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;string&lt;/FONT&gt; photoId = flickr.UploadPicture(file, title, dscription, tags);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; file &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"test.jpg"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; title &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"Test Photo"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; descripton &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"This is the description of the photo"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; tags &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"tag1,tag2,tag3"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; photoId &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;String&lt;/FONT&gt; = f.UploadPicture(file, title, dscription, tags)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The method has parameters for setting the photo's title, description, tags, and whether the photo is public of private (three optional Boolean parameters not shown above).&lt;/P&gt;
&lt;H3&gt;Updating Photos&lt;/H3&gt;
&lt;P&gt;Once you've uploaded some a photo you might want to add it to a set, add it to a group or two, or update the description, title or add some tags.&lt;/P&gt;
&lt;P&gt;The following code updates the title and description of the previously uploaded photo, and then adds it to the first set in the user's list of sets.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Visual C#&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;flickr.PhotosSetMeta(photoId, &lt;FONT color=#800000 family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;"New Title"&lt;/FONT&gt;, &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"New Description"&lt;/FONT&gt;);&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Get list of users sets&lt;/FONT&gt; Photosets sets = flickr.PhotosetsGetList();&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Get the first set in the collection&lt;/FONT&gt;&lt;BR&gt;Photoset set = sets.PhotosetCollection[0];&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;// Add the photo to that set&lt;/FONT&gt;&lt;BR&gt;flickr.PhotosetsAddPhoto(set.PhotosetId, photoId);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Visual Basic&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;f.PhotosSetMeta(photoId, &lt;FONT color=#800000 family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;"New Title"&lt;/FONT&gt;, &lt;FONT color=#800000 family="Microsoft Sans Serif"&gt;"New Description"&lt;/FONT&gt;)&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Get list of users sets&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; sets &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; Photosets = f.PhotosetsGetList();&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Get the first set in the collection&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans Serif"&gt;set&lt;/FONT&gt; &lt;FONT color=#0000ff family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;As&lt;/FONT&gt; Photoset = sets.PhotosetCollection(0)&lt;BR&gt;&lt;FONT color=#008000 family="Microsoft Sans Serif"&gt;' Add the photo to that set&lt;/FONT&gt;&lt;BR&gt;f.PhotosetsAddPhoto(&lt;FONT color=#0000ff family="Microsoft Sans &amp;#13;&amp;#10;Serif"&gt;set&lt;/FONT&gt;.PhotosetId, photoId)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;H2&gt;Conclusion&lt;/H2&gt;
&lt;P&gt;As you can see, the actual mechanics of communicating with Flickr are relatively simple. The hard part is coming up with the idea for a groovy new application.&lt;/P&gt;
&lt;P&gt;In the second part of this application, I will develop an application based on the WIA Coding 4 Fun article &lt;A href="http://msdn.microsoft.com/coding4fun/someassemblyrequired/lookatme/default.aspx" mce_href="http://msdn.microsoft.com/coding4fun/someassemblyrequired/lookatme/default.aspx"&gt;Look at Me! Windows Image Acquisition&lt;/A&gt;, which you could use to automatically upload images when you connect a compatible device to your computer.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1126978" 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/web+services/default.aspx">web services</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/web/default.aspx">web</category></item></channel></rss>