Win7 Jump List

Probably about the new Win7 features just lazy person hasn’t written, and a lot of reviews on the internet on how to apply it. I noticed that reading technical articles, which simply tell show to apply, or that tool is not very interesting. Much more interesting when technology is used on a particular useful example, resulting in a small useful program. Of course, this turns out not always, but lately I’ve been more and more I try to do.

Thus, we’ll solve the following problem: I have a lot of icons in the taskbar is attached. 2 studios, SQL Server, Expression studio, office applications, browsers – all this would be helpful to group and to the default run basic applications.

The main functional

To get started with a Quick Jump List you need to download Windows API Code Pack. After this create any project which in the end will create the window for user, it’s no need to show. I decided to train on WPF. So we have a project that creates a window. As a result, empirically it was found that the code to create “jump list” may be placed only after fully initialize at least one window (usually main). So in my opinion, to create a suitable response to the end of the loading window.

private void Window_Loaded(object sender, RoutedEventArgs e) {
    CreateJumpList();
}

The list of actions (programs) will be based on some of the data entered by the user.You need to know:

  • The Way to the program
  • Name to display
  • Will it be the default action

For these data, I created a small class

[Serializable]
public class LinkInfo {
    public string Name { get; set; }
    public string AppPath{ get; set; }
    public bool IsDefault{ get; set; }
}

I did not bother to check and so on, because this example, and remember that only 20% of the time spent on writing the functional. I did not want to spend more time than you need, everything else can be finished alone.

Suppose we have already a list of items LinkInfo, and we build the actual “just list.”First, add references to namespaces and Microsoft.WindowsAPICodePack.Shell and Microsoft.WindowsAPICodePack.Taskbar, then it is already possible to write real code.

Let’s start with the creation of the Jump List and categories.

var JList = JumpList.CreateJumpList();
JList.ClearAllUserTasks();

var category = new JumpListCustomCategory("Tools");

JList.AddCustomCategories(category);

Все просто и логично, вот что я люблю! =) Создание элементов списка тоже не будет rocket science.

settings.Links.ForEach(item => {
     var link = new JumpListLink(item.AppPath, item.Name) {
                     IconReference = new IconReference(item.AppPath, 0 );  };
     category.AddJumpListItems(link);
});

If an application has a few icons, you can specify it through a resource id when creating indetificator IconReference.
To separate one category from another, you can use the following code:

JList.AddUserTasks(new JumpListSeparator());

You can add links to websites, and the folder. The way is a string, and the system will calculate what meant.

JList.AddUserTasks(new JumpListLink("http://violet-tape.net", "Violet Tape"));

JList.AddUserTasks(new JumpListLink("C:\\temp", "Temp") {
            IconReference = new IconReference(setTools, 0)
});

In general, the behavior of clicking on links can be described like this: “Run this is where I show and how – puzzle out youself!”

Additional Functionality

Do not dwell in detail on how to save and load settings and stuff like that. Let’s talk about the very small nuances of the application.
Once we have assigned the default application, call our program should run the necessary program and this complete its activity (close). And at the same time we must be able to tweaking the program after the appointment of CDS programs. Yes, let’s look at the start arguments .
It is necessary to make the point in “just list” to launch the program in setup mode. Let us for this parameter will be «-s». Then the entry in jump list will be such

var setTools = Assembly.GetExecutingAssembly().Location;

var link = new JumpListLink(setTools, "Set tools") {
         IconReference = new IconReference(setTools, 0),
         Arguments = "-s"
};

As you can see, nothing does not restrict us in the construction of list items. You can pass the start arguments to the applications, the working directory, as well as the form in which to show the window – minimize, maximize, as it is (and more)
About how to work with arguments and application properties discussed earlier, so do not dwell on it.

Conclusion

This could be the starting point of the program. You can still realize a lot of things and of course to work on optimizing the code. Do not update the data as done in this program, use MVVMLight! =) The next article will continue to work on this program, to use the new features done Win 7.

Hard’n’heavy!

Tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>