本文整理匯總了C#中System.Windows.Shell.JumpList類的典型用法代碼示例。如果您正苦於以下問題:C# JumpList類的具體用法?C# JumpList怎麽用?C# JumpList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JumpList類屬於System.Windows.Shell命名空間,在下文中一共展示了JumpList類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: JumpList_JumpItemsRejected
//引入命名空間
using System.Text;
using System.Windows;
using System.Windows.Shell;
namespace JumpListSample
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private void JumpList_JumpItemsRejected(object sender, System.Windows.Shell.JumpItemsRejectedEventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0} Jump Items Rejected:\n", e.RejectionReasons.Count);
for (int i = 0; i < e.RejectionReasons.Count; ++i)
{
if (e.RejectedItems[i].GetType() == typeof(JumpPath))
sb.AppendFormat("Reason: {0}\tItem: {1}\n", e.RejectionReasons[i], ((JumpPath)e.RejectedItems[i]).Path);
else
sb.AppendFormat("Reason: {0}\tItem: {1}\n", e.RejectionReasons[i], ((JumpTask)e.RejectedItems[i]).ApplicationPath);
}
MessageBox.Show(sb.ToString());
}
private void JumpList_JumpItemsRemovedByUser(object sender, System.Windows.Shell.JumpItemsRemovedEventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0} Jump Items Removed by the user:\n", e.RemovedItems.Count);
for (int i = 0; i < e.RemovedItems.Count; ++i)
{
sb.AppendFormat("{0}\n", e.RemovedItems[i]);
}
MessageBox.Show(sb.ToString());
}
}
}
示例2: MainWindow
//引入命名空間
using System;
using System.IO;
using System.Windows;
using System.Windows.Shell;
namespace JumpListSample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void AddTask(object sender, RoutedEventArgs e)
{
// Configure a new JumpTask.
JumpTask jumpTask1 = new JumpTask();
// Get the path to Calculator and set the JumpTask properties.
jumpTask1.ApplicationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.SystemX86), "calc.exe");
jumpTask1.IconResourcePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.SystemX86), "calc.exe");
jumpTask1.Title = "Calculator";
jumpTask1.Description = "Open Calculator.";
jumpTask1.CustomCategory = "User Added Tasks";
// Get the JumpList from the application and update it.
JumpList jumpList1 = JumpList.GetJumpList(App.Current);
jumpList1.JumpItems.Add(jumpTask1);
JumpList.AddToRecentCategory(jumpTask1);
jumpList1.Apply();
}
private void ClearJumpList(object sender, RoutedEventArgs e)
{
JumpList jumpList1 = JumpList.GetJumpList(App.Current);
jumpList1.JumpItems.Clear();
jumpList1.Apply();
}
private void SetNewJumpList(object sender, RoutedEventArgs e)
{
//Configure a new JumpTask
JumpTask jumpTask1 = new JumpTask();
// Get the path to WordPad and set the JumpTask properties.
jumpTask1.ApplicationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "write.exe");
jumpTask1.IconResourcePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "write.exe");
jumpTask1.Title = "WordPad";
jumpTask1.Description = "Open WordPad.";
jumpTask1.CustomCategory = "Jump List 2";
// Create and set the new JumpList.
JumpList jumpList2 = new JumpList();
jumpList2.JumpItems.Add(jumpTask1);
JumpList.SetJumpList(App.Current, jumpList2);
}
}
}