private void AddButton_Click(object sender, EventArgs e) { if (int.TryParse(AddTextBox.Text, out int value)) { var item = new SortedItem(value, items.Count); items.Add(item); this.panel3.Controls.Add(item.ProgressBar); this.panel3.Controls.Add(item.Label); } AddTextBox.Clear(); }
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(); }
/// <summary> /// Adds a checkbox with the given text to the checklist /// </summary> /// <param name="text">The text on the checkbox</param> private void AddItem(object text) { string itemText = text.ToString(); // Error validatation. If the default to-do is there still, remove it. If it's empty, return if (string.IsNullOrWhiteSpace(text.ToString())) { return; } else if (CheckListItems.Count == 1 && CheckListList.ElementAt(0).Content.ToString() == DefaultTODO) { CheckListList.RemoveAt(0); } // Make a checkbox for the item and add it. CheckListList.Add(MakeCheckBoxForItem(itemText)); AddTextBox.Clear(); // Save the newly created item. DataDealer.WriteChecklistData(CheckListItems); // Fire the event. ItemAdded?.Invoke(this, itemText); }
private void AddTextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e) { AddTextBox.Clear(); }