public static string AskValue(IWin32Window owner, string caption = "InputBox", string description = "Insert a new value.", string value = "") { InputBox input = new InputBox(); string ret = ""; try { input.Text = caption; input.lbDescription.Text = description; input.txValue.Text = value; input.ShowDialog(owner); if (input.DialogResult == System.Windows.Forms.DialogResult.OK) { ret = input.txValue.Text; } input.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.GetType().FullName, ex.Message); } return ret; }
//======================================================================== public string PromptInput(string prompt) { InputBox inp = new InputBox("Run Report", prompt, "", false); if (inp.ShowDialog(this) == DialogResult.Cancel) { inp.Dispose(); return(null); } string result = inp.Input; inp.Dispose(); return(result); }
void ReleaseDesignerOutlets() { if (OutputBox != null) { OutputBox.Dispose(); OutputBox = null; } if (InputBox != null) { InputBox.Dispose(); InputBox = null; } if (OutputUnitPicker != null) { OutputUnitPicker.Dispose(); OutputUnitPicker = null; } if (InputUnitPicker != null) { InputUnitPicker.Dispose(); InputUnitPicker = null; } if (DpEntryField != null) { DpEntryField.Dispose(); DpEntryField = null; } }
private void change_all_selected_cells(DataGridView dgv) { InputBox testdialog = new InputBox(); if (testdialog.ShowDialog(this) == DialogResult.OK) { foreach (DataGridViewTextBoxCell cell in dgv.SelectedCells.OfType <DataGridViewTextBoxCell>()) { cell.Value = testdialog.tb.Text; } } testdialog.Dispose(); }
public static String Show(String Prompt, String Title = "", String DefaultResponse = "", int XPos = -1, int YPos = -1) { InputBox form = new InputBox(); Form parent = null; if (Application.OpenForms.Count > 0) { parent = Application.OpenForms[0]; } if (Prompt != null) { form.lblPrompt.Text = Prompt; } if (Title != null && Title.Length > 0) { form.Text = Title; } else if (parent != null) { form.Text = parent.Text; } if (DefaultResponse != null && DefaultResponse.Length > 0) { form.txtOutput.Text = DefaultResponse; } if (XPos >= 0 && YPos >= 0) { form.StartPosition = FormStartPosition.Manual; form.DesktopLocation = new Point(XPos, YPos); } else if (parent != null) { form.StartPosition = FormStartPosition.CenterParent; } else { form.StartPosition = FormStartPosition.CenterScreen; } form.ShowDialog(parent); String ret = form.Output; form.Dispose(); return(ret); }
public static string Show(string title, string label, string textbox) { InputBox box = new InputBox(); box.Text = title; box.label.Text = label; box.textbox.Text = textbox; box.ShowDialog(); string retval = box.retval; box.Dispose(); return(retval); }
void ReleaseDesignerOutlets() { if (ChatInput != null) { ChatInput.Dispose(); ChatInput = null; } if (InputBox != null) { InputBox.Dispose(); InputBox = null; } if (InputBoxBottomConstraint != null) { InputBoxBottomConstraint.Dispose(); InputBoxBottomConstraint = null; } if (InputBoxTopRuler != null) { InputBoxTopRuler.Dispose(); InputBoxTopRuler = null; } if (InputRightConstraint != null) { InputRightConstraint.Dispose(); InputRightConstraint = null; } if (MessageTable != null) { MessageTable.Dispose(); MessageTable = null; } if (Send != null) { Send.Dispose(); Send = null; } if (SendRightConstraint != null) { SendRightConstraint.Dispose(); SendRightConstraint = null; } }
// 自定义输入窗在显示/隐藏时,禁用/启用其他控件 private void inputBox_VisibleChanged(object sender, EventArgs e) { //自定义输入窗显示,并绑定小键盘 if (inputBox.Visible) { InputBoxBindingMinikeyboard(); } //自定义输入窗隐藏,启用所有控件,重新绑定小键盘 else { foreach (Control control in Controls) { control.Enabled = true; } miniKeyboard.Press -= MiniKeyboardHandler_Input; miniKeyboard.Press += MiniKeyboardHandler_CheckInput; } inputBox.Dispose(); }
public static InputBoxResult ShowDialog(IWin32Window owner, string captionText, string defaultValue, Image iconImage) { InputBox inputBox = new InputBox(); inputBox.Caption = captionText; inputBox.InputValue = defaultValue; inputBox.IconImage = iconImage; InputBoxResult result = new InputBoxResult(); result.dialogResult = inputBox.ShowDialog(owner); result.val = inputBox.InputValue; inputBox.Dispose(); inputBox = null; return result; }
public static string Show(string title, string label, string textbox) { InputBox box = new InputBox(); box.Text = title; box.label.Text = label; box.textbox.Text = textbox; box.ShowDialog(); string retval = box.retval; box.Dispose(); return retval; }
void ReleaseDesignerOutlets() { if (GameModeLabel != null) { GameModeLabel.Dispose(); GameModeLabel = null; } if (BGBox != null) { BGBox.Dispose(); BGBox = null; } if (TextArea != null) { TextArea.Dispose(); TextArea = null; } if (VerticalLine != null) { VerticalLine.Dispose(); VerticalLine = null; } if (HorizontalLine != null) { HorizontalLine.Dispose(); HorizontalLine = null; } if (AccuracyText != null) { AccuracyText.Dispose(); AccuracyText = null; } if (SpeedText != null) { SpeedText.Dispose(); SpeedText = null; } if (DurationText != null) { DurationText.Dispose(); DurationText = null; } if (AccuracyNum != null) { AccuracyNum.Dispose(); AccuracyNum = null; } if (SpeedNum != null) { SpeedNum.Dispose(); SpeedNum = null; } if (DurationNum != null) { DurationNum.Dispose(); DurationNum = null; } if (BGBoxWhite != null) { BGBoxWhite.Dispose(); BGBoxWhite = null; } if (InputBox != null) { InputBox.Dispose(); InputBox = null; } }
public static String Show(String Prompt, String Title = "", String DefaultResponse = "", int XPos = -1, int YPos = -1) { InputBox form = new InputBox(); Form parent = null; if (Application.OpenForms.Count > 0) parent = Application.OpenForms[0]; if (Prompt != null) form.lblPrompt.Text = Prompt; if (Title != null && Title.Length > 0) { form.Text = Title; } else if (parent != null) { form.Text = parent.Text; } if (DefaultResponse != null && DefaultResponse.Length > 0) form.txtOutput.Text = DefaultResponse; if (XPos >= 0 && YPos >= 0) { form.StartPosition = FormStartPosition.Manual; form.DesktopLocation = new Point(XPos, YPos); } else if (parent != null) form.StartPosition = FormStartPosition.CenterParent; else form.StartPosition = FormStartPosition.CenterScreen; form.ShowDialog(parent); String ret = form.Output; form.Dispose(); return ret; }
public static DialogResult ShowDialog(string caption, string prompt, string defaultValue, out string input, InputBoxResultType validationType) { // Create an instance of the InputBox class. InputBox inputBox = new InputBox(); // Set the members of the new instance // according to the value of the parameters if (string.IsNullOrEmpty(caption)) { inputBox.Text = Application.ProductName; } else { inputBox.Text = caption; } if (!string.IsNullOrEmpty(prompt)) { inputBox.lblPrompt.Text = prompt; } if (!string.IsNullOrEmpty(defaultValue)) { inputBox.defaultValue = inputBox.txtInput.Text = defaultValue; } // Calculate size required for prompt message and adjust // Label and dialog size to fit. Size promptSize = inputBox.lblPrompt.CreateGraphics().MeasureString(prompt, inputBox.lblPrompt.Font, inputBox.ClientRectangle.Width - 20).ToSize(); // a little wriggle room if (promptSize.Height > inputBox.lblPrompt.Height) { promptSize.Width += 4; promptSize.Height += 4; } inputBox.lblPrompt.Width = inputBox.ClientRectangle.Width - 20; inputBox.lblPrompt.Height = Math.Max(inputBox.lblPrompt.Height, promptSize.Height); int postLabelMargin = 2; if ((inputBox.lblPrompt.Top + inputBox.lblPrompt.Height + postLabelMargin) > inputBox.txtInput.Top) { inputBox.ClientSize = new Size(inputBox.ClientSize.Width, inputBox.ClientSize.Height + (inputBox.lblPrompt.Top + inputBox.lblPrompt.Height + postLabelMargin - inputBox.txtInput.Top)); } else if ((inputBox.lblPrompt.Top + inputBox.lblPrompt.Height + postLabelMargin) < inputBox.txtInput.Top) { inputBox.ClientSize = new Size(inputBox.ClientSize.Width, inputBox.ClientSize.Height - (inputBox.lblPrompt.Top + inputBox.lblPrompt.Height + postLabelMargin - inputBox.txtInput.Top)); } // Ensure that the value of input is set // There will be a compile error later if not input = string.Empty; // Declare a variable to hold the result to be // returned on exitting the method DialogResult result = DialogResult.None; // Loop round until the user enters // some valid data, or cancels. while (result == DialogResult.None) { result = inputBox.ShowDialog(); if (result == DialogResult.OK) { // if user clicked OK, validate the entry input = inputBox.txtInput.Text; // Only test if specific type is required if (validationType != InputBoxResultType.Any) { // If the test fails - Invalid input. if (!inputBox.Validate(validationType)) { // Set variables ready for another loop input = string.Empty; // result to 'None' to ensure while loop // repeats result = DialogResult.None; // Let user know there is a problem MessageBox.Show(inputBox, "La informacion que ha ingresado no es valida " + validationType.ToString() + "."); // Set the focus back to the TextBox inputBox.txtInput.Select(); } } } else { // User has cancelled. // Use the defaultValue if there is one, or else // an empty string. if (string.IsNullOrEmpty(inputBox.defaultValue)) { input = string.Empty; } else { input = inputBox.defaultValue; } } } // Trash the dialog if it is hanging around. if (inputBox != null) { inputBox.Dispose(); } // Send back the result. return result; }
//------------------------------------------------------------------------ private void btnTest_Click(object sender, EventArgs e) { SymSession test = new SymSession(); try { if (!test.Connect(Server.IP, Server.Port)) { MessageBox.Show(test.error, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string aixPwd = Server.AixPwd; if (aixPwd.Trim().Length == 0) { InputBox inp = new InputBox("Test Sym Connection", "Please Enter AIX Password for Server \"" + Server.Alias + "\".", "", true); if (inp.ShowDialog(this) == DialogResult.Cancel) { return; } aixPwd = inp.Input; inp.Dispose(); } bool retry = true; bool result = test.Login(Server.AixUsr, aixPwd, txtSym.Text, txtID.Text); while (retry && (!result)) { retry = false; if (result == false) { if (test.error == "Invalid AIX Login") { InputBox inp = new InputBox("Test Sym Connection", "Invalid AIX Login.\nPlease Re-Enter or Cancel (ESC).", "", true); if (inp.ShowDialog(this) == DialogResult.Cancel) { return; } aixPwd = inp.Input; inp.Dispose(); result = test.Login(Server.AixUsr, aixPwd, txtSym.Text, txtID.Text, 1); retry = true; } else if (test.error == "Invalid Sym User") { InputBox inp = new InputBox("Test Sym Connection", "Invalid Sym User ID.\nPlease Re-Enter or Cancel (ESC).", "", true); if (inp.ShowDialog(this) == DialogResult.Cancel) { return; } txtID.Text = inp.Input; inp.Dispose(); result = test.Login(Server.AixUsr, aixPwd, txtSym.Text, txtID.Text, 2); retry = true; } else { retry = (MessageBox.Show("Error Connecting to Sym\nError: " + test.error + "\n\nRetry?", "Sym Connection Test", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes); } if ((!retry) && (!result)) { test.Disconnect(); return; } } } } catch (Exception ex) { MessageBox.Show("Error During Login Test\n" + ex.Message, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } test.Disconnect(); MessageBox.Show("Sym Connected Okay!", "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.None); }
private async Task OnHandleHey(ConsoleKeyInfo keyInfo) { if (InputBox.IsInputBlocked) { return; } OnKeyPress(keyInfo); if (keyInfo.Key == ConsoleKey.Enter) { ConsoleString output = ConsoleString.Empty; try { var args = Args.Convert(InputBox.Value.ToString()); AddHistory(InputBox.Value.ToString()); if (def.ExceptionBehavior?.Policy == ArgExceptionPolicy.StandardExceptionHandling) { def.ExceptionBehavior = new ArgExceptionBehavior(ArgExceptionPolicy.DontHandleExceptions); } ArgAction action; ConsoleOutInterceptor.Instance.Attach(); try { action = Args.ParseAction(def, args); } finally { ConsoleOutInterceptor.Instance.Detatch(); } InputBox.Dispose(); output = new ConsoleString(ConsoleOutInterceptor.Instance.ReadAndClear()); if (action.Cancelled == false) { var oldDef = Args.GetAmbientDefinition(); try { Args.SetAmbientDefinition(def); await Run(action); } finally { Args.SetAmbientDefinition(oldDef); } } } catch (Exception ex) { var inner = ex; if (ex is AggregateException && (ex as AggregateException).InnerExceptions.Count == 1) { inner = ex.InnerException; } if (ex is ArgException == false) { throw; } output = inner.Message.ToRed(); } finally { if (IsExpired == false) { HardRefresh(output); } } } else if (keyInfo.Key == ConsoleKey.Tab) { ConsoleCharacter?prototype = InputBox.Value.Length == 0 ? (ConsoleCharacter?)null : InputBox.Value[InputBox.Value.Length - 1]; InputBox.RichTextEditor.RegisterKeyPress(keyInfo, prototype); } else if (keyInfo.Key == ConsoleKey.UpArrow) { if (HasHistory()) { InputBox.Value = GetHistoryPrevious(); SetOutput(CreateAssistiveText()); } } else if (keyInfo.Key == ConsoleKey.DownArrow) { if (HasHistory()) { InputBox.Value = GetHistoryNext(); SetOutput(CreateAssistiveText()); } } else if (RichTextCommandLineReader.IsWriteable(keyInfo)) { SetOutput(CreateAssistiveText()); } AfterKeyPress(keyInfo); }