Jocelyn Mae Villaraza Singapore Philippines

Stuff

 

February 2010
M T W T F S S
« Jan    
1234567
891011121314
15161718192021
22232425262728

iPadding V1 – The Designer Story

imageWith the whole iPad buzz going around last week, I decided to build last friday’s TechFriday app around the theme.

Introducing iPadding v1! It’s basically a WPF application that allows you to drag and drop shortcuts onto the screen and save it for when it’s presentation time. My desktop is constantly cluttered and as much as I’d like to use the hide desktop icons features, I do want some shortcuts readily available. Even with the pinning feature of Windows 7, I just end up with a cluttered task bark instead Sad What I’ve been doing till now is creating a folder with the shortcuts of everything I want to show so i just have that pinned (or open by default) onto my taskbar.

So for TechFriday, I decided to make this little app that will store shortcuts in a window that looks like the iPad (or should i say P88?).

Version 1 includes the following features:

  • Drag & Drop items onto the screen
  • Click and Delete shortcuts that you want removed
  • Double-clicking to start an application
  • ClickOnce deployment enabling ease of deployment and distributing updates
  • and of course, clicking the button formerly know as the start button to save your shortcuts and shut down Smile

You can check out the application at http://bit.ly/b7893s and explore the source code here.

How I did it?

iPadding States

If you open up the project you’ll find the following state groups. (The third state is currently not supported in this release Smile)

image

The iPadLoading state simple sets the opacity of a canvas with the “broken window” logo to 100% while the iPadLoaded state does the reverse.

image

iPadding Components

For this version, we only have two major components to the app: icApps and btnStart

Let’s start with the btnStart as it is the easiest. This control is basically a styled button.

1. Start by adding a button onto the screen, then right-clicking, Edit Template –> Edit a Copy

image

You’ll then be prompted with a dialog box that will allow you to specify properties of this style. First is the Name, second is where you want to define the style in. The default is set to This Document which means the style will only be visible in this screen/page/usercontrol. Application will allow the style to be visible to the other pages/windows/usercontrols in the application. You can also select Resource dictionary to put the style in a separate file altogether and allow you to import the Resource Dictionary along with all the styles defined in it in other projects and applications.

image

 

For this button style, I made use of images to for 2 of the different button states: MouseOver and Normal.

image

The default style of the button contains the chrome and a ContentPresenter. The ContentPresenter is basically where Button.Content will be displayed. If you’ve been playing with WPF/Silverlight, you’ll know that you can not only assign text to as button contents, but images, videos and other controls as well.

In this case, I just want a simple image, so I can go ahead and delete the default contents and replace it with a grid that contains my button images. In this case, I added 2 images, one to depict the button in Normal state, and another on MouseOver state.

When you click on a state, you’ll notice the state recording turns on.Once this is so, you can start changing properties of your design elements to reflect your desired look.

imageimage

Now we’re pretty much done with the StartButton design. Let’s put in a stub where our developer can plug in the code to make the app function as it is supposed to. To do this, let’s first return to the Window Scope

image

Next, while the button is selected, go to the properties tab an click on events.

image

Once the tab is activated, you can type in the method name you want called on the Click event

image

Doing this will activate the XAML editor in Blend and automatically insert the method stub for you or your developer to fill in once you are ready to start filling in the application logic. Let’s leave this for now and go on to the next component.

image

The next control is icApps is a styled ItemsControl that will contain all the apps that you drag and drop into the window. Let’s first go to our Asset Library and drop in the ItemsControl onto our Window. You might want to drop it into a Grid to fix the layout.

image

Next, we need to think about how we want to layout the items in our control. If you look at the iPhone, the apps are actually lined up in a 4 x 5 grid. However, since in the future, I’d like to be able to resize the screen and have the apps line up depending on the space, I’ll use a WrapPanel to manage the layout. To do this, I’ll right-click on the ItemsControl –> Edit Additional Templates –> Edit Layout of Items – >Edit a Copy. Again this will bring you a dialog box that will allow you to name and specify where you want your style created.

image

You’ll notice that the default layout is a StackPanel, but we’ll go ahead and change this into a WrapPanel.

image

You might also want to ensure that the ScrollBarVisibilities are properly set. I’ll be disabling scrolling for this version till I figure out how I want to page / scroll through my items.

image

Now that we have the layout set, we’ll now take a look at the template for generated items. So same as before, right-click on the ItemsControl -> Edit Additional Templates –> Edit Generated Items –> Edit a Copy. If you’re wondering why it’s “Edit a Copy”, WPF controls come with default templates that developers and designers can easily replace but because Blend needs to have a fall back in cases of new controls, the default templates are stored somewhere and are read-only for us. But we can always create our own style and set it as a default for all the controls in our project by selecting Apply to All in the Create Style Resource dialog.

I want the Apps to be visualize as buttons that can get focus when clicked so that the users can delete them if he chooses to, and launch the application when double clicked. I don’t want to recreate a control as the Button control can pretty much do what I need it to do. So what I’ll do in my data template is add a 120×120 grid to constrain the button size, and put a button inside and style it as I want and for this I’ve created a style called AppButton style. that has the following:

imageYou’ll notice that since I’m styling a button, the template already comes with the common button states such as MouseOver and FocusStates. This will make it much easier for me to fix my controls visuals through states instead of having to code it all up myself.

If you look at the object tree, I have an image will I will later on show how I tie up to the Icon of whatever shortcut is dragged into my app. I have a text block that will also display the name of that shortcut, and two rectangles that will basically be my MouseOverVisual and FocusVisual. Both these visuals have an opacity of 0% by default, and I simply edit the corresponding states to set the opacity to 100%.

I mentioned that for the image and text block, I wanted it to be bound to whatever the icon and name was used in the shortcut dragged into the app. Later on we’ll be using the ShellObject defined in the http://code.msdn.microsoft.com/WindowsAPICodePack The ShellObject data object has quite a number of properties but the one I’m intersted in would be Thumbnail, which is an Icon object which in turn has a MediumBitmapSource (medium because we’re looking at displaying bigger icons than the ones we see in details view of explorer) and Name, which will hold the filename on the shortcut.

As a designer, all I care about would be that those two properties of the data object will be present when the time comes. I can use data binding to link the properties of the data object with properties in my UI.

First off is the TextBlock. With the the TextBlock selected, I’ll head over to the properties panel and look for the text property since this is what I want to bind to the Name property of the data object. I can do so by clicking on the button right beside the Text textbox.

image

I’ll then select Data Binding.

image

You can data bind this the Text property to virtually anything as you’ll see in the dialog box that pops up, from data fields, to other elements properties. In this case, since we don’t have access to our data objects just yet, I’ll go straight to Explicit Data Context and tick the “Use a custom path expression” and put in the Name property. Again as a designer, I don’t have to care where that value comes from but i know that whatever data object is bound to this button, I’ll get access to a property called Name that will hold the name of the application or shortcut of the app I want to run.

image

I’ll do the same for the img object with the source property. This time, I’m binding it to “Thumbnail.MediumBitmapSource” since my developer tells me, there’s an existing object that we can use and that property is going to give me the filename of the icon i can use in my button.

image

Now that’s done, let’s help out our developer a little bit.We’ve decided that the behavior of this app is such that if a button is clicked, it’ll bring focus to that button. This is already the default behavior of a button and since we’ve only styled a button and not made our own, we won’t have to worry about building that behavior. The next behavior is that when double clicked, it runs the application associated with it. To do this, let’s exit scope one level up to the AppButton. We can either do as we did previously by clicking on the up arrow imageor by clicking AppButton on the bread crumb bar at the top of the XAML designer page: image 

With the AppButton selected, we’ll go to the events tab imageon the Properties page, go to MouseDoubleClick and type in a name of method that will hold the code to run the shortcut associated to the button. imageOnce we press enter, we’ll be brought to the code behind and we can write a little note to our developer to put in that piece of code here. If as a designer, later on you feel that it’ll be better to have the application run at a different event, you can simply move that method name to another event in the events list, and your developer won’t have to change their code.

image

Once that’s done, we can exit again till we’re all the way up on the window level. What we have done is basically create an ItemsControl with our custom style that displays a square button and a text block (as well as some visuals for mouse over and focus states). We’ve styled these buttons in such a way that the images and textblocks are bound to properties Name and Thumbnail.MediumBitmapSource. The idea here is that our developer will eventually bind this ItemsControl with a list of ShellObjects which we are told have those properties. Each shell object will be bound to a generated item with the template we defined. We’ve also created a method for our developer to implement that runs the associated application when the button is double clicked.

Next post will cover the developer portion of this application. Smile For now, you can download and try out the application on http://www.badgorilla.net/ipadding

New Year Deserves A New Post

I have a good feeling about 2010. I think this year is going to be a year of change. I just realized that this year I’ll be turning 27 and that to me is just a bit scary. I still have a lot that I want to do and if I don’t start putting my mind to it, it’ll never happen. When I first thought of coming to Singapore, I had a plan in mind: That I would do SG for 1 or 2 years, then AUS, then the US. Somewhere along the way, I got a bit sidetracked :) What can I say, Singapore is definitely a great place to work. Here everything just works AND you feel safe at all times. I realized though that I’m getting a biiit too comfortable with the way things are around here. I’m just scared that before I know it, I might be permanently trapped in this  comfort zone and forget that I should be moving around while I still can. So this year will probably be the year I start exploring again. It was supposed to be last year but I guess we all know the world wasn’t in that great a shape. Hopefully, this year will be different. I’m looking forward to new things in my life. People back home are experiencing lots of new things from a different aspect in life. I can’t have that just yet, but I  would also want something to be excited about. Hopefully this year will be the year. :)

You’re probably wondering where the new year’s resolutions are. Well, there aren’t going to be any this year.  As per experience, they just don’t work. :p But one thing’s for sure, 2010 sounds like a great year. And I’m looking forward to making it so.

Pickupflowers.com Review

image 

Doesn’t guarantee mean anything anymore?

I call BS on this as I’ve had a TERRIBLE experience.

I made an order with them on 22nd of December, specifically because they had a statement on their site that they guarantee delivery on or before Christmas. I received a confirmation email with the following note: "Order Before 12/23/09 5:00 AM*CDT time for assured delivery of this gift to your loved one on or before Christmas." And since the deliveries are made through local florists, as stated http://www.pickupflowers.com/info/about-us that’s not hard to believe.

On the 23rd, i went online with their Live Assistance CSR inquiring about the order. I was told that the order was "delivered to the recipient". So I contact my recipient and ask about the delivery and he says he hasn’t received anything.

On the 24th, I send an email to customer service asking for the details of the so called delivery to ask who has signed for it – No response.

On the 25th I call their CSR informing them that I’ve spoken to the intended recipient and that he hasn’t received any packages which they had claimed they delivered and would like to know when and to whom exactly they delivered the package to. He said he would check with their local agent. I mention to him that if this doesn’t get delivered on or before 27th, I would like to cancel the order as the recipient will have left the place of delivery on the 28th (local time). He says he will check with the local agent and get back to me. I ask HOW he will get back to me, and he says he will send me an email.

On the 26th, I send an email to the CSR stating i am still waiting on feedback regarding my order. At this point, I’m assuming the order has gotten delivered to the wrong place or whatever so I tell them i hope i will not be seeing a bill for this.

I finally got a reply from their CSR email address, apologizing for the inconvenience, and that they were still waiting for the reply of the local agent regarding the non delivery of the order and that they would get back to me immediately after receiving the information from them.

On the 29th, i reply to them expressing my dissatisfaction with their service and informing them that the recipient has already left the place of delivery.

Later on in the day, I check my credit card account and notice that I was charged for this service. I send them an email wanting to know why i was charged for an order that was never delivered. – No response

I contact their Live Assistance and explain my situation. They went on about explaining the weather conditions hence the order was not fulfilled in time but that it was going to be delivered “today”. How they will manage, that i have no idea as the recipient had already left. My biggest issue is that I was told it was delivered to the recipient when in fact it was not, and now they’ve delivered it when the recipient is no longer there.

Then he goes on to tell me that as a token of their apology they will refund me 50%. Not 50% plus the order value, but 50% OF the order value.

So in effect, paid the 50% for the stress of having to chase after their customer service people to tell me what was going on, and for not having been able to a gift of Christmas cheer to the intended recipient.

image

In summary, i guess you can say i won’t be joining their "more than 100,000 satisfied customers across 80 countries".

This rant has also been posted on http://bit.ly/6YTzgy for the benefit of everyone who is evaluating delivery companies to entrust with something as sacred as delivering flowers and the like.

Happy Holidays Everyone!

I was listening to some Christmas music today and the holiday spirit got the best of me. I managed to make a customizable e-greeting card using Silverlight 4. Since MS has only released a developer beta and no go-live license, users will have to manually download the Silverlight 4 beta plugin. I modified the html code that the Silverlight SDK spits out to show this image and redirect it straight to the Silverlight Tools Page:

MerryChristmas

I didn’t want to reinvent the wheel so I used some code that was already out there:

http://www.wintellect.com/CS/blogs/jprosise/archive/2009/07/17/fun-with-savefiledialog-and-writeablebitmap.aspx

- Code to encode an image to PNG and save to local hard drive

http://channel9.msdn.com/learn/courses/Silverlight4/MagicMirror/MagicMirror/

- Silverlight 4 code to capture images from a Web Camera and Print

Tools I used:

Visual Studio 2010 Beta 2 

Microsoft Expression Design

Microsoft Expression Blend Preview for .NET 4

And here’s the app! And yes, this qualifies for a TechFriday cause Christmas is on a— FRIDAY!

Tip the Day: watch videos on extended monitor while working on primary

Have you ever tried watching a code walkthrough video, wanting to follow along with visual studio but have a hard time because the video players are too small for you to read the code? and when you do full screen, you’ll have to pause and play while you “unfullscreen” to switch to Visual Studio to follow along?

image

The solution is simple: browser zoom is your friend. Most of the online video players are configured to be scalable so you can actually do the following:

1. Set your browser to full screen (F11 for IE8)

2. Set the zoom level to a comfortable size.

image

As you can see in the screen shot above, I’m able to watch the video on my extended monitor, at a size where i can read the code comfortably, while still being to work on my primary screen. :)

Making Your Win7 JumpLists Trigger on the Same Application Instance

As promised in my previous post, I’ll be talking about how to create jumplist integrated single instance applications, much like how Outlook, Windows Media Player.

At first, i thought it would need to involve a bit of windows messaging but then I found this blog post that details how to create single instance WPF applications. I rewrote our sample from the previous post to adopt this model. I based my code on the post so I recommend reading that post first to have a better understanding of how we are creating this single instance application.

Explaining a bit what is going on here, we basically have 3 major classes:

image

The SingleInstanceManager, as the name implies, manages the instances of your application. If you take a look at the code, basically it creates an instance of your application if it is an initial startup. When a next instance is triggered to start up, it activates the the MainWindow through Win7Application and processes any arguments passed in the triggering of the subsequent instances.

Win7Application is basically our replacement for App.xaml because we want to be able to control when we activate the MainWindow of our application. We also process any arguments of our application in this class.

  public void ProcessArgs(string[] args, bool isFirstInstance)
        {
            if (args.Length > 0)
            {
                if (isFirstInstance)
                    AppWindow.initState = args[0];
                else
                    AppWindow.updateState(args[0]);
            }

        }

If you look at the ProcessArgs method in the sample attached, we’re basically setting an initial state (initState) property to the value of the argument as this is expected from the jumplists we have defined in my previous post. If this is not the first instance, we call the updateState() method which I have exposed as a public method in the MainWindow class. 

These are basically the changes I made to MainWindow.xaml.cs:

        private void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {

            WindowJumpList = JumpList.CreateJumpList();
            initializeJumplist();
            if (initState != null)
                updateState(initState);

        }
        public  void updateState(string state)
        {
            ExtendedVisualStateManager.GoToElementState(LayoutRoot, state, true);

        }

You can download the source here:

Gone Grey!

80s

Managing WPF Screens with Windows 7 Jumplists and the Visual State Manager

We’re having our Singapore launch of Windows 7 this November and in honor of that, I’ll be devoting my upcoming (and long overdue) TechFridays to everything Windows 7. For this post, I’ll be talking about how you can use the Visual State Manager for WPF to manage the different screen states in your application in conjunction with your Windows 7 Jumplists.

Before we start, make sure you have the following downloaded:

1. WPF Toolkit – This enables VSM support in current WPF projects

2. http://code.msdn.microsoft.com/WindowsAPICodePack – provides managed wrappers that allow you to easily incorporate Windows 7 JumpLists into your application

* make sure you add references to the above binaries and your set to go.

If you’re not familiar with the Visual State Manager, you can read http://windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-visual-state-manager-overview.aspx for a brief overview.

What I have is an application with several screens grouped into panels. I also have a visual state group “ScreenStates” where i have 3 states, one for each screen.

image

This should make for easier screen management. You can make use of Blend behaviors to activate these states on the click of the corresponding navigation button / link. If you open up the Behaviors tab in the asset library, you’ll find the GoToStateAction that you can click and drag onto the appropriate control that you want to trigger the state activation.

image

In the screen below, I added the behavior to my GalleryButton. On the properties panel, you’ll see that you can set the StateName you want to activate on the trigger, in this case, the GalleryButton’s Click event.

image

Next we we want to enable Windows 7 Jumplists in our application. Windows 7 is all about helping users become more efficient and one of the features that enable this is the jumplist. Below is a screenshot of Outlook’s jumplists. The application basically exposes tasks that would normally take a few clicks to get to so instead of having to spend the time starting the app and clicking the appropriate menus/options, you jump straight into the screen you want.

image

Below is one way you can integrate jumplists into the app we are building. First, you’ll need to define and initialize a few variables we will be needing to manage the jumplist: the Jumplist itself, and the folder where the assembly is executing.

        private JumpList WindowJumpList;
        string executableFolder;

	private void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
	{
			// TODO: Add event handler implementation here.
            WindowJumpList = JumpList.CreateJumpList();
            executableFolder = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            initializeJumplist();
            string[] arguments = Environment.GetCommandLineArgs();
            if (arguments.Length > 1)
            {
                ProcessArguments(arguments[1]);
            }
	}

The following code then initializes the jumplist. Note that the tasks are shell links to the application executable, with the state names of our screens as the arguments. This will make it easier later on to process the arguments and activate the appropriate screen.

image

The last method is the ProcessArguments method. There is a slight kink in the VisualStateManager that won’t allow you to “go to state” as you normally would unless the target is a UserControl. In this case, we had to use a work around which i found here

image

when you compile and run your app, you’ll see the following jumplist tasks and will be able to activate the corresponding screens straight from the jumplist.

image

image

You can download and try out the code here:

This version launches a new instance every time you click on a task on the jumplist. In my next post, I’ll post a sample on how to create jumplist enabled single instance WPF applications. Till next time!

First long distance bike ride!

Last weekend, my team at work had an outing at East Coast Park and thanks to @nenggiin we had an awesome time, going on a pseudo scavenger hunt on bikes.  :) Prior to that, I think the last time I remember being on a bike was when I was 8 years old. Back then, I had pink bike with training wheels. My granddad used to take us out in the afternoon at the plaza beside our house. When I grew older, I didn’t really get into riding bikes and I never went past using them without the training wheels :|

Suffice it to say that last Friday was definitely interesting for me. You know how they say that you never forget how to ride a bike. Well I was a bit ambitious and thinking that applied to folks who had training wheels on. But the good news is I somehow managed :) Well, I did crash into a tree and a few bushes a couple of times but nothing more than a few bruises. It was well worth it though, we definitely had a lot of fun that day. And I have to say, I felt proud of myself for being able to ride a bike, even though I still had to learn how to turn and to stop. :p

I was proudly telling my story to the F when we decided to check out some bikes during the weekend. We both thought it would be fun to be able to just cycle around to the nearer-by places we go to and getting some exercise while we’re at it. We went bike hunting on Sunday. At first aiming for Carrefour, we saw a bike shop somewhere around Tanglin Road and stopped to browse there. Sure enough, we found our bikes in less than an hour and were already excited to ride them home. We were extremely disappointed when after we paid, they told us that they would be delivering it the following day.

That was just as well because on Monday when the bikes arrived and we took it out for a spin, I was back to my old clumsy mode and I could barely get going! In my mind, I was starting to regret buying the bike so impulsively :S With F’s patience, I eventually got going again except for when there were people around. For some reason, the more I try to evade them, the more I seem to be aiming towards them. Eventually we gave up for the day, but there was a spark of hope that I might be able to pull this off eventually.

We decided it would probably be better to cycle at night when there are less cars too so I could at least ride on the road sometimes instead of the narrow sidewalk where I can’t manage to maintain my balance enough to let other people pass. Yesterday, we went out and bought some lights for the bikes and today, on my runner friend Eugene’s suggestion, went for the Park Connector nearby. Surprisingly, the ride was much better today, although I still managed to crash myself into a garbage bin but that’s alright. Judging by the way the oncoming biker laughed, at least I made someone’s day by providing some comic relief.

This was the route we took:

 

and of course, here’ is the bike:

photo

I had an awesome time today, except for the part when we had to ride through a path surrounded with, I would say easily 10-15 barking dogs. :| I like dogs, and I don’t mind barking ones either. But I realized while I was on that path, the number of barking dogs make a difference. So yes, maybe not pass by that part of the route next time.

TechFriday: Jumping into Jumplists

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)

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 )

image

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.

image .

For this example, we’ll learn how to use our applications existing custom functions (and icons) with Windows 7 jumplists but first, download the Windows 7 Taskbar Developer Resource

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.

image

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.

private void ProcessArguments()
{
    string[] args = Environment.GetCommandLineArgs();

    if (args.Length > 1)
    {
        if (args[1].Equals("/r"))
        {
            LoadRedScreen();
        }
        else if (args[1].Equals("/g"))
        {
            LoadGreenScreen();
        }

    }
}

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).

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

using Windows7.DesktopIntegration;
using System.IO;
using System.Reflection;

Next we add the following properties to the form:

string appID = "Hello Windows 7";
JumpListManager jlm;
    

The key thing here is the JumpListManager but if you want more information on the appID and all the goodness it brings, visit http://windowsteamblog.com/blogs/developers/archive/2009/06/18/developing-for-the-windows-7-taskbar-application-id.aspx. The next thing I have to do is override

protected override void WndProc(ref Message m)
{
    base.WndProc(ref m);
}

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:

OperatingSystem os = Environment.OSVersion;
if ((os.Version.Major == 6 && os.Version.Minor >= 1) || os.Version.Major > 6)
{
    //some code
}

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.

if (m.Msg == Windows7Taskbar.TaskbarButtonCreatedMessage)
{
    try
    {

        jlm = new JumpListManager(appID);
        jlm.UserRemovedItems += delegate { };

        string strAppDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
        string app = Assembly.GetEntryAssembly().GetName().Name + ".exe";

        jlm.AddUserTask(new ShellLink
        {
            Title = "Color it Red!",
            Path = Path.Combine(strAppDir, app),
            Arguments = "/r",
            IconLocation = Path.Combine(strAppDir, @"ico\Red.ico")

        });

        jlm.AddUserTask(new ShellLink
        {
            Title = "Color it Green!",
            Path = Path.Combine(strAppDir, app),
            Arguments = "/g",
            IconLocation = Path.Combine(strAppDir, @"ico\green.ico")
        });
        jlm.Refresh();

        ProcessArguments();
    }
    catch (Exception)
    {

    }

Let’s break this down.

image

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.

image

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.

image

I’ve mentioned we can add a few other things such as Recent Documents & Frequent Documents  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:

image

Path, Arguments, and IconLocation are pretty self explanatory.

image

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.

image

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.

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! :)

RESOURCES:

Windows 7 RC Training Kit for Developers

Managed APIs in this sample 

Other Managed APIs available: