コード例 #1
0
        private void DisableSelectedApp()
        {
            if (ManageListView.SelectedItems.Count <= 0)
            {
                return;
            }
            string appName = ManageListView.SelectedItems[0].SubItems[0].Text;
            string appPath = ManageListView.SelectedItems[0].SubItems[1].Text;
            string appId   = ManageListView.SelectedItems[0].SubItems[2].Text;

            string currentLnkPath = PrimaryParent.GetLnkPathForTargetName(Path.GetFileNameWithoutExtension(appPath).ToLower());

            if (File.Exists(currentLnkPath) && Common.TaskbarManagerInstance.GetApplicationIdForShortcut(currentLnkPath) == appId)
            {
                DialogResult unpinResult = new PinPrompt(true, currentLnkPath, appName, appPath, appId).ShowDialog();
                if (unpinResult != DialogResult.OK)
                {
                    return;
                }
            }

            if (PrimaryParent.CurrentAppId != null && PrimaryParent.CurrentAppId.Equals(appId))
            {
                if (!PrimaryParent.ClearAppLoaded(true))
                {
                    return;                                      // Asks "do you want save?"
                }
            }

            Preferences.DisableApp(appId, appPath, appName);

            // Refresh applist
            PopulateManageListBox();
            UpdateButtonStatus();
        }
コード例 #2
0
        private void DeleteSelectedApp()
        {
            if (ManageListView.SelectedItems.Count <= 0)
            {
                return;
            }
            string appName = ManageListView.SelectedItems[0].SubItems[0].Text;
            string appPath = ManageListView.SelectedItems[0].SubItems[1].Text;
            string appId   = ManageListView.SelectedItems[0].SubItems[2].Text;

            DialogResult deleteDialogResult = MessageBox.Show("Are you sure you want to delete \"" +
                                                              appName +
                                                              "\" permanently?",
                                                              "Delete",
                                                              MessageBoxButtons.YesNo,
                                                              MessageBoxIcon.Exclamation);

            if (deleteDialogResult != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }

            string currentLnkPath = PrimaryParent.GetLnkPathForTargetName(Path.GetFileNameWithoutExtension(appPath).ToLower());

            if (File.Exists(currentLnkPath) && Common.TaskbarManagerInstance.GetApplicationIdForShortcut(currentLnkPath) == appId)
            {
                DialogResult unpinResult = new PinPrompt(true, currentLnkPath, appName, appPath, appId).ShowDialog();
                if (unpinResult != DialogResult.OK)
                {
                    return;
                }
            }

            if (PrimaryParent.CurrentAppId != null && PrimaryParent.CurrentAppId.Equals(appId))
            {
                if (!PrimaryParent.ClearAppLoaded(true, false))
                {
                    return;
                }
            }

            // Delete app from internal, applist.xml, and appdata
            if (ManageListView.SelectedItems[0].Group == ManageListView.Groups[1])
            {
                Preferences.DeleteApp(appId, appPath, true);
            }
            else
            {
                Preferences.DeleteApp(appId, appPath);
            }

            // Erase the old jumplist from the shell
            Preferences.EraseJumplist(appId); // Erase the old jumplist, too.

            // Refresh applist
            PopulateManageListBox();
            UpdateButtonStatus();
        }
コード例 #3
0
        private void EnableSelectedApp()
        {
            if (ManageListView.SelectedItems.Count <= 0)
            {
                return;
            }
            string appName = ManageListView.SelectedItems[0].SubItems[0].Text;
            string appPath = ManageListView.SelectedItems[0].SubItems[1].Text;
            string appId   = ManageListView.SelectedItems[0].SubItems[2].Text;

            if (Environment.OSVersion.Version.Major >= 10)
            {
                string existingLnkPath = PrimaryParent.GetLnkPathForTargetName(Path.GetFileNameWithoutExtension(appPath).ToLower());
                if (File.Exists(existingLnkPath))
                {
                    DialogResult unpinResult = new PinPrompt(true, existingLnkPath, appName, appPath, appId).ShowDialog();
                    if (unpinResult != DialogResult.OK)
                    {
                        return;
                    }
                }
            }

            // Enable app
            Preferences.EnableApp(appId, appPath);

            if (Environment.OSVersion.Version.Major >= 10)
            {
                DialogResult unpinResult = new PinPrompt(false, "", appName, appPath, appId, (Environment.OSVersion.Version.Build < 10586)).ShowDialog();
                if (unpinResult != DialogResult.OK)
                {
                    //Preferences.EraseJumplist(appId);
                    //Preferences.DisableApp(appId, appPath, appName);

                    return;
                }
                else
                {
                    this.TopMost = true;
                    this.TopMost = false;
                }
            }

            // Refresh applist
            PopulateManageListBox();
            UpdateButtonStatus();
        }