예제 #1
0
 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);
 }
예제 #2
0
    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
                });
            }
        }
    }
예제 #3
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);
        }
    }