public MessageBoxResponse GetNumericUserInput(string question, string title, int defaultValue, int minValue, int maxValue, Form parent = null) { NumberDialog dialog = new NumberDialog(title, question, defaultValue, minValue, maxValue); if (parent == null) { CenterDialog(dialog); } var input = 0; var validInput = false; DialogResult result; do { result = dialog.ShowDialog(parent); if (result == DialogResult.OK) { if (dialog.Value == 0) { continue; } input = dialog.Value; } validInput = true; }while (!validInput && result != DialogResult.OK); return(new MessageBoxResponse(Enum <MessageResult> .ConvertFromOtherEnumValue(result), input.ToString())); }
private void PasteClipboardFiltersMultipleTimes() { Point cursor = Cursor.Position; using ( NumberDialog numberDialog = new NumberDialog("Number of Copies", "How many copies of the given filter(s)?", 1, 1, 1000) ) { if (numberDialog.ShowDialog() == DialogResult.OK) { PasteClipboardFilters(cursor, numberDialog.Value); } } }
private void ZigZagItems_Click(object sender, EventArgs e) { var selectedindexes = elementList.SelectedIndices; var indexMap = new Dictionary <int, ListViewItem>(); int IterationCounter = 0; NumberDialog numberDialog = new NumberDialog("ZigZag Length", "How many pixels to ZigZag?", 2, 2, selectedindexes.Count); DialogResult Answer; do { Answer = numberDialog.ShowDialog(); if (Answer == DialogResult.OK) { if (selectedindexes.Count % numberDialog.Value == 0) // Selected pixels must be evenly divisable by zigzag length. { int ZigZagLength = numberDialog.Value; for (int i = 1; i < (selectedindexes.Count / (ZigZagLength * 2) + .5); i++) { for (int Zig = 1; Zig <= ZigZagLength; Zig++) { IterationCounter++; indexMap.Add(selectedindexes[IterationCounter - 1], elementList.Items[selectedindexes[IterationCounter - 1]]); } if (IterationCounter >= selectedindexes.Count) { break; } int LastZig = IterationCounter; for (int Zag = ZigZagLength; Zag >= 1; Zag--) { IterationCounter++; indexMap.Add(selectedindexes[LastZig + Zag - 1], elementList.Items[selectedindexes[IterationCounter - 1]]); } if (IterationCounter >= selectedindexes.Count) { break; } } foreach (var item in indexMap) { elementList.Items.RemoveAt(item.Key); elementList.Items.Insert(item.Key, (ListViewItem)item.Value.Clone()); elementList.Items[item.Key].Selected = true; } ReIndexElementNodes(); return; } else { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) var messageBox = new MessageBoxForm("The total selected pixels must be evenly divisable by the zigzag length", "Zigzag Error", false, false); MessageBoxForm.msgIcon = System.Drawing.SystemIcons.Exclamation; //this is used if you want to add a system icon to the message form. messageBox.ShowDialog(); } } } while (Answer == DialogResult.OK); }