123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Diagnostics.CodeAnalysis;
- using System.IO;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading;
- using System.Windows;
- using System.Windows.Markup;
- using Standard;
- namespace Microsoft.Windows.Shell;
- [ContentProperty("JumpItems")]
- public sealed class JumpList : ISupportInitialize
- {
- public static void AddToRecentCategory(string itemPath)
- {
- Verify.FileExists(itemPath, "itemPath");
- itemPath = Path.GetFullPath(itemPath);
- NativeMethods.SHAddToRecentDocs(itemPath);
- }
- [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
- public static void AddToRecentCategory(JumpPath jumpPath)
- {
- Verify.IsNotNull<JumpPath>(jumpPath, "jumpPath");
- JumpList.AddToRecentCategory(jumpPath.Path);
- }
- public static void AddToRecentCategory(JumpTask jumpTask)
- {
- Verify.IsNotNull<JumpTask>(jumpTask, "jumpTask");
- if (Utility.IsOSWindows7OrNewer)
- {
- IShellLinkW shellLinkW = JumpList.CreateLinkFromJumpTask(jumpTask, false);
- try
- {
- if (shellLinkW != null)
- {
- NativeMethods.SHAddToRecentDocs(shellLinkW);
- }
- }
- finally
- {
- Utility.SafeRelease<IShellLinkW>(ref shellLinkW);
- }
- }
- }
- public static void SetJumpList(Application application, JumpList value)
- {
- Verify.IsNotNull<Application>(application, "application");
- lock (JumpList.s_lock)
- {
- JumpList jumpList;
- if (JumpList.s_applicationMap.TryGetValue(application, out jumpList) && jumpList != null)
- {
- jumpList._application = null;
- }
- JumpList.s_applicationMap[application] = value;
- if (value != null)
- {
- value._application = application;
- }
- }
- if (value != null)
- {
- value.ApplyFromApplication();
- }
- }
- public static JumpList GetJumpList(Application application)
- {
- Verify.IsNotNull<Application>(application, "application");
- JumpList result;
- JumpList.s_applicationMap.TryGetValue(application, out result);
- return result;
- }
- public JumpList() : this(null, false, false)
- {
- this._initializing = null;
- }
- public JumpList(IEnumerable<JumpItem> items, bool showFrequent, bool showRecent)
- {
- if (items != null)
- {
- this._jumpItems = new List<JumpItem>(items);
- }
- else
- {
- this._jumpItems = new List<JumpItem>();
- }
- this.ShowFrequentCategory = showFrequent;
- this.ShowRecentCategory = showRecent;
- this._initializing = new bool?(false);
- }
- public bool ShowFrequentCategory { get; set; }
- public bool ShowRecentCategory { get; set; }
- [SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
- public List<JumpItem> JumpItems
- {
- get
- {
- return this._jumpItems;
- }
- }
- private bool _IsUnmodified
- {
- get
- {
- return this._initializing == null && this.JumpItems.Count == 0 && !this.ShowRecentCategory && !this.ShowFrequentCategory;
- }
- }
- [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "BeginInit")]
- public void BeginInit()
- {
- if (!this._IsUnmodified)
- {
- throw new InvalidOperationException("Calls to BeginInit cannot be nested.");
- }
- this._initializing = new bool?(true);
- }
- [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "EndInit")]
- [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "BeginInit")]
- public void EndInit()
- {
- if (this._initializing != true)
- {
- throw new NotSupportedException("Can't call EndInit without first calling BeginInit.");
- }
- this._initializing = new bool?(false);
- this.ApplyFromApplication();
- }
- private static string _RuntimeId
- {
- get
- {
- string result;
- HRESULT hrLeft = NativeMethods.GetCurrentProcessExplicitAppUserModelID(out result);
- if (hrLeft == HRESULT.E_FAIL)
- {
- hrLeft = HRESULT.S_OK;
- result = null;
- }
- hrLeft.ThrowIfFailed();
- return result;
- }
- }
- [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "JumpList")]
- [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "EndInit")]
- public void Apply()
- {
- if (this._initializing == true)
- {
- throw new InvalidOperationException("The JumpList can't be applied until EndInit has been called.");
- }
- this._initializing = new bool?(false);
- this._ApplyList();
- }
- private void ApplyFromApplication()
- {
- if (this._initializing != true && !this._IsUnmodified)
- {
- this._initializing = new bool?(false);
- }
- if (this._application == Application.Current && this._initializing == false)
- {
- this._ApplyList();
- }
- }
- [SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Standard.Verify.IsApartmentState(System.Threading.ApartmentState,System.String)")]
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "JumpLists")]
- private void _ApplyList()
- {
- Verify.IsApartmentState(ApartmentState.STA, "JumpLists can only be effected on STA threads.");
- if (!Utility.IsOSWindows7OrNewer)
- {
- this.RejectEverything();
- return;
- }
- List<JumpItem> jumpItems;
- List<JumpList._RejectedJumpItemPair> list;
- List<JumpList._ShellObjectPair> list2;
- try
- {
- this._BuildShellLists(out jumpItems, out list, out list2);
- }
- catch (Exception)
- {
- this.RejectEverything();
- return;
- }
- this._jumpItems = jumpItems;
- EventHandler<JumpItemsRejectedEventArgs> jumpItemsRejected = this.JumpItemsRejected;
- EventHandler<JumpItemsRemovedEventArgs> jumpItemsRemovedByUser = this.JumpItemsRemovedByUser;
- if (list.Count > 0 && jumpItemsRejected != null)
- {
- List<JumpItem> list3 = new List<JumpItem>(list.Count);
- List<JumpItemRejectionReason> list4 = new List<JumpItemRejectionReason>(list.Count);
- foreach (JumpList._RejectedJumpItemPair rejectedJumpItemPair in list)
- {
- list3.Add(rejectedJumpItemPair.JumpItem);
- list4.Add(rejectedJumpItemPair.Reason);
- }
- jumpItemsRejected(this, new JumpItemsRejectedEventArgs(list3, list4));
- }
- if (list2.Count > 0 && jumpItemsRemovedByUser != null)
- {
- List<JumpItem> list5 = new List<JumpItem>(list2.Count);
- foreach (JumpList._ShellObjectPair shellObjectPair in list2)
- {
- if (shellObjectPair.JumpItem != null)
- {
- list5.Add(shellObjectPair.JumpItem);
- }
- }
- if (list5.Count > 0)
- {
- jumpItemsRemovedByUser(this, new JumpItemsRemovedEventArgs(list5));
- }
- }
- }
- private void _BuildShellLists(out List<JumpItem> successList, out List<JumpList._RejectedJumpItemPair> rejectedList, out List<JumpList._ShellObjectPair> removedList)
- {
- List<List<JumpList._ShellObjectPair>> list = null;
- removedList = null;
- ICustomDestinationList customDestinationList = CLSID.CoCreateInstance<ICustomDestinationList>("77f10cf0-3db5-4966-b520-b7c54fd35ed6");
- try
- {
- string runtimeId = JumpList._RuntimeId;
- if (!string.IsNullOrEmpty(runtimeId))
- {
- customDestinationList.SetAppID(runtimeId);
- }
- Guid guid = new Guid("92CA9DCD-5622-4bba-A805-5E9F541BD8C9");
- uint num;
- IObjectArray shellObjects = (IObjectArray) customDestinationList.BeginList(out num, ref guid);
- removedList = JumpList.GenerateJumpItems(shellObjects);
- successList = new List<JumpItem>(this.JumpItems.Count);
- rejectedList = new List<JumpList._RejectedJumpItemPair>(this.JumpItems.Count);
- list = new List<List<JumpList._ShellObjectPair>>
- {
- new List<JumpList._ShellObjectPair>()
- };
- foreach (JumpItem jumpItem in this.JumpItems)
- {
- if (jumpItem == null)
- {
- rejectedList.Add(new JumpList._RejectedJumpItemPair
- {
- JumpItem = jumpItem,
- Reason = JumpItemRejectionReason.InvalidItem
- });
- }
- else
- {
- object obj = null;
- try
- {
- obj = JumpList.GetShellObjectForJumpItem(jumpItem);
- if (obj == null)
- {
- rejectedList.Add(new JumpList._RejectedJumpItemPair
- {
- Reason = JumpItemRejectionReason.InvalidItem,
- JumpItem = jumpItem
- });
- }
- else if (JumpList.ListContainsShellObject(removedList, obj))
- {
- rejectedList.Add(new JumpList._RejectedJumpItemPair
- {
- Reason = JumpItemRejectionReason.RemovedByUser,
- JumpItem = jumpItem
- });
- }
- else
- {
- JumpList._ShellObjectPair item = new JumpList._ShellObjectPair
- {
- JumpItem = jumpItem,
- ShellObject = obj
- };
- if (string.IsNullOrEmpty(jumpItem.CustomCategory))
- {
- list[0].Add(item);
- }
- else
- {
- bool flag = false;
- foreach (List<JumpList._ShellObjectPair> list2 in list)
- {
- if (list2.Count > 0 && list2[0].JumpItem.CustomCategory == jumpItem.CustomCategory)
- {
- list2.Add(item);
- flag = true;
- break;
- }
- }
- if (!flag)
- {
- list.Add(new List<JumpList._ShellObjectPair>
- {
- item
- });
- }
- }
- obj = null;
- }
- }
- finally
- {
- Utility.SafeRelease<object>(ref obj);
- }
- }
- }
- list.Reverse();
- if (this.ShowFrequentCategory)
- {
- customDestinationList.AppendKnownCategory(KDC.FREQUENT);
- }
- if (this.ShowRecentCategory)
- {
- customDestinationList.AppendKnownCategory(KDC.RECENT);
- }
- foreach (List<JumpList._ShellObjectPair> list3 in list)
- {
- if (list3.Count > 0)
- {
- string customCategory = list3[0].JumpItem.CustomCategory;
- JumpList.AddCategory(customDestinationList, customCategory, list3, successList, rejectedList);
- }
- }
- customDestinationList.CommitList();
- successList.Reverse();
- }
- finally
- {
- Utility.SafeRelease<ICustomDestinationList>(ref customDestinationList);
- if (list != null)
- {
- foreach (List<JumpList._ShellObjectPair> list4 in list)
- {
- JumpList._ShellObjectPair.ReleaseShellObjects(list4);
- }
- }
- JumpList._ShellObjectPair.ReleaseShellObjects(removedList);
- }
- }
- private static bool ListContainsShellObject(List<JumpList._ShellObjectPair> removedList, object shellObject)
- {
- if (removedList.Count == 0)
- {
- return false;
- }
- IShellItem shellItem = shellObject as IShellItem;
- if (shellItem != null)
- {
- foreach (JumpList._ShellObjectPair shellObjectPair in removedList)
- {
- IShellItem shellItem2 = shellObjectPair.ShellObject as IShellItem;
- if (shellItem2 != null && shellItem.Compare(shellItem2, (SICHINT) 805306368u) == 0)
- {
- return true;
- }
- }
- return false;
- }
- IShellLinkW shellLinkW = shellObject as IShellLinkW;
- if (shellLinkW != null)
- {
- foreach (JumpList._ShellObjectPair shellObjectPair2 in removedList)
- {
- IShellLinkW shellLinkW2 = shellObjectPair2.ShellObject as IShellLinkW;
- if (shellLinkW2 != null)
- {
- string a = JumpList.ShellLinkToString(shellLinkW2);
- string b = JumpList.ShellLinkToString(shellLinkW);
- if (a == b)
- {
- return true;
- }
- }
- }
- return false;
- }
- return false;
- }
- private static object GetShellObjectForJumpItem(JumpItem jumpItem)
- {
- JumpPath jumpPath = jumpItem as JumpPath;
- JumpTask jumpTask = jumpItem as JumpTask;
- if (jumpPath != null)
- {
- return JumpList.CreateItemFromJumpPath(jumpPath);
- }
- if (jumpTask != null)
- {
- return JumpList.CreateLinkFromJumpTask(jumpTask, true);
- }
- return null;
- }
- private static List<JumpList._ShellObjectPair> GenerateJumpItems(IObjectArray shellObjects)
- {
- List<JumpList._ShellObjectPair> list = new List<JumpList._ShellObjectPair>();
- Guid guid = new Guid("00000000-0000-0000-C000-000000000046");
- uint count = shellObjects.GetCount();
- for (uint num = 0u; num < count; num += 1u)
- {
- object at = shellObjects.GetAt(num, ref guid);
- JumpItem jumpItem = null;
- try
- {
- jumpItem = JumpList.GetJumpItemForShellObject(at);
- }
- catch (Exception ex)
- {
- if (ex is NullReferenceException || ex is SEHException)
- {
- throw;
- }
- }
- list.Add(new JumpList._ShellObjectPair
- {
- ShellObject = at,
- JumpItem = jumpItem
- });
- }
- return list;
- }
- private static void AddCategory(ICustomDestinationList cdl, string category, List<JumpList._ShellObjectPair> jumpItems, List<JumpItem> successList, List<JumpList._RejectedJumpItemPair> rejectionList)
- {
- JumpList.AddCategory(cdl, category, jumpItems, successList, rejectionList, true);
- }
- private static void AddCategory(ICustomDestinationList cdl, string category, List<JumpList._ShellObjectPair> jumpItems, List<JumpItem> successList, List<JumpList._RejectedJumpItemPair> rejectionList, bool isHeterogenous)
- {
- IObjectCollection objectCollection = (IObjectCollection) Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("2d3468c1-36a7-43b6-ac24-d3f02fd9607a")));
- foreach (JumpList._ShellObjectPair shellObjectPair in jumpItems)
- {
- objectCollection.AddObject(shellObjectPair.ShellObject);
- }
- HRESULT hrLeft;
- if (string.IsNullOrEmpty(category))
- {
- hrLeft = cdl.AddUserTasks(objectCollection);
- }
- else
- {
- hrLeft = cdl.AppendCategory(category, objectCollection);
- }
- if (hrLeft.Succeeded)
- {
- int num = jumpItems.Count;
- while (--num >= 0)
- {
- successList.Add(jumpItems[num].JumpItem);
- }
- return;
- }
- if (isHeterogenous && hrLeft == HRESULT.DESTS_E_NO_MATCHING_ASSOC_HANDLER)
- {
- Utility.SafeRelease<IObjectCollection>(ref objectCollection);
- List<JumpList._ShellObjectPair> list = new List<JumpList._ShellObjectPair>();
- foreach (JumpList._ShellObjectPair shellObjectPair2 in jumpItems)
- {
- if (shellObjectPair2.JumpItem is JumpPath)
- {
- rejectionList.Add(new JumpList._RejectedJumpItemPair
- {
- JumpItem = shellObjectPair2.JumpItem,
- Reason = JumpItemRejectionReason.NoRegisteredHandler
- });
- }
- else
- {
- list.Add(shellObjectPair2);
- }
- }
- if (list.Count > 0)
- {
- JumpList.AddCategory(cdl, category, list, successList, rejectionList, false);
- return;
- }
- }
- else
- {
- foreach (JumpList._ShellObjectPair shellObjectPair3 in jumpItems)
- {
- rejectionList.Add(new JumpList._RejectedJumpItemPair
- {
- JumpItem = shellObjectPair3.JumpItem,
- Reason = JumpItemRejectionReason.InvalidItem
- });
- }
- }
- }
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- private static IShellLinkW CreateLinkFromJumpTask(JumpTask jumpTask, bool allowSeparators)
- {
- if (string.IsNullOrEmpty(jumpTask.Title) && (!allowSeparators || !string.IsNullOrEmpty(jumpTask.CustomCategory)))
- {
- return null;
- }
- IShellLinkW shellLinkW = (IShellLinkW) Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("00021401-0000-0000-C000-000000000046")));
- IShellLinkW result;
- try
- {
- string path = JumpList._FullName;
- if (!string.IsNullOrEmpty(jumpTask.ApplicationPath))
- {
- path = jumpTask.ApplicationPath;
- }
- shellLinkW.SetPath(path);
- if (!string.IsNullOrEmpty(jumpTask.WorkingDirectory))
- {
- shellLinkW.SetWorkingDirectory(jumpTask.WorkingDirectory);
- }
- if (!string.IsNullOrEmpty(jumpTask.Arguments))
- {
- shellLinkW.SetArguments(jumpTask.Arguments);
- }
- if (jumpTask.IconResourceIndex != -1)
- {
- string pszIconPath = JumpList._FullName;
- if (!string.IsNullOrEmpty(jumpTask.IconResourcePath))
- {
- if ((long) jumpTask.IconResourcePath.Length >= 260L)
- {
- return null;
- }
- pszIconPath = jumpTask.IconResourcePath;
- }
- shellLinkW.SetIconLocation(pszIconPath, jumpTask.IconResourceIndex);
- }
- if (!string.IsNullOrEmpty(jumpTask.Description))
- {
- shellLinkW.SetDescription(jumpTask.Description);
- }
- IPropertyStore propertyStore = (IPropertyStore) shellLinkW;
- using (PROPVARIANT propvariant = new PROPVARIANT())
- {
- PKEY pkey = default(PKEY);
- if (!string.IsNullOrEmpty(jumpTask.Title))
- {
- propvariant.SetValue(jumpTask.Title);
- pkey = PKEY.Title;
- }
- else
- {
- propvariant.SetValue(true);
- pkey = PKEY.AppUserModel_IsDestListSeparator;
- }
- propertyStore.SetValue(ref pkey, propvariant);
- }
- propertyStore.Commit();
- IShellLinkW shellLinkW2 = shellLinkW;
- shellLinkW = null;
- result = shellLinkW2;
- }
- catch (Exception)
- {
- result = null;
- }
- finally
- {
- Utility.SafeRelease<IShellLinkW>(ref shellLinkW);
- }
- return result;
- }
- private static IShellItem2 GetShellItemForPath(string path)
- {
- if (string.IsNullOrEmpty(path))
- {
- return null;
- }
- Guid guid = new Guid("7e9fb0d3-919f-4307-ab2e-9b1860310c93");
- object obj;
- HRESULT hrLeft = NativeMethods.SHCreateItemFromParsingName(path, null, ref guid, out obj);
- if (hrLeft == (HRESULT) Win32Error.ERROR_FILE_NOT_FOUND || hrLeft == (HRESULT) Win32Error.ERROR_PATH_NOT_FOUND)
- {
- hrLeft = HRESULT.S_OK;
- obj = null;
- }
- hrLeft.ThrowIfFailed();
- return (IShellItem2) obj;
- }
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- private static IShellItem2 CreateItemFromJumpPath(JumpPath jumpPath)
- {
- try
- {
- return JumpList.GetShellItemForPath(Path.GetFullPath(jumpPath.Path));
- }
- catch (Exception)
- {
- }
- return null;
- }
- private static JumpItem GetJumpItemForShellObject(object shellObject)
- {
- IShellItem2 shellItem = shellObject as IShellItem2;
- IShellLinkW shellLinkW = shellObject as IShellLinkW;
- if (shellItem != null)
- {
- return new JumpPath
- {
- Path = shellItem.GetDisplayName((SIGDN) 2147647488u)
- };
- }
- if (shellLinkW != null)
- {
- StringBuilder stringBuilder = new StringBuilder(260);
- shellLinkW.GetPath(stringBuilder, stringBuilder.Capacity, null, SLGP.RAWPATH);
- StringBuilder stringBuilder2 = new StringBuilder(1024);
- shellLinkW.GetArguments(stringBuilder2, stringBuilder2.Capacity);
- StringBuilder stringBuilder3 = new StringBuilder(1024);
- shellLinkW.GetDescription(stringBuilder3, stringBuilder3.Capacity);
- StringBuilder stringBuilder4 = new StringBuilder(260);
- int iconResourceIndex;
- shellLinkW.GetIconLocation(stringBuilder4, stringBuilder4.Capacity, out iconResourceIndex);
- StringBuilder stringBuilder5 = new StringBuilder(260);
- shellLinkW.GetWorkingDirectory(stringBuilder5, stringBuilder5.Capacity);
- JumpTask jumpTask = new JumpTask
- {
- ApplicationPath = stringBuilder.ToString(),
- Arguments = stringBuilder2.ToString(),
- Description = stringBuilder3.ToString(),
- IconResourceIndex = iconResourceIndex,
- IconResourcePath = stringBuilder4.ToString(),
- WorkingDirectory = stringBuilder5.ToString()
- };
- using (PROPVARIANT propvariant = new PROPVARIANT())
- {
- IPropertyStore propertyStore = (IPropertyStore) shellLinkW;
- PKEY title = PKEY.Title;
- propertyStore.GetValue(ref title, propvariant);
- jumpTask.Title = (propvariant.GetValue() ?? "");
- }
- return jumpTask;
- }
- return null;
- }
- private static string ShellLinkToString(IShellLinkW shellLink)
- {
- StringBuilder stringBuilder = new StringBuilder(260);
- shellLink.GetPath(stringBuilder, stringBuilder.Capacity, null, SLGP.RAWPATH);
- string text = null;
- using (PROPVARIANT propvariant = new PROPVARIANT())
- {
- IPropertyStore propertyStore = (IPropertyStore) shellLink;
- PKEY title = PKEY.Title;
- propertyStore.GetValue(ref title, propvariant);
- text = (propvariant.GetValue() ?? "");
- }
- StringBuilder stringBuilder2 = new StringBuilder(1024);
- shellLink.GetArguments(stringBuilder2, stringBuilder2.Capacity);
- return stringBuilder.ToString().ToUpperInvariant() + text.ToUpperInvariant() + stringBuilder2.ToString();
- }
- private void RejectEverything()
- {
- EventHandler<JumpItemsRejectedEventArgs> jumpItemsRejected = this.JumpItemsRejected;
- if (jumpItemsRejected == null)
- {
- this._jumpItems.Clear();
- return;
- }
- if (this._jumpItems.Count > 0)
- {
- List<JumpItemRejectionReason> list = new List<JumpItemRejectionReason>(this.JumpItems.Count);
- for (int i = 0; i < this.JumpItems.Count; i++)
- {
- list.Add(JumpItemRejectionReason.InvalidItem);
- }
- JumpItemsRejectedEventArgs e = new JumpItemsRejectedEventArgs(this.JumpItems, list);
- this._jumpItems.Clear();
- jumpItemsRejected(this, e);
- }
- }
- public event EventHandler<JumpItemsRejectedEventArgs> JumpItemsRejected;
- public event EventHandler<JumpItemsRemovedEventArgs> JumpItemsRemovedByUser;
- private static readonly object s_lock = new object();
- private static readonly Dictionary<Application, JumpList> s_applicationMap = new Dictionary<Application, JumpList>();
- private Application _application;
- private bool? _initializing;
- private List<JumpItem> _jumpItems;
- private static readonly string _FullName = NativeMethods.GetModuleFileName(IntPtr.Zero);
- private class _RejectedJumpItemPair
- {
- public JumpItem JumpItem { get; set; }
- public JumpItemRejectionReason Reason { get; set; }
- }
- private class _ShellObjectPair
- {
- public JumpItem JumpItem { get; set; }
- public object ShellObject { get; set; }
- public static void ReleaseShellObjects(List<JumpList._ShellObjectPair> list)
- {
- if (list != null)
- {
- foreach (JumpList._ShellObjectPair shellObjectPair in list)
- {
- object shellObject = shellObjectPair.ShellObject;
- shellObjectPair.ShellObject = null;
- Utility.SafeRelease<object>(ref shellObject);
- }
- }
- }
- }
- }
|