示例#1
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();
        }