<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Aimee Gurl... &#187; .NET</title>
	<atom:link href="http://aimeegurl.com/tag/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://aimeegurl.com</link>
	<description>for as long as i can remember, technology has always fascinated me</description>
	<lastBuildDate>Thu, 29 Jul 2010 03:28:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Consuming data from Nimbus Using LinqToXML (Updated) on iPhone + WP7!</title>
		<link>http://aimeegurl.com/2010/03/16/consuming-data-from-nimbus-using-linqtoxml-2/</link>
		<comments>http://aimeegurl.com/2010/03/16/consuming-data-from-nimbus-using-linqtoxml-2/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 20:21:57 +0000</pubDate>
		<dc:creator>Aimee</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[MonoTouch.NET]]></category>
		<category><![CDATA[Project Nimbus]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[visualstudio2010]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://aimeegurl.com/2010/03/16/consuming-data-from-nimbus-using-linqtoxml-2/</guid>
		<description><![CDATA[<p id="top" />I’ve been starting to explore iPhone development lately. At first I was taking my time at learning at Objective C which went fine for a while but one of the guys on the project was asking if I could help build some apps for Project Nimbus, translation: build stuff fast. We talked about [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />I’ve been starting to explore iPhone development lately. At first I was taking my time at learning at Objective C which went fine for a while but one of the guys on the project was asking if I could help build some apps for <a href="http://www.projectnimbus.org">Project Nimbus</a>, translation: build stuff fast. We talked about <a href="http://MonoTouch.NET">MonoTouch.NET</a> which is basically a framework that will allow you to code apps with .NET. JOY!!</p>
<p>First a quick intro about <a href="http://www.projectnimbus.org">Project Nimbus</a>: as Chewy would put it, it’s basically a supermarket for data here in Singapore. The team is hard at work at securing data from all sorts of providers. They currently have <a href="http://www.hungrygowhere.com/">Hungry Go Where</a>, <a href="http://www.lta.gov.sg">Land Transport Authority</a>, <a href="http://www.nea.gov.sg">National Environment Agency</a>, and <a href="http://www.nlb.gov.sg/">National Library Board </a>onboard as data providers, and i know they have quite a few more coming. What this means for developers is that if they have a great idea, they don’t have to go out by themselves with these big agencies and possibly spend tons of money on acquiring the data. If you want to find out more, check out <a href="http://projectnimbus.org/about/">http://projectnimbus.org/about/</a> for more information. They also very keen on getting input from developers as to what types of data they think would be useful, as well as feedback on the project as well. If you’re interested, the about page has a link to contact them <img src='http://aimeegurl.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So back to my application. Right now, I’m figuring out how to actually get the data from the service. Looking at <a href="http://projectnimbus.org/2010/02/23/what-is-returned-from-data-service/">this entry</a>, they actually provide a link to the data that’s returned when you make a call to the service. Check out the post, and towards the end, you’ll find a few links that shows how the data looks like.</p>
<p>First we create a webrequest to the URL that gives me the dataset we want. In this case, we want to get access to the NowcastSet i.e. current weather. The service actually gets authentication from the headers so we add these two keys &amp; values. We then make the request and read it into a string for parsing later on.</p>
<p><img src="http://aimeegurl.com/wp-content/uploads/2010/03/wpid-PastedGraphic6.6QgjwaKOHyeZ.jpg" alt="wpid-PastedGraphic6.6QgjwaKOHyeZ.jpg" width="826" height="113" /></p>
<p>Next, if we look at the <a href="http://nimbusproject.cloudapp.net/neaodataservice.svc/ForecastSet?AccountKey=NimbusAdmin&amp;UniqueUserID=A66D951F49F54A63B040CFAA2FD553C0">dataset</a> that’s returned, we see that it makes use of a few namespaces. To make things WHOLE lot easier for us, we’ll use one of the cool features of the .NET Framework which I LOVE called LinqToXML. If you want to find out more, check out <a href="http://msdn.microsoft.com/en-us/library/bb387098.aspx">http://msdn.microsoft.com/en-us/library/bb387098.aspx</a>.</p>
<p>Let’s first add the System.Xml.Linq namespace in order to use it’s classes.</p>
<p><img src="http://aimeegurl.com/wp-content/uploads/2010/03/wpid-PastedGraphic1.ItVM3vydQ2bH.jpg" alt="wpid-PastedGraphic1.ItVM3vydQ2bH.jpg" width="651" height="316" /></p>
<p>We can now add a our XNamespaces:<br />
<img src="http://aimeegurl.com/wp-content/uploads/2010/03/wpid-PastedGraphic2.CJ4wKM6qhF3A.jpg" alt="wpid-PastedGraphic2.CJ4wKM6qhF3A.jpg" width="620" height="65" /></p>
<p>The following stuff is just magic. With just one statement using LinqToXML, we’re able to parse the xml string without having to use xpath or regex, etc. And, if you read the statement, it’s actually pretty descriptive of what it is trying to accomplish.</p>
<p><img src="http://aimeegurl.com/wp-content/uploads/2010/03/wpid-PastedGraphic4.SILwDB5lGtqK.jpg" alt="wpid-PastedGraphic4.SILwDB5lGtqK.jpg" width="715" height="157" /></p>
<p>Given the structure of our sample data, we see that we’re essentially getting elements from <strong>entry.content.properties</strong>.</p>
<p><img src="http://aimeegurl.com/wp-content/uploads/2010/03/wpid-PastedGraphic9.u4eWF4QbhRSy.jpg" alt="wpid-PastedGraphic9.u4eWF4QbhRSy.jpg" width="446" height="415" /></p>
<p>Note that the following line is just to make things a bit easier to read.<br />
<img style="border-width: 0px;" src="http://aimeegurl.com/wp-content/uploads/2010/03/wpid-PastedGraphic10.hKnF61uZzy7F.jpg" border="0" alt="wpid-PastedGraphic10.hKnF61uZzy7F.jpg" width="535" height="17" /></p>
<p>You can also just do the following and remove the let line, though I find it a bit more confusing to understand at first glance.<br />
<img style="border-width: 0px;" src="http://aimeegurl.com/wp-content/uploads/2010/03/wpid-PastedGraphic11.yB7JdULt8nja.jpg" border="0" alt="wpid-PastedGraphic11.yB7JdULt8nja.jpg" width="562" height="10" /></p>
<p>This is the full code:</p>
<pre class="code">    <span style="color: blue;">public </span><span style="color: #2b91af;">List</span>&lt;WeatherEntry&gt; GetWeatherFromNimbusNEA(<span style="color: blue;">string </span>AccountKey, <span style="color: blue;">string </span>UniqueUserID)
    {

        System.Net.WebRequest wr=
          HttpWebRequest.Create(
<span style="color: #a31515;">            "http://api.projectnimbus.org/neaodataservice.svc/NowcastSet"</span>);</pre>
<pre class="code">        wr.Headers.Add(<span style="color: #a31515;">"AccountKey"</span>,AccountKey);
        wr.Headers.Add(<span style="color: #a31515;">"UniqueUserID"</span>,UniqueUserID);
        wr.Method = <span style="color: #a31515;">"GET"</span>;
        WebResponse res = wr.GetResponse();
        <span style="color: blue;">string </span>resStr
         = <span style="color: blue;">new </span>System.IO.<span style="color: #2b91af;">StreamReader</span>(res.GetResponseStream()).ReadToEnd();

        XNamespace atomNS
          = <span style="color: #a31515;">"http://www.w3.org/2005/Atom"</span>;</pre>
<pre class="code">        XNamespace dNS 
          = <span style="color: #a31515;">"http://schemas.microsoft.com/ado/2007/08/dataservices"</span>;</pre>
<pre class="code">        XNamespace mNS
          = <span style="color: #a31515;">"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"</span>;

        <span style="color: #2b91af;">List</span>&lt;WeatherEntry&gt; results
          = (<span style="color: blue;">from </span>item <span style="color: blue;">in </span>XElement.Parse(resStr).Descendants(atomNS + <span style="color: #a31515;">"entry"</span>)
            <span style="color: blue;">let </span>weather = item.Element(atomNS + <span style="color: #a31515;">"content"</span>).Element(mNS +<span style="color: #a31515;">"properties"</span>)
                <span style="color: blue;">select new </span>WeatherEntry() {
                Area = weather.Element(dNS +<span style="color: #a31515;">"Area"</span>).Value,
                Condition = weather.Element(dNS +<span style="color: #a31515;">"Condition"</span>).Value,
                Lat = weather.Element(dNS + <span style="color: #a31515;">"Latitude"</span>).Value,
                Lon = weather.Element(dNS + <span style="color: #a31515;">"Longitude"</span>).Value
            }).ToList();

        <span style="color: blue;">return </span>results;
    }

}</pre>
<p><em>//Blogging using a trial version of MacJournal. Windows Live Writer is still my favorite blogging software, and it’s not just because it’s free. </em></p>
<p><em>// Update @ 3.40 on my Win7 partition.. I missed you Windows Live Writer!</em></p>
<p><em> </em></p>
<p><em>// </em><em>and <a href="http://gallery.live.com/liveItemDetail.aspx?li=d8835a5e-28da-4242-82eb-e1a006b083b9&amp;bt=9&amp;pl=8">the vspaste add-in!!</a></em></p>
<p>It’s an hour after the end of the <a href="http://live.visitmix.com">Mix Keynote</a>. I started watching the video on my Mac partition so I couldn’t download the tools straight away. After it was over, I rebooted, uninstalled my pre-RC bits and installed the tools for Windows Phone 7 Series (which you can find <a href="http://developer.windowsphone.com">here</a>), fired it up and created a new Windows Phone List Application:</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2010/03/image1.png"><img style="margin: 0px 20px; display: inline; border-width: 0px;" title="image" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb1.png" border="0" alt="image" width="640" height="405" /></a></p>
<p>Since this is mainly a ProjectNimbus post, I won’t dive into how to build the WP7 app but there’s a new training kit up on channel 9 <a href="http://channel9.msdn.com/learn/courses/WP7TrainingKit/">http://channel9.msdn.com/learn/courses/WP7TrainingKit/</a> if you want to learn more.</p>
<p>I did make a few tweaks in my code since the original code wasn’t doing downloads asynchronously (which it should, to improve your apps performance and not lock the UI). So how does my code look now?</p>
<pre class="code"><span style="color: blue;">public void  </span>GetWeatherFromNimbusNEA(<span style="color: blue;">string </span>AccountKey, <span style="color: blue;">string </span>UniqueUserID)
 {

     <span style="color: #2b91af;">WebClient </span>wc = <span style="color: blue;">new </span><span style="color: #2b91af;">WebClient</span>();</pre>
<pre class="code"><span style="color: green;">     </span>wc.Headers[<span style="color: #a31515;">"AccountKey"</span>] = AccountKey;
     wc.Headers[<span style="color: #a31515;">"UniqueUserID"</span>] = UniqueUserID;
     wc.DownloadStringCompleted
      +=<span style="color: blue;">new </span><span style="color: #2b91af;">DownloadStringCompletedEventHandler</span>(wc_DownloadStringCompleted);
     wc.DownloadStringAsync(
<span style="color: blue;">      new </span><span style="color: #2b91af;">Uri</span>(<span style="color: #a31515;">"http://api.projectnimbus.org/neaodataservice.svc/NowcastSet"</span>));

 }

 <span style="color: blue;">void </span>wc_DownloadStringCompleted(<span style="color: blue;">object </span>sender, <span style="color: #2b91af;">DownloadStringCompletedEventArgs </span>e)
 {
     <span style="color: blue;">string </span>resStr = e.Result;

     <span style="color: #2b91af;">XNamespace </span>atomNS
      = <span style="color: #a31515;">"http://www.w3.org/2005/Atom"</span>;
     <span style="color: #2b91af;">XNamespace </span>dNS
      = <span style="color: #a31515;">"http://schemas.microsoft.com/ado/2007/08/dataservices"</span>;
     <span style="color: #2b91af;">XNamespace </span>mNS
      = <span style="color: #a31515;">"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"</span>;

     <span style="color: blue;">var </span>results
     = (<span style="color: blue;">from </span>item <span style="color: blue;">in </span><span style="color: #2b91af;">XElement</span>.Parse(resStr)
         .Descendants(atomNS + <span style="color: #a31515;">"entry"</span>)
<span style="color: blue;">          let </span>weather = item.Element(atomNS + <span style="color: #a31515;">"content"</span>)
                        .Element(mNS + <span style="color: #a31515;">"properties"</span>)</pre>
<pre class="code">                 <span style="color: blue;">select new </span><span style="color: #2b91af;">WeatherEntryViewModel</span>()
                  {
                   Area = weather.Element(dNS + <span style="color: #a31515;">"Area"</span>).Value,
                   Condition = weather
                               .Element(dNS + <span style="color: #a31515;">"Condition"</span>).Value,
                   Lat = weather.Element(dNS + <span style="color: #a31515;">"Latitude"</span>).Value,
                   Lon = weather.Element(dNS + <span style="color: #a31515;">"Longitude"</span>).Value
                  });
     <span style="color: blue;">foreach </span>(<span style="color: blue;">var </span>r <span style="color: blue;">in </span>results) {
         Items.Add(r);
     }
 }</pre>
<p>It’s practically the same code except I switched to the WebClient which Silverlight developers are already familiar with to download the string asynchronously. Once the results are returned, I add them to an observable collection which I have data-bound my UI Elements to.</p>
<pre class="code">Items = <span style="color: blue;">new </span><span style="color: #2b91af;">ObservableCollection</span>&lt;<span style="color: #2b91af;">WeatherEntryViewModel</span>&gt;();</pre>
<p>The result is a basic list like application that displays weather information:</p>
<p><img style="margin: 0px 20px; display: inline; border-width: 0px;" title="image" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb2.png" border="0" alt="image" width="278" height="480" /></p>
<p>I’m excited about the WP7 platform and it’s definitely going to be a focus in my upcoming TechFriday posts! Next thing on my learning list is to share code between my two application platforms, iPhone and WP7. One thing is for sure though, I’m very happy with Project Nimbus as well because it provides a lot of data that I can already start playing around with. Kudos to the team! <img class="wlEmoticon wlEmoticon-smile" src="http://aimeegurl.com/wp-content/uploads/2010/03/wlEmoticonsmile.png" alt="Smile" /></p>
]]></content:encoded>
			<wfw:commentRss>http://aimeegurl.com/2010/03/16/consuming-data-from-nimbus-using-linqtoxml-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>TechFriday: Jumping into Jumplists</title>
		<link>http://aimeegurl.com/2009/07/10/techfriday-jumping-into-jumplists/</link>
		<comments>http://aimeegurl.com/2009/07/10/techfriday-jumping-into-jumplists/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 17:48:35 +0000</pubDate>
		<dc:creator>Aimee</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[jumplist]]></category>
		<category><![CDATA[sample code]]></category>
		<category><![CDATA[techfriday]]></category>
		<category><![CDATA[Windows7]]></category>

		<guid isPermaLink="false">http://aimeegurl.com/2009/07/10/techfriday-jumping-into-jumplists/</guid>
		<description><![CDATA[<p id="top" />
<p>Everybody’s excited about Windows 7 and there might be a few of you guys out there wanting to take advantage of some of the new features of the OS in your applications. In this post, I’ll show you how you can quickly add Jumplist support to your existing application (Yes, even WinForms applications)</p>
<p>In [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />
<p>Everybody’s excited about Windows 7 and there might be a few of you guys out there wanting to take advantage of some of the new features of the OS in your applications. In this post, I’ll show you how you can quickly add Jumplist support to your existing application (Yes, even WinForms applications)</p>
<p>In order to keep things simple, let’s just make the assumption that this existing application of mine has 3 very useful screens: Default, Green Mode and Red Mode ( I’m a developer, I’m not very creative ) </p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2009/07/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2009/07/image_thumb.png" width="588" height="371" /></a> </p>
<p>Because I want to save my user some additional clicks to get into green / red mode, I can take advantage of a new feature of Windows 7 called Jumplists: when a user right-clicks on my app’s icon on the Windows 7 task bar, this menu pops up and gives him access to tasks that we expect him to frequent. There are a lot of tutorials out there that teach how to add Recent/Frequent documents to this list. The samples included in the library we’ll be using will show you how.</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2009/07/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2009/07/image_thumb1.png" width="306" height="229" /></a> .</p>
<p>For this example, we’ll learn how to use our applications existing custom functions (and icons) with Windows 7 jumplists but first, download <a href="http://code.msdn.microsoft.com/Windows7Taskbar">the Windows 7 Taskbar Developer Resource</a></p>
<p>For this example, I have a very simple Hello Windows 7 application. In the application, I have a menu bar that loads up additional screens. In this case, it’s just the same screen and switching the colors, but it could easily be a function that will load up another UserControl with different functions. Productivity is key, so I’d like to allow my user to go straight to these screens on startup. </p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2009/07/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2009/07/image_thumb2.png" width="1028" height="550" /></a> </p>
<p>In order to enable this, I’ve made a method that will allow the application to switch between user screens based on command line arguments when launching the application.</p>
<pre class="code"><span style="color: blue">private void </span>ProcessArguments()
{
    <span style="color: blue">string</span>[] args = <span style="color: #2b91af">Environment</span>.GetCommandLineArgs();

    <span style="color: blue">if </span>(args.Length &gt; 1)
    {
        <span style="color: blue">if </span>(args[1].Equals(<span style="color: #a31515">&quot;/r&quot;</span>))
        {
            LoadRedScreen();
        }
        <span style="color: blue">else if </span>(args[1].Equals(<span style="color: #a31515">&quot;/g&quot;</span>))
        {
            LoadGreenScreen();
        }

    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>In this piece of code, I’m basically checking that IF there are arguments passed when running the application, I’ll be calling a method to load the appropriate UserControl (We’ve already seen that this is the same method invoked by the menu item in our Menubar).</p>
<p>Now we start using the libraries provided for us to make it easier to integrate with the Windows 7 Taskbar. But first let’s import the namespace of the library, plus some additional ones we will be using along the way</p>
<pre class="code"><span style="color: blue">using </span>Windows7.DesktopIntegration;
<span style="color: blue">using </span>System.IO;
<span style="color: blue">using </span>System.Reflection;</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Next we add the following properties to the form:</p>
<pre class="code"><span style="color: blue">string </span>appID = <span style="color: #a31515">&quot;Hello Windows 7&quot;</span>;
<span style="color: #2b91af">JumpListManager </span>jlm;
    </pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The key thing here is the JumpListManager but if you want more information on the appID and all the goodness it brings, visit <a title="http://windowsteamblog.com/blogs/developers/archive/2009/06/18/developing-for-the-windows-7-taskbar-application-id.aspx" href="http://windowsteamblog.com/blogs/developers/archive/2009/06/18/developing-for-the-windows-7-taskbar-application-id.aspx">http://windowsteamblog.com/blogs/developers/archive/2009/06/18/developing-for-the-windows-7-taskbar-application-id.aspx</a>. The next thing I have to do is override </p>
<pre class="code"><span style="color: blue">protected override void </span>WndProc(<span style="color: blue">ref </span><span style="color: #2b91af">Message </span>m)
{
    <span style="color: blue">base</span>.WndProc(<span style="color: blue">ref </span>m);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Before we start jumping into adding jumplists, we want to remember that since this is an existing application meant to be run in existing versions of Windows, we’d like to make sure that we’ll only execute the additional code IF the application is running in Windows 7, otherwise, operate as usual. To do this, we check whether the OS version is 6.1 or greater (RC builds still register Major version as 6) with this code:</p>
<pre class="code"><span style="color: #2b91af">OperatingSystem </span>os = <span style="color: #2b91af">Environment</span>.OSVersion;
<span style="color: blue">if </span>((os.Version.Major == 6 &amp;&amp; os.Version.Minor &gt;= 1) || os.Version.Major &gt; 6)
{
    <span style="color: green">//some code
</span>}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Now for the fun part. The OS message that we want to lookout for is the message that tells us that the taskbar button has been created. Then we can start adding the Jumplist items to the button.</p>
<pre class="code"><span style="color: blue">if </span>(m.Msg == <span style="color: #2b91af">Windows7Taskbar</span>.TaskbarButtonCreatedMessage)
{
    <span style="color: blue">try
    </span>{

        jlm = <span style="color: blue">new </span><span style="color: #2b91af">JumpListManager</span>(appID);
        jlm.UserRemovedItems += <span style="color: blue">delegate </span>{ };

        <span style="color: blue">string </span>strAppDir = <span style="color: #2b91af">Path</span>.GetDirectoryName(<span style="color: #2b91af">Assembly</span>.GetEntryAssembly().Location);
        <span style="color: blue">string </span>app = <span style="color: #2b91af">Assembly</span>.GetEntryAssembly().GetName().Name + <span style="color: #a31515">&quot;.exe&quot;</span>;

        jlm.AddUserTask(<span style="color: blue">new </span><span style="color: #2b91af">ShellLink
        </span>{
            Title = <span style="color: #a31515">&quot;Color it Red!&quot;</span>,
            Path = <span style="color: #2b91af">Path</span>.Combine(strAppDir, app),
            Arguments = <span style="color: #a31515">&quot;/r&quot;</span>,
            IconLocation = <span style="color: #2b91af">Path</span>.Combine(strAppDir, <span style="color: #a31515">@&quot;ico\Red.ico&quot;</span>)

        });

        jlm.AddUserTask(<span style="color: blue">new </span><span style="color: #2b91af">ShellLink
        </span>{
            Title = <span style="color: #a31515">&quot;Color it Green!&quot;</span>,
            Path = <span style="color: #2b91af">Path</span>.Combine(strAppDir, app),
            Arguments = <span style="color: #a31515">&quot;/g&quot;</span>,
            IconLocation = <span style="color: #2b91af">Path</span>.Combine(strAppDir, <span style="color: #a31515">@&quot;ico\green.ico&quot;</span>)
        });
        jlm.Refresh();

        ProcessArguments();
    }
    <span style="color: blue">catch </span>(<span style="color: #2b91af">Exception</span>)
    {

    }</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Let’s break this down. </p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2009/07/image3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2009/07/image_thumb3.png" width="316" height="45" /></a> </p>
<p>We start by creating a new instance of the JumpListManager passing the appID we’ve assigned to our app. Next we register to the UserRemovedItems event as this is required if we want to refresh the JumpList after adding items to it. In this case, we do nothing when any items are removed.</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2009/07/image4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2009/07/image_thumb4.png" width="649" height="49" /></a> </p>
<p>Here, we get the directory where the application is running as well as the app name itself, so we can tell the JumpList link what to invoke when it is clicked. Basically it’s emulating running your app from a command prompt and passing the arguments (if any). Now we can proceed to adding our JumpList items.</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2009/07/image5.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2009/07/image_thumb5.png" width="516" height="165" /></a> </p>
<p>I’ve mentioned we can add a few other things such as Recent Documents &amp; Frequent Documents&#160; but you’ll find lots of resources on this on the net as well as the samples for the library. In this case, we’re adding a new User Task to the jumplist which results in having these links under a “Tasks” header as below:</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2009/07/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2009/07/image_thumb1.png" width="306" height="229" /></a></p>
<p>Path, Arguments, and IconLocation are pretty self explanatory. </p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2009/07/image6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2009/07/image_thumb6.png" width="227" height="496" /></a> </p>
<p>I need to make sure my icons are available to my application so here I’ve placed all my custom icons in one directory and set the property so the IDE knows to copy these files to the output directory.</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2009/07/image7.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2009/07/image_thumb7.png" width="177" height="41" /></a> </p>
<p>After defining my JumpList links, I can call a Refresh on the JumpListManager so it loads up all my new links. After this, I make a call to my ProcessArguments method. This will make sure it runs the additional code if any arguments were passed when running the application. Of course, if you see that your users may want to run your app from a command line and pass arguments manually, you might want to put this call outside of the if statement or anywhere before your first form completes loading.</p>
<p>It’s that easy! If you got lost on the way, here’s the source to this project. If you manage to get your JumpLists going, feel free post a link to your app! <img src='http://aimeegurl.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p><iframe style="border-bottom: #dde5e9 1px solid; border-left: #dde5e9 1px solid; padding-bottom: 0px; background-color: #ffffff; margin: 3px; padding-left: 0px; width: 240px; padding-right: 0px; height: 66px; border-top: #dde5e9 1px solid; border-right: #dde5e9 1px solid; padding-top: 0px" marginheight="0" src="http://cid-bdfb7845c22e26b6.skydrive.live.com/embedrowdetail.aspx/Projects/TechFriday/Hello%20Windows%207.zip" frameborder="0" marginwidth="0" scrolling="no"></iframe></p>
<p><strong>RESOURCES:</strong></p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=12100526-ed26-476b-8e20-69662b8546c1">Windows 7 RC Training Kit for Developers</a></p>
<p>Managed APIs in this sample&#160; </p>
<ul>
<li>Windows 7 Taskbar &#8211; <a title="http://code.msdn.microsoft.com/Windows7Taskbar" href="http://code.msdn.microsoft.com/Windows7Taskbar">http://code.msdn.microsoft.com/Windows7Taskbar</a> </li>
</ul>
<p>Other Managed APIs available:</p>
<ul>
<li>Windows API Code Pack for Microsoft .NET Framework &#8211; <a title="http://code.msdn.microsoft.com/WindowsAPICodePack" href="http://code.msdn.microsoft.com/WindowsAPICodePack">http://code.msdn.microsoft.com/WindowsAPICodePack</a> </li>
<li>Windows 7 Taskbar Extensions &#8211; <a title="http://windows7taskbarext.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22682" href="http://windows7taskbarext.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22682">http://windows7taskbarext.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22682</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://aimeegurl.com/2009/07/10/techfriday-jumping-into-jumplists/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using the Facebook Developer Toolkit 2.0 for Canvas Based applications</title>
		<link>http://aimeegurl.com/2008/08/27/using-the-facebook-developer-toolkit-20-for-canvas-based-applications/</link>
		<comments>http://aimeegurl.com/2008/08/27/using-the-facebook-developer-toolkit-20-for-canvas-based-applications/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 16:03:26 +0000</pubDate>
		<dc:creator>Aimee</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Code Bits]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[facebook developer toolkit]]></category>

		<guid isPermaLink="false">http://aimeegurl.com/2008/08/27/using-the-facebook-developer-toolkit-20-for-canvas-based-applications/</guid>
		<description><![CDATA[<p id="top" />
<p>I missed the release of the latest version of the Facebook Developer Toolkit from clarity consulting so I decided to play around with it after our Mix It Up event.</p>
<p>There have been much changes to the toolkit since the last time I looked into it. It took me a few minutes to try [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />
<p>I missed the release of the latest version of the <a href="http://www.codeplex.com/FacebookToolkit">Facebook Developer Toolkit</a> from clarity consulting so I decided to play around with it after our <a href="http://www.microsoft.com/singapore/msdn/mixitup">Mix It Up</a> event.</p>
<p>There have been much changes to the toolkit since the last time I looked into it. It took me a few minutes to try to figure out how to get a simple application out. <a href="http://www.codeplex.com/FacebookToolkit/Release/ProjectReleases.aspx?ReleaseId=13985">The documentation posted here</a> is a bit outdated so let me post my own little how-to. They’ve actually made it a lot easier but the new API needs a bit of getting used to I guess. It’s a bit confusing as the APIs for CanvasFBMLBasePage is different from CanvasIFrameBasePage. I hope they standardize soon though. Considering that this is supposedly an RC, it doesn’t seem like they’ve settled on a convention yet.</p>
<p>So again, assumption is:</p>
<p>1. You’re using C# as your language</p>
<p>2. You’re building an app with the CanvasFBMLBasePage (haven’t tried out the Master Page yet.. baby steps my friend)</p>
<p>1. Visit <a href="http://www.facebook.com/developers">http://www.facebook.com/developers</a> and <a href="http://www.new.facebook.com/developers/editapp.php?new">Setup A New Application</a>. Expand the optional fields and set up your application, making sure you have the following details filled in:</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2008/08/image3.png"><img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="592" alt="image" src="http://aimeegurl.com/wp-content/uploads/2008/08/image-thumb2.png" width="611" border="0"></a> </p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2008/08/image4.png"><img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="90" alt="image" src="http://aimeegurl.com/wp-content/uploads/2008/08/image-thumb3.png" width="482" border="0"></a> </p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2008/08/image5.png"><img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="132" alt="image" src="http://aimeegurl.com/wp-content/uploads/2008/08/image-thumb4.png" width="518" border="0"></a> </p>
<p>2. Once you have successfully set this up, take note of your API Key and Secret:</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2008/08/image6.png"><img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="89" alt="image" src="http://aimeegurl.com/wp-content/uploads/2008/08/image-thumb5.png" width="230" border="0"></a> </p>
<p>3. Fire up Visual Studio 2008 and set up a new ASP.NET Web Application</p>
<p>4. Open up Default.aspx and remove everything but the first line (which is the page directive that says tells .NET which is the CodeFile. Your default.aspx should look something like this:</p>
</p>
</p>
<pre class="code"><span style="background: #ffee62">&lt;%</span><span style="color: blue">@ </span><span style="color: #a31515">Page </span><span style="color: red">Language</span><span style="color: blue">="C#" </span><span style="color: red">AutoEventWireup</span><span style="color: blue">="true"  </span><span style="color: red">CodeFile</span><span style="color: blue">="Default.aspx.cs" </span><span style="color: red">Inherits</span><span style="color: blue">="_Default" </span><span style="background: #ffee62">%&gt;
</span><span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">label </span><span style="color: red">ID</span><span style="color: blue">="Content" </span><span style="color: red">runat</span><span style="color: blue">="server" </span><span style="color: red">text</span><span style="color: blue">="Label"&gt;&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">label</span><span style="color: blue">&gt;
</span></pre>
<p>// For convenience, I added an asp.net label control where I would write out the <a href="http://wiki.developers.facebook.com/index.php/FBML">FBML</a> later on. If you’d rather use Response.Write() you could do that as well. Then you wouldn’t need to have the second line on Default.aspx</p>
</p>
</p>
</p>
</p>
<p>5. Before we dig into the CS files, we’ll need to add a reference to the <a href="http://www.codeplex.com/FacebookToolkit/Release/ProjectReleases.aspx?ReleaseId=13985">facebook dlls that we can download from codeplex</a>. Simply select to download bin.zip and it should give you the dlls necessary for you to build a Facebook app. Unzip this in a location you can easily find. Go to your Solution Explorer and right-click on your project –&gt; Add Reference</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2008/08/image7.png"><img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="image" src="http://aimeegurl.com/wp-content/uploads/2008/08/image-thumb6.png" width="220" border="0"></a> </p>
<p>Click on the Browse tab and navigate to where you extracted the binaries for the toolkit. You will want to add a reference to both facebook.dll and facebook.web.dll //yes, the non-caps irks me too.. wait till you see the classes *sigh*</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2008/08/image8.png"><img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="412" alt="image" src="http://aimeegurl.com/wp-content/uploads/2008/08/image-thumb7.png" width="483" border="0"></a> </p>
<p>When you finish adding these two necessaries, it’ll pull some other files along for the ride as well so don’t be surprised about that. </p>
<p>6. Now that’s finished, we can open up our .CS file and start by importing the necessary namespaces namely:</p>
<pre class="code"><span style="color: blue">using </span>facebook;
<span style="color: blue">using </span>facebook.web;</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>and then, make our class inherit from the CanvasFBMLBasePage class that is part of the toolkit. This base class should take care of all the nitty gritties of dealing with Facebook and making sure it knows who you are (or in this case, your application)</p>
<pre class="code"><span style="color: blue">public partial class </span><span style="color: #2b91af">_Default </span>: <span style="color: #2b91af">CanvasFBMLBasePage
</span>{
    <span style="color: blue">protected void </span>Page_Load(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e)
    {

    }
}</pre>
<pre class="code">&nbsp;</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>7. Before we proceed, lets add a snippet to our web.config file to set our APIKEY and secret. The base class will be looking at our web.config file for the values to use to authenticate with Facebook. All you need to do is find this section:</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2008/08/image9.png"><img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="96" alt="image" src="http://aimeegurl.com/wp-content/uploads/2008/08/image-thumb8.png" width="240" border="0"></a> </p>
<p>and replace it with something like:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">appSettings</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">add </span><span style="color: red">key</span><span style="color: blue">=</span>"<span style="color: blue">APIKey</span>" <span style="color: red">value </span><span style="color: blue">=</span>"<span style="color: blue">8e38f5fc72b989b8146dc91ece7e9b6a</span>"<span style="color: blue">/&gt;
  &lt;</span><span style="color: #a31515">add </span><span style="color: red">key</span><span style="color: blue">=</span>"<span style="color: blue">Secret</span>" <span style="color: red">value </span><span style="color: blue">=</span>"<span style="color: blue">d9a5bd957d3aa1c69316839f1543fce0</span>"<span style="color: blue">/&gt;
&lt;/</span><span style="color: #a31515">appSettings</span><span style="color: blue">&gt;</span></pre>
<p>of course put in the APIKey and Secret that was provided to you by Facebook. Don’t go using my key, it won’t work with your URL anyway <img src='http://aimeegurl.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Make sure you SAVE!</p>
<p>8. Going back to Default.aspx.cs, we can now proceed to add logic to our application.</p>
<pre class="code"><span style="color: blue">protected void </span>Page_Load(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e)
{
    <span style="color: blue">base</span>.Page_Init(sender, e); // this is the code that will call the base</pre>
<pre class="code">                               // methods that deal with authenticating </pre>
<pre class="code">                               // with facebook and all that mumbo jumbo</pre>
<pre class="code">&nbsp;</pre>
<blockquote><pre class="code"><span style="color: blue">if</span>(!IsPostBack)    {
    stringuid = <span style="color: blue">base</span>.API.uid.ToString(); <span style="color: green">// this is the code to retrieve</span></pre>
<pre class="code"><span style="color: green">                                          // the userid of the logged in user </span></pre>
<pre class="code"><span style="color: green">                                          //(the person accessing your application</span></pre>
<pre class="code">   Content.Text = <span style="color: #a31515">"&lt;fb:profile-pic uid='" </span>+ uid + <span style="color: #a31515">"'/&gt;"</span>;               // You can also do something </pre>
<pre class="code">   Content.Text+= <span style="color: #a31515">"hello, &lt;fb:name uid='"</span>+ uid + <span style="color: #a31515">"' useyou='false'/&gt;"</span>; // like Response.Write( </pre>
<pre class="code">                                                                       // <span style="color: #a31515">"&lt;fb:profile-pic uid='" </span>+</pre>
<pre class="code">                                                                       // uid + <span style="color: #a31515">"'/&gt;"</span>); for this part</pre>
<pre class="code">   Content.Text += <span style="color: #a31515">" you have "</span>+ <span style="color: blue">base</span>.API.friends.get().Count + <span style="color: #a31515">" friends so far "</span>; </pre>
<pre class="code">   <span style="color: green">//anything you need to know about your user, you will find from base.API – all your base are belong to us</span></pre>
<p><a href="http://11011.net/software/vspaste"></a>
<pre class="code">

<a href="http://11011.net/software/vspaste"></a>}}</pre>
</blockquote>
<p>9. Once that’s done, we can now go and publish our application by right-clicking on the project in solution explore and selecting publish</p>
<p>&nbsp;<a href="http://aimeegurl.com/wp-content/uploads/2008/08/image10.png"><img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="216" alt="image" src="http://aimeegurl.com/wp-content/uploads/2008/08/image-thumb9.png" width="266" border="0"></a> </p>
<p>Make sure you are publishing to the Callback URL you specified when you applied for the Application Key and Secret. </p>
<p>10. When you’re done publishing and you try to access the application, you should see something like this:</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2008/08/image11.png"><img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="349" alt="image" src="http://aimeegurl.com/wp-content/uploads/2008/08/image-thumb10.png" width="755" border="0"></a> </p>
<p>and when you click allow, you’ll get:</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2008/08/image12.png"><img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="211" alt="image" src="http://aimeegurl.com/wp-content/uploads/2008/08/image-thumb11.png" width="518" border="0"></a> </p>
<p>Some issues I noticed though is that when I try to access the application URL when I am logged out, Facebook tells me that the page cannot be found. But when I access it when I’m already logged in, it’ll prompt me to allow the application to access my information if i have not yet added the app. I’m checking with the forum on codeplex to see whether this is a Facebook issue or whether it’s the Tool&#8217;kit’s</p>
<p>Congratulations! You have now built your first FBML based Facebook application! Will let you know how far I go with this new framework.</p>
<p>It seems to be cleaner code right now, but I guess I’ll need to fool around with this to find out more. </p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
<p>Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://aimeegurl.com/2008/08/27/using-the-facebook-developer-toolkit-20-for-canvas-based-applications/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
