/// <summary> /// Displays a prompt in a dialog box, waits for the user to input text or click a button. /// </summary> /// <param name="prompt">String expression displayed as the message in the dialog box</param> /// <param name="title">String expression displayed in the title bar of the dialog box</param> /// <param name="defaultResponse">String expression displayed in the text box as the default response</param> /// <param name="validator">Delegate used to validate the text</param> /// <param name="xpos">Numeric expression that specifies the distance of the left edge of the dialog box from the left edge of the screen.</param> /// <param name="ypos">Numeric expression that specifies the distance of the upper edge of the dialog box from the top of the screen</param> /// <returns>An CurveSelectBoxResult object with the Text and the OK property set to true when OK was clicked.</returns> public static CurveSelectBoxResult Show(string prompt, string title, string defaultResponse, int xpos, int ypos) { using (CurveSelectBox form = new CurveSelectBox()) { form.labelPrompt.Text = prompt; form.Text = title; form.lstCurves.Text = defaultResponse; if (xpos >= 0 && ypos >= 0) { form.StartPosition = FormStartPosition.Manual; form.Left = xpos; form.Top = ypos; } //form.Validator = validator; DialogResult result = form.ShowDialog(); CurveSelectBoxResult retval = new CurveSelectBoxResult(); if (result == DialogResult.OK) { retval.Text = form.lstCurves.Text; if (retval.Text != null && retval.Text.Trim() != "") { foreach (IObject3D obj in SceneManager.Instance.ObjectList) { if (obj.Name == retval.Text) { retval.SelectedCurve = (Midget.Curve)obj; break; } } } retval.OK = true; } return(retval); } }
/// <summary> /// Displays a prompt in a dialog box, waits for the user to input text or click a button. /// </summary> /// <param name="prompt">String expression displayed as the message in the dialog box</param> /// <param name="title">String expression displayed in the title bar of the dialog box</param> /// <param name="defaultResponse">String expression displayed in the text box as the default response</param> /// <param name="validator">Delegate used to validate the text</param> /// <param name="xpos">Numeric expression that specifies the distance of the left edge of the dialog box from the left edge of the screen.</param> /// <param name="ypos">Numeric expression that specifies the distance of the upper edge of the dialog box from the top of the screen</param> /// <returns>An CurveSelectBoxResult object with the Text and the OK property set to true when OK was clicked.</returns> public static CurveSelectBoxResult Show(string prompt, string title, string defaultResponse, int xpos, int ypos) { using (CurveSelectBox form = new CurveSelectBox()) { form.labelPrompt.Text = prompt; form.Text = title; form.lstCurves.Text = defaultResponse; if (xpos >= 0 && ypos >= 0) { form.StartPosition = FormStartPosition.Manual; form.Left = xpos; form.Top = ypos; } //form.Validator = validator; DialogResult result = form.ShowDialog(); CurveSelectBoxResult retval = new CurveSelectBoxResult(); if (result == DialogResult.OK) { retval.Text = form.lstCurves.Text; if (retval.Text != null && retval.Text.Trim() != "") { foreach (IObject3D obj in SceneManager.Instance.ObjectList) { if (obj.Name == retval.Text) { retval.SelectedCurve = (Midget.Curve)obj; break; } } } retval.OK = true; } return retval; } }