private async void LoadToolStripMenuItem_Click(object sender, EventArgs e) { if (ModListView.Items.Count != 0) { DialogResult overwrite = MessageBox.Show("The mod list is not empty, are you sure you want to overwrite the current list?", "Confirm Overwrite", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (overwrite == DialogResult.No) { return; } } try { if (LoadModListDialog.ShowDialog() == DialogResult.OK) { ToggleLoadingLabel(true); ModListView.BeginUpdate(); ModListView.Items.Clear(); ModListView.Sorting = SortOrder.None; await Task.Run(() => LoadModList(LoadModListDialog.FileName)); if (KeepSortedCheckBox.Checked) { ModListView.Sorting = SortOrder.Ascending; ModListView.Sort(); } ModListView.EndUpdate(); ToggleLoadingLabel(false); } } catch (Exception ex) { MessageBox.Show($"There was an error loading the mod list.\r\n\r\nType: {ex.GetType().Name}\r\n\r\n{ex.Message}", "Error Loading Mod List", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadGitHubButton_Click(object sender, EventArgs e) { if (ModListView.Items.Count != 0) { DialogResult overwrite = MessageBox.Show("The download list is not empty, are you sure you want to overwrite the current list?", "Confirm Overwrite", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (overwrite == DialogResult.No) { return; } } try { ToggleLoadingLabel(true); ModListView.BeginUpdate(); ModListView.Items.Clear(); Pack selectedPack = (Pack)PacksComboBox.SelectedItem; WebClient client = new WebClient(); client.Headers.Add("user-agent", UserAgent); string modListString = client.DownloadString(selectedPack.ModListURL); LoadModList(null, modListString); ModListView.EndUpdate(); ToggleLoadingLabel(false); if (ReleaseTypeComboBox.SelectedItem != null) { if (ModListView.Items.Count != 0) { UpdateButton.Enabled = true; } else { UpdateButton.Enabled = false; } } if (GameVersionsComboBox.SelectedItem != null) { if (ModListView.Items.Count != 0) { UpdateButton.Enabled = true; } else { UpdateButton.Enabled = false; } } } catch (Exception ex) { MessageBox.Show($"There was an error loading the mod list from GitHub.\r\n\r\nType: {ex.GetType().Name}\r\n\r\n{ex.Message}", "Error Loading Mod List", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async void LoadLocalButton_Click(object sender, EventArgs e) { if (ModListView.Items.Count != 0) { DialogResult overwrite = MessageBox.Show("The download list is not empty, are you sure you want to overwrite the current list?", "Confirm Overwrite", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (overwrite == DialogResult.No) { return; } } try { if (LoadModListDialog.ShowDialog() == DialogResult.OK) { ToggleLoadingLabel(true); ModListView.BeginUpdate(); ModListView.Items.Clear(); await Task.Run(() => LoadModList(LoadModListDialog.FileName)); ModListView.EndUpdate(); ToggleLoadingLabel(false); if (ReleaseTypeComboBox.SelectedItem != null) { if (ModListView.Items.Count != 0) { UpdateButton.Enabled = true; } else { UpdateButton.Enabled = false; } } if (GameVersionsComboBox.SelectedItem != null) { if (ModListView.Items.Count != 0) { UpdateButton.Enabled = true; } else { UpdateButton.Enabled = false; } } } } catch (Exception ex) { MessageBox.Show($"There was an error loading the mod list.\r\n\r\nType: {ex.GetType().Name}\r\n\r\n{ex.Message}", "Error Loading Mod List", MessageBoxButtons.OK, MessageBoxIcon.Error); } }