Jump Lists for Windows 7 Taskbar Development

  

In this article, we begin to introduce another highlight of the taskbar: Jump Lists (hereinafter referred to as JL). JL allows users to quickly and easily find the files (documents, images, audio or video, etc.) and links or shortcuts to the application. Take the IE browser as an example to see what features JL has:


· In the red area "Taskbar Tasks", some default tasks of the application are placed: "Open IE browser", "Unpin from the taskbar", "Close the program". Regardless of whether you have developed a "Taskbar Tasks" list for JL, it will appear in all applications, such as the previous instance program (as shown below).


· “User Tasks” contains some of the features provided by the application itself, through which you can directly manipulate the application. For example, open a new IE tag.

· “Known Category” This list is the Windows 7 default category and contains three modes: “Recent”, “Frequent”, “Neither”. The following picture shows the Frequent mode. Its function is to record the content of the frequently viewed webpage so that it can be browsed again in the future. As time goes by, the webpage link in the list will change or disappear. In addition to the "Known Category" list, you also create a "Custom Category" (more on this later).

· “Pinned Category” As mentioned above, the pages in the “Frequent Category” list will change frequently. You can make it permanent by right-clicking the page in the list (as shown below).


Create a User Tasks List

Now I want to add a JL to my program. Let's first introduce how to create a User Tasks list. 1. Create a JL instance from the JumpList class. 2. Use the JumpListLink(string pathValue, string titleValue) method (pathValue: application path, titleValue: link name) to create Windows applications such as "Notepad" and "Artboard" and "Website Address" as User Tasks. link. 3. Add these links to the JL using the AddUserTasks(params IJumpListTask[] tasks) method. The following code shows:

private JumpList jumpList;
private string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
private void addAPPS_Click(object sender, RoutedEventArgs e)
{
IJumpListTask notepadTask = new JumpListLink(Path.Combine(systemPath, "notepad.exe"), "Notepad")
{
IconReference = new IconReference(Path.Combine(systemPath, "notepad.exe") , 0)
};

IJumpListTask paintTask = new JumpListLink (Path.Combine (systemPath, "mspaint.exe"), "Paint")
{
IconReference = new IconReference (Path .Combine (systemPath, "mspaint.exe"), 0)
};

IJumpListTask jlSeparator = new JumpListSeparator ();

IJumpListTask linkTask = new JumpListLink ( "http: //Gnielee.cnblogs.com", "GnIE's Blog")
{
IconReference = new IconReference ( "C: \\\\ Program Files \\\\ Internet Explorer \\\\ IExplore.exe", 0)
};

jumpList.AddUserTasks (notepadTask, paintTask, jlSeparator, linkTask);
jumpList.Refresh();
}

In the above program, "program link" (JumpListLink, where IconReference is the link icon) and "JumpListSeparator" are created through the IJumpListTask interface; use AddUserTasks Pay attention to the positional relationship of each link; you must use the Refresh method to refresh the JL to display the latest JL content (the following effect diagram).


Creating a Known Category List

Before using the Known Category feature, you need to register the file type for the program. Then you can preset the Known Category to "Recent" via the KnownCategoryToDisplay property. ", "Frequent", "Neither", when the test program opens a file, the corresponding file link will be displayed in the Known Category list. The following code shows:

if (!UtilitIEs.IsApplicationRegistered(TaskbarManager.Instance.ApplicationId))
{
UtilitIEs.RegisterFileAssociations(TaskbarManager.Instance.ApplicationId, false,
TaskbarManager.Instance .ApplicationId, Assembly.GetExecutingAssembly().Location,
".jpg", ".png", ".gif", ".JPG", ".PNG", ".GIF");
} < BR>jumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;
CommonOpenFileDialog cfd = new CommonOpenFileDialog();
cfd.ShowDialog();
jumpList.Refresh();

Open the demo.png file Post-JL effects:


The JumpListKnownCategoryType enumeration defines three types of Known Category: "Neither", "Recent", "Frequent", and can also be modified by the KnownCategoryOrdinalPosition property. Category in JL:

switch (this.knownCategory.SelectionBoxItem.ToString())
{
case "None":
jumpL ist.KnownCategoryToDisplay = JumpListKnownCategoryType.Neither;
break;
case "Recent":
jumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;
break;
case "Frequent":
jumpList. KnownCategoryToDisplay = JumpListKnownCategoryType.Frequent;
break;
}
jumpList.KnownCategoryOrdinalPosition = Convert.ToInt32(this.categoryPostion.SelectionBoxItem.ToString());
jumpList.Refresh();

The effect of modifying Recent to Frequent:


Creating a Custom Category list

Like the way the JumpList was created above, 1. Creating a custom by using the JumpListCustomCategory class Classification" list instance. 2. Name the list by the JumpListCustomCategory(string categoryName) method. 3. Add the link to the category using the AddJumpListItems method. The following code shows:

private JumpListCustomCategory customCategory;
private void addCus_Click(object sender, RoutedEventArgs e)
{
if (this.categoryName.Text.Length > 0)
{
customCategory = new JumpListCustomCategory (this.categoryName.Text);
jumpList.AddCustomCategorIEs (customCategory);.

JumpListLink jlItem = new JumpListLink (Assembly.GetExecutingAssembly () Location, this.categoryName .Text + ".png")
{
IconReference = new IconReference(Assembly.GetEntryAssembly().Location, 0)
};
customCategory.AddJumpListItems(jlItem);
jumpList. Refresh();
}
}




KnownCategoryOrdinalPosition effect

IconReference in the above code From the application's own Icon property, provided that you need to set an icon for it in the application properties. (As shown below). At this point, the development of the taskbar in Windows 7 has been completed, I hope this series is helpful to everyone.



Copyright © Windows knowledge All Rights Reserved