<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Stefan Wick's Weblog - Tips for WP7, Silverlight, WPF and Tablet PC</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/swick/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/swick/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 05:32:24 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>WP7 Mango: Image Download With Custom Referer Header</title>
      <link>https://docs.microsoft.com/archive/blogs/swick/wp7-mango-image-download-with-custom-referer-header</link>
      <pubDate>Thu, 04 Aug 2011 00:14:00 GMT</pubDate>
      <dc:creator><![CDATA[Stefan Wick - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/swick/2011/08/04/wp7-mango-image-download-with-custom-referer-header/</guid>
      <description><![CDATA[In Mango we have enabled setting the referer header (and many other headers)&nbsp;on...]]></description>
      <content:encoded><![CDATA[<p>In Mango we have enabled setting the referer header (and many other headers)&nbsp;on HttpWebRequests. One question that popped up a few times: how do I use this with the Image element and data-binding&nbsp;to download my images. Here is a quick sample to demonstrate how you can do this.</p>
<p>1. Step: define a custom attached property on Image that takes the URI to your image.</p>
<pre class="scroll"><code class="csharp"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/6431.step1.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-93-41/6431.step1.PNG"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/6431.step1.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-93-41/6431.step1.PNG" /></a></code>&nbsp;</pre>
<p>&nbsp;</p>
<p>2. Step: implement the download piece when the property changes&nbsp;and customize the header as needed.</p>
<p><span style="font-size: small;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/6428.step2.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-93-41/6428.step2.PNG"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/6428.step2.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-93-41/6428.step2.PNG" /></a></span><code class="csharp">&nbsp;</code></p>
<p><code class="csharp"></code>&nbsp;</p>
<p>3. Step:&nbsp;Now use your brand new property in your app's XAML.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/1638.step3.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-93-41/1638.step3.PNG"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/1638.step3.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-93-41/1638.step3.PNG" /></a></p>
<p>&nbsp;</p>
<p>Full sample project is attached.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/19/26/58/ImageWithCustomReferer.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-19-26-58/ImageWithCustomReferer.zip">ImageWithCustomReferer.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Demos from my MIX 2011 session - Part 1: Navigation Tips</title>
      <link>https://docs.microsoft.com/archive/blogs/swick/demos-from-my-mix-2011-session-part-1-navigation-tips</link>
      <pubDate>Mon, 18 Apr 2011 23:26:00 GMT</pubDate>
      <dc:creator><![CDATA[Stefan Wick - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/swick/2011/04/18/demos-from-my-mix-2011-session-part-1-navigation-tips/</guid>
      <description><![CDATA[I have attached the first of the demos from my MIX 2011 session. Note that I have attached two...]]></description>
      <content:encoded><![CDATA[<p>I have attached the first of the demos from my <a href="https://channel9.msdn.com/events/MIX/MIX11/DVC04">MIX 2011 session</a>. Note that I have attached two versions: the 'before' version to illustrate the problems, and the 'after' version to show the fixes. This post will walk you through each of the tips and describes the code changes being made:</p>
<h3>Tip 1: Circular Navigation</h3>
<p>Consider the following sequence in the demo app: Log in (empty user/pwd)&nbsp;-&gt; Send a Message -&gt; type something -&gt; hit 'Home' button (in the App Bar) -&gt; Get Stock Quotes -&gt; hit 'Home' button -&gt; Send a Message.&nbsp; While you do this, please monitor the helper control on the top right, which shows you the current navigation backstack. The result will look like this:</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/2134.tips1_1.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/225x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-93-41/2134.tips1_5F00_1.PNG" border="0" /></p>
<p>There are two small problems&nbsp;here that will likely confuse the user: (a) the user didn't get back to the message they were typing and (b) the user is deeper in the navigation stack than likely intended. To solve this and avoid confusion, you have two options (I chose option A for my demo):</p>
<p><strong>Solution A:</strong> Avoid Circulation Navigation altogether. In this case, just get rid of the 'Home' App Bar Buttons and the user will be just fine using standard means of navigation.<br /><strong>Solution B: </strong>Instead of navigating forward to 'Home', walk the backstack programmatically, until you reach the Start Page. More details in this<a href="https://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/12/13/solving-circular-navigation-in-windows-phone-silverlight-applications.aspx"> white paper</a>&nbsp;by Yochay Kiriaty.</p>
<p>&nbsp;</p>
<h3>Tip 2: Dealing with transient Pages on the Backstack</h3>
<p>If you now hit the back button a couple of times from the current state of the app, you will notice two issues: (a) we get back to the LoginPage and (b) we can't exit the app as the back key seems to get stuck. The latter is big no-no and will cause your app to fail certification. It's an easy fix though as the app was just marking the back key as handled for no valid reason, so removing the highlighted line will fix this:</p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: black; font-size: 8pt; mso-fareast-font-family: 'Times New Roman';">protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)<br />{<br /><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%;"><span style="background-color: #ff0000;"><strong>e.Cancel = true;<br /></strong></span></span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>base.OnBackKeyPress(e);<br />}</span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: black; font-size: 8pt; mso-fareast-font-family: 'Times New Roman';"></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: black; font-size: 8pt; mso-fareast-font-family: 'Times New Roman';"><o:p></o:p></span></p>
<p>&nbsp;</p>
<p>But how do we&nbsp;fix the root problem of hitting the LoginPage on our way back and exit the app cleanly? Again there are a few options to fix this. My personal preference is the following: I consider the LoginPage semantically not really a page that participates in navigation, but rather a control that overlays the StartPage and is shown only if the StartPage is navigated to without an existing user context. To implement this, I just move LoginPage code into a control (LoginControl) and include that in the StartPage. The StartPage now can control the visiblity of the LoginControl programatically as needed.</p>
<p><strong></strong>&nbsp;<img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/2235.tips2_1.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-93-41/2235.tips2_5F00_1.PNG" border="0" /></p>
<p>For completeness sake, alternate methods for solving the problem of dealing with transient pages on the backstack include cancelling the navigation or using UriMapper. Peter Torr has a <a href="https://blogs.msdn.com/b/ptorr/archive/2010/08/28/redirecting-an-initial-navigation.aspx">blog post covering both</a>.</p>
<p>&nbsp;</p>
<h3>Tip 3: Saving Page state on Tombstoning</h3>
<p>Consider the following scenario in the demo app:&nbsp; We navigate to the "Send a Message" page and start typing a message. Now we want to find some data on the Internet and use copy &amp; paste to include it in the message. For that we hit the Search button in the App Bar, do our search and then navigate back. The result is very frustrating: the message that we had typed&nbsp;tediously is now gone. Why is that, what happened here? Tombstone happened!</p>
<p>The short story is this: when the user navigates forward, away from your app, then your app will receive an entry on the global backstack, get a chance to save its state and then the process will be shut down. The longer story is documented <a href="https://msdn.microsoft.com/en-us/library/ff817008(v=VS.92).aspx">here</a>. So the problem in the demo app was that we didn't save our state before we got Tombstoned. The general recommendation for saving your Page's state is to persist it in OnNavigatedFrom() and restore it in OnNavigatedTo(), in MessagePage.xaml.cs:</p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 8pt;">protected</span><span style="font-family: Consolas; font-size: 8pt;"> <span style="color: blue;">override</span> <span style="color: blue;">void</span>OnNavigatedFrom(<span style="color: #2b91af;">NavigationEventArgs</span> e)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">base</span>.OnNavigatedFrom(e);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; color: blue; mso-highlight: yellow;">if</span><span style="background: yellow; mso-highlight: yellow;"> (<span style="color: #2b91af;">App</span>.CurrentNavigationMode != <span style="color: #2b91af;">NavigationMode</span>.Back)</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">{</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; color: blue; mso-highlight: yellow;">this</span><span style="background: yellow; mso-highlight: yellow;">.State[<span style="color: #a31515;">"message"</span>] = tbMsgBody.Text;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">}</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 8pt;">protected</span><span style="font-family: Consolas; font-size: 8pt;"> <span style="color: blue;">override</span> <span style="color: blue;">void</span>OnNavigatedTo(<span style="color: #2b91af;">NavigationEventArgs</span> e)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">base</span>.OnNavigatedTo(e);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; color: blue; mso-highlight: yellow;">if</span><span style="background: yellow; mso-highlight: yellow;"> (<span style="color: blue;">this</span>.State.ContainsKey(<span style="color: #a31515;">"message"</span>))</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">{</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">tbMsgBody.Text = <span style="color: blue;">this</span>.State[<span style="color: #a31515;">"message"</span>] <span style="color: blue;">as</span> <span style="color: blue;">string</span>;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">}</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;">}</span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><o:p></o:p></span></p>
<p>&nbsp;</p>
<p>I want to point out one small optimization I have made here in the OnNavigatedFrom() call:&nbsp; I will not save the state if my navigation goes backwards. This is because when going backwards, the current page (and its state) drops off the backstack. There is no way the user could ever come back to that page&nbsp;instance, so there is no need really to persist that state. In this app it doesn't buy us much performance gain, but on pages that save&nbsp;large amounts of data, you can save precious CPU and battery with this optimization. Unfortunately, it's not completely straight forward to figure out the navigation mode, so I had to build a little static helper property. It's something we want to improve in the next version.</p>
<p>&nbsp;</p>
<h3>Tip&nbsp;4:&nbsp;&nbsp;Saving Application state on Tombstoning</h3>
<p>Since the state is being saved on a per page basis, it is important to perform Tombstone tests for each page in our app. So let's start a fresh instance of our app and test the Stock Quote Page:&nbsp; After the quotes are downloaded, hit the Windows button to navigate forward (which will Tombstone our app). Now watch what happens when we come back to our app: Without debugger you will just see a little flicker and then you are back at the start screen. With debugger attached you will see that we are crashing in the constructor of the StockPage class.</p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 8pt;">public </span><span style="font-family: Consolas; font-size: 8pt;">StockPage()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>InitializeComponent();<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><strong><span style="background: red; mso-highlight: red;">tbCurrentUser.Text = <span style="color: #a31515;">"CurrentUser: "</span> + <span style="color: #2b91af;">App</span>.CurrentUser.Name;</span><o:p></o:p></strong></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">this</span>.Loaded += <span style="color: blue;">new</span> <span style="color: #2b91af;">RoutedEventHandler</span>(StockPage_Loaded);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;">}<o:p></o:p></span></p>
<p>&nbsp;</p>
<p>The reason for this is fairly simple: the constructor assumes that the static Application property for the user context is always set (since it's set during Login), however this&nbsp;won't&nbsp;be true when returning from Tombstone, if we don't preserve the application state correctly. The general recommendation for saving global app state is to do this in the Deactivated event and then&nbsp;restore it in the Activated event. The latter was missing in the demo app, hence the crash. So now we are adding the highlighted line to fix this problem (in App.xaml.cs):</p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 8pt;">private</span><span style="font-family: Consolas; font-size: 8pt;"> <span style="color: blue;">void</span> Application_Activated(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">ActivatedEventArgs</span> e)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; color: #2b91af; mso-highlight: yellow;">App</span><span style="background: yellow; mso-highlight: yellow;">.CurrentUser = <span style="color: #2b91af;">PhoneApplicationService</span>.Current.State[<span style="color: #a31515;">"userContext"</span>] <span style="color: blue;">as</span> <span style="color: #2b91af;">UserContext</span>;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 8pt;">private</span><span style="font-family: Consolas; font-size: 8pt;"> <span style="color: blue;">void</span> Application_Deactivated(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">DeactivatedEventArgs</span> e)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">PhoneApplicationService</span>.Current.State[<span style="color: #a31515;">"userContext"</span>] = <span style="color: #2b91af;">App</span>.CurrentUser;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 8pt;">}<o:p></o:p></span></p>
<p>&nbsp;</p>
<p>With these four tips/fixes, our app is now much more robust and consistent from a navigation perspective compared to where we started. There are still some other problems in the app, related to the various different phones states though. This will be the topic of my next blog post.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/15/55/67/NavigationTips.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-15-55-67/NavigationTips.zip">NavigationTips.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>MIX 2011: My Windows Phone 7 Session</title>
      <link>https://docs.microsoft.com/archive/blogs/swick/mix-2011-my-windows-phone-7-session</link>
      <pubDate>Sat, 16 Apr 2011 07:20:00 GMT</pubDate>
      <dc:creator><![CDATA[Stefan Wick - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/swick/2011/04/16/mix-2011-my-windows-phone-7-session/</guid>
      <description><![CDATA[I just got back from Las Vegas where I had the opportunity to attend and speak at the MIX 2011...]]></description>
      <content:encoded><![CDATA[<p>I just got back from Las Vegas where I had the opportunity to attend and speak at the MIX 2011 conference. A recording of my session can be viewed here&nbsp;on Channel9: <a href="https://channel9.msdn.com/Events/MIX/MIX11/DVC04">Expert Lessons: Top Tips for Building a Successful Windows Phone Application</a>&nbsp;</p>
<p>I had a great time at MIX and I am very excited about the new Windows Phone Mango features we announced as well as all the cool stuff that is coming in Silverlight 5. Watch the <a href="https://channel9.msdn.com/Events/MIX/MIX11/KEY02">Day 2 Keynote</a> for some great demos around the new features. The Silverlight 5 Beta is available for download now <a href="https://www.silverlight.net/getstarted/silverlight-5-beta/">here</a>, the Windows Phone Mango Tools/Emulator will become available a little later next month.</p>
<p>This weekend I will work on some follow-up posts to my MIX session and get the demo/samples uploaded here. Stay tuned ...&nbsp; :-)</p>
<p><strong>Update (4/20): </strong>attaching my slide deck</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/15/47/71/04.swick.tips.03292011.psf.pptx" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-15-47-71/04.swick.tips.03292011.psf.pptx">04.swick.tips.03292011.psf.pptx</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Image Tips for Windows Phone 7</title>
      <link>https://docs.microsoft.com/archive/blogs/swick/image-tips-for-windows-phone-7</link>
      <pubDate>Thu, 07 Apr 2011 22:43:00 GMT</pubDate>
      <dc:creator><![CDATA[Stefan Wick - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/swick/2011/04/07/image-tips-for-windows-phone-7/</guid>
      <description><![CDATA[If you are&nbsp;developing for&nbsp;Windows Phone&nbsp;you have probably been using the&nbsp;the...]]></description>
      <content:encoded><![CDATA[<p>If you are&nbsp;developing for&nbsp;Windows Phone&nbsp;you have probably been using the&nbsp;the Image element in various places of your UI already. Using the Image element is very easy and&nbsp;wouldn't warrent&nbsp;a blog post: just set the Source property to the URI of your image and you are done, right? Yeah, pretty much - however, there are a couple subtle details that are very useful to know, especially if you want to optimize your app for best performance and memory usage. Most of these little tips aren't specific to the phone - they apply also to Silverlight desktop - but on the phone it is so much more important to pay attention to the little performance details that can turn a good app into an awesome app. To help illustrate the points, I have attached a sample app that demonstrates the results you can achieve by applying these tips.</p>
<p><strong>JPG vs. PNG</strong></p>
<p>If you can make a choice between using JPG and PNG, choose JPG for all your opaque images. The JPG decoder in the Windows Phone 7 operating system is considerably faster than the PNG decoder. If you need to use images that have transparency, PNG is your only choice though.</p>
<p><strong>Resource vs. Content</strong></p>
<p>Images (or any files for that matter) that are part of your Windows Phone XAP can have their "Build Type" set to either "Resource" or "Content" in Visual Studio. At first sight it doesn't seem to make any difference what you choose here, as in both cases your files end up getting packaged up in the XAP. The difference becomes visible when you crack open your XAP (rename it to .zip and unzip it): now you can see all your files of type "Content", but you won't&nbsp;find the files of type "Resource" because those are embedded in the assemblies (.dll files). OK, why do I care? You care because the&nbsp;larger your application's DLL, the slower your app will launch. On the other hand, once they are&nbsp;loaded the images will show up quicker compared to having them load from disk later. <span style="text-decoration: underline;">Summary</span>: include your images as "Content" to optimize for quick start up, include them as "Resource" to optimize for quick access.</p>
<p>The other thing to note as that there is a difference in URI syntax for images included as "Content" vs. "Resource". Check out the attached sample and navigate to the "Content vs. Resource" page&nbsp;for more details on this.</p>
<p><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;">Content: </span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Image</span><span style="font-family: Consolas; color: red; font-size: 9.5pt;"> </span><span style="font-family: Times New Roman; font-size: small;">Source</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">="/ImagesAsContent/smiley1.png"/&gt;</span><span style="font-size: small;"><u1:p><span style="font-family: 'Calibri','sans-serif'; color: black;">&nbsp;</span></u1:p><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"><o:p></o:p></span></span></p>
<p><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;">Resource: </span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Image</span><span style="font-family: Consolas; color: red; font-size: 9.5pt;"> </span><span style="font-family: Times New Roman; font-size: small;">Source</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">="..\ImagesAsResource\smiley3.png"/&gt;</span><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;">&nbsp;<o:p></o:p></span></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/1541.ResourceContent.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-93-41/1541.ResourceContent.PNG" border="0" /></p>
<p>&nbsp;</p>
<p><strong>Async vs. Sync Loading of images</strong></p>
<p>If you drill a little <span style="font-family: arial,helvetica,sans-serif;">deeper </span>into the Imaging APIs you will come across the BitmapImage class, which is doing most of the work behind the scenes when you create an Image. It can load things in two different modes:</p>
<p><span style="font-family: Consolas; color: black; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"><span style="background-color: #ffffcc;">&nbsp; BitmapImage.UriSource = uriSource; </span></span><span style="background-color: #ffffcc;"><span style="font-family: Consolas; color: green; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';">// loads the image via URI, asynchronously<br /></span><span style="line-height: 115%; font-family: Consolas; color: black; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">&nbsp; BitmapImage.SetSource(stream);&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="line-height: 115%; font-family: Consolas; color: green; font-size: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">// loads the image from stream, synchronously</span></span></p>
<p class="MsoNormal"><span lang="EN" style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN;">Note that loading the image asynchronously doesn't mean it will happen completely off-thread. This is because currently the image decode is happening on the UI thread. For some more information about asynchronous loading of images while keeping the UI thread responsive check out this <a href="https://blogs.msdn.com/b/delay/archive/2011/03/03/quot-your-feedback-is-important-to-us-please-stay-on-the-line-quot-improving-windows-phone-7-application-performance-is-even-easier-with-these-lowprofileimageloader-and-deferredloadlistbox-updates.aspxblog%20post"><b><span style="color: #0066cc; text-decoration: none; text-underline: none;">blog post</span></b></a> by David Anson.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN" style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN;">Some more trivia about async vs. sync loading:</span></p>
<ul>
<li>
<div class="MsoNormal"><span lang="EN" style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN;"></span><span lang="EN" style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN;">If you load an invalid image file synchronously, you will get an exception</span></div>
</li>
<li>
<div class="MsoNormal"><span lang="EN" style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN;"></span><span lang="EN" style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN;">If you load an invalid image file asynchronously,&nbsp;the ImageFailed event fires (if you are subscribed)</span></div>
</li>
<li>
<div class="MsoNormal"><span lang="EN" style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN;"></span><span lang="EN" style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN;">If you&nbsp;load an valid image file asynchronously, the ImageOpened event fires when it's done loading</span></div>
</li>
<li>
<div class="MsoNormal"><span lang="EN" style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN;"></span><span lang="EN" style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN;">If you&nbsp;load an valid image file synchronously, the ImageOpened event does not fire<o:p></o:p></span></div>
</li>
</ul>
<p class="MsoNormal"><span lang="EN" style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN;">To these differences in action check out the attached sample and navigate to the "Loading" page:</span></p>
<p>&nbsp;<img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/3247.Loading.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-93-41/3247.Loading.PNG" border="0" /></p>
<p>&nbsp;</p>
<p><strong>Image Caching</strong></p>
<p>This is an important one, and MSDN is currently fairly silent about it. If you were ever wondering why your image memory didn't get released after clearing the Source and removing the Image from the tree, you were most likely seeing Image caching in action. This is an intended performance optimization, to avoid (down)loading and decoding the same image over and over again. Instead we keep a cache in memory that we can easily and quickly reuse. This is not to confuse with the browser cache for downloaded files.</p>
<p>While this is a nice and free performance optimization, at times it can blow your memory&nbsp; unnecessarily, especially when you cycle through many images that you will never come back to. Their cache will use up memory for the lifetime of your app. The good news is that you can delete the cache when you decided that you no longer need it:<span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;"><code class="csharp"></code></span></p>
<p class="MsoNormal"><span style="background-color: #ffffcc;"><span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;">&nbsp; BitmapImage</span><span style="font-family: Consolas; font-size: 9.5pt;"> bitmapImage = image.Source <span style="color: blue;">as</span> <span style="color: #2b91af;">BitmapImage</span>;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="background-color: #ffffcc;">&nbsp; bitmapImage.UriSource = <span style="color: blue;">null</span>;</span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"></span><span style="line-height: 115%; font-family: Consolas; font-size: 9.5pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="background-color: #ffffcc;">&nbsp; image.Source = <span style="color: blue;">null</span>;</span></span></p>
<p>Being smart about this can save you quite a bit of memory usage, which is a precious resource on a phone device. In the sample app, go to the "Caching" page and monitor the memory usage as you show/clear the image. Then check the box and try again. You will see a difference of ~3MB in the example case.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/5621.Caching.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-93-41/5621.Caching.PNG" border="0" /></p>
<p><strong></strong></p>
<p><strong>BitmapCreateOptions</strong></p>
<p>This is a quick, yet interesting one. If you create BitmapImage objects by hand, you might wonder why it doesn't report the size of the image after you think it's done creating the image. This is because by default the <a href="https://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.createoptions(v=VS.95).aspxCreateOptions property">CreateOptions property </a>is set to "DelayCreation", which means that the object really gets created only when it's indeed needed, meaning the BitmapImage is assigned as the source of an Image element or an ImageBrush that are in the live tree. This allows creating collections of BitmapImages up front on start up, without having to pay all the cost (CPU &amp; memory)&nbsp;until the app actually needs the respective images. If you want to force immediate creation, set the CreateOptions to "None". There is another option (IgnoreImageCache) that isn't terribly useful for many practical purposes, but it's needed by the design tools (e.g. Blend).</p>
<p>In the sample app, if you go to the "CreateOptions" page, go through the Create/Show/Clear sequence once with CreateOptions=DelayCreation and once with CreateOptions=None and monitor the Size value to see the difference in action.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/8547.CreateOptions.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-93-41/8547.CreateOptions.PNG" border="0" /></p>
<p>&nbsp;</p>
<p><strong>Custom Decoding</strong></p>
<p>By default the Imaging APIs will decode images in their natural resolution (except when auto-downsampling, more about that later). However, in many cases this is more than you actually need on a phone display. If you are downloading a collection of 320x320 images from a service only to display them as 32x32 thumbnails, you would be wasting a lot of memory if you decode them at their natural resolution.</p>
<p>On Windows Phone (specifically, not on desktop) the platform provides the <a href="https://msdn.microsoft.com/en-us/library/ff708091(v=VS.92).aspxPictureDecoder">PictureDecoder</a> API that allows to specify the resolution you want to decode to:</p>
<p><span style="line-height: 115%; font-family: Consolas; font-size: 9.5pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="background-color: #ffffcc;">&nbsp; image.Source = <span style="color: #2b91af;">PictureDecoder</span>.DecodeJpeg(jpgStream, 192, 256);</span></span></p>
<p><strong><em>Note</em>: </strong>in the current release there is an unfortunate bug in this API as the values&nbsp;for width and height are swapped. To workaround it just pass your width into the height parameter and vice-versa. This will be future compatible, as we will fix this with a quirks mode for existing apps.</p>
<p>To see the memory gains from doing this, open the sample app and navigate to the "Custom Decoding" page. Switch between the two resolutions and monitor the memory usage.</p>
<p>&nbsp;<img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/6253.Decoding.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-93-41/6253.Decoding.PNG" border="0" /></p>
<p>&nbsp;</p>
<p><strong>Auto Downsampling</strong></p>
<p>This is the last piece of need-to-know trivia when dealing with images in Silverlight for Windows Phone 7. The background is that individual elements are limited to 2048x2048 size on Windows Phone 7. Anything beyond that will be clipped. This means that if you want to consume an image that is larger than 2048 pixels in either dimension, it will not show correctly/completely. To avoid this potential confusion, the platform automatically downsamples large images so that they fit into 2048x2048. This is different from desktop Silverlight where this limitation does not exist.</p>
<p>In the sample app I am consuming an image of size&nbsp;3000x2102, which subsequently gets downsamples to 1500x1051.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/6242.downsample.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-93-41/6242.downsample.PNG" border="0" /></p>
<p>&nbsp;</p>
<p>Phew, this post was longer than I thought it would be. Turns out there are a lot of little things to learn about Images in Silverlight for Windows Phone 7. Thanks for reading this far and I hope you found this post and the attached sample app helpful.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/15/12/49/ImageTips.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-15-12-49/ImageTips.zip">ImageTips.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>A (slightly) new direction</title>
      <link>https://docs.microsoft.com/archive/blogs/swick/a-slightly-new-direction</link>
      <pubDate>Thu, 07 Apr 2011 17:03:00 GMT</pubDate>
      <dc:creator><![CDATA[Stefan Wick - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/swick/2011/04/07/a-slightly-new-direction/</guid>
      <description><![CDATA[For the last 18 months I have been (and I&nbsp;still am)&nbsp;working on an exciting new project:...]]></description>
      <content:encoded><![CDATA[<p>For the last 18 months I have been (and I&nbsp;still am)&nbsp;working on an exciting new project: Silverlight for Windows Phone 7. I haven't had much of a chance to continue my posts about Silverlight, Tablet PC etc., but I am planning pick this up again now and post some hopefully useful tips and samples here. Those will mostly be about building (and testing) Silverlight apps for Windows Phone 7, so that is a bit of a change in direction from the past.</p>
<p>Stay tuned for more.</p>
<p>Cheers, Stefan Wick</p>]]></content:encoded>
    </item>
    <item>
      <title>Silverlight 4 OOB - Handwriting Recognition &amp; Text-To-Speech</title>
      <link>https://docs.microsoft.com/archive/blogs/swick/silverlight-4-oob-handwriting-recognition-text-to-speech</link>
      <pubDate>Thu, 07 Apr 2011 14:42:00 GMT</pubDate>
      <dc:creator><![CDATA[Stefan Wick - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/swick/2011/04/07/silverlight-4-oob-handwriting-recognition-text-to-speech/</guid>
      <description><![CDATA[I have been sitting on this sample for quite a while, but never found the time to get it ready for a...]]></description>
      <content:encoded><![CDATA[<p>I have been sitting on this sample for quite a while, but never found the time to get it ready for a post. Before I switch the focus of my blog over to Windows Phone 7 development, I wanted to get this out of the way first :-)</p>
<p>With Silverlight 4, we introduced an exciting new capability for Out-Of-Browser apps: <a href="https://msdn.microsoft.com/en-us/library/ee721083(v=VS.95).aspxTrusted Applications">Trusted Applications</a>&nbsp;- one of the key new fatures of Trusted Applications is the ability to integrate with COM Automation interfaces on your Windows PC. What does this mean? This allows you to&nbsp;call into native components on your system that are either provided by the OS or installed by the user or system admin. On MSDN you can find some <a href="https://msdn.microsoft.com/en-us/library/ff457794(v=VS.95).aspxsample code">sample code </a>for the canonical example that highlights the power of this feature: integrating Microsoft Office features into your Silverlight application.</p>
<p>In this blog post, however, I want to show some other cool things you can do with these new APIs on your PC: I want to use the systems handwriting recognizer as well as the systems speech synthesizer within my Silverlight application. Let's do the easy part first and take a look at how we get the speech synthesis done (in the attached sample, this plays back the recognized handwriting):</p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt;">
<tbody>
<tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes;">
<td width="28" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">1<o:p></o:p></span></p>
</td>
<td width="516" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 386.9pt; padding-right: 5.4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">private</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">void</span> btnSpeak_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">RoutedEventArgs</span> e)<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">2<o:p></o:p></span></p>
</td>
<td width="516" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 386.9pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">3<o:p></o:p></span></p>
</td>
<td width="516" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 386.9pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">dynamic</span> spVoice = <span style="color: #2b91af;">AutomationFactory</span>.CreateObject(<span style="color: #a31515;">"SAPI.SpVoice.1"</span>);<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">4<o:p></o:p></span></p>
</td>
<td width="516" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 386.9pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>spVoice.Speak(tbResult.Text);<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 4; mso-yfti-lastrow: yes;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">5<o:p></o:p></span></p>
</td>
<td width="516" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 386.9pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p>In <strong>line 3</strong> we create&nbsp;an instance of the&nbsp;SAPI.SpVoice (SAPI = <a href="https://msdn.microsoft.com/en-us/library/ms723627(VS.85).aspxMicrosoft Speach API">Microsoft Speach API</a>). Now we can just call the Speak() method (<strong>line 4</strong>)&nbsp;in order to have the desired text spoken by the machine. Make sure you turn on your speakers.</p>
<p>For the handwriting recognition part, the code looks a little bit more complicated, mostly for two reasons: The COM Automation API for Ink has some oddities &amp; we need to convert the users strokes from pixel space into HiMetric. Here is the full code needed to implement this as extension method on Inkpresenter to have its writing recognized by the system's handwriting recognizer:</p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt;">
<tbody>
<tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes;">
<td width="28" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">1<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">private</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">const</span> <span style="color: blue;">double</span> HiMetricFactor = 26.46d; <span style="color: green;">// = 1000 * 2.53 / 96</span><o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">2<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">public static string Recognize(this InkPresenter presenter)<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">3<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">4<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>dynamic recognizers = AutomationFactory.CreateObject("msinkaut.InkRecognizers");<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 4;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">5<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">dynamic</span> reco = recognizers.GetDefaultRecognizer(1033);<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 5;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">6<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>dynamic context = reco.CreateRecognizerContext();<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 6;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">7<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">dynamic</span> inkCol = <span style="color: #2b91af;">AutomationFactory</span>.CreateObject(<span style="color: #a31515;">"msinkaut.InkCollector"</span>);<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 7;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">8<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>dynamic ink = inkCol.Ink;<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 8;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">9<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 9;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">10<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>foreach (Stroke stroke in presenter.Strokes)<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 10;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">11<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 11;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">12<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">int</span>[] packets = <span style="color: blue;">new</span> <span style="color: blue;">int</span>[stroke.StylusPoints.Count * 2];<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 12;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">13<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = 0; i &lt; stroke.StylusPoints.Count; i++)<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 13;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">14<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 14;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">15<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>packets[i * 2] = (<span style="color: blue;">int</span>)(stroke.StylusPoints[i].X * HiMetricFactor);<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 15;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">16<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>packets[i * 2 + 1] = (<span style="color: blue;">int</span>)(stroke.StylusPoints[i].Y * HiMetricFactor);<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 16;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">17<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 17;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">18<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">dynamic</span> inkStroke = ink.CreateStroke(packets, <span style="color: blue;">null</span>);<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 18;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">19<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 19;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">20<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 20;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">21<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>context.Strokes = ink.Strokes;<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 21;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">22<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">dynamic</span> result = context.Recognize(<span style="color: blue;">null</span>);<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 22;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">23<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">return</span> result.TopString;<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 23; mso-yfti-lastrow: yes;">
<td width="28" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 21.25pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">24<o:p></o:p></span></p>
</td>
<td width="599" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; padding-left: 5.4pt; width: 449.55pt; padding-right: 5.4pt; background: #daeef3; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-background-themecolor: accent5; mso-background-themetint: 51;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p>If you are a little lost, that's OK. Here is how/why it works: :-)</p>
<p>On <strong>line 1</strong> we just define the conversion factor for pixels to HiMetric (the coordinate space used by the native handwriting recognizer on the Windows system).<strong> Lines 4-6</strong> are all about getting us a new <a href="https://msdn.microsoft.com/en-us/library/bb431688.aspxRecognizerContext">RecognizerContext</a>, which is the primary interface for the native recognition engines. In <strong>lines 6-7</strong> I am using a little trick to get a new empty Ink object. There is no Automation-compliany way to produce one, but I can&nbsp;create an InkCollector that owns an Ink object. Then I can steal it for my purpose. All of <strong>lines 10-19 </strong>are about converting the Silverlight Stroke data (from pixels) into native Stroke data (in HiMetric). Last but not least, in <strong>lines 21-23</strong> we pass the Strokes down to the recognizer have have them recognized synchronously.</p>
<p>The full source code for the sample is attached to this post. When you run it, please be sure to run it as Out-Of-Browser app, because Trusted Application features aren't supported in the browser in Silverlight 4.</p>
<p>Enjoy! :-)</p>
<p>&nbsp;<img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/1856.ink.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-93-41/1856.ink.PNG" border="0" /></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/93/41/7128.text.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-93-41/7128.text.PNG" border="0" /></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/15/11/33/HandwritingRecognitionDemo.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-15-11-33/HandwritingRecognitionDemo.zip">HandwritingRecognitionDemo.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Silverlight 3: Perspective 3D</title>
      <link>https://docs.microsoft.com/archive/blogs/swick/silverlight-3-perspective-3d</link>
      <pubDate>Wed, 18 Mar 2009 03:24:00 GMT</pubDate>
      <dc:creator><![CDATA[swick]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/swick/2009/03/18/silverlight-3-perspective-3d/</guid>
      <description><![CDATA[Silverlight 3 Beta has been&nbsp;released today. This release includes a number of exciting new...]]></description>
      <content:encoded><![CDATA[<p>Silverlight 3 Beta has been&nbsp;released today. This release includes a number of exciting new features that I want to illustrate with a series of quick samples on my blog. (<a href="https://silverlight.net/getstarted/silverlight3/default.aspx">more info on Silverlight 3 Beta and how to get the bits and tools</a>).</p>
<p>The first new feature I want to show is Perspective 3D transformation. We have added a powerful new property 'Projection' to UIElement that lets you rotate and move any element in your&nbsp;tree in 3D space! The usage is very simple, no complicated math required - just set the Projection property to a PlaneProjection&nbsp;in XAML or code and specify how you want to rotate or move your elements. You can then change these properties dynamically at runtime, either through code or animations.</p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;">&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt;">Grid</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;"> &gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt;"><span>&nbsp;&nbsp;</span></span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;">&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt;">Grid.Projection</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt;"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;">&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt;">PlaneProjection</span><span style="font-family: 'Courier New'; color: red; font-size: 8pt;"> RotationX</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;">="20"</span><span style="font-family: 'Courier New'; color: red; font-size: 8pt;"> RotationY</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;">="30"</span><span style="font-family: 'Courier New'; color: red; font-size: 8pt;"> RotationZ</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;">="-10"/&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt;"><span>&nbsp;&nbsp;</span></span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;">&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt;">Grid.Projection</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;">&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 8pt;">Grid</span><span style="font-family: 'Courier New'; color: blue; font-size: 8pt;">&gt;<o:p></o:p></span></p>
<p>(<a href="https://msdn.microsoft.com/en-us/library/dd470131(VS.96).aspx">More info on Perspective 3D in Silverlight 3 Beta</a>)</p>
<p>Below is a live example of this new feature in action. The source is attached to this post. Note that&nbsp;you need the Silverlight 3 Beta Tools for VS in order to build the project. To view the live sample on this page you just need the <a href="https://go.microsoft.com/fwlink/?linkid=143433">Silverlight 3 Beta runtime</a> installed. In the sample I have two surfaces back-to-back to each other, simulating a postcard in 3D space. Use the sliders to rotate the postcard around x, y or z axis. To demonstrate that the projected visuals are actually live and also take input, I have ink-enabled then, so you can draw on either side of the postcard.</p>
<p><b>The below sample has been update for the Silverlight 3&nbsp;RTW Runtime (<a href="https://www.microsoft.com/silverlight/get-started/install/default.aspx">download</a></b><b>)</b></p>
<p><iframe scrolling="no" frameborder="0" src="https://silverlight.services.live.com/invoke/34348/InkPostcard_rtw/iframe.html" style="width: 550px; height: 450px;"></iframe></p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/48/62/06/InkPostcard.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-48-62-06/InkPostcard.zip">InkPostcard.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Pan Zoom Example</title>
      <link>https://docs.microsoft.com/archive/blogs/swick/pan-zoom-example</link>
      <pubDate>Sun, 07 Dec 2008 00:32:00 GMT</pubDate>
      <dc:creator><![CDATA[swick]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/swick/2008/12/07/pan-zoom-example/</guid>
      <description><![CDATA[I am hosting this sample here to demonstrate the solution to this forum...]]></description>
      <content:encoded><![CDATA[<P>I am hosting this sample here to demonstrate the solution to this forum thread:</P><A href="https://silverlight.net/forums/p/51139/134135.aspx">https://silverlight.net/forums/p/51139/134135.aspx</A> 
<P mce_keep="true">&nbsp;</P><IFRAME style="WIDTH: 500px; HEIGHT: 400px" src="https://silverlight.services.live.com/invoke/34348/PanZoomSample/iframe.html" frameBorder=0 scrolling=no mce_src="https://silverlight.services.live.com/invoke/34348/PanZoomSample/iframe.html"></IFRAME>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/18/16/98/SilverlightApplication39.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-18-16-98/SilverlightApplication39.zip">SilverlightApplication39.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Custom Ink Rendering in Silverlight 2</title>
      <link>https://docs.microsoft.com/archive/blogs/swick/custom-ink-rendering-in-silverlight-2</link>
      <pubDate>Mon, 01 Dec 2008 16:26:00 GMT</pubDate>
      <dc:creator><![CDATA[swick]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/swick/2008/12/01/custom-ink-rendering-in-silverlight-2/</guid>
      <description><![CDATA[Drawing ink with the built-in stroke objects works great for handwriting and annotations. In some...]]></description>
      <content:encoded><![CDATA[<P>Drawing ink with the built-in stroke objects works great for handwriting and annotations. In some scenarios, however, you may want something more fancy that takes advantage of Silverlight's rich graphics capabilities.</P>
<P>Creating ink strokes with a customized appearance is fairly straight forward with Silverlight 2. You basically collect StylusPoints in mouse events as usual, but instead of adding them to stroke objects, you just draw your own geometries or shapes at the stylus/mouse location.</P>
<P>When collecting sample points during the MouseMove event, please be sure to call the <A class="" href="https://msdn.microsoft.com/en-us/library/cc626521(VS.95).aspx" mce_href="https://msdn.microsoft.com/en-us/library/cc626521(VS.95).aspx">StylusDevice.GetStylusPoints()</A> method and process all points returned from that call. This will ensure that stylus users will get the full fidelity of input points, since their pointing device reports points more often than the MouseMove events fires. Also it is good practice to interpolate points between sample points, since they won't usually be equidistant.</P>
<P>I have a attached a sample project that demonstrates the concept end-to-end using&nbsp;Ellipse shapes with a&nbsp;LinearGradientBrush to give my ink strokes a custom look. Below is live version of the sample for you to play with.</P><IFRAME style="WIDTH: 500px; HEIGHT: 400px" src="https://silverlight.services.live.com/invoke/34348/CustumInkRendering/iframe.html" frameBorder=0 scrolling=no mce_src="https://silverlight.services.live.com/invoke/34348/CustumInkRendering/iframe.html"></IFRAME>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/16/17/26/CustomInkRendering.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-16-17-26/CustomInkRendering.zip">CustomInkRendering.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Back-of-pen Erasing in Silverlight</title>
      <link>https://docs.microsoft.com/archive/blogs/swick/back-of-pen-erasing-in-silverlight</link>
      <pubDate>Mon, 01 Dec 2008 16:25:00 GMT</pubDate>
      <dc:creator><![CDATA[swick]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/swick/2008/12/01/back-of-pen-erasing-in-silverlight/</guid>
      <description><![CDATA[As addendum to my previous post Erasing Ink in Silverlight 2&nbsp;I want to show how to enable...]]></description>
      <content:encoded><![CDATA[<P>As addendum to my previous post <A class="" href="https://blogs.msdn.com/swick/archive/2008/11/30/erasing-ink-in-silverlight-2.aspx" mce_href="https://blogs.msdn.com/swick/archive/2008/11/30/erasing-ink-in-silverlight-2.aspx">Erasing Ink in Silverlight 2</A>&nbsp;I want to show how to enable back-of-pen erasing for users with a compatible stylus device (e.g. on a Tablet PC or with an external&nbsp;Graphics Tablet).</P>
<P>The key that enables this scenario&nbsp;is the&nbsp;<A class="" href="https://msdn.microsoft.com/en-us/library/system.windows.input.stylusdevice.inverted(VS.95).aspx" mce_href="https://msdn.microsoft.com/en-us/library/system.windows.input.stylusdevice.inverted(VS.95).aspx">StylusDevice.Inverted</A> property. It reports during mouse events whether&nbsp;the front-of-pen (stylus) or back-of-pen (eraser) is being used. The app can then switch into inking or erasing mode automatically, according to this value.</P>
<P>Here is the code-behind you need to add for an InkPresenter to enable this scenario:</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">public</SPAN><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> <SPAN style="COLOR: blue">partial</SPAN> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">Page</SPAN> : <SPAN style="COLOR: #2b91af">UserControl<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> Page()<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>InitializeComponent();<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">void</SPAN> inkPresenter_MouseLeftButtonDown(<SPAN style="COLOR: blue">object</SPAN> sender,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #2b91af">MouseButtonEventArgs</SPAN> e)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>inkPresenter.CaptureMouse();<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (e.StylusDevice.Inverted == <SPAN style="COLOR: blue">false</SPAN>)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">// ink mode<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>newStroke =</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">Stroke</SPAN>(e.StylusDevice.GetStylusPoints(inkPresenter));<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>inkPresenter.Strokes.Add(newStroke);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">else<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">// erase mode<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>erasePoints = e.StylusDevice.GetStylusPoints(inkPresenter);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">void</SPAN> inkPresenter_MouseMove(<SPAN style="COLOR: blue">object</SPAN> sender, <SPAN style="COLOR: #2b91af">MouseEventArgs</SPAN> e)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (e.StylusDevice.Inverted == <SPAN style="COLOR: blue">false</SPAN>)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">// ink mode<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (newStroke != <SPAN style="COLOR: blue">null</SPAN>)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>newStroke.StylusPoints.Add(</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.StylusDevice.GetStylusPoints(inkPresenter));<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">else</SPAN> <SPAN style="COLOR: blue">if</SPAN> (e.StylusDevice.Inverted == <SPAN style="COLOR: blue">true</SPAN>)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">// erase mode<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (erasePoints != <SPAN style="COLOR: blue">null</SPAN>)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>erasePoints.Add(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.StylusDevice.GetStylusPoints(inkPresenter));<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">StrokeCollection</SPAN> hitStrokes =<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inkPresenter.Strokes.HitTest(erasePoints);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">foreach</SPAN> (<SPAN style="COLOR: #2b91af">Stroke</SPAN> hitStroke <SPAN style="COLOR: blue">in</SPAN> hitStrokes)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN>inkPresenter.Strokes.Remove(hitStroke);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">void</SPAN> inkPresenter_MouseLeftButtonUp(<SPAN style="COLOR: blue">object</SPAN> sender,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #2b91af">MouseButtonEventArgs</SPAN> e)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>inkPresenter.ReleaseMouseCapture();<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>erasePoints = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>newStroke = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: #2b91af">StylusPointCollection</SPAN> erasePoints = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: #2b91af">Stroke</SPAN> newStroke = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">}</SPAN><SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%"><o:p></o:p></SPAN></P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
  </channel>
</rss>