<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0">
  <channel>
    <title>Jesper Niedermann's .NET Blog</title>
    <link>http://www.niedermann.dk/</link>
    <description>about .NET and related technologies</description>
    <language>en-us</language>
    <copyright>Jesper Niedermann</copyright>
    <lastBuildDate>Wed, 07 Sep 2011 07:09:15 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>jesper@niedermann.dk</managingEditor>
    <webMaster>jesper@niedermann.dk</webMaster>
    <item>
      <trackback:ping>http://www.niedermann.dk/Trackback.aspx?guid=a74f17f5-be55-4552-935d-84a0476ebd80</trackback:ping>
      <pingback:server>http://www.niedermann.dk/pingback.aspx</pingback:server>
      <pingback:target>http://www.niedermann.dk/PermaLink,guid,a74f17f5-be55-4552-935d-84a0476ebd80.aspx</pingback:target>
      <dc:creator>Jesper Niedermann</dc:creator>
      <wfw:comment>http://www.niedermann.dk/CommentView,guid,a74f17f5-be55-4552-935d-84a0476ebd80.aspx</wfw:comment>
      <wfw:commentRss>http://www.niedermann.dk/SyndicationService.asmx/GetEntryCommentsRss?guid=a74f17f5-be55-4552-935d-84a0476ebd80</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I finally got around to upgrading and releasing Solzip for VS2010.
</p>
        <p>
Solzip is a tool for zipping Visual Studio C# solutions from a right click menu in
the solution explorer. You can also Zip individual projects.
</p>
        <p>
You can install it from <a href="http://solzip.codeplex.com">http://solzip.codeplex.com</a> or
from the Extension Manager in Visual Studio.
</p>
        <p>
You can choose to install a command line version or the Visual Studio version either
one that requires <a href="http://mme.codeplex.com">MME</a> or a single file install
which includes MME. Furthermore there is a GAX version for the ambitious.
</p>
        <p>
The one you install from the Extension Manager is the single file install.
</p>
        <p>
BTW: In case you did not notice I upgraded <a href="http://mme.codeplex.com">MME</a> in
July to enable right click menus in the code window as well as in the solution explorer.
</p>
        <img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=a74f17f5-be55-4552-935d-84a0476ebd80" />
      </body>
      <title>Solzip 1.3 for VS2010 released</title>
      <guid isPermaLink="false">http://www.niedermann.dk/PermaLink,guid,a74f17f5-be55-4552-935d-84a0476ebd80.aspx</guid>
      <link>http://www.niedermann.dk/2011/09/07/Solzip13ForVS2010Released.aspx</link>
      <pubDate>Wed, 07 Sep 2011 07:09:15 GMT</pubDate>
      <description>&lt;p&gt;
I finally got around to upgrading and releasing Solzip for VS2010.
&lt;/p&gt;
&lt;p&gt;
Solzip is a tool for zipping Visual Studio C# solutions from a right click menu in
the solution explorer. You can also Zip individual projects.
&lt;/p&gt;
&lt;p&gt;
You can install it from &lt;a href="http://solzip.codeplex.com"&gt;http://solzip.codeplex.com&lt;/a&gt; or
from the Extension Manager in Visual Studio.
&lt;/p&gt;
&lt;p&gt;
You can choose to install a command line version or the Visual Studio version either
one that requires &lt;a href="http://mme.codeplex.com"&gt;MME&lt;/a&gt; or a single file install
which includes MME. Furthermore there is a GAX version for the ambitious.
&lt;/p&gt;
&lt;p&gt;
The one you install from the Extension Manager is the single file install.
&lt;/p&gt;
&lt;p&gt;
BTW: In case you did not notice I upgraded &lt;a href="http://mme.codeplex.com"&gt;MME&lt;/a&gt; in
July to enable right click menus in the code window as well as in the solution explorer.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=a74f17f5-be55-4552-935d-84a0476ebd80" /&gt;</description>
      <comments>http://www.niedermann.dk/CommentView,guid,a74f17f5-be55-4552-935d-84a0476ebd80.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.niedermann.dk/Trackback.aspx?guid=b1b55fb7-acf6-4dcc-a879-451c76fd0f18</trackback:ping>
      <pingback:server>http://www.niedermann.dk/pingback.aspx</pingback:server>
      <pingback:target>http://www.niedermann.dk/PermaLink,guid,b1b55fb7-acf6-4dcc-a879-451c76fd0f18.aspx</pingback:target>
      <dc:creator>Jesper Niedermann</dc:creator>
      <wfw:comment>http://www.niedermann.dk/CommentView,guid,b1b55fb7-acf6-4dcc-a879-451c76fd0f18.aspx</wfw:comment>
      <wfw:commentRss>http://www.niedermann.dk/SyndicationService.asmx/GetEntryCommentsRss?guid=b1b55fb7-acf6-4dcc-a879-451c76fd0f18</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When making the WP7 game <a href="http://windowsphone.com/s?appid=ab75a012-53a3-e011-986b-78e7d1fa76f8">Photo
Challenge</a> we quickly agreed that we needed leaderboards. The problem is that is
time consuming to build a scalable high quality leaderboard service tailor made for
our game and secondly we would have to pay for server storage for a game that statistically
won’t make a dime anyway. This meant that we searched for a ready to use leaderboard
service. It wasn’t easy to find. But then a miracle happened. We found the amazing <a href="http://www.mogade.com/">Mogade.com</a>.
</p>
        <p>
          <a href="http://www.mogade.com/">Mogade.com</a> is an incredible fit for our game. 
</p>
        <p>
Features:
</p>
        <ul>
          <li>
Most importantly there is great support from the developer Karl Seguin when you run
into trouble (which we did – actually one of our problems led him to find and fix
a bug in the service).</li>
          <li>
It has an easy to use API. The basic API is Rest based with data transferred in JSon
format. This means that is possible to access the leaderboards from any application.
I am currently working on an ASP.NET MVC / JQuery based web page to access our leaderboards
on the web.</li>
          <li>
On top of the REST API there is a WP7 API which you can reference from your game and
it looks like an Android API is currently under development.</li>
          <li>
When you register an account you gain access to adding any number of games, to each
of these games you can add a number of leaderboards.</li>
          <li>
Furthermore mogade.com supports achievements and even has some Facebook integration
which I haven’t looked into yet.</li>
          <li>
There is also statistics. A cheap way to see the popularity of your game. On the AppHubs
you can see number of downloads, but on Mogade.com you can actually see how many are
playing your game.</li>
          <li>
For accessing a leaderboard from your game you use a gamekey a  leaderboardkey
and a secret. Each of these are Guid like Id’s. You can fetch pages of 50 scores at
a time, and you can get the Rank of a specific user.</li>
          <li>
The leaderboards can be defined as High-to-low or low-to-high. Meaning if it is preferable
to have a low or a high score.</li>
          <li>
Each score is associated with a username, a rank and the date&amp;time at which the
score was added.</li>
          <li>
In the WP7 API there are a number of ways to define a user in mogade.com terms e.g.
one uses your liveid and another the deviceid combined with a username. The last one
is the one we use. This means that 2 users with the same username but different phones
will be two distinct users on the leaderboard.</li>
        </ul>
        <p>
To get started you should download the code from Github <a href="https://github.com/mogade/mogade-windowsphone">https://github.com/mogade/mogade-windowsphone</a> and
look at the samples there. Furthermore I found this nice blogpost to help me get going <a href="http://briansolli.wordpress.com/2011/03/30/online-leaderboard-for-your-wp7-game">http://briansolli.wordpress.com/2011/03/30/online-leaderboard-for-your-wp7-game</a></p>
        <p>
In <a href="http://www.niedermann.dk/2011/07/26/PhotoChallengeReleased.aspx">http://www.niedermann.dk/2011/07/26/PhotoChallengeReleased.aspx</a> you
can see a screenshot of the graphical look of the leaderboard we came up with in Photo
Challenge.
</p>
        <img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=b1b55fb7-acf6-4dcc-a879-451c76fd0f18" />
      </body>
      <title>Mogade.com an amazing free Leaderboard Service</title>
      <guid isPermaLink="false">http://www.niedermann.dk/PermaLink,guid,b1b55fb7-acf6-4dcc-a879-451c76fd0f18.aspx</guid>
      <link>http://www.niedermann.dk/2011/07/28/MogadecomAnAmazingFreeLeaderboardService.aspx</link>
      <pubDate>Thu, 28 Jul 2011 22:35:35 GMT</pubDate>
      <description>&lt;p&gt;
When making the WP7 game &lt;a href="http://windowsphone.com/s?appid=ab75a012-53a3-e011-986b-78e7d1fa76f8"&gt;Photo
Challenge&lt;/a&gt; we quickly agreed that we needed leaderboards. The problem is that is
time consuming to build a scalable high quality leaderboard service tailor made for
our game and secondly we would have to pay for server storage for a game that statistically
won’t make a dime anyway. This meant that we searched for a ready to use leaderboard
service. It wasn’t easy to find. But then a miracle happened. We found the amazing &lt;a href="http://www.mogade.com/"&gt;Mogade.com&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.mogade.com/"&gt;Mogade.com&lt;/a&gt; is an incredible fit for our game. 
&lt;/p&gt;
&lt;p&gt;
Features:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Most importantly there is great support from the developer Karl Seguin when you run
into trouble (which we did – actually one of our problems led him to find and fix
a bug in the service).&lt;/li&gt;
&lt;li&gt;
It has an easy to use API. The basic API is Rest based with data transferred in JSon
format. This means that is possible to access the leaderboards from any application.
I am currently working on an ASP.NET MVC / JQuery based web page to access our leaderboards
on the web.&lt;/li&gt;
&lt;li&gt;
On top of the REST API there is a WP7 API which you can reference from your game and
it looks like an Android API is currently under development.&lt;/li&gt;
&lt;li&gt;
When you register an account you gain access to adding any number of games, to each
of these games you can add a number of leaderboards.&lt;/li&gt;
&lt;li&gt;
Furthermore mogade.com supports achievements and even has some Facebook integration
which I haven’t looked into yet.&lt;/li&gt;
&lt;li&gt;
There is also statistics. A cheap way to see the popularity of your game. On the AppHubs
you can see number of downloads, but on Mogade.com you can actually see how many are
playing your game.&lt;/li&gt;
&lt;li&gt;
For accessing a leaderboard from your game you use a gamekey a&amp;nbsp; leaderboardkey
and a secret. Each of these are Guid like Id’s. You can fetch pages of 50 scores at
a time, and you can get the Rank of a specific user.&lt;/li&gt;
&lt;li&gt;
The leaderboards can be defined as High-to-low or low-to-high. Meaning if it is preferable
to have a low or a high score.&lt;/li&gt;
&lt;li&gt;
Each score is associated with a username, a rank and the date&amp;amp;time at which the
score was added.&lt;/li&gt;
&lt;li&gt;
In the WP7 API there are a number of ways to define a user in mogade.com terms e.g.
one uses your liveid and another the deviceid combined with a username. The last one
is the one we use. This means that 2 users with the same username but different phones
will be two distinct users on the leaderboard.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
To get started you should download the code from Github &lt;a href="https://github.com/mogade/mogade-windowsphone"&gt;https://github.com/mogade/mogade-windowsphone&lt;/a&gt; and
look at the samples there. Furthermore I found this nice blogpost to help me get going &lt;a href="http://briansolli.wordpress.com/2011/03/30/online-leaderboard-for-your-wp7-game"&gt;http://briansolli.wordpress.com/2011/03/30/online-leaderboard-for-your-wp7-game&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
In &lt;a href="http://www.niedermann.dk/2011/07/26/PhotoChallengeReleased.aspx"&gt;http://www.niedermann.dk/2011/07/26/PhotoChallengeReleased.aspx&lt;/a&gt; you
can see a screenshot of the graphical look of the leaderboard we came up with in Photo
Challenge.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=b1b55fb7-acf6-4dcc-a879-451c76fd0f18" /&gt;</description>
      <comments>http://www.niedermann.dk/CommentView,guid,b1b55fb7-acf6-4dcc-a879-451c76fd0f18.aspx</comments>
      <category>Games &amp; Puzzles</category>
      <category>Windows Phone 7</category>
    </item>
    <item>
      <trackback:ping>http://www.niedermann.dk/Trackback.aspx?guid=a2344822-70c0-47fe-a621-9476f3acb46e</trackback:ping>
      <pingback:server>http://www.niedermann.dk/pingback.aspx</pingback:server>
      <pingback:target>http://www.niedermann.dk/PermaLink,guid,a2344822-70c0-47fe-a621-9476f3acb46e.aspx</pingback:target>
      <dc:creator>Jesper Niedermann</dc:creator>
      <wfw:comment>http://www.niedermann.dk/CommentView,guid,a2344822-70c0-47fe-a621-9476f3acb46e.aspx</wfw:comment>
      <wfw:commentRss>http://www.niedermann.dk/SyndicationService.asmx/GetEntryCommentsRss?guid=a2344822-70c0-47fe-a621-9476f3acb46e</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I and a team of 1 graphic artist and 1 sound engineer just finished our first game
for Windows Phone 7 called “<a href="http://windowsphone.com/s?appid=ab75a012-53a3-e011-986b-78e7d1fa76f8">Photo
Challenge</a>” a few weeks ago. We planned this pretty simple game to get experience
before going for the big hit. The concept has been seen before. A Puzzle Slider where
you have to solve a square puzzle with 2x2, 3x3, 4x4, 5x5 or 6x6 squares with one
square missing. The Puzzle can be made from you own photos or from some build in ones.
Here is a few screenshots:
</p>
        <p>
          <a href="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_1_2.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="screenshot_1" border="0" alt="screenshot_1" src="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_1_thumb.png" width="148" height="244" />
          </a>
          <a href="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_2_2.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="screenshot_2" border="0" alt="screenshot_2" src="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_2_thumb.png" width="148" height="244" />
          </a>
          <a href="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_4_2.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="screenshot_4" border="0" alt="screenshot_4" src="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_4_thumb.png" width="148" height="244" />
          </a>
          <a href="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_7_2.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="screenshot_7" border="0" alt="screenshot_7" src="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_7_thumb.png" width="148" height="244" />
          </a>
        </p>
        <p>
The point of the game is to solve the puzzle as fast as possible to make it to the
leaderboards. We used the great service Mogade.com for the leaderboards. I plan to
cover that aspect in another post.
</p>
        <p>
We are very satisfied with the style and feel of the final game. Even for such a simple
game details are important. Similar competing games seems to have been made in Silverlight
and thus are more limited with regards to graphics and sound than our XNA game.
</p>
        <p>
Some of the learnings from making the game are:
</p>
        <ul>
          <li>
XNA is a fantastic framework and my own framework for XNA developed over time for
PC and XBox could be used directly with very few changes.</li>
          <li>
WP7 has a fantastic developer platform. IMO better than the iPhones. 
</li>
          <li>
The WP7 API’s still lacks a lot of functionality that is present in the iPhone API’s
but slowly catching up.</li>
          <li>
If you use some of the build in “Tasks” like the PhotoChooserTask or the MarketplaceReviewTask
you cannot play sounds on the device if it is connected via USB to the computer. Sounds
like a small thing but it means you cannot debug on the device ! Really horrible.
My solution was to not play music and sound effects in the DEBUG edition.</li>
          <li>
On the other hand you can debug on the emulator. On the iPhone it is extremly important
to debug directly on the iPhone because the iPhone simulator cannot be trusted. I
have often experienced that code working in the iPhone simulator was not working on
the device. This never happened once for the WP7 emulator and my Samsung Omnia 7.
Still it is important to be able to debug on the device since there are things not
available in the emulator.</li>
          <li>
As mentioned the API is somewhat lacking. E.g it is impossible to send images in emails
via the EmailComposeTask. It is not possible to integrate facebook in an XNA app and
so forth. The last one is supposed to be fixed in the Mango update since it has opened
up for mixing Silverlight and XNA. I have not tried it yet. But hope it will be possible.
Facebook integration in games is almost a must these days.</li>
          <li>
Despite being extremely happy with the developing experience for WP7 the iPhone is
still an overall better smartphone experience in my opinion (seen from a user perspective).
I hope and think WP7 will catch up in time. Competition is good.</li>
        </ul>
        <img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=a2344822-70c0-47fe-a621-9476f3acb46e" />
      </body>
      <title>Photo Challenge released</title>
      <guid isPermaLink="false">http://www.niedermann.dk/PermaLink,guid,a2344822-70c0-47fe-a621-9476f3acb46e.aspx</guid>
      <link>http://www.niedermann.dk/2011/07/26/PhotoChallengeReleased.aspx</link>
      <pubDate>Tue, 26 Jul 2011 22:47:58 GMT</pubDate>
      <description>&lt;p&gt;
I and a team of 1 graphic artist and 1 sound engineer just finished our first game
for Windows Phone 7 called “&lt;a href="http://windowsphone.com/s?appid=ab75a012-53a3-e011-986b-78e7d1fa76f8"&gt;Photo
Challenge&lt;/a&gt;” a few weeks ago. We planned this pretty simple game to get experience
before going for the big hit. The concept has been seen before. A Puzzle Slider where
you have to solve a square puzzle with 2x2, 3x3, 4x4, 5x5 or 6x6 squares with one
square missing. The Puzzle can be made from you own photos or from some build in ones.
Here is a few screenshots:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_1_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="screenshot_1" border="0" alt="screenshot_1" src="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_1_thumb.png" width="148" height="244"&gt;&lt;/a&gt;&lt;a href="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_2_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="screenshot_2" border="0" alt="screenshot_2" src="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_2_thumb.png" width="148" height="244"&gt;&lt;/a&gt;&lt;a href="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_4_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="screenshot_4" border="0" alt="screenshot_4" src="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_4_thumb.png" width="148" height="244"&gt;&lt;/a&gt;&lt;a href="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_7_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="screenshot_7" border="0" alt="screenshot_7" src="http://www.niedermann.dk/content/binary/Windows-Live-Writer/Photo-Challenge-released_147DB/screenshot_7_thumb.png" width="148" height="244"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The point of the game is to solve the puzzle as fast as possible to make it to the
leaderboards. We used the great service Mogade.com for the leaderboards. I plan to
cover that aspect in another post.
&lt;/p&gt;
&lt;p&gt;
We are very satisfied with the style and feel of the final game. Even for such a simple
game details are important. Similar competing games seems to have been made in Silverlight
and thus are more limited with regards to graphics and sound than our XNA game.
&lt;/p&gt;
&lt;p&gt;
Some of the learnings from making the game are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
XNA is a fantastic framework and my own framework for XNA developed over time for
PC and XBox could be used directly with very few changes.&lt;/li&gt;
&lt;li&gt;
WP7 has a fantastic developer platform. IMO better than the iPhones. 
&lt;/li&gt;
&lt;li&gt;
The WP7 API’s still lacks a lot of functionality that is present in the iPhone API’s
but slowly catching up.&lt;/li&gt;
&lt;li&gt;
If you use some of the build in “Tasks” like the PhotoChooserTask or the MarketplaceReviewTask
you cannot play sounds on the device if it is connected via USB to the computer. Sounds
like a small thing but it means you cannot debug on the device ! Really horrible.
My solution was to not play music and sound effects in the DEBUG edition.&lt;/li&gt;
&lt;li&gt;
On the other hand you can debug on the emulator. On the iPhone it is extremly important
to debug directly on the iPhone because the iPhone simulator cannot be trusted. I
have often experienced that code working in the iPhone simulator was not working on
the device. This never happened once for the WP7 emulator and my Samsung Omnia 7.
Still it is important to be able to debug on the device since there are things not
available in the emulator.&lt;/li&gt;
&lt;li&gt;
As mentioned the API is somewhat lacking. E.g it is impossible to send images in emails
via the EmailComposeTask. It is not possible to integrate facebook in an XNA app and
so forth. The last one is supposed to be fixed in the Mango update since it has opened
up for mixing Silverlight and XNA. I have not tried it yet. But hope it will be possible.
Facebook integration in games is almost a must these days.&lt;/li&gt;
&lt;li&gt;
Despite being extremely happy with the developing experience for WP7 the iPhone is
still an overall better smartphone experience in my opinion (seen from a user perspective).
I hope and think WP7 will catch up in time. Competition is good.&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=a2344822-70c0-47fe-a621-9476f3acb46e" /&gt;</description>
      <comments>http://www.niedermann.dk/CommentView,guid,a2344822-70c0-47fe-a621-9476f3acb46e.aspx</comments>
      <category>Games &amp; Puzzles</category>
      <category>Windows Phone 7</category>
      <category>XNA</category>
    </item>
    <item>
      <trackback:ping>http://www.niedermann.dk/Trackback.aspx?guid=e13397fd-27f8-47ed-8ecb-a40c599a7656</trackback:ping>
      <pingback:server>http://www.niedermann.dk/pingback.aspx</pingback:server>
      <pingback:target>http://www.niedermann.dk/PermaLink,guid,e13397fd-27f8-47ed-8ecb-a40c599a7656.aspx</pingback:target>
      <dc:creator>Jesper Niedermann</dc:creator>
      <wfw:comment>http://www.niedermann.dk/CommentView,guid,e13397fd-27f8-47ed-8ecb-a40c599a7656.aspx</wfw:comment>
      <wfw:commentRss>http://www.niedermann.dk/SyndicationService.asmx/GetEntryCommentsRss?guid=e13397fd-27f8-47ed-8ecb-a40c599a7656</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When we were to publish a free version of our new Windows Phone Game <a href="http://windowsphone.com/s?appid=ab75a012-53a3-e011-986b-78e7d1fa76f8">Photo
Challenge</a> I wanted to maintain both the free and paid version in the same Repository.
I wanted the solution file and project file for the new free app to use the same source
files as the paid app. This gave some headaches because there needs to be a physical
WMAppManifest.xml file for each App. I googled various approaches but I finally made
up an entirely different approach which I thought fitted our project best. Here is
the steps I took:
</p>
        <ul>
          <li>
Copied the solution file PhotoChallenge.sln to PhotoChallengeFree.sln – placed in
the same folder 
</li>
          <li>
Copied the project file PhotoChallenge.csproj to PhotoChallengeFree.csproj – placed
in the same folder 
</li>
          <li>
Changed PhotoChallengeFree.sln via notepad to refer to PhotoChallengeFree.csproj 
</li>
          <li>
Copied AssemblyInfo.cs to two new folders. One for the paid app and one for the free
app. 
</li>
          <li>
Deleted AssemblyInfo.cs from both PhotoChallenge.csproj and PhotoChallengeFree.csproj 
</li>
          <li>
From PhotoChallenge.csproj I linked to the new Paid version of AssemblyInfo.cs – using
Add –&gt; Existing File, but choosing Add As Link instead of Add. 
</li>
          <li>
The same in PhotoChallengeFree.csproj. But this time linking to the Free version of
AssemblyInfo.cs 
</li>
          <li>
Changed the following properties in the free version of AssemblyInfo.cs: <font size="2" face="Consolas"><font size="2" face="Consolas">AssemblyTitle,
AssemblyProduct and Guid.</font></font></li>
        </ul>
        <p>
          <font size="2" face="Consolas">
            <font size="2" face="Consolas">
              <font size="1" face="Verdana">I
actually wanted to manipulate WMAppManifest.xml in the same way as I did AssemblyInfo.cs.
But this turned out to be impossible. The WMAppManifest.xml file has to be physical
– not a link. Instead I did this:</font>
            </font>
          </font>
        </p>
        <ul>
          <li>
            <font size="1">Made a project folder in PhotoChallenge.csproj called PropertiesPaid</font>
          </li>
          <li>
            <font size="1">Made a project folder in PhotoChallengeFree.csproj called PropertiesFree</font>
          </li>
          <li>
            <font size="1">Copied WMAppManifest.xml to the new folders and added the relevant
one to each project.</font>
          </li>
          <li>
            <font size="1">Deleted WMAppManifest.xml from the properties folder. </font>
          </li>
          <li>
            <font size="1">Opened the project files in Notepad (actually I chose “Unload Project”
in Visual Studio and then “Edit PhotoChallenge.csproj”). And changed this:</font>
          </li>
        </ul>
        <pre class="xml" name="code">&lt;XnaWindowsPhoneManifestTemplate&gt;Properties\WMAppManifest.xml&lt;/XnaWindowsPhoneManifestTemplate&gt;</pre>
        <p>
          <font size="1">To this:</font>
        </p>
        <pre class="xml" name="code">&lt;XnaWindowsPhoneManifestTemplate&gt;PropertiesPaid\WMAppManifest.xml&lt;/XnaWindowsPhoneManifestTemplate&gt;</pre>
        <font size="2" face="Consolas">
          <font size="2" face="Consolas">
            <p>
              <font size="1" face="Verdana">Then I reloaded the project in Visual Studio, and did
the same for the free project. But now refering to the PropertiesFree folder.</font>
            </p>
            <p>
              <font size="1" face="Verdana">In the free version of WMAppManifest.xml I changed the
Title and TokenId to match the AssemblyTitle and AssemblyProduct of AssemblyInfo.cs.
Furthermore I changed the ProductId to match the Guid of the AssemblyInfo.cs.</font>
            </p>
            <p>
              <font size="1" face="Verdana">The actual differences between the free and paid version
in the source file I maintain using a new compilation symbol I made called “FREE”
so I can make statements like this:</font>
            </p>
            <pre class="c#" name="code">#if FREE<br />
//Some code<br />
#endif</pre>
            <p>
              <font size="1" face="Verdana">Altogether my approach seems to work extremely well
to minimize maintainance of the two versions of the same app.</font>
            </p>
            <p>
              <font size="1" face="Verdana">One small problem: For some reason which I have not
bothered to find out I cannot use the Compilation symbol Free in the PhotoChallenge.csproj
project itself, but I have some other referenced projects where it is no problem.
So I just have a class in the referenced project which I can use where ever I have
to check if the current version is paid or free:</font>
            </p>
            <pre class="c#" name="code">public static class Edition<br />
{ 
<br />
public static bool IsFree<br />
{ 
<br />
get<br />
{ 
<br />
#if FREE 
<br />
return true; 
<br />
#else 
<br />
return false;<br />
#endif 
<br />
} 
<br />
}<br />
}</pre>
          </font>
        </font>
        <img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=e13397fd-27f8-47ed-8ecb-a40c599a7656" />
      </body>
      <title>How to maintain more than one WMAppManifest.xml files for different versions of your Windows Phone App</title>
      <guid isPermaLink="false">http://www.niedermann.dk/PermaLink,guid,e13397fd-27f8-47ed-8ecb-a40c599a7656.aspx</guid>
      <link>http://www.niedermann.dk/2011/07/24/HowToMaintainMoreThanOneWMAppManifestxmlFilesForDifferentVersionsOfYourWindowsPhoneApp.aspx</link>
      <pubDate>Sun, 24 Jul 2011 18:46:58 GMT</pubDate>
      <description>&lt;p&gt;
When we were to publish a free version of our new Windows Phone Game &lt;a href="http://windowsphone.com/s?appid=ab75a012-53a3-e011-986b-78e7d1fa76f8"&gt;Photo
Challenge&lt;/a&gt; I wanted to maintain both the free and paid version in the same Repository.
I wanted the solution file and project file for the new free app to use the same source
files as the paid app. This gave some headaches because there needs to be a physical
WMAppManifest.xml file for each App. I googled various approaches but I finally made
up an entirely different approach which I thought fitted our project best. Here is
the steps I took:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Copied the solution file PhotoChallenge.sln to PhotoChallengeFree.sln – placed in
the same folder 
&lt;li&gt;
Copied the project file PhotoChallenge.csproj to PhotoChallengeFree.csproj – placed
in the same folder 
&lt;li&gt;
Changed PhotoChallengeFree.sln via notepad to refer to PhotoChallengeFree.csproj 
&lt;li&gt;
Copied AssemblyInfo.cs to two new folders. One for the paid app and one for the free
app. 
&lt;li&gt;
Deleted AssemblyInfo.cs from both PhotoChallenge.csproj and PhotoChallengeFree.csproj 
&lt;li&gt;
From PhotoChallenge.csproj I linked to the new Paid version of AssemblyInfo.cs – using
Add –&amp;gt; Existing File, but choosing Add As Link instead of Add. 
&lt;li&gt;
The same in PhotoChallengeFree.csproj. But this time linking to the Free version of
AssemblyInfo.cs 
&lt;li&gt;
Changed the following properties in the free version of AssemblyInfo.cs: &lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt;AssemblyTitle,
AssemblyProduct and Guid.&lt;/font&gt;&lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt;&lt;font size="1" face="Verdana"&gt;I
actually wanted to manipulate WMAppManifest.xml in the same way as I did AssemblyInfo.cs.
But this turned out to be impossible. The WMAppManifest.xml file has to be physical
– not a link. Instead I did this:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;font size="1"&gt;Made a project folder in PhotoChallenge.csproj called PropertiesPaid&lt;/font&gt; 
&lt;li&gt;
&lt;font size="1"&gt;Made a project folder in PhotoChallengeFree.csproj called PropertiesFree&lt;/font&gt; 
&lt;li&gt;
&lt;font size="1"&gt;Copied WMAppManifest.xml to the new folders and added the relevant
one to each project.&lt;/font&gt; 
&lt;li&gt;
&lt;font size="1"&gt;Deleted WMAppManifest.xml from the properties folder. &lt;/font&gt; 
&lt;li&gt;
&lt;font size="1"&gt;Opened the project files in Notepad (actually I chose “Unload Project”
in Visual Studio and then “Edit PhotoChallenge.csproj”). And changed this:&lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="xml" name="code"&gt;&amp;lt;XnaWindowsPhoneManifestTemplate&amp;gt;Properties\WMAppManifest.xml&amp;lt;/XnaWindowsPhoneManifestTemplate&amp;gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font size="1"&gt;To this:&lt;/font&gt;
&lt;/p&gt;
&lt;pre class="xml" name="code"&gt;&amp;lt;XnaWindowsPhoneManifestTemplate&amp;gt;PropertiesPaid\WMAppManifest.xml&amp;lt;/XnaWindowsPhoneManifestTemplate&amp;gt;&lt;/pre&gt;&lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt; 
&lt;p&gt;
&lt;font size="1" face="Verdana"&gt;Then I reloaded the project in Visual Studio, and did
the same for the free project. But now refering to the PropertiesFree folder.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size="1" face="Verdana"&gt;In the free version of WMAppManifest.xml I changed the
Title and TokenId to match the AssemblyTitle and AssemblyProduct of AssemblyInfo.cs.
Furthermore I changed the ProductId to match the Guid of the AssemblyInfo.cs.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size="1" face="Verdana"&gt;The actual differences between the free and paid version
in the source file I maintain using a new compilation symbol I made called “FREE”
so I can make statements like this:&lt;/font&gt;
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;#if FREE&lt;br&gt;
//Some code&lt;br&gt;
#endif&lt;/pre&gt;
&lt;p&gt;
&lt;font size="1" face="Verdana"&gt;Altogether my approach seems to work extremely well
to minimize maintainance of the two versions of the same app.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size="1" face="Verdana"&gt;One small problem: For some reason which I have not
bothered to find out I cannot use the Compilation symbol Free in the PhotoChallenge.csproj
project itself, but I have some other referenced projects where it is no problem.
So I just have a class in the referenced project which I can use where ever I have
to check if the current version is paid or free:&lt;/font&gt;
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;public static class Edition&lt;br&gt;
{ 
&lt;br&gt;
public static bool IsFree&lt;br&gt;
{ 
&lt;br&gt;
get&lt;br&gt;
{ 
&lt;br&gt;
#if FREE 
&lt;br&gt;
return true; 
&lt;br&gt;
#else 
&lt;br&gt;
return false;&lt;br&gt;
#endif 
&lt;br&gt;
} 
&lt;br&gt;
}&lt;br&gt;
}&lt;/pre&gt;&lt;/font&gt;&lt;/font&gt;&lt;img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=e13397fd-27f8-47ed-8ecb-a40c599a7656" /&gt;</description>
      <comments>http://www.niedermann.dk/CommentView,guid,e13397fd-27f8-47ed-8ecb-a40c599a7656.aspx</comments>
      <category>Visual Studio</category>
      <category>Windows Phone 7</category>
    </item>
    <item>
      <trackback:ping>http://www.niedermann.dk/Trackback.aspx?guid=c47712fd-4535-4f7e-8f4e-a8c88a28cf14</trackback:ping>
      <pingback:server>http://www.niedermann.dk/pingback.aspx</pingback:server>
      <pingback:target>http://www.niedermann.dk/PermaLink,guid,c47712fd-4535-4f7e-8f4e-a8c88a28cf14.aspx</pingback:target>
      <dc:creator>Jesper Niedermann</dc:creator>
      <wfw:comment>http://www.niedermann.dk/CommentView,guid,c47712fd-4535-4f7e-8f4e-a8c88a28cf14.aspx</wfw:comment>
      <wfw:commentRss>http://www.niedermann.dk/SyndicationService.asmx/GetEntryCommentsRss?guid=c47712fd-4535-4f7e-8f4e-a8c88a28cf14</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I like the new look and feel of IE9 but it is not without startup problems though.
If you want to use Google as your favorite search provider what do you do ? Well lots
of places on the web tells you to go to “Internet options” –&gt; Change Search Defaults
(Settings) and then press the lower left link “Find more search providers…”. 
</p>
        <p>
I did this but was perplexed. Google was not listed ! 
</p>
        <p>
After going back and forth a few times I noticed something in the address bar. 
</p>
        <p>
          <a title="http://www.iegallery.com/da/addons/?feature=searchproviders" href="http://www.iegallery.com/da/addons/?feature=searchproviders">http://www.iegallery.com/da/addons/?feature=searchproviders</a>
        </p>
        <p>
Notice the “da” in the link. Apparently the link is dependent on your country of origin.
</p>
        <p>
So I changed it to
</p>
        <p>
          <a href="http://www.iegallery.com/us/addons/?feature=searchproviders">http://www.iegallery.com/us/addons/?feature=searchproviders</a>
        </p>
        <p>
And sure enough. I could now choose Google as my default search provider.
</p>
        <p>
Hope this helps someone :)
</p>
        <img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=c47712fd-4535-4f7e-8f4e-a8c88a28cf14" />
      </body>
      <title>Cannot set google as default Search provider IE9</title>
      <guid isPermaLink="false">http://www.niedermann.dk/PermaLink,guid,c47712fd-4535-4f7e-8f4e-a8c88a28cf14.aspx</guid>
      <link>http://www.niedermann.dk/2011/04/18/CannotSetGoogleAsDefaultSearchProviderIE9.aspx</link>
      <pubDate>Mon, 18 Apr 2011 08:02:31 GMT</pubDate>
      <description>&lt;p&gt;
I like the new look and feel of IE9 but it is not without startup problems though.
If you want to use Google as your favorite search provider what do you do ? Well lots
of places on the web tells you to go to “Internet options” –&amp;gt; Change Search Defaults
(Settings) and then press the lower left link “Find more search providers…”. 
&lt;/p&gt;
&lt;p&gt;
I did this but was perplexed. Google was not listed ! 
&lt;/p&gt;
&lt;p&gt;
After going back and forth a few times I noticed something in the address bar. 
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://www.iegallery.com/da/addons/?feature=searchproviders" href="http://www.iegallery.com/da/addons/?feature=searchproviders"&gt;http://www.iegallery.com/da/addons/?feature=searchproviders&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Notice the “da” in the link. Apparently the link is dependent on your country of origin.
&lt;/p&gt;
&lt;p&gt;
So I changed it to
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.iegallery.com/us/addons/?feature=searchproviders"&gt;http://www.iegallery.com/us/addons/?feature=searchproviders&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
And sure enough. I could now choose Google as my default search provider.
&lt;/p&gt;
&lt;p&gt;
Hope this helps someone :)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=c47712fd-4535-4f7e-8f4e-a8c88a28cf14" /&gt;</description>
      <comments>http://www.niedermann.dk/CommentView,guid,c47712fd-4535-4f7e-8f4e-a8c88a28cf14.aspx</comments>
      <category>IE9</category>
    </item>
    <item>
      <trackback:ping>http://www.niedermann.dk/Trackback.aspx?guid=85830aad-38de-4edb-9c1c-da24a00a7fb9</trackback:ping>
      <pingback:server>http://www.niedermann.dk/pingback.aspx</pingback:server>
      <pingback:target>http://www.niedermann.dk/PermaLink,guid,85830aad-38de-4edb-9c1c-da24a00a7fb9.aspx</pingback:target>
      <dc:creator>Jesper Niedermann</dc:creator>
      <wfw:comment>http://www.niedermann.dk/CommentView,guid,85830aad-38de-4edb-9c1c-da24a00a7fb9.aspx</wfw:comment>
      <wfw:commentRss>http://www.niedermann.dk/SyndicationService.asmx/GetEntryCommentsRss?guid=85830aad-38de-4edb-9c1c-da24a00a7fb9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The new Guidance Automation Framework GAX 2010 and GAT 2010 which is installed through
the Extension Manager in Visual Studio 2010, provides a nicer usability experience
compared to the Visual Studio 2008 predecessor. It is installed using the new vsix
installer. A vsix install is much nicer than the old msi install since it integrates
into Visual Studio. You can uninstall using the Extension Manager and if a new version
comes out it should appear on the Updates tab of the extension manager.
</p>
        <p>
Another nice thing is that a generated factory template solution now only consists
of one project which itself results in a vsix file. So the installer of your own generated
factories will also be vsix files. Nice…
</p>
        <p>
But nicest of all is the fact that it is automatically integrated with the Visual
Studio 2010 Experimental Instance (formerly known as Experimental Hive). Before you
had to manually edit your recipes to get them to register in the Experimental Hive.
But know you just press Ctrl+F5 and the Experimental Instance is automatically launched
with your factory installed. It is now almost easy to debug your recipes. :)
</p>
        <p>
But apparently there are few weird bugs in GAX/GAT 2010. One I run into all the time
is this error:
</p>
        <p>
Unable to read the project file 'Something.csproj'. 
</p>
        <p>
C:\Something\Something\Something.csproj(354,3): The imported project "C:\Microsoft.Practices.RecipeFramework.Build.targets"
was not found. Confirm that the path in the &lt;Import&gt; declaration is correct,
and that the file exists on disk.
</p>
        <p>
Which happens when I try to open a Guidance Automation solution. 
</p>
        <p>
For some reason the declaration of the variable RecipeFramework in the project file
is not provided. This I deal with by editing the Project file by hand and adding a
declaration to the end of the first PropertyGroup like this: 
</p>
        <p>
  
</p>
        <pre class="xml" name="code">  &lt;RecipeFrameworkPath&gt;$(DevEnvDir)Extensions\Microsoft patterns and practices\GAX 2010\2.0.20406.0&lt;/RecipeFrameworkPath&gt;</pre>
        <p>
After applying this fix I can open the solution.
</p>
        <p>
I have read somewhere that it is important to adhere to the following install order:
</p>
        <ol>
        </ol>
        <ol>
          <li>
Visual Studio 2010 Ultimate or Professional (obviously) 
</li>
          <li>
The Visual Studio 2010 SDK 
</li>
          <li>
GAX 2010 
</li>
          <li>
GAT 2010</li>
        </ol>
        <p>
And this might be what I have screwed up on the particular machine where I get the
error. 
</p>
        <p>
Anyway the above mentioned fix works. And overall I am very satisfied with the new
improvements in GAX/GAT.
</p>
        <img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=85830aad-38de-4edb-9c1c-da24a00a7fb9" />
      </body>
      <title>Guidance Automation 2010 Bug: The imported project "C:\Microsoft.Practices.RecipeFramework.Build.targets" was not found</title>
      <guid isPermaLink="false">http://www.niedermann.dk/PermaLink,guid,85830aad-38de-4edb-9c1c-da24a00a7fb9.aspx</guid>
      <link>http://www.niedermann.dk/2010/08/31/GuidanceAutomation2010BugTheImportedProjectCMicrosoftPracticesRecipeFrameworkBuildtargetsWasNotFound.aspx</link>
      <pubDate>Tue, 31 Aug 2010 16:31:11 GMT</pubDate>
      <description>&lt;p&gt;
The new Guidance Automation Framework GAX 2010 and GAT 2010 which is installed through
the Extension Manager in Visual Studio 2010, provides a nicer usability experience
compared to the Visual Studio 2008 predecessor. It is installed using the new vsix
installer. A vsix install is much nicer than the old msi install since it integrates
into Visual Studio. You can uninstall using the Extension Manager and if a new version
comes out it should appear on the Updates tab of the extension manager.
&lt;/p&gt;
&lt;p&gt;
Another nice thing is that a generated factory template solution now only consists
of one project which itself results in a vsix file. So the installer of your own generated
factories will also be vsix files. Nice…
&lt;/p&gt;
&lt;p&gt;
But nicest of all is the fact that it is automatically integrated with the Visual
Studio 2010 Experimental Instance (formerly known as Experimental Hive). Before you
had to manually edit your recipes to get them to register in the Experimental Hive.
But know you just press Ctrl+F5 and the Experimental Instance is automatically launched
with your factory installed. It is now almost easy to debug your recipes. :)
&lt;/p&gt;
&lt;p&gt;
But apparently there are few weird bugs in GAX/GAT 2010. One I run into all the time
is this error:
&lt;/p&gt;
&lt;p&gt;
Unable to read the project file 'Something.csproj'. 
&lt;p&gt;
C:\Something\Something\Something.csproj(354,3): The imported project "C:\Microsoft.Practices.RecipeFramework.Build.targets"
was not found. Confirm that the path in the &amp;lt;Import&amp;gt; declaration is correct,
and that the file exists on disk.
&lt;/p&gt;
&lt;p&gt;
Which happens when I try to open a Guidance Automation solution. 
&lt;/p&gt;
&lt;p&gt;
For some reason the declaration of the variable RecipeFramework in the project file
is not provided. This I deal with by editing the Project file by hand and adding a
declaration to the end of the first PropertyGroup like this: 
&lt;p&gt;
&amp;nbsp; &lt;pre class="xml" name="code"&gt;  &amp;lt;RecipeFrameworkPath&amp;gt;$(DevEnvDir)Extensions\Microsoft patterns and practices\GAX 2010\2.0.20406.0&amp;lt;/RecipeFrameworkPath&amp;gt;&lt;/pre&gt;
&lt;p&gt;
After applying this fix I can open the solution.
&lt;/p&gt;
&lt;p&gt;
I have read somewhere that it is important to adhere to the following install order:
&lt;/p&gt;
&lt;ol&gt;
&lt;ol&gt;
&lt;li&gt;
Visual Studio 2010 Ultimate or Professional (obviously) 
&lt;li&gt;
The Visual Studio 2010 SDK 
&lt;li&gt;
GAX 2010 
&lt;li&gt;
GAT 2010&lt;/li&gt;
&lt;/ol&gt;
&gt;
&lt;p&gt;
And this might be what I have screwed up on the particular machine where I get the
error. 
&lt;/p&gt;
&lt;p&gt;
Anyway the above mentioned fix works. And overall I am very satisfied with the new
improvements in GAX/GAT.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=85830aad-38de-4edb-9c1c-da24a00a7fb9" /&gt;</description>
      <comments>http://www.niedermann.dk/CommentView,guid,85830aad-38de-4edb-9c1c-da24a00a7fb9.aspx</comments>
      <category>.NET</category>
      <category>GAX</category>
      <category>Tips &amp; Tricks</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.niedermann.dk/Trackback.aspx?guid=cbfce837-1ab4-46ce-ba51-b67ab69cc1dc</trackback:ping>
      <pingback:server>http://www.niedermann.dk/pingback.aspx</pingback:server>
      <pingback:target>http://www.niedermann.dk/PermaLink,guid,cbfce837-1ab4-46ce-ba51-b67ab69cc1dc.aspx</pingback:target>
      <dc:creator>Jesper Niedermann</dc:creator>
      <wfw:comment>http://www.niedermann.dk/CommentView,guid,cbfce837-1ab4-46ce-ba51-b67ab69cc1dc.aspx</wfw:comment>
      <wfw:commentRss>http://www.niedermann.dk/SyndicationService.asmx/GetEntryCommentsRss?guid=cbfce837-1ab4-46ce-ba51-b67ab69cc1dc</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Imagine that you want to make an extension for Visual Studio 2010 that creates new
custom right click menus for the Solution Explorer. Imagine that you could do it by
just implementing a good old .NET interface like this:
</p>
        <pre class="c#" name="code">public class MenuManager : IMenuManager<br />
{<br />
public IEnumerable&lt;IMenuItem&gt; GetMenus(ContextLevels menuForLevel)<br />
{<br />
var menuItems = new List&lt;IMenuItem&gt;();<br />
var menuItem1 = new MenuItem("My Menu1");<br />
menuItems.Add(menuItem1);<br />
var menuItem2 = new MenuItem("My Menu2");<br />
menuItems.Add(menuItem2);<br />
return menuItems;<br />
}<br /><br />
public string MainMenu()<br />
{<br />
return "My Main Menu";<br />
}<br />
}</pre>
        <p>
 
</p>
        <p>
Well it turns out you can. In <a href="http://mme.codeplex.com/" target="_blank">MME</a> I
have helped you do exactly that. No more using the convoluted add-in model of Visual
Studio to accomplish this goal. And it is also much simpler than using GAX/GAT (that
can do so much more to be fair).
</p>
        <p>
You can easily install MME, either by downloading directly from <a href="http://mme.codeplex.com/" target="_blank">Codeplex</a> or
by installing directly from the Extension Manager in Visual Studio 2010 (you can find
it under the Tools menu).
</p>
        <p>
MME does not work for the Express editions of VS.
</p>
        <p>
I also recommend installing the MME MenuManager template which you can also find in
the Extension Manager.
</p>
        <p>
At codeplex you can read more about <a href="http://mme.codeplex.com/wikipage?title=implementing&amp;referringTitle=Documentation" target="_blank">implementing</a> and <a href="http://mme.codeplex.com/wikipage?title=deploying&amp;referringTitle=Documentation" target="_blank">deploying</a> MME’s
and also get further insight on the <a href="http://mme.codeplex.com/wikipage?title=Architecture&amp;referringTitle=Documentation" target="_blank">architecture.</a></p>
        <img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=cbfce837-1ab4-46ce-ba51-b67ab69cc1dc" />
      </body>
      <title>Right Click menus for Visual Studio 2010</title>
      <guid isPermaLink="false">http://www.niedermann.dk/PermaLink,guid,cbfce837-1ab4-46ce-ba51-b67ab69cc1dc.aspx</guid>
      <link>http://www.niedermann.dk/2010/06/13/RightClickMenusForVisualStudio2010.aspx</link>
      <pubDate>Sun, 13 Jun 2010 17:20:02 GMT</pubDate>
      <description>&lt;p&gt;
Imagine that you want to make an extension for Visual Studio 2010 that creates new
custom right click menus for the Solution Explorer. Imagine that you could do it by
just implementing a good old .NET interface like this:
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;public class MenuManager : IMenuManager&lt;br&gt;
{&lt;br&gt;
public IEnumerable&amp;lt;IMenuItem&amp;gt; GetMenus(ContextLevels menuForLevel)&lt;br&gt;
{&lt;br&gt;
var menuItems = new List&amp;lt;IMenuItem&amp;gt;();&lt;br&gt;
var menuItem1 = new MenuItem("My Menu1");&lt;br&gt;
menuItems.Add(menuItem1);&lt;br&gt;
var menuItem2 = new MenuItem("My Menu2");&lt;br&gt;
menuItems.Add(menuItem2);&lt;br&gt;
return menuItems;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
public string MainMenu()&lt;br&gt;
{&lt;br&gt;
return "My Main Menu";&lt;br&gt;
}&lt;br&gt;
}&lt;/pre&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Well it turns out you can. In &lt;a href="http://mme.codeplex.com/" target="_blank"&gt;MME&lt;/a&gt; I
have helped you do exactly that. No more using the convoluted add-in model of Visual
Studio to accomplish this goal. And it is also much simpler than using GAX/GAT (that
can do so much more to be fair).
&lt;/p&gt;
&lt;p&gt;
You can easily install MME, either by downloading directly from &lt;a href="http://mme.codeplex.com/" target="_blank"&gt;Codeplex&lt;/a&gt; or
by installing directly from the Extension Manager in Visual Studio 2010 (you can find
it under the Tools menu).
&lt;/p&gt;
&lt;p&gt;
MME does not work for the Express editions of VS.
&lt;/p&gt;
&lt;p&gt;
I also recommend installing the MME MenuManager template which you can also find in
the Extension Manager.
&lt;/p&gt;
&lt;p&gt;
At codeplex you can read more about &lt;a href="http://mme.codeplex.com/wikipage?title=implementing&amp;amp;referringTitle=Documentation" target="_blank"&gt;implementing&lt;/a&gt; and &lt;a href="http://mme.codeplex.com/wikipage?title=deploying&amp;amp;referringTitle=Documentation" target="_blank"&gt;deploying&lt;/a&gt; MME’s
and also get further insight on the &lt;a href="http://mme.codeplex.com/wikipage?title=Architecture&amp;amp;referringTitle=Documentation" target="_blank"&gt;architecture.&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=cbfce837-1ab4-46ce-ba51-b67ab69cc1dc" /&gt;</description>
      <comments>http://www.niedermann.dk/CommentView,guid,cbfce837-1ab4-46ce-ba51-b67ab69cc1dc.aspx</comments>
      <category>Tools</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.niedermann.dk/Trackback.aspx?guid=91776158-a7f1-490d-a36f-dd9def7cf9ee</trackback:ping>
      <pingback:server>http://www.niedermann.dk/pingback.aspx</pingback:server>
      <pingback:target>http://www.niedermann.dk/PermaLink,guid,91776158-a7f1-490d-a36f-dd9def7cf9ee.aspx</pingback:target>
      <dc:creator>Jesper Niedermann</dc:creator>
      <wfw:comment>http://www.niedermann.dk/CommentView,guid,91776158-a7f1-490d-a36f-dd9def7cf9ee.aspx</wfw:comment>
      <wfw:commentRss>http://www.niedermann.dk/SyndicationService.asmx/GetEntryCommentsRss?guid=91776158-a7f1-490d-a36f-dd9def7cf9ee</wfw:commentRss>
      <slash:comments>6</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Windows developers who are used to click events in WinForms, WPF or Silverlight might
miss click and double click events, but because of the game loop where everything
is drawn and updated every few milliseconds an event based approach is probably not
a good idea in most cases. Not so much because of the performance of an event based
approach, but more because the complexity is overwhelming. If several users clicks
and double clicks several keys on the keyboard simultaneously, how would you decide
which of these are clicked and in which order, and further more it is not obvious
to subscribers of the events that they are in the game loop, so they might do code
which performs inadequately.
</p>
        <p>
I have made a few generic classes that expands the MouseState, GamePadState and KeyboardState
in order to make click “events” available. But of course I utilize the standard polling
mechanism in XNA which is to call GetState() on each device.
</p>
        <p>
The approach is that I call my own version of GetState() in the main game loop. My
GetState() method first enqueues the state in a Queue, and then dequeues all states
older than 500 ms, before the state is returned. In this way a historical map of user
interactions is maintained at all times.
</p>
        <p>
Now I can simply check if a key or button was clicked by checking if the key was pressed
and then released “historically”. Similarly I can check for double click by checking
if the key or button was pressed, then released, then pressed again and then released
again.
</p>
        <p>
Now you probably realize why I go back 500 ms. It is because this is the standard
time in which a double click should be executed.
</p>
        <p>
I have used this approach in the game Protect the Carrot at <a href="http://ptc.codeplex.com">http://ptc.codeplex.com</a> and
it works like a charm (The url for the game does not work today, since the game will
only be published in a few weeks).
</p>
        <p>
Here is the implementation of the MouseExtended class which uses this approach:
</p>
        <pre class="c#" name="code">using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using Microsoft.Xna.Framework.Input;<br />
using Microsoft.Xna.Framework;<br /><br />
namespace PTC.Input<br />
{<br />
public class MouseExtended : InputDeviceExtended&lt;MouseState&gt;<br />
{<br />
private static MouseExtended m_Current;<br />
public static MouseExtended Current<br />
{<br />
get<br />
{<br />
if (m_Current == null)<br />
{<br />
m_Current = new MouseExtended();<br />
}<br />
return m_Current;<br />
}<br />
}<br /><br />
public MouseState GetState(GameTime currentTime)<br />
{<br />
DequeueOldStates(currentTime);<br />
MouseState state = Mouse.GetState();<br />
EnqueueNewState(currentTime, state);<br />
return state;<br />
}<br /><br />
private bool ClickCount(MouseButton checkButton, int requiredCount)<br />
{<br />
ButtonState found = ButtonState.Released;<br />
int count = 0;<br />
foreach (InputStateExtended&lt;MouseState&gt; stateExt in RecordedStates)<br />
{<br />
if (found == ButtonState.Pressed &amp;&amp; 
<br />
ButtonStateToCheck(stateExt.State, checkButton) == ButtonState.Released)<br />
{<br />
count++;<br />
if (count &gt;= requiredCount)<br />
return true;<br />
}<br />
found = ButtonStateToCheck(stateExt.State, checkButton);<br />
}<br />
return false;<br />
}<br /><br />
private ButtonState ButtonStateToCheck(MouseState state, MouseButton checkButton)<br />
{<br />
switch (checkButton)<br />
{<br />
case MouseButton.Left:<br />
return state.LeftButton;<br />
case MouseButton.Middle:<br />
return state.MiddleButton;<br />
case MouseButton.Right:<br />
return state.RightButton;<br />
case MouseButton.XButton1:<br />
return state.XButton1;<br />
case MouseButton.XButton2:<br />
return state.XButton2;<br />
default:<br />
return state.LeftButton;<br />
}<br />
}<br /><br />
public bool WasSingleClick(MouseButton checkButton)<br />
{<br />
return(ClickCount(checkButton, 1));<br />
}<br /><br />
public bool WasDoubleClick(MouseButton checkButton)<br />
{<br />
return (ClickCount(checkButton, 2));<br />
}<br /><br />
}<br />
}</pre>
        <p>
And here is the generic InputDeviceExtended class which MouseExtended inherits:
</p>
        <pre class="c#" name="code">using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using Microsoft.Xna.Framework;<br />
using Microsoft.Xna.Framework.Audio;<br />
using Microsoft.Xna.Framework.Content;<br />
using Microsoft.Xna.Framework.GamerServices;<br />
using Microsoft.Xna.Framework.Graphics;<br />
using Microsoft.Xna.Framework.Input;<br />
using Microsoft.Xna.Framework.Media;<br />
using Microsoft.Xna.Framework.Net;<br />
using Microsoft.Xna.Framework.Storage;<br /><br />
namespace PTC.Input<br />
{<br />
public class InputDeviceExtended&lt;S&gt; where S : struct<br />
{<br />
private Queue&lt;InputStateExtended&lt;S&gt;&gt; m_RecordedStates = new Queue&lt;InputStateExtended&lt;S&gt;&gt;();<br /><br />
public Queue&lt;InputStateExtended&lt;S&gt;&gt; RecordedStates<br />
{<br />
get { return m_RecordedStates; }<br />
}<br /><br />
private Stack&lt;InputStateExtended&lt;S&gt;&gt; m_StatesForReuse = new Stack&lt;InputStateExtended&lt;S&gt;&gt;();<br /><br />
protected void EnqueueNewState(GameTime time, S state)<br />
{<br />
if (!state.Equals(m_CurrentState))<br />
{<br />
m_CurrentState = state;<br />
m_RecordedStates.Enqueue(CreateState(time, state));<br />
}<br />
}<br /><br />
private S m_CurrentState;<br />
public S CurrentState<br />
{<br />
get { return m_CurrentState; }<br />
}<br /><br />
protected void DequeueOldStates(GameTime currentTime)<br />
{<br />
InputStateExtended&lt;S&gt; state = null;<br />
if (m_RecordedStates.Count &gt; 0)<br />
{<br />
state = m_RecordedStates.Peek();<br />
}<br />
if (state != null &amp;&amp; state.StateTime &lt; currentTime.TotalRealTime.Subtract(new
TimeSpan(0, 0, 0, 0, InputDeviceConstants.ClickCountTimeMS)))<br />
{<br />
m_StatesForReuse.Push(m_RecordedStates.Dequeue());<br />
DequeueOldStates(currentTime);<br />
}<br />
}<br /><br />
private InputStateExtended&lt;S&gt; CreateState(GameTime time, S state)<br />
{<br />
if (m_StatesForReuse.Count &gt; 0)<br />
{<br />
//Reuses the object to fight of the GC<br />
InputStateExtended&lt;S&gt; stateExt = m_StatesForReuse.Pop();<br />
stateExt.StateTime = time.TotalRealTime;<br />
stateExt.State = state;<br />
return stateExt;<br />
}<br />
else<br />
{<br />
return new InputStateExtended&lt;S&gt;(time, state);<br />
}<br />
}<br />
}<br />
}</pre>
        <p>
Notice that the Recorded States are reused. When dequeued from the queue the are added
to a reuse stack. This is a standard trick to fight of the Garbage Collector, by always
keeping a reference to objects on the heap they never become garbage + they are reused
so the memory use will not explode.
</p>
        <p>
I have also implemented the necessary extended classes for the Keyboard and the gamepad.
I have included them in the attachment to this post. I have not tested the GamepadExtended
class since I do not own a Gamepad, but it is implemented exactly as the keyboard
and mouse classes and ought to work. 
</p>
        <p>
To wire up the new classes you just add the relevant Getstate() calls to the Update
game loop like so:
</p>
        <pre class="c#" name="code">protected override void Update(GameTime gameTime)<br />
{<br />
KeyboardExtended.Current.GetState(gameTime);<br />
MouseExtended.Current.GetState(gameTime);<br />
base.Update(gameTime);<br />
}</pre>
        <p>
And then you can check for click and double click “events”. For instance you check
for double click of the left mouse button like this:
</p>
        <pre class="c#" name="code">if(MouseExtended.Current.WasDoubleClick(MouseButton.Left)))<br />
{<br />
//Do double click reaction<br />
}</pre>
        <p>
Hope you like the stuff.And look out for the amazing “Protect The Carrot” game within
the next month or so, at <a href="http://ptc.codeplex.com">http://ptc.codeplex.com</a></p>
        <p>
In InputDeviceExtended.zip I have included the code for all the InputDevice classes.
</p>
        <p>
        </p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:f7cf6f0f-1ed3-4885-8873-f8eaf969cb75" class="wlWriterEditableSmartContent">
          <p>
            <a href="http://www.niedermann.dk/content/binary/WindowsLiveWriter/ClickanddoubleclickinXNAGames_EF42/InputDeviceExtended.zip" target="_blank">InputDeviceExtended.zip</a>
          </p>
        </div>
        <img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=91776158-a7f1-490d-a36f-dd9def7cf9ee" />
      </body>
      <title>Click and double click in XNA Games</title>
      <guid isPermaLink="false">http://www.niedermann.dk/PermaLink,guid,91776158-a7f1-490d-a36f-dd9def7cf9ee.aspx</guid>
      <link>http://www.niedermann.dk/2010/05/12/ClickAndDoubleClickInXNAGames.aspx</link>
      <pubDate>Wed, 12 May 2010 20:38:51 GMT</pubDate>
      <description>&lt;p&gt;
Windows developers who are used to click events in WinForms, WPF or Silverlight might
miss click and double click events, but because of the game loop where everything
is drawn and updated every few milliseconds an event based approach is probably not
a good idea in most cases. Not so much because of the performance of an event based
approach, but more because the complexity is overwhelming. If several users clicks
and double clicks several keys on the keyboard simultaneously, how would you decide
which of these are clicked and in which order, and further more it is not obvious
to subscribers of the events that they are in the game loop, so they might do code
which performs inadequately.
&lt;/p&gt;
&lt;p&gt;
I have made a few generic classes that expands the MouseState, GamePadState and KeyboardState
in order to make click “events” available. But of course I utilize the standard polling
mechanism in XNA which is to call GetState() on each device.
&lt;/p&gt;
&lt;p&gt;
The approach is that I call my own version of GetState() in the main game loop. My
GetState() method first enqueues the state in a Queue, and then dequeues all states
older than 500 ms, before the state is returned. In this way a historical map of user
interactions is maintained at all times.
&lt;/p&gt;
&lt;p&gt;
Now I can simply check if a key or button was clicked by checking if the key was pressed
and then released “historically”. Similarly I can check for double click by checking
if the key or button was pressed, then released, then pressed again and then released
again.
&lt;/p&gt;
&lt;p&gt;
Now you probably realize why I go back 500 ms. It is because this is the standard
time in which a double click should be executed.
&lt;/p&gt;
&lt;p&gt;
I have used this approach in the game Protect the Carrot at &lt;a href="http://ptc.codeplex.com"&gt;http://ptc.codeplex.com&lt;/a&gt; and
it works like a charm (The url for the game does not work today, since the game will
only be published in a few weeks).
&lt;/p&gt;
&lt;p&gt;
Here is the implementation of the MouseExtended class which uses this approach:
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;using System;&lt;br&gt;
using System.Collections.Generic;&lt;br&gt;
using System.Linq;&lt;br&gt;
using System.Text;&lt;br&gt;
using Microsoft.Xna.Framework.Input;&lt;br&gt;
using Microsoft.Xna.Framework;&lt;br&gt;
&lt;br&gt;
namespace PTC.Input&lt;br&gt;
{&lt;br&gt;
public class MouseExtended : InputDeviceExtended&amp;lt;MouseState&amp;gt;&lt;br&gt;
{&lt;br&gt;
private static MouseExtended m_Current;&lt;br&gt;
public static MouseExtended Current&lt;br&gt;
{&lt;br&gt;
get&lt;br&gt;
{&lt;br&gt;
if (m_Current == null)&lt;br&gt;
{&lt;br&gt;
m_Current = new MouseExtended();&lt;br&gt;
}&lt;br&gt;
return m_Current;&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
public MouseState GetState(GameTime currentTime)&lt;br&gt;
{&lt;br&gt;
DequeueOldStates(currentTime);&lt;br&gt;
MouseState state = Mouse.GetState();&lt;br&gt;
EnqueueNewState(currentTime, state);&lt;br&gt;
return state;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
private bool ClickCount(MouseButton checkButton, int requiredCount)&lt;br&gt;
{&lt;br&gt;
ButtonState found = ButtonState.Released;&lt;br&gt;
int count = 0;&lt;br&gt;
foreach (InputStateExtended&amp;lt;MouseState&amp;gt; stateExt in RecordedStates)&lt;br&gt;
{&lt;br&gt;
if (found == ButtonState.Pressed &amp;amp;&amp;amp; 
&lt;br&gt;
ButtonStateToCheck(stateExt.State, checkButton) == ButtonState.Released)&lt;br&gt;
{&lt;br&gt;
count++;&lt;br&gt;
if (count &amp;gt;= requiredCount)&lt;br&gt;
return true;&lt;br&gt;
}&lt;br&gt;
found = ButtonStateToCheck(stateExt.State, checkButton);&lt;br&gt;
}&lt;br&gt;
return false;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
private ButtonState ButtonStateToCheck(MouseState state, MouseButton checkButton)&lt;br&gt;
{&lt;br&gt;
switch (checkButton)&lt;br&gt;
{&lt;br&gt;
case MouseButton.Left:&lt;br&gt;
return state.LeftButton;&lt;br&gt;
case MouseButton.Middle:&lt;br&gt;
return state.MiddleButton;&lt;br&gt;
case MouseButton.Right:&lt;br&gt;
return state.RightButton;&lt;br&gt;
case MouseButton.XButton1:&lt;br&gt;
return state.XButton1;&lt;br&gt;
case MouseButton.XButton2:&lt;br&gt;
return state.XButton2;&lt;br&gt;
default:&lt;br&gt;
return state.LeftButton;&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
public bool WasSingleClick(MouseButton checkButton)&lt;br&gt;
{&lt;br&gt;
return(ClickCount(checkButton, 1));&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
public bool WasDoubleClick(MouseButton checkButton)&lt;br&gt;
{&lt;br&gt;
return (ClickCount(checkButton, 2));&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
}&lt;br&gt;
}&lt;/pre&gt;
&lt;p&gt;
And here is the generic InputDeviceExtended class which MouseExtended inherits:
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;using System;&lt;br&gt;
using System.Collections.Generic;&lt;br&gt;
using System.Linq;&lt;br&gt;
using Microsoft.Xna.Framework;&lt;br&gt;
using Microsoft.Xna.Framework.Audio;&lt;br&gt;
using Microsoft.Xna.Framework.Content;&lt;br&gt;
using Microsoft.Xna.Framework.GamerServices;&lt;br&gt;
using Microsoft.Xna.Framework.Graphics;&lt;br&gt;
using Microsoft.Xna.Framework.Input;&lt;br&gt;
using Microsoft.Xna.Framework.Media;&lt;br&gt;
using Microsoft.Xna.Framework.Net;&lt;br&gt;
using Microsoft.Xna.Framework.Storage;&lt;br&gt;
&lt;br&gt;
namespace PTC.Input&lt;br&gt;
{&lt;br&gt;
public class InputDeviceExtended&amp;lt;S&amp;gt; where S : struct&lt;br&gt;
{&lt;br&gt;
private Queue&amp;lt;InputStateExtended&amp;lt;S&amp;gt;&amp;gt; m_RecordedStates = new Queue&amp;lt;InputStateExtended&amp;lt;S&amp;gt;&amp;gt;();&lt;br&gt;
&lt;br&gt;
public Queue&amp;lt;InputStateExtended&amp;lt;S&amp;gt;&amp;gt; RecordedStates&lt;br&gt;
{&lt;br&gt;
get { return m_RecordedStates; }&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
private Stack&amp;lt;InputStateExtended&amp;lt;S&amp;gt;&amp;gt; m_StatesForReuse = new Stack&amp;lt;InputStateExtended&amp;lt;S&amp;gt;&amp;gt;();&lt;br&gt;
&lt;br&gt;
protected void EnqueueNewState(GameTime time, S state)&lt;br&gt;
{&lt;br&gt;
if (!state.Equals(m_CurrentState))&lt;br&gt;
{&lt;br&gt;
m_CurrentState = state;&lt;br&gt;
m_RecordedStates.Enqueue(CreateState(time, state));&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
private S m_CurrentState;&lt;br&gt;
public S CurrentState&lt;br&gt;
{&lt;br&gt;
get { return m_CurrentState; }&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
protected void DequeueOldStates(GameTime currentTime)&lt;br&gt;
{&lt;br&gt;
InputStateExtended&amp;lt;S&amp;gt; state = null;&lt;br&gt;
if (m_RecordedStates.Count &amp;gt; 0)&lt;br&gt;
{&lt;br&gt;
state = m_RecordedStates.Peek();&lt;br&gt;
}&lt;br&gt;
if (state != null &amp;amp;&amp;amp; state.StateTime &amp;lt; currentTime.TotalRealTime.Subtract(new
TimeSpan(0, 0, 0, 0, InputDeviceConstants.ClickCountTimeMS)))&lt;br&gt;
{&lt;br&gt;
m_StatesForReuse.Push(m_RecordedStates.Dequeue());&lt;br&gt;
DequeueOldStates(currentTime);&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
private InputStateExtended&amp;lt;S&amp;gt; CreateState(GameTime time, S state)&lt;br&gt;
{&lt;br&gt;
if (m_StatesForReuse.Count &amp;gt; 0)&lt;br&gt;
{&lt;br&gt;
//Reuses the object to fight of the GC&lt;br&gt;
InputStateExtended&amp;lt;S&amp;gt; stateExt = m_StatesForReuse.Pop();&lt;br&gt;
stateExt.StateTime = time.TotalRealTime;&lt;br&gt;
stateExt.State = state;&lt;br&gt;
return stateExt;&lt;br&gt;
}&lt;br&gt;
else&lt;br&gt;
{&lt;br&gt;
return new InputStateExtended&amp;lt;S&amp;gt;(time, state);&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
}&lt;/pre&gt;
&lt;p&gt;
Notice that the Recorded States are reused. When dequeued from the queue the are added
to a reuse stack. This is a standard trick to fight of the Garbage Collector, by always
keeping a reference to objects on the heap they never become garbage + they are reused
so the memory use will not explode.
&lt;/p&gt;
&lt;p&gt;
I have also implemented the necessary extended classes for the Keyboard and the gamepad.
I have included them in the attachment to this post. I have not tested the GamepadExtended
class since I do not own a Gamepad, but it is implemented exactly as the keyboard
and mouse classes and ought to work. 
&lt;/p&gt;
&lt;p&gt;
To wire up the new classes you just add the relevant Getstate() calls to the Update
game loop like so:
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;protected override void Update(GameTime gameTime)&lt;br&gt;
{&lt;br&gt;
KeyboardExtended.Current.GetState(gameTime);&lt;br&gt;
MouseExtended.Current.GetState(gameTime);&lt;br&gt;
base.Update(gameTime);&lt;br&gt;
}&lt;/pre&gt;
&lt;p&gt;
And then you can check for click and double click “events”. For instance you check
for double click of the left mouse button like this:
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;if(MouseExtended.Current.WasDoubleClick(MouseButton.Left)))&lt;br&gt;
{&lt;br&gt;
//Do double click reaction&lt;br&gt;
}&lt;/pre&gt;
&lt;p&gt;
Hope you like the stuff.And look out for the amazing “Protect The Carrot” game within
the next month or so, at &lt;a href="http://ptc.codeplex.com"&gt;http://ptc.codeplex.com&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
In InputDeviceExtended.zip I have included the code for all the InputDevice classes.
&lt;/p&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:f7cf6f0f-1ed3-4885-8873-f8eaf969cb75" class="wlWriterEditableSmartContent"&gt;
&lt;p&gt;
&lt;a href="http://www.niedermann.dk/content/binary/WindowsLiveWriter/ClickanddoubleclickinXNAGames_EF42/InputDeviceExtended.zip" target="_blank"&gt;InputDeviceExtended.zip&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&gt;
&lt;img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=91776158-a7f1-490d-a36f-dd9def7cf9ee" /&gt;</description>
      <comments>http://www.niedermann.dk/CommentView,guid,91776158-a7f1-490d-a36f-dd9def7cf9ee.aspx</comments>
      <category>.NET</category>
      <category>Tips &amp; Tricks</category>
      <category>XNA</category>
    </item>
    <item>
      <trackback:ping>http://www.niedermann.dk/Trackback.aspx?guid=75f4c0a6-612f-47d7-a2e7-518675fec14a</trackback:ping>
      <pingback:server>http://www.niedermann.dk/pingback.aspx</pingback:server>
      <pingback:target>http://www.niedermann.dk/PermaLink,guid,75f4c0a6-612f-47d7-a2e7-518675fec14a.aspx</pingback:target>
      <dc:creator>Jesper Niedermann</dc:creator>
      <wfw:comment>http://www.niedermann.dk/CommentView,guid,75f4c0a6-612f-47d7-a2e7-518675fec14a.aspx</wfw:comment>
      <wfw:commentRss>http://www.niedermann.dk/SyndicationService.asmx/GetEntryCommentsRss?guid=75f4c0a6-612f-47d7-a2e7-518675fec14a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In Microsoft CRM you have no choice when doing updates to the database. You have to
use the CRM Web Service. 
</p>
        <p>
Microsoft does not support direct SQL updates of the underlying SQL Server tables,
because of the behind the scenes CRM magic.
</p>
        <p>
The Web Service is OK for small amounts of data. But recently I had a case where I
had to code an import of a spreadsheet with up to 100.000 rows into CRM.
</p>
        <p>
This would result in 600.000 web service calls, since there was 5 retrieves for each
updates. The first tests showed that each web service call would be about 1,5 seconds
even though they were done internally on the CRM server a fast quad-core 64 bit machine.
This would be 900.000 seconds or 250 hours, more than 10 consecutive days.
</p>
        <p>
Too slow for our particular business need.
</p>
        <p>
Fortunately <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.unsafeauthenticatedconnectionsharing(VS.71).aspx" target="_blank">UnsafeAuthenticatedConnectionSharing</a> came
to the rescue.
</p>
        <pre class="xml" name="code">proxy.OnGetWebRequest += (sender, e) =&gt;<br />
{<br />
e.WebRequest.ConnectionGroupName = InitUserId.ToString();<br />
e.WebRequest.UnsafeAuthenticatedConnectionSharing = true;<br />
};</pre>
        <p>
On the CrmService proxy you set the <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.unsafeauthenticatedconnectionsharing(VS.71).aspx" target="_blank">UnsafeAuthenticatedConnectionSharing</a> to
true. This just means that other calls to the web service will use the same connection
to the database, and without reauthenticating. Which means that the next call with <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.unsafeauthenticatedconnectionsharing(VS.71).aspx" target="_blank">UnsafeAuthenticatedConnectionSharing</a> set
to true, will use the same connection. And will be assumed to be the same user. <a href="http://msdn.microsoft.com/en-us/library/system.net.webrequest.connectiongroupname.aspx" target="_blank">ConnectionGroupName</a> is
a convenient way to split up the connections so that we don’t accidentally reuse connections
between different users. This can be done simply by using the guid of the current
CRM User.
</p>
        <p>
And now the important thing. This makes the web service call take 3/100 seconds. About
50 times faster ! The 600.000 calls can be done in 5 hours. Of course this speed was
only attained because all calls where done internally on the CRM Server.
</p>
        <p>
So why are these two settings not the default ? I don’t know. Perhaps because if you
have a site with millions of users the amount of memory used up by each connection
will be too big. But on a typical CRM site I would guess there would not be enough
users to make this a problem. 
</p>
        <p>
But to be safe, if you just use the 2 properties in the areas that need performance
with little concurrency between users you will be OK.
</p>
        <p>
This and other performance best practices for CRM can be seen on <a href="http://technet.microsoft.com/en-us/library/bb955073.aspx" target="_blank">technet</a>.
But I don’t think any will outperform this one.
</p>
        <img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=75f4c0a6-612f-47d7-a2e7-518675fec14a" />
      </body>
      <title>Fast bulk updates and inserts in Microsoft CRM 4.0</title>
      <guid isPermaLink="false">http://www.niedermann.dk/PermaLink,guid,75f4c0a6-612f-47d7-a2e7-518675fec14a.aspx</guid>
      <link>http://www.niedermann.dk/2010/03/07/FastBulkUpdatesAndInsertsInMicrosoftCRM40.aspx</link>
      <pubDate>Sun, 07 Mar 2010 14:39:19 GMT</pubDate>
      <description>&lt;p&gt;
In Microsoft CRM you have no choice when doing updates to the database. You have to
use the CRM Web Service. 
&lt;/p&gt;
&lt;p&gt;
Microsoft does not support direct SQL updates of the underlying SQL Server tables,
because of the behind the scenes CRM magic.
&lt;/p&gt;
&lt;p&gt;
The Web Service is OK for small amounts of data. But recently I had a case where I
had to code an import of a spreadsheet with up to 100.000 rows into CRM.
&lt;/p&gt;
&lt;p&gt;
This would result in 600.000 web service calls, since there was 5 retrieves for each
updates. The first tests showed that each web service call would be about 1,5 seconds
even though they were done internally on the CRM server a fast quad-core 64 bit machine.
This would be 900.000 seconds or 250 hours, more than 10 consecutive days.
&lt;/p&gt;
&lt;p&gt;
Too slow for our particular business need.
&lt;/p&gt;
&lt;p&gt;
Fortunately &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.unsafeauthenticatedconnectionsharing(VS.71).aspx" target="_blank"&gt;UnsafeAuthenticatedConnectionSharing&lt;/a&gt; came
to the rescue.
&lt;/p&gt;
&lt;pre class="xml" name="code"&gt;proxy.OnGetWebRequest += (sender, e) =&amp;gt;&lt;br&gt;
{&lt;br&gt;
e.WebRequest.ConnectionGroupName = InitUserId.ToString();&lt;br&gt;
e.WebRequest.UnsafeAuthenticatedConnectionSharing = true;&lt;br&gt;
};&lt;/pre&gt;
&lt;p&gt;
On the CrmService proxy you set the &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.unsafeauthenticatedconnectionsharing(VS.71).aspx" target="_blank"&gt;UnsafeAuthenticatedConnectionSharing&lt;/a&gt; to
true. This just means that other calls to the web service will use the same connection
to the database, and without reauthenticating. Which means that the next call with &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.unsafeauthenticatedconnectionsharing(VS.71).aspx" target="_blank"&gt;UnsafeAuthenticatedConnectionSharing&lt;/a&gt; set
to true, will use the same connection. And will be assumed to be the same user. &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.webrequest.connectiongroupname.aspx" target="_blank"&gt;ConnectionGroupName&lt;/a&gt; is
a convenient way to split up the connections so that we don’t accidentally reuse connections
between different users. This can be done simply by using the guid of the current
CRM User.
&lt;/p&gt;
&lt;p&gt;
And now the important thing. This makes the web service call take 3/100 seconds. About
50 times faster ! The 600.000 calls can be done in 5 hours. Of course this speed was
only attained because all calls where done internally on the CRM Server.
&lt;/p&gt;
&lt;p&gt;
So why are these two settings not the default ? I don’t know. Perhaps because if you
have a site with millions of users the amount of memory used up by each connection
will be too big. But on a typical CRM site I would guess there would not be enough
users to make this a problem. 
&lt;/p&gt;
&lt;p&gt;
But to be safe, if you just use the 2 properties in the areas that need performance
with little concurrency between users you will be OK.
&lt;/p&gt;
&lt;p&gt;
This and other performance best practices for CRM can be seen on &lt;a href="http://technet.microsoft.com/en-us/library/bb955073.aspx" target="_blank"&gt;technet&lt;/a&gt;.
But I don’t think any will outperform this one.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=75f4c0a6-612f-47d7-a2e7-518675fec14a" /&gt;</description>
      <comments>http://www.niedermann.dk/CommentView,guid,75f4c0a6-612f-47d7-a2e7-518675fec14a.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.niedermann.dk/Trackback.aspx?guid=0a44a9f8-67aa-45a8-aea4-d644321cd0f7</trackback:ping>
      <pingback:server>http://www.niedermann.dk/pingback.aspx</pingback:server>
      <pingback:target>http://www.niedermann.dk/PermaLink,guid,0a44a9f8-67aa-45a8-aea4-d644321cd0f7.aspx</pingback:target>
      <dc:creator>Jesper Niedermann</dc:creator>
      <wfw:comment>http://www.niedermann.dk/CommentView,guid,0a44a9f8-67aa-45a8-aea4-d644321cd0f7.aspx</wfw:comment>
      <wfw:commentRss>http://www.niedermann.dk/SyndicationService.asmx/GetEntryCommentsRss?guid=0a44a9f8-67aa-45a8-aea4-d644321cd0f7</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the <a href="http://www.niedermann.dk/2009/10/20/Windows7ContestFinished.aspx" target="_blank">Day
View</a> project I needed to open a Windows 7 Sticky Note programmatically and write
to it. Unfortunately I found out that there is not an API for the Sticky Notes application.
At least not a managed one.
</p>
        <p>
So I had to fake it and make my own API. I have made a small class that basicly uses
Process.Start to open the program, and SendKeys to write to the Note.
</p>
        <p>
Here it is:
</p>
        <pre class="c#" name="code">using System;<br />
using System.Diagnostics;<br />
using System.IO;<br />
using System.Runtime.InteropServices;<br />
using System.Threading;<br />
using System.Windows.Forms;<br /><br />
namespace DayView<br />
{<br />
public class StickyNote<br />
{<br />
private const string m_ProcessName = "StikyNot";<br />
private readonly string m_ProcessFileName = Path.Combine(Environment.SystemDirectory,
"StikyNot.exe");<br />
private event EventHandler m_Activated = delegate { };<br />
[DllImport("user32.dll")]<br />
[return: MarshalAs(UnmanagedType.Bool)]<br />
static extern bool SetForegroundWindow(IntPtr hWnd);<br /><br />
public void Activate()<br />
{<br />
bool makeNewNote = true;<br />
Process p = FindProcess();<br />
if (p == null)<br />
{<br />
p = StartProcess();<br />
if (!NoteContainsText(p.MainWindowHandle))<br />
{<br />
makeNewNote = false;<br />
}<br />
}<br />
var state = new StickyNoteState();<br />
state.MakeNewNote = makeNewNote;<br />
state.StickyNoteProcess = p;<br />
ThreadPool.QueueUserWorkItem(Activate, state);<br />
}<br /><br />
private void Activate(object state)<br />
{<br />
var stickyNoteState = state as StickyNoteState;<br />
if (stickyNoteState.MakeNewNote)<br />
{<br />
NewNote(stickyNoteState.StickyNoteProcess);<br />
}<br />
OnActivated();<br />
}<br /><br />
private Process StartProcess()<br />
{<br />
var startInfo = new ProcessStartInfo(m_ProcessFileName);<br />
Process p = Process.Start(startInfo);<br />
Thread.Sleep(200); //This is an annoying hack. I haven't been able to find another
way to be sure the process is started.<br />
return p;<br />
}<br /><br />
private void NewNote(Process p)<br />
{<br />
SetForegroundWindow(p.MainWindowHandle);<br />
Signal("^n"); 
<br />
}<br /><br />
/// &lt;summary&gt;<br />
/// Weird hack to find out if note contains text.<br />
/// &lt;/summary&gt;<br />
/// &lt;returns&gt;&lt;/returns&gt;<br />
private bool NoteContainsText(IntPtr handle)<br />
{<br />
string textOfClipboard = Clipboard.GetText();<br />
Signal("^a");<br />
Signal("^c");<br />
Signal("{RIGHT}");<br />
string noteText = Clipboard.GetText().Trim();<br />
if (textOfClipboard == null)<br />
{<br />
Clipboard.SetText(textOfClipboard);<br />
}<br />
return !string.IsNullOrEmpty(noteText);<br />
}<br /><br />
private Process FindProcess()<br />
{<br />
Process[] processes = Process.GetProcessesByName(m_ProcessName);<br />
if(processes != null &amp;&amp; processes.Length &gt; 0)<br />
{<br />
return processes[0];<br />
}<br />
return null;<br />
}<br /><br />
internal void OnActivated()<br />
{<br />
m_Activated(this, new EventArgs());<br />
}<br /><br />
public event EventHandler Activated<br />
{<br />
add { m_Activated += value; }<br />
remove { m_Activated -= value; }<br />
}<br /><br />
public void Signal(string message)<br />
{<br />
SendKeys.SendWait(message);<br />
SendKeys.Flush();<br />
}<br />
}<br /><br />
public class StickyNoteState<br />
{<br />
public bool MakeNewNote { get; set; }<br />
public Process StickyNoteProcess { get; set; }<br /><br />
}<br />
}</pre>
        <p>
It works OK. The only really buggy thing in the code is in line 47, where I have to
use a Thread.Sleep in order to make sure the note is loaded before I write to it.
Unfortunately this is necessary because the Process class does not provide an event
to signal when it has finished loading. I arbitrarily chose 200 milliseconds for the
Sleep. Larger values might be necessary on slower computers.
</p>
        <p>
In order to use the class you have to configure SendKeys in your app.config like this:
</p>
        <pre class="xml" name="code">&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br />
&lt;configuration&gt;<br />
&lt;appSettings&gt;<br />
&lt;add key="SendKeys" value="SendInput"/&gt;<br />
&lt;/appSettings&gt;<br />
&lt;/configuration&gt;</pre>
        <img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=0a44a9f8-67aa-45a8-aea4-d644321cd0f7" />
      </body>
      <title>API for Sticky Notes in Windows 7</title>
      <guid isPermaLink="false">http://www.niedermann.dk/PermaLink,guid,0a44a9f8-67aa-45a8-aea4-d644321cd0f7.aspx</guid>
      <link>http://www.niedermann.dk/2009/11/13/APIForStickyNotesInWindows7.aspx</link>
      <pubDate>Fri, 13 Nov 2009 23:28:10 GMT</pubDate>
      <description>&lt;p&gt;
In the &lt;a href="http://www.niedermann.dk/2009/10/20/Windows7ContestFinished.aspx" target="_blank"&gt;Day
View&lt;/a&gt; project I needed to open a Windows 7 Sticky Note programmatically and write
to it. Unfortunately I found out that there is not an API for the Sticky Notes application.
At least not a managed one.
&lt;/p&gt;
&lt;p&gt;
So I had to fake it and make my own API. I have made a small class that basicly uses
Process.Start to open the program, and SendKeys to write to the Note.
&lt;/p&gt;
&lt;p&gt;
Here it is:
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;using System;&lt;br&gt;
using System.Diagnostics;&lt;br&gt;
using System.IO;&lt;br&gt;
using System.Runtime.InteropServices;&lt;br&gt;
using System.Threading;&lt;br&gt;
using System.Windows.Forms;&lt;br&gt;
&lt;br&gt;
namespace DayView&lt;br&gt;
{&lt;br&gt;
public class StickyNote&lt;br&gt;
{&lt;br&gt;
private const string m_ProcessName = "StikyNot";&lt;br&gt;
private readonly string m_ProcessFileName = Path.Combine(Environment.SystemDirectory,
"StikyNot.exe");&lt;br&gt;
private event EventHandler m_Activated = delegate { };&lt;br&gt;
[DllImport("user32.dll")]&lt;br&gt;
[return: MarshalAs(UnmanagedType.Bool)]&lt;br&gt;
static extern bool SetForegroundWindow(IntPtr hWnd);&lt;br&gt;
&lt;br&gt;
public void Activate()&lt;br&gt;
{&lt;br&gt;
bool makeNewNote = true;&lt;br&gt;
Process p = FindProcess();&lt;br&gt;
if (p == null)&lt;br&gt;
{&lt;br&gt;
p = StartProcess();&lt;br&gt;
if (!NoteContainsText(p.MainWindowHandle))&lt;br&gt;
{&lt;br&gt;
makeNewNote = false;&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
var state = new StickyNoteState();&lt;br&gt;
state.MakeNewNote = makeNewNote;&lt;br&gt;
state.StickyNoteProcess = p;&lt;br&gt;
ThreadPool.QueueUserWorkItem(Activate, state);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
private void Activate(object state)&lt;br&gt;
{&lt;br&gt;
var stickyNoteState = state as StickyNoteState;&lt;br&gt;
if (stickyNoteState.MakeNewNote)&lt;br&gt;
{&lt;br&gt;
NewNote(stickyNoteState.StickyNoteProcess);&lt;br&gt;
}&lt;br&gt;
OnActivated();&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
private Process StartProcess()&lt;br&gt;
{&lt;br&gt;
var startInfo = new ProcessStartInfo(m_ProcessFileName);&lt;br&gt;
Process p = Process.Start(startInfo);&lt;br&gt;
Thread.Sleep(200); //This is an annoying hack. I haven't been able to find another
way to be sure the process is started.&lt;br&gt;
return p;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
private void NewNote(Process p)&lt;br&gt;
{&lt;br&gt;
SetForegroundWindow(p.MainWindowHandle);&lt;br&gt;
Signal("^n"); 
&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
/// &amp;lt;summary&amp;gt;&lt;br&gt;
/// Weird hack to find out if note contains text.&lt;br&gt;
/// &amp;lt;/summary&amp;gt;&lt;br&gt;
/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
private bool NoteContainsText(IntPtr handle)&lt;br&gt;
{&lt;br&gt;
string textOfClipboard = Clipboard.GetText();&lt;br&gt;
Signal("^a");&lt;br&gt;
Signal("^c");&lt;br&gt;
Signal("{RIGHT}");&lt;br&gt;
string noteText = Clipboard.GetText().Trim();&lt;br&gt;
if (textOfClipboard == null)&lt;br&gt;
{&lt;br&gt;
Clipboard.SetText(textOfClipboard);&lt;br&gt;
}&lt;br&gt;
return !string.IsNullOrEmpty(noteText);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
private Process FindProcess()&lt;br&gt;
{&lt;br&gt;
Process[] processes = Process.GetProcessesByName(m_ProcessName);&lt;br&gt;
if(processes != null &amp;amp;&amp;amp; processes.Length &amp;gt; 0)&lt;br&gt;
{&lt;br&gt;
return processes[0];&lt;br&gt;
}&lt;br&gt;
return null;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
internal void OnActivated()&lt;br&gt;
{&lt;br&gt;
m_Activated(this, new EventArgs());&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
public event EventHandler Activated&lt;br&gt;
{&lt;br&gt;
add { m_Activated += value; }&lt;br&gt;
remove { m_Activated -= value; }&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
public void Signal(string message)&lt;br&gt;
{&lt;br&gt;
SendKeys.SendWait(message);&lt;br&gt;
SendKeys.Flush();&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
public class StickyNoteState&lt;br&gt;
{&lt;br&gt;
public bool MakeNewNote { get; set; }&lt;br&gt;
public Process StickyNoteProcess { get; set; }&lt;br&gt;
&lt;br&gt;
}&lt;br&gt;
}&lt;/pre&gt;
&lt;p&gt;
It works OK. The only really buggy thing in the code is in line 47, where I have to
use a Thread.Sleep in order to make sure the note is loaded before I write to it.
Unfortunately this is necessary because the Process class does not provide an event
to signal when it has finished loading. I arbitrarily chose 200 milliseconds for the
Sleep. Larger values might be necessary on slower computers.
&lt;/p&gt;
&lt;p&gt;
In order to use the class you have to configure SendKeys in your app.config like this:
&lt;/p&gt;
&lt;pre class="xml" name="code"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;br&gt;
&amp;lt;configuration&amp;gt;&lt;br&gt;
&amp;lt;appSettings&amp;gt;&lt;br&gt;
&amp;lt;add key="SendKeys" value="SendInput"/&amp;gt;&lt;br&gt;
&amp;lt;/appSettings&amp;gt;&lt;br&gt;
&amp;lt;/configuration&amp;gt;&lt;/pre&gt;&lt;img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=0a44a9f8-67aa-45a8-aea4-d644321cd0f7" /&gt;</description>
      <comments>http://www.niedermann.dk/CommentView,guid,0a44a9f8-67aa-45a8-aea4-d644321cd0f7.aspx</comments>
      <category>.NET</category>
      <category>Tips &amp; Tricks</category>
      <category>Windows 7</category>
    </item>
    <item>
      <trackback:ping>http://www.niedermann.dk/Trackback.aspx?guid=d70452c9-013d-49b4-82cc-b5290ae51893</trackback:ping>
      <pingback:server>http://www.niedermann.dk/pingback.aspx</pingback:server>
      <pingback:target>http://www.niedermann.dk/PermaLink,guid,d70452c9-013d-49b4-82cc-b5290ae51893.aspx</pingback:target>
      <dc:creator>Jesper Niedermann</dc:creator>
      <wfw:comment>http://www.niedermann.dk/CommentView,guid,d70452c9-013d-49b4-82cc-b5290ae51893.aspx</wfw:comment>
      <wfw:commentRss>http://www.niedermann.dk/SyndicationService.asmx/GetEntryCommentsRss?guid=d70452c9-013d-49b4-82cc-b5290ae51893</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am currently developing the game Klimakonflikt with 5 other guys. It is a Retro
arcade game, Pac-man style, with nice 2D Graphics and music. Here is a screenshot
from the game:
</p>
        <p>
          <a href="http://www.niedermann.dk/content/binary/WindowsLiveWriter/RetroXNAGameKlimakonfliktunderdevelopmen_1B4/klimakonflikt_screenshot_4.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="klimakonflikt_screenshot" border="0" alt="klimakonflikt_screenshot" src="http://www.niedermann.dk/content/binary/WindowsLiveWriter/RetroXNAGameKlimakonfliktunderdevelopmen_1B4/klimakonflikt_screenshot_thumb_1.png" width="415" height="295" />
          </a>
        </p>
        <p>
The current release, documentation and source code can be downloaded from here <a href="http://klimakonflikt.codeplex.com" target="_blank">http://klimakonflikt.codeplex.com</a> 
</p>
        <p>
The game is inherently for 2 players but we are working on the single player edition.
The AI in the current release is pretty daft, but in the next release it will be much
improved. Also we are working on a WPF leveleditor, powerups and other fun stuff.
</p>
        <p>
One of my co-developers Jakob has released a blog about the game and XNA development
in general at <a href="http://xnafan.net" target="_blank">http://xnafan.net</a></p>
        <img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=d70452c9-013d-49b4-82cc-b5290ae51893" />
      </body>
      <title>Retro XNA Game Klimakonflikt under development</title>
      <guid isPermaLink="false">http://www.niedermann.dk/PermaLink,guid,d70452c9-013d-49b4-82cc-b5290ae51893.aspx</guid>
      <link>http://www.niedermann.dk/2009/11/13/RetroXNAGameKlimakonfliktUnderDevelopment.aspx</link>
      <pubDate>Fri, 13 Nov 2009 23:11:29 GMT</pubDate>
      <description>&lt;p&gt;
I am currently developing the game Klimakonflikt with 5 other guys. It is a Retro
arcade game, Pac-man style, with nice 2D Graphics and music. Here is a screenshot
from the game:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.niedermann.dk/content/binary/WindowsLiveWriter/RetroXNAGameKlimakonfliktunderdevelopmen_1B4/klimakonflikt_screenshot_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="klimakonflikt_screenshot" border="0" alt="klimakonflikt_screenshot" src="http://www.niedermann.dk/content/binary/WindowsLiveWriter/RetroXNAGameKlimakonfliktunderdevelopmen_1B4/klimakonflikt_screenshot_thumb_1.png" width="415" height="295"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The current release, documentation and source code can be downloaded from here &lt;a href="http://klimakonflikt.codeplex.com" target="_blank"&gt;http://klimakonflikt.codeplex.com&lt;/a&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The game is inherently for 2 players but we are working on the single player edition.
The AI in the current release is pretty daft, but in the next release it will be much
improved. Also we are working on a WPF leveleditor, powerups and other fun stuff.
&lt;/p&gt;
&lt;p&gt;
One of my co-developers Jakob has released a blog about the game and XNA development
in general at &lt;a href="http://xnafan.net" target="_blank"&gt;http://xnafan.net&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.niedermann.dk/aggbug.ashx?id=d70452c9-013d-49b4-82cc-b5290ae51893" /&gt;</description>
      <comments>http://www.niedermann.dk/CommentView,guid,d70452c9-013d-49b4-82cc-b5290ae51893.aspx</comments>
      <category>.NET</category>
      <category>Games &amp; Puzzles</category>
      <category>WPF</category>
      <category>XNA</category>
    </item>
  </channel>
</rss>
