예제 #1
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();
        }