<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://bloggingabout.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Ed Giardina's .NET Blog : C#</title><link>http://bloggingabout.net/blogs/egiardina/archive/tags/C_2300_/default.aspx</link><description>Tags: C#</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Adding Swipe functionality to WPF Applications</title><link>http://bloggingabout.net/blogs/egiardina/archive/2010/11/23/adding-swipe-functionality-to-wpf-applications.aspx</link><pubDate>Tue, 23 Nov 2010 19:52:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:484335</guid><dc:creator>Richthofen</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/egiardina/rsscomments.aspx?PostID=484335</wfw:commentRss><comments>http://bloggingabout.net/blogs/egiardina/archive/2010/11/23/adding-swipe-functionality-to-wpf-applications.aspx#comments</comments><description>&lt;p&gt;As part of a kiosk application written in WPF, the client wanted &amp;#39;Swipe&amp;#39;-like functionality similar to many touch-enabled smartphones. It&amp;#39;s actually not that hard in .NET 4 and WPF.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;First, add a property to your page/control that keeps track of the Touch that the user has initiated to start the swipe event:&lt;/p&gt;
&lt;p&gt;protected TouchPoint TouchStart;&lt;/p&gt;
&lt;p&gt;In the codebehind of the Page or Control you&amp;#39;re building, add the following handlers:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;public BasePage()&lt;/p&gt;
&lt;p&gt;&lt;span&gt;		&lt;/span&gt;{&lt;/p&gt;
&lt;p&gt;&lt;span&gt;			&lt;/span&gt;this.TouchDown += new EventHandler&amp;lt;TouchEventArgs&amp;gt;(BasePage_TouchDown);&lt;/p&gt;
&lt;p&gt;&lt;span&gt;			&lt;/span&gt;this.TouchMove += new EventHandler&amp;lt;TouchEventArgs&amp;gt;(BasePage_TouchMove); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;		&lt;/span&gt;}&lt;/p&gt;
&lt;p&gt;These handlers help detect when a user has pressed down and moved his/her finger over your page or control.&lt;/p&gt;
&lt;p&gt;Next, handle the initial Touch event that triggers the swipe:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;void BasePage_TouchDown(object sender, TouchEventArgs e)&lt;/p&gt;
&lt;p&gt;{&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TouchStart = e.GetTouchPoint(this);&amp;nbsp;}&lt;/p&gt;
&lt;p&gt;Finally, handle the movement aspect of the touch. If the movement exceeds some threshhold; then we consider it a swipe and execute whatever code we want to do (Navigation, animation, etc)&lt;/p&gt;
&lt;p&gt;Here, &amp;#39;AlreadySwiped&amp;#39; is just a flag property so we don&amp;#39;t execute the same task multiple times if the swipe exceeds our threshhold more than once. You are responsible for resetting it after you do your on-swiped code.&amp;nbsp;Also, I used 200 pixels as the swipe threshhold, but you may want a bigger/smaller value. You may also want to consider percentages of X here instead of actual pixels.&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;void BasePage_TouchMove(object sender, TouchEventArgs e)&lt;/p&gt;
&lt;p&gt;&lt;span&gt;		&lt;/span&gt;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (!AlreadySwiped)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var Touch = e.GetTouchPoint(this);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//right now a swipe is 200 pixels&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Swipe Left&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (TouchStart != null &amp;amp;&amp;amp; Touch.Position.X &amp;gt; (TouchStart.Position.X + 200))&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RunMyCustomCode();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AlreadySwiped = true;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Swipe Right&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (TouchStart != null &amp;amp;&amp;amp; Touch.Position.X &amp;lt; (TouchStart.Position.X - 200))&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;RunMyCustomCodeSwipeRight();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AlreadySwiped = true;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;e.Handled = true;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;		&lt;/span&gt;}&lt;/p&gt;
&lt;/p&gt;
&lt;p&gt;This should be straightforward but send me a message if you have any questions.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=484335" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/WPF/default.aspx">WPF</category><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/Touch/default.aspx">Touch</category><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/Swipe/default.aspx">Swipe</category></item><item><title>asp:menu control and SiteMap, 'Selected' Item must match exact url?</title><link>http://bloggingabout.net/blogs/egiardina/archive/2008/05/22/asp-menu-control-and-sitemap-selected-item-must-match-exact-url.aspx</link><pubDate>Thu, 22 May 2008 06:13:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:459238</guid><dc:creator>Richthofen</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/egiardina/rsscomments.aspx?PostID=459238</wfw:commentRss><comments>http://bloggingabout.net/blogs/egiardina/archive/2008/05/22/asp-menu-control-and-sitemap-selected-item-must-match-exact-url.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;So I am back into making .NET websites... and I love the web.sitemap feature of .NET 2.0+ However, I like my web folder structure to be semantic. This means that instead of clunky files with extensions, I like to have a directory for every portion of the site. Example:&lt;/p&gt;
&lt;p&gt;http://www.website.com/products/, http://www.website.com/aboutus/&lt;/p&gt;
&lt;p&gt;And then every folder has a Default.aspx ... but the problem with this is that the sitemap, when connected to an ASP.NET Menu control, is that the selected page is only recognized if the page name is included... so my sitemap has to be /products/Default.aspx , instead of just /products/... that&amp;#39;s a bummer, because then I lose my semantic &amp;#39;feel&amp;#39;. &lt;/p&gt;
&lt;p&gt;Anyone have any ideas on how to modify this? I&amp;#39;d prefer not to override the Menu control if I don&amp;#39;t have to.&lt;/p&gt;
&lt;p&gt;Update: So I dug a little deeper and found a solution. First, in your web.sitemap file, keep all the URLs to be exact, including the Default.aspx file. Then, in your menu control, add an onDataBound event handler as such:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:10pt;line-height:115%;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="font-size:9pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; SubMenu_DataBound(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="font-size:9pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="font-size:9pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;MenuItem&lt;/span&gt; Mi &lt;span style="color:blue;"&gt;in&lt;/span&gt; ((&lt;span style="color:#2b91af;"&gt;Menu&lt;/span&gt;)sender).Items)&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="font-size:9pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="font-size:9pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:green;"&gt;//Trim default.aspx from Menu Item URL; this is for SEO&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="font-size:9pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Mi.NavigateUrl = Mi.NavigateUrl.Replace(&lt;span style="color:#a31515;"&gt;&amp;quot;Default.aspx&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt;line-height:normal;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="font-size:9pt;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;span style="font-size:9pt;line-height:115%;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 10pt;" class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 10pt;" class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=459238" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/Menu+Control/default.aspx">Menu Control</category><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/CSS/default.aspx">CSS</category><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>XNA 2.0 and Drawable Game Components</title><link>http://bloggingabout.net/blogs/egiardina/archive/2008/01/07/xna-2-0-and-drawable-game-components.aspx</link><pubDate>Mon, 07 Jan 2008 18:28:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:454619</guid><dc:creator>Richthofen</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/egiardina/rsscomments.aspx?PostID=454619</wfw:commentRss><comments>http://bloggingabout.net/blogs/egiardina/archive/2008/01/07/xna-2-0-and-drawable-game-components.aspx#comments</comments><description>&lt;p&gt;So I recently updated my XNA project to 2.0 to take advantage of the cool networking libraries and such. However, now I&amp;#39;ve noticed that game components I add to the component list no longer automatically begin calling their draw methods once they&amp;#39;re added. Perhaps previously I was implementing DrawableGameComponents wrong, but I was under the assumption that once you add them to the components list, they automagically draw themselves. They did in 1.0, and now in 2.0 I have to manually call their .Draw method. Maybe the XNA community can help out with this?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;UPDATE: This article by a member of the XNA team may shed light on my problem. there&amp;#39;s a property of a DrawableGameComponent called &amp;#39;Visible&amp;#39;... it may have been set default true in 1.0 and 2.0 its no longer default enabled.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/etayrien/archive/2007/02/02/first-person-shooter-cameras.aspx"&gt;http://blogs.msdn.com/etayrien/archive/2007/02/02/first-person-shooter-cameras.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=454619" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/DrawableGameComponent/default.aspx">DrawableGameComponent</category><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/XNA+2.0/default.aspx">XNA 2.0</category><category domain="http://bloggingabout.net/blogs/egiardina/archive/tags/XNA/default.aspx">XNA</category></item></channel></rss>