private void buttonUninstall_Click(object sender, EventArgs e) //sends checked indices to ModManager for uninstallation. { // Get the indices of all checked mods, and their names. CheckedListBox.CheckedIndexCollection checkedModIndices = listInstalledMods.CheckedIndices; CheckedListBox.CheckedItemCollection checkedModItems = listInstalledMods.CheckedItems; string markedModNames = ""; foreach (object mod in checkedModItems) { markedModNames += "\n" + mod.ToString(); } if (!(MessageBox.Show("The following mods will be uninstalled:\n" + markedModNames, "SnakeBite", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)) { return; } log.ClearPage(); SetVisiblePage(log); ProgressWindow.Show("Uninstalling Mod(s)", "Uninstalling, please wait...", new Action((MethodInvoker) delegate { UninstallManager.UninstallMods(checkedModIndices); }), log); RefreshInstalledMods(true); }
//TODO: not enough info in ModEntry to match uninstall using passed in filename public void ProcessUninstallMod(List <string> modPaths, bool skipcleanup)// command-line uninstall using list of mod names { for (int i = 0; i < listInstalledMods.Items.Count; i++) { listInstalledMods.SetItemCheckState(i, CheckState.Unchecked); } var mods = manager.GetInstalledMods(); foreach (string modPath in modPaths) { ModEntry mod = mods.FirstOrDefault(entry => entry.Name == modPath); // select mod if (mod != null) { listInstalledMods.SetItemCheckState(mods.IndexOf(mod), CheckState.Checked); } } CheckedListBox.CheckedIndexCollection checkedModIndices = listInstalledMods.CheckedIndices; ProgressWindow.Show("Uninstalling Mod", "Uninstalling...", new Action((MethodInvoker) delegate { UninstallManager.UninstallMods(checkedModIndices, skipcleanup); }), log); }
public void ProcessUninstallMod(ModEntry mod, bool skipcleanup)// command-line uninstall. This checks the mod it was passed, and puts it in a 1-item list to be uninstalled. { for (int i = 0; i < listInstalledMods.Items.Count; i++) { listInstalledMods.SetItemCheckState(i, CheckState.Unchecked); } var mods = manager.GetInstalledMods(); listInstalledMods.SetItemCheckState(mods.IndexOf(mod), CheckState.Checked); CheckedListBox.CheckedIndexCollection checkedModIndex = listInstalledMods.CheckedIndices; ProgressWindow.Show("Uninstalling Mod", "Uninstalling...", new Action((MethodInvoker) delegate { UninstallManager.UninstallMods(checkedModIndex, skipcleanup); }), log); }