private void AddButton_Click(object sender, EventArgs e) { string url = AddTextBox.Text.Trim(); // Check if the URL is blank. if (url == string.Empty) { MessageBox.Show("The link can not be blank!", "Blank Input", MessageBoxButtons.OK, MessageBoxIcon.Hand); AddTextBox.Focus(); return; } // Check if the URL is a valid URL. if (!IsValidURL(url, UriKind.Absolute)) { MessageBox.Show("The link it not valid!\r\nMake sure it contains the proper protocol prefix (http, https)...", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Hand); AddTextBox.Focus(); return; } // Check if the URL is a CurseForge link. if (!URLContainsDomain(url, "minecraft.curseforge.com")) { MessageBox.Show("The link it not a valid CurseForge link!", "Invalid Domain", MessageBoxButtons.OK, MessageBoxIcon.Hand); AddTextBox.Focus(); return; } ToggleProcessing(true); try { NewMod.Link = url; (Mod Mod, Exception Exception)parseResult = Parsing.ParseForInfo(NewMod); NewMod = parseResult.Mod; if (parseResult.Exception != null) { throw parseResult.Exception; } if (NewMod == null) { throw new ArgumentNullException("NewMod"); } DialogResult = DialogResult.OK; } catch (Exception ex) { AbortError = ex.Message; DialogResult = DialogResult.Abort; } }
private void AddNumberButton_Click(object sender, EventArgs e) { if (int.TryParse(AddTextBox.Text, out int value) && value <= maxValue) { if (sortedItemsCount >= maxSortedItemsCount) { VisualPanel.Controls.Clear(); sortedItemsCount = 0; items.Clear(); values.Clear(); } SortedItem item = new SortedItem(VisualPanel, ++sortedItemsCount, value); items.Add(item); values.Add(value); } AddTextBox.Text = ""; AddTextBox.Focus(); }