Exemplo n.º 1
0
        public static void DeleteApp(string appId, string appPath)
        {
            // 1. Delete from internal jumplist
            try
            {
                Common.AppIds.Remove(appId);
                Common.AppProcessNames.Remove(Path.GetFileNameWithoutExtension(appPath));
                Common.AppCount--;

                // 2. Rewrite AppList.xml without the appid.
                WriteAppListXml();
            }
            catch (Exception e) { /* Just means app was disabled. */ }

            // T7EBackground should be replacing the window and shortcut appids here.
            // RACE CONDITION: Prevent OrigProperties/App Name.lnk from deleting before
            // T7EBackground gets around to it. For now, we just leave it.
            // Not a good practice?

            // 3. Erase the corresponding jumplist
            try
            {
                JumpList dummyList = JumpList.CreateJumpListForAppId(appId);
                dummyList.Refresh();
            }
            catch (Exception e) { }
            // Reset this window's appid!

            // 4. Delete the app from AppData
            Directory.Delete(Path.Combine(Common.Path_AppData, appId), true);
            // Delete OrigProperties/App Name.lnk
        }
Exemplo n.º 2
0
        private void EraseJumplist(string appId)
        {
            try
            {
                JumpList dummyList = JumpList.CreateJumpListForAppId(appId);
                dummyList.Refresh();

                // Set appid back
                SetAppIdBackAfterJumplist();
            }
            catch (Exception e) { Console.Write("Erase Jumplist Error: " + e.Message); }
        }
Exemplo n.º 3
0
        static public void EraseJumplist(string appId)
        {
            try
            {
                JumpList dummyList = JumpList.CreateJumpListForAppId(appId);
                dummyList.ClearAllUserTasks();
                dummyList.Refresh();

                // Set appid back
                SetAppIdBackAfterJumplist();
            }
            catch (Exception e) { }
        }
Exemplo n.º 4
0
        static public void SetAppIdBackAfterJumplist()
        {
            JumpList ownList = JumpList.CreateJumpListForAppId("T7E.Meta");

            // BUG: WE NEED TO FIGURE OUT HOW TO RETURN JUMP LIST TO NORMAL

            /*ownList.AddUserTasks(new JumpListLink
             * {
             *  Title = "Visit the official website",
             *  Path = "%windir%\\explorer.exe",
             *  Arguments = "\"http://jumplist.gsdn-media.com\"",
             *  IconReference = new IconReference(Path.Combine(Common.EnvPath_SystemRoot, "system32\\shell32.dll"), 135)
             * });*/
            ownList.Refresh();
            Common.TaskbarManagerInstance.SetCurrentProcessAppId("");
        }
Exemplo n.º 5
0
        static public bool ApplyBlankJumplistToTaskbar(Primary parent)
        {
            bool result = false;

            try
            {
                // ////////
                JumpList dummyList = JumpList.CreateJumpListForAppId(parent.CurrentAppId);
                dummyList.ClearAllUserTasks();
                dummyList.Refresh();
                // Remove appid from own window!
                SetAppIdBackAfterJumplist();
                result = true;
            }
            catch (Exception e)
            {
                MessageBox.Show("JumpList applying not successful." + "\r\n"
                                + e.ToString());
            }

            return(result);
        }
Exemplo n.º 6
0
        static public bool ApplyJumplistToTaskbar(Primary parent)
        {
            bool result = false;

            try
            {
                JumpList newList = JumpList.CreateJumpListForAppId(parent.CurrentAppId);
                //newList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;
                //newList.KnownCategoryOrdinalPosition = 0;

                ListBox.ObjectCollection jumplistItems = parent.JumplistListBox.Items;
                for (int i = 0; i < jumplistItems.Count; i++)
                {
                    // Look for a category
                    T7EJumplistItem.ItemTypeVar jumplistItemType = ((T7EJumplistItem)jumplistItems[i]).ItemType;
                    if (jumplistItemType == T7EJumplistItem.ItemTypeVar.Category ||
                        jumplistItemType == T7EJumplistItem.ItemTypeVar.CategoryTasks)
                    {
                        JumpListCustomCategory category = new JumpListCustomCategory(((T7EJumplistItem)jumplistItems[i]).ItemName);

                        // Look for a task
                        for (int j = i + 1; j < jumplistItems.Count; j++)
                        {
                            i = j - 1; // When J loop is exited, i has to be less.
                            T7EJumplistItem jumplistItem = (T7EJumplistItem)jumplistItems[j];
                            switch (jumplistItem.ItemType)
                            {
                            case T7EJumplistItem.ItemTypeVar.Category:
                            case T7EJumplistItem.ItemTypeVar.CategoryTasks:
                                j = jumplistItems.Count;     // Exit the for loop
                                break;

                            case T7EJumplistItem.ItemTypeVar.Task:
                                if (jumplistItemType == T7EJumplistItem.ItemTypeVar.Category)
                                {
                                    category.AddJumpListItems(
                                        ParseApplyJumpListTask(parent, jumplistItem, j));
                                }
                                else
                                {
                                    newList.AddUserTasks(
                                        ParseApplyJumpListTask(parent, jumplistItem, j));
                                }
                                break;

                            case T7EJumplistItem.ItemTypeVar.FileFolder:
                                // If file is an EXE, just pass the path over.
                                // TODO: Merge "Command line" and "File/Folder shortcut" into one dialog, based on "Command Line"

                                JumpListLink link = new JumpListLink
                                {
                                    Title     = jumplistItem.ItemName,
                                    Path      = "C:\\Windows\\explorer.exe",
                                    Arguments = jumplistItem.FilePath
                                                // working directory here? We don't know what the program is.
                                                // AHK doesn't detect the default program's working dir, either.
                                };
                                if (jumplistItem.FileRunWithApp)
                                {
                                    link.Path = parent.CurrentAppPath;
                                    // we use working dir here because we KNOW the program to use
                                    link.WorkingDirectory = Path.GetDirectoryName(parent.CurrentAppPath);
                                }


                                if (Path.GetExtension(jumplistItem.FilePath).ToLower() == ".exe")
                                {
                                    link.Path      = jumplistItem.FilePath;
                                    link.Arguments = "";
                                    // we use working dir here because we KNOW the program to use
                                    link.WorkingDirectory = Path.GetDirectoryName(jumplistItem.FilePath);
                                }


                                // Format icon
                                if (jumplistItem.ItemIconToString().Equals("Don't use an icon") != true)
                                {
                                    // Icon processing
                                    string localIconPath = IconPathToLocal(jumplistItem.ItemIconPath, jumplistItem.ItemIconIndex, j, parent.CurrentAppId, false);
                                    if (File.Exists(localIconPath))
                                    {
                                        link.IconReference = new IconReference(localIconPath, 0);
                                    }
                                }

                                if (jumplistItemType == T7EJumplistItem.ItemTypeVar.Category)
                                {
                                    category.AddJumpListItems(link);
                                }
                                else
                                {
                                    newList.AddUserTasks(link);
                                }
                                break;

                            case T7EJumplistItem.ItemTypeVar.Separator:
                                if (jumplistItemType == T7EJumplistItem.ItemTypeVar.CategoryTasks)
                                {
                                    newList.AddUserTasks(new JumpListSeparator());
                                }
                                break;
                            }
                        }

                        if (jumplistItemType == T7EJumplistItem.ItemTypeVar.Category)
                        {
                            newList.AddCustomCategories(category);
                        }
                    }
                }

                // ////////
                JumpList dummyList = JumpList.CreateJumpListForAppId(parent.CurrentAppId);

                /*dummyList.AddUserTasks(new JumpListLink
                 * {
                 *  Title = "Dummy",
                 *  Path = "%windir%\\explorer.exe"
                 * });*/
                dummyList.ClearAllUserTasks();
                dummyList.Refresh();
                newList.Refresh();
                // Remove appid from own window!
                SetAppIdBackAfterJumplist();
                result = true;
            }
            catch (Exception e)
            {
                MessageBox.Show("JumpList applying not successful." + "\r\n"
                                + e.ToString());
            }

            return(result);
        }
Exemplo n.º 7
0
        public bool ApplyJumplistToTaskbar()
        {
            bool result = false;

            try
            {
                JumpList newList = JumpList.CreateJumpListForAppId(CurrentAppId);

                ListBox.ObjectCollection jumplistItems = JumplistListBox.Items;
                for (int i = 0; i < jumplistItems.Count; i++)
                {
                    // Look for a category
                    JumpListItemObject.ItemTypeVar jumplistItemType = ((JumpListItemObject)jumplistItems[i]).ItemType;
                    if (jumplistItemType == JumpListItemObject.ItemTypeVar.Category ||
                        jumplistItemType == JumpListItemObject.ItemTypeVar.CategoryTasks)
                    {
                        JumpListCustomCategory category = new JumpListCustomCategory(((JumpListItemObject)jumplistItems[i]).ItemName);

                        // Look for a task
                        for (int j = i + 1; j < jumplistItems.Count; j++)
                        {
                            i = j - 1; // When J loop is exited, i has to be less.
                            JumpListItemObject jumplistItem = (JumpListItemObject)jumplistItems[j];
                            switch (jumplistItem.ItemType)
                            {
                            case JumpListItemObject.ItemTypeVar.Category:
                            case JumpListItemObject.ItemTypeVar.CategoryTasks:
                                j = jumplistItems.Count;     // Exit the for loop
                                break;

                            case JumpListItemObject.ItemTypeVar.Task:
                                if (jumplistItemType == JumpListItemObject.ItemTypeVar.Category)
                                {
                                    category.AddJumpListItems(
                                        ParseApplyJumpListTask(jumplistItem, j));
                                }
                                else
                                {
                                    newList.AddUserTasks(
                                        ParseApplyJumpListTask(jumplistItem, j));
                                }
                                break;

                            case JumpListItemObject.ItemTypeVar.FileFolder:
                                JumpListLink link = new JumpListLink
                                {
                                    Title     = jumplistItem.ItemName,
                                    Path      = "C:\\Windows\\explorer.exe",
                                    Arguments = jumplistItem.FilePath
                                };
                                if (jumplistItem.FileRunWithApp)
                                {
                                    link.Path = CurrentAppPath;
                                }
                                // Format icon
                                if (jumplistItem.ItemIconToString().Equals("Don't use an icon") != true)
                                {
                                    // Icon processing
                                    string localIconPath = IconPathToLocal(jumplistItem.ItemIconPath, jumplistItem.ItemIconIndex, j, CurrentAppId, false);
                                    if (File.Exists(localIconPath))
                                    {
                                        link.IconReference = new IconReference(localIconPath, 0);
                                    }
                                }

                                if (jumplistItemType == JumpListItemObject.ItemTypeVar.Category)
                                {
                                    category.AddJumpListItems(link);
                                }
                                else
                                {
                                    newList.AddUserTasks(link);
                                }
                                break;

                            case JumpListItemObject.ItemTypeVar.Separator:
                                if (jumplistItemType == JumpListItemObject.ItemTypeVar.CategoryTasks)
                                {
                                    newList.AddUserTasks(new JumpListSeparator());
                                }
                                break;
                            }
                        }

                        if (jumplistItemType == JumpListItemObject.ItemTypeVar.Category)
                        {
                            newList.AddCustomCategories(category);
                        }
                    }
                }

                // ////////
                JumpList dummyList = JumpList.CreateJumpListForAppId(CurrentAppId);
                dummyList.AddUserTasks(new JumpListLink
                {
                    Title = "Dummy",
                    Path  = "%windir%\\explorer.exe"
                });
                dummyList.Refresh();
                newList.Refresh();
                // Remove appid from own window!
                SetAppIdBackAfterJumplist();
                result = true;
            }
            catch (Exception e)
            {
                MessageBox.Show("JumpList applying not successful." + "\r\n"
                                + e.ToString());
            }

            return(result);
        }