Example #1
0
        private static List <_ShellObjectPair> GenerateJumpItems(IObjectArray shellObjects)
        {
            Debug.Assert(shellObjects != null);

            var retList = new List <_ShellObjectPair>();

            Guid unknownIid = new Guid(IID.Unknown);
            uint count      = shellObjects.GetCount();

            for (uint i = 0; i < count; ++i)
            {
                // This is potentially a heterogenous list, so get as an IUnknown and QI afterwards.
                object   unk  = shellObjects.GetAt(i, ref unknownIid);
                JumpItem item = null;
                try
                {
                    item = GetJumpItemForShellObject(unk);
                }
                catch (Exception e)
                {
                    if (e is NullReferenceException || e is System.Runtime.InteropServices.SEHException)
                    {
                        throw;
                    }
                    // If we failed the conversion we still want to keep the shell interface for comparision.
                    // Just leave the JumpItem property as null.
                }
                retList.Add(new _ShellObjectPair {
                    ShellObject = unk, JumpItem = item
                });
            }

            return(retList);
        }
Example #2
0
        private IEnumerable <string> ProcessDeletedItems(IObjectArray removedItems)
        {
            List <string> removedItemsArray = new List <string>();

            uint count;

            removedItems.GetCount(out count);

            // Process each removed item based on its type
            for (uint i = 0; i < count; i++)
            {
                // Native call to retrieve objects from IObjectArray
                object item;
                removedItems.GetAt(i,
                                   ref TaskbarNativeMethods.TaskbarGuids.IUnknown,
                                   out item);

                IShellItem  shellItem = item as IShellItem;
                IShellLinkW shellLink;
                // Process item
                if (shellItem != null)
                {
                    removedItemsArray.Add(RemoveCustomCategoryItem(shellItem));
                }
                else if ((shellLink = item as IShellLinkW) != null)
                {
                    removedItemsArray.Add(RemoveCustomCategoryLink(shellLink));
                }
            }
            return(removedItemsArray);
        }
Example #3
0
        private static List <_ShellObjectPair> GenerateJumpItems(IObjectArray shellObjects)
        {
            Debug.Assert(shellObjects != null);
            var retList    = new List <_ShellObjectPair>();
            var unknownIid = new Guid(IID.Unknown);
            var count      = shellObjects.GetCount();

            for (uint i = 0; i < count; ++i)
            {
                var      unk  = shellObjects.GetAt(i, ref unknownIid);
                JumpItem item = null;
                try
                {
                    item = GetJumpItemForShellObject(unk);
                }
                catch (Exception e)
                {
                    if (e is NullReferenceException || e is SEHException)
                    {
                        throw;
                    }
                }
                retList.Add(new _ShellObjectPair {
                    ShellObject = unk, JumpItem = item
                });
            }
            return(retList);
        }
Example #4
0
        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);
        }
Example #5
0
 /// <summary>
 ///     An extension method which allows IObjectArrays to be more naturally indexed.
 /// </summary>
 /// <param name="arr">The Object array to be indexed.</param>
 /// <param name="i">The index of the requested item.</param>
 /// <typeparam name="TElement">The type of the requested item.</typeparam>
 /// <returns>The element at index <paramref name="i" /> of <paramref name="arr" />.</returns>
 public static TElement Get <TElement>(this IObjectArray arr, int i)
 {
     arr.GetAt(
         (uint)i,
         typeof(IVirtualDesktop).GUID,
         out var desktop);
     return((TElement)desktop);
 }
Example #6
0
        public static void CreateJumpList(NoteManager note_manager)
        {
            ICustomDestinationList custom_destinationd_list = null;
            IObjectArray           removed_objects          = null;

            try {
                custom_destinationd_list =
                    (ICustomDestinationList)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID.DestinationList));

                uint slots;
                Guid riid = CLSID.IObjectArray;

                Logger.Debug("Windows Taskbar: Begin jump list");
                custom_destinationd_list.BeginList(out slots, ref riid, out removed_objects);

                try {
                    AddUserTasks(custom_destinationd_list);
                } catch (UnauthorizedAccessException uae) {
                    Logger.Warn("Access denied adding user tasks to jump list: {0}\n{1}",
                                uae.Message, uae.StackTrace);
                }
                try {
                    AddRecentNotes(custom_destinationd_list, note_manager, slots);
                } catch (UnauthorizedAccessException uae) {
                    Logger.Warn("Access denied adding recent notes to jump list: {0}\n{1}",
                                uae.Message, uae.StackTrace);
                }

                Logger.Debug("Windows Taskbar: Commit jump list");
                custom_destinationd_list.CommitList();
            } catch (Exception e) {
                Logger.Error("Error creating jump list: {0}\n{1}", e.Message, e.StackTrace);
                if (custom_destinationd_list != null)
                {
                    custom_destinationd_list.AbortList();
                }
            } finally {
                if (removed_objects != null)
                {
                    Marshal.FinalReleaseComObject(removed_objects);
                    removed_objects = null;
                }

                if (custom_destinationd_list != null)
                {
                    Marshal.FinalReleaseComObject(custom_destinationd_list);
                    custom_destinationd_list = null;
                }
            }
        }
Example #7
0
        private static void UnsafeSetWallpaper(string imagePath)
        {
            Guid         currentDesktopId = manager.GetCurrentDesktop(IntPtr.Zero).GetId();
            IObjectArray objectArray      = manager.GetDesktops(IntPtr.Zero);

            for (uint i = 0u; i < objectArray.GetCount(); i++)
            {
                objectArray.GetAt(i, typeof(IVirtualDesktop).GUID, out object virtualDesktop);
                if ((virtualDesktop as IVirtualDesktop).GetId() != currentDesktopId)
                {
                    manager.SetWallpaperPath((IVirtualDesktop)virtualDesktop, imagePath);
                }
            }
        }
Example #8
0
        private IEnumerable ProcessDeletedItems(IObjectArray removedItems)
        {
            uint count;

            removedItems.GetCount(out count);

            if (count == 0)
            {
                return new string[] { }
            }
            ;

            // String array passed to the user via the JumpListItemsRemoved
            // event
            List <string> removedItemsArray = new List <string>();

            // Process each removed item based on it's type
            for (uint i = 0; i < count; i++)
            {
                // Native call to retrieve objects from IObjectArray
                object item;
                removedItems.GetAt(i,
                                   ref TaskbarNativeMethods.IID_IUnknown,
                                   out item);

                // Process item
                if (item is IShellItem)
                {
                    removedItemsArray.Add(RemoveCustomCategoryItem((IShellItem)item));
                }
                else if (item is IShellLinkW)
                {
                    removedItemsArray.Add(RemoveCustomCategoryLink((IShellLinkW)item));
                }
            }

            return(removedItemsArray);
        }
Example #9
0
        // Adds a custom category to the Jump List. Each item that should be in the category is added to an ordered collection, and then the
        // category is appended to the Jump List as a whole.
        private static void _AddCategoryToList(ICustomDestinationList pcdl, IObjectArray poaRemoved)
        {
            var poc = new IObjectCollection();

            foreach (var fn in c_rgpszFiles)
            {
                if (SHCreateItemInKnownFolder(KNOWNFOLDERID.FOLDERID_Documents.Guid(), KNOWN_FOLDER_FLAG.KF_FLAG_DEFAULT, fn, typeof(IShellItem).GUID, out var ppv).Succeeded)
                {
                    var psi = ppv as IShellItem;
                    // Items listed in the removed list may not be re-added to the Jump List during this list-building transaction. They
                    // should not be re-added to the Jump List until the user has used the item again. The AppendCategory call below will
                    // fail if an attempt to add an item in the removed list is made.
                    if (!_IsItemInArray(psi, poaRemoved))
                    {
                        poc.AddObject(psi);
                    }
                }

                // Add the category to the Jump List. If there were more categories, they would appear from top to bottom in the order they
                // were appended.
                pcdl.AppendCategory("Custom Category", poc);
            }
        }
Example #10
0
 /// <summary>Defines a custom category and the destinations that it contains, for inclusion in a custom Jump List.</summary>
 /// <param name="pszCategory">
 /// A pointer to a string that contains the display name of the custom category. This string is shown in the category's header in the Jump List. The
 /// string can directly hold the display name or it can be an indirect string representation, such as "@shell32.dll,-1324", to use a stored string.
 /// An indirect string enables the category header to be displayed in the user's selected language. <note>Each custom category must have a unique
 /// name. Duplicate category names will cause presentation issues in the Jump List.</note>
 /// </param>
 /// <param name="poa">
 /// A pointer to an IObjectArray that represents one or more IShellItem objects that represent the destinations in the category. Some destinations in
 /// the list might also be represented by IShellLink objects, although less often. <note>Any IShellLink used here must declare an argument list
 /// through SetArguments. Adding an IShellLink object with no arguments to a custom category is not supported since a user cannot pin or unpin this
 /// type of item from a Jump List, nor can they be added or removed.</note>
 /// </param>
 void AppendCategory([MarshalAs(UnmanagedType.LPWStr)] string pszCategory, IObjectArray poa);
Example #11
0
 /// <summary>Specifies items to include in the Tasks category of a custom Jump List.</summary>
 /// <param name="poa">
 /// A pointer to an IObjectArray that represents one or more IShellLink (or, more rarely, IShellItem) objects that represent the tasks. <note>Any
 /// IShellLink used here must declare an argument list through SetArguments. Adding an IShellLink object with no arguments to a custom category is
 /// not supported. A user cannot pin or unpin this type of item from a Jump List, nor can they be added or removed.</note>
 /// </param>
 void AddUserTasks(IObjectArray poa);
Example #12
0
 /// <summary>Adds the objects contained in an IObjectArray to the collection.</summary>
 /// <param name="poaSource">Pointer to the IObjectArray whose contents are to be added to the collection.</param>
 void AddFromArray(IObjectArray poaSource);
Example #13
0
        private static List<_ShellObjectPair> GenerateJumpItems(IObjectArray shellObjects)
        {
            Debug.Assert(shellObjects != null);

            var retList = new List<_ShellObjectPair>();

            Guid unknownIid = new Guid(IID.Unknown);
            uint count = shellObjects.GetCount();
            for (uint i = 0; i < count; ++i)
            {
                // This is potentially a heterogenous list, so get as an IUnknown and QI afterwards.
                object unk = shellObjects.GetAt(i, ref unknownIid);
                JumpItem item = null;
                try
                {
                    item = GetJumpItemForShellObject(unk);
                }
                catch (Exception e)
                {
                    if (e is NullReferenceException || e is System.Runtime.InteropServices.SEHException)
                    {
                        throw;
                    }
                    // If we failed the conversion we still want to keep the shell interface for comparision.
                    // Just leave the JumpItem property as null.
                }
                retList.Add(new _ShellObjectPair { ShellObject = unk, JumpItem = item });
            }

            return retList;
        }
 public void VirtualDesktopMoved(IObjectArray p0, IVirtualDesktop pDesktop, int nIndexFrom, int nIndexTo)
 {
     this.MovedCore(p0, pDesktop, nIndexFrom, nIndexTo);
 }
Example #15
0
        private IEnumerable ProcessDeletedItems(IObjectArray removedItems)
        {
            uint count;
            removedItems.GetCount(out count);

            if (count == 0)
                return new string[] { };

            // String array passed to the user via the JumpListItemsRemoved
            // event
            List<string> removedItemsArray = new List<string>();

            // Process each removed item based on it's type
            for (uint i = 0; i < count; i++)
            {
                // Native call to retrieve objects from IObjectArray
                object item;
                removedItems.GetAt(i,
                    ref TaskbarNativeMethods.IID_IUnknown,
                    out item);

                // Process item
                if (item is IShellItem)
                {
                    removedItemsArray.Add(RemoveCustomCategoryItem((IShellItem)item));
                }
                else if (item is IShellLinkW)
                {
                    removedItemsArray.Add(RemoveCustomCategoryLink((IShellLinkW)item));
                }
            }

            return removedItemsArray;
        }
 public int GetViewsByZOrder(out IObjectArray array) => this.wrapped.GetViewsByZOrder(out array);
        /// <summary>
        /// Retrieves all application destinations belonging to the specified
        /// application destination type.
        /// </summary>
        /// <param name="type">The application destination type.</param>
        /// <returns>A copy of the application destinations belonging to
        /// the specified type; modifying the returned objects has no effect
        /// on the application's destination list.</returns>
        public IEnumerable <IJumpListDestination> GetApplicationDestinations(ApplicationDestinationType type)
        {
            if (type == ApplicationDestinationType.None)
            {
                throw new ArgumentException("ApplicationDestinationType can't be NONE");
            }

            IApplicationDocumentLists destinations = (IApplicationDocumentLists) new CApplicationDocumentLists();
            Guid iidObjectArray = typeof(IObjectArray).GUID;

            object  obj;
            HResult getListResult = destinations.GetList((AppDocListType)type, 100, ref iidObjectArray, out obj);

            getListResult.ThrowIf();

            List <IJumpListDestination> returnValue = new List <IJumpListDestination>();

            Guid         iidShellItem = typeof(IShellItem).GUID;
            Guid         iidShellLink = typeof(IShellLinkW).GUID;
            IObjectArray array        = (IObjectArray)obj;

            uint    count;
            HResult getCountResult = array.GetCount(out count);

            getCountResult.ThrowIf();

            for (uint i = 0; i < count; ++i)
            {
                try
                {
                    array.GetAt(i, ref iidShellItem, out obj);
                }
                catch (Exception) //Wrong type
                { }

                if (obj == null)
                {
                    HResult getAtResult = array.GetAt(i, ref iidShellLink, out obj);
                    getAtResult.ThrowIf();
                    //This shouldn't fail since if it's not IShellItem
                    //then it must be IShellLink.

                    IShellLinkW link    = (IShellLinkW)obj;
                    ShellLink   wrapper = new ShellLink();

                    StringBuilder sb            = new StringBuilder(256);
                    HResult       getPathResult = link.GetPath(sb, sb.Capacity, IntPtr.Zero, 2);
                    getPathResult.ThrowIf();
                    wrapper.Path = sb.ToString();

                    HResult getArgumentsResult = link.GetArguments(sb, sb.Capacity);
                    getArgumentsResult.ThrowIf();
                    wrapper.Arguments = sb.ToString();

                    int     iconId;
                    HResult getIconLocationResult = link.GetIconLocation(sb, sb.Capacity, out iconId);
                    getIconLocationResult.ThrowIf();
                    wrapper.IconIndex    = iconId;
                    wrapper.IconLocation = sb.ToString();

                    uint    showCmd;
                    HResult getShowCmdResult = link.GetShowCmd(out showCmd);
                    getShowCmdResult.ThrowIf();
                    wrapper.ShowCommand = (WindowShowCommand)showCmd;

                    HResult getWorkingDirectoryResult = link.GetWorkingDirectory(sb, sb.Capacity);
                    getWorkingDirectoryResult.ThrowIf();
                    wrapper.WorkingDirectory = sb.ToString();

                    returnValue.Add(wrapper);
                }
                else //It's an IShellItem.
                {
                    IShellItem item    = (IShellItem)obj;
                    ShellItem  wrapper = new ShellItem();

                    string  path;
                    HResult getDisplayNameResult = item.GetDisplayName(SIGDN.SIGDN_FILESYSPATH, out path);
                    getDisplayNameResult.ThrowIf();
                    wrapper.Path = path;

                    //Title and Category are irrelevant here, because it's
                    //an IShellItem.  The user might want to see them, but he's
                    //free to go to the IShellItem and look at its property store.

                    returnValue.Add(wrapper);
                }
            }
            return(returnValue);
        }
Example #18
0
 public void VirtualDesktopMoved(IObjectArray p0, IVirtualDesktop pDesktop, int nFromIndex, int nToIndex)
 {
     this.VirtualDesktopMovedCore(pDesktop, nFromIndex, nToIndex);
 }
 public int GetViewsByAppUserModelId(string id, out IObjectArray array) => this.wrapped.GetViewsByAppUserModelId(id, out array);
Example #20
0
        private IEnumerable<string> ProcessDeletedItems(IObjectArray removedItems)
        {
            List<string> removedItemsArray = new List<string>();

            uint count;
            removedItems.GetCount(out count);

            // Process each removed item based on its type
            for (uint i = 0; i < count; i++)
            {
                // Native call to retrieve objects from IObjectArray
                object item;
                removedItems.GetAt(i,
                    ref TaskbarNativeMethods.TaskbarGuids.IUnknown,
                    out item);

                IShellItem shellItem = item as IShellItem;
                IShellLinkW shellLink;
                // Process item
                if (shellItem != null)
                {
                    removedItemsArray.Add(RemoveCustomCategoryItem(shellItem));
                }
                else if ((shellLink = item as IShellLinkW) != null)
                {
                    removedItemsArray.Add(RemoveCustomCategoryLink(shellLink));
                }
            }
            return removedItemsArray;
        }
 public void VirtualDesktopCreated(IObjectArray p0, IVirtualDesktop pDesktop)
 {
     this.CreatedCore(pDesktop);
 }
 public void VirtualDesktopDestroyed(IObjectArray p0, IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback)
 {
     this.DestroyedCore(pDesktopDestroyed, pDesktopFallback);
 }
Example #23
0
        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 bool BeginList()
        {
            if (UserRemovedItems == null)
            {
                throw new InvalidOperationException("You must register for the JumpListManager.UserRemovedItems event before adding any items");
            }

            object obj;

            _customDestinationList.BeginList(out _maxSlotsInList, ref SafeNativeMethods.IID_IObjectArray, out obj);

            IObjectArray removedItems = (IObjectArray)obj;
            uint         count;

            removedItems.GetCount(out count);
            if (count == 0)
            {
                return(true);
            }

            string[] removedItemsArr = new string[count];
            for (uint i = 0; i < count; ++i)
            {
                object item;
                removedItems.GetAt(i, ref SafeNativeMethods.IID_IUnknown, out item);

                try
                {
                    IShellLinkW shellLink = (IShellLinkW)item;
                    if (shellLink != null)
                    {
                        StringBuilder sb = new StringBuilder(256);
                        shellLink.GetPath(sb, sb.Capacity, IntPtr.Zero, 2);
                        removedItemsArr[i] = sb.ToString();
                    }
                    continue;
                }
                catch (InvalidCastException) //It's not a ShellLink
                {  }

                try
                {
                    IShellItem shellItem = (IShellItem)item;
                    if (shellItem != null)
                    {
                        string path;
                        shellItem.GetDisplayName(SIGDN.SIGDN_FILESYSPATH, out path);
                        removedItemsArr[i] = path;
                    }
                }
                catch (InvalidCastException)
                {
                    //It's neither a shell link nor a shell item.
                    //This is impossible.
                    Debug.Assert(false,
                                 "List of removed items contains something that is neither a shell item nor a shell link");
                }
            }

            UserRemovedItemsEventArgs args = new UserRemovedItemsEventArgs(removedItemsArr);

            UserRemovedItems(this, args);
            if (args.Cancel)
            {
                _customDestinationList.AbortList();
            }
            return(!args.Cancel);
        }
        private void ApplyList()
        {
            Verify.IsApartmentState(ApartmentState.STA);
            if (!Utilities.IsOSWindows7OrNewer)
            {
                this.RejectEverything();
                return;
            }
            List <List <JumpList._ShellObjectPair> > list  = null;
            List <JumpList._ShellObjectPair>         list2 = null;
            ICustomDestinationList customDestinationList   = (ICustomDestinationList)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("77f10cf0-3db5-4966-b520-b7c54fd35ed6")));
            List <JumpItem>        list3;
            List <JumpList._RejectedJumpItemPair> list4;

            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);
                list2 = JumpList.GenerateJumpItems(shellObjects);
                list3 = new List <JumpItem>(this.JumpItems.Count);
                list4 = 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)
                    {
                        list4.Add(new JumpList._RejectedJumpItemPair
                        {
                            JumpItem = jumpItem,
                            Reason   = JumpItemRejectionReason.InvalidItem
                        });
                    }
                    else
                    {
                        object obj = null;
                        try
                        {
                            obj = JumpList.GetShellObjectForJumpItem(jumpItem);
                            if (obj == null)
                            {
                                list4.Add(new JumpList._RejectedJumpItemPair
                                {
                                    Reason   = JumpItemRejectionReason.InvalidItem,
                                    JumpItem = jumpItem
                                });
                            }
                            else if (JumpList.ListContainsShellObject(list2, obj))
                            {
                                list4.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> list5 in list)
                                    {
                                        if (list5.Count > 0 && list5[0].JumpItem.CustomCategory == jumpItem.CustomCategory)
                                        {
                                            list5.Add(item);
                                            flag = true;
                                            break;
                                        }
                                    }
                                    if (!flag)
                                    {
                                        list.Add(new List <JumpList._ShellObjectPair>
                                        {
                                            item
                                        });
                                    }
                                }
                                obj = null;
                            }
                        }
                        finally
                        {
                            Utilities.SafeRelease <object>(ref obj);
                        }
                    }
                }
                list.Reverse();
                if (this.ShowFrequentCategory)
                {
                    customDestinationList.AppendKnownCategory(KDC.FREQUENT);
                }
                if (this.ShowRecentCategory)
                {
                    customDestinationList.AppendKnownCategory(KDC.RECENT);
                }
                foreach (List <JumpList._ShellObjectPair> list6 in list)
                {
                    if (list6.Count > 0)
                    {
                        string customCategory = list6[0].JumpItem.CustomCategory;
                        JumpList.AddCategory(customDestinationList, customCategory, list6, list3, list4);
                    }
                }
                customDestinationList.CommitList();
            }
            catch
            {
                if (TraceShell.IsEnabled)
                {
                    TraceShell.Trace(TraceEventType.Error, TraceShell.RejectingJumpItemsBecauseCatastrophicFailure);
                }
                this.RejectEverything();
                return;
            }
            finally
            {
                Utilities.SafeRelease <ICustomDestinationList>(ref customDestinationList);
                if (list != null)
                {
                    foreach (List <JumpList._ShellObjectPair> list7 in list)
                    {
                        JumpList._ShellObjectPair.ReleaseShellObjects(list7);
                    }
                }
                JumpList._ShellObjectPair.ReleaseShellObjects(list2);
            }
            list3.Reverse();
            this._jumpItems = list3;
            EventHandler <JumpItemsRejectedEventArgs> jumpItemsRejected      = this.JumpItemsRejected;
            EventHandler <JumpItemsRemovedEventArgs>  jumpItemsRemovedByUser = this.JumpItemsRemovedByUser;

            if (list4.Count > 0 && jumpItemsRejected != null)
            {
                List <JumpItem> list8 = new List <JumpItem>(list4.Count);
                List <JumpItemRejectionReason> list9 = new List <JumpItemRejectionReason>(list4.Count);
                foreach (JumpList._RejectedJumpItemPair rejectedJumpItemPair in list4)
                {
                    list8.Add(rejectedJumpItemPair.JumpItem);
                    list9.Add(rejectedJumpItemPair.Reason);
                }
                jumpItemsRejected(this, new JumpItemsRejectedEventArgs(list8, list9));
            }
            if (list2.Count > 0 && jumpItemsRemovedByUser != null)
            {
                List <JumpItem> list10 = new List <JumpItem>(list2.Count);
                foreach (JumpList._ShellObjectPair shellObjectPair in list2)
                {
                    if (shellObjectPair.JumpItem != null)
                    {
                        list10.Add(shellObjectPair.JumpItem);
                    }
                }
                if (list10.Count > 0)
                {
                    jumpItemsRemovedByUser(this, new JumpItemsRemovedEventArgs(list10));
                }
            }
        }
 public void CurrentVirtualDesktopChanged(IObjectArray p0, IVirtualDesktop pDesktopOld, IVirtualDesktop pDesktopNew)
 {
     this.CurrentChangedCore(pDesktopOld, pDesktopNew);
 }