public static ShowDialog ( IWin32Window p_wndOwner, string p_strPrompt, string p_strCaption, string p_strDefault ) : string | ||
p_wndOwner | IWin32Window | The owner of the prompt window. |
p_strPrompt | string | The prompt message. |
p_strCaption | string | The title of the dialog window. |
p_strDefault | string | The default prompted text. |
Результат | string |
/// <summary> /// Displays a prompt dialog with the given message. /// </summary> /// <param name="p_wndOwner">The owner of the prompt window.</param> /// <param name="p_strPrompt">The prompt message.</param> /// <param name="p_strCaption">The title of the dialog window.</param> /// <param name="p_strDefault">The default prompted text.</param> /// <param name="p_strValidationPattern">The regular expression to use to validate the entered text.</param> /// <param name="p_strErrorMessage">The error message to display if the entered text fails validation.</param> /// <returns>The entered prompted text, or <c>null</c> if the user /// cancelled the dialog.</returns> public static string ShowDialog(IWin32Window p_wndOwner, string p_strPrompt, string p_strCaption, string p_strDefault, string p_strValidationPattern, string p_strErrorMessage) { PromptDialog dlgPrompt = new PromptDialog(); dlgPrompt.Text = p_strCaption; dlgPrompt.EnteredText = p_strDefault; dlgPrompt.Prompt = p_strPrompt; dlgPrompt.ValidationPattern = p_strValidationPattern; dlgPrompt.ValidationErrorMessage = p_strErrorMessage; if (dlgPrompt.ShowDialog(p_wndOwner) == DialogResult.OK) return dlgPrompt.EnteredText; return null; }
/// <summary> /// Displays a prompt dialog with the given message. /// </summary> /// <param name="p_wndOwner">The owner of the prompt window.</param> /// <param name="p_strPrompt">The prompt message.</param> /// <param name="p_strCaption">The title of the dialog window.</param> /// <param name="p_strDefault">The default prompted text.</param> /// <param name="p_strValidationPattern">The regular expression to use to validate the entered text.</param> /// <param name="p_strErrorMessage">The error message to display if the entered text fails validation.</param> /// <returns>The entered prompted text, or <c>null</c> if the user /// cancelled the dialog.</returns> public static PromptDialog ShowDialog(string p_strSharedLabel, IWin32Window p_wndOwner, string p_strPrompt, string p_strCaption, string p_strDefault, string p_strValidationPattern, string p_strErrorMessage) { PromptDialog dlgPrompt = new PromptDialog(); dlgPrompt.Text = p_strCaption; dlgPrompt.EnteredText = p_strDefault; dlgPrompt.cbShared.Checked = false; if (p_strCaption == "Set the Profile name") { dlgPrompt.cbShared.Visible = false; dlgPrompt.tbxPath.Visible = true; } if (p_strCaption == "Rename Local") { dlgPrompt.cbShared.Visible = true; dlgPrompt.cbShared.Enabled = false; dlgPrompt.tbxPath.Visible = true; p_strSharedLabel = "Rename Online"; } if (p_strCaption == "Rename Online") { dlgPrompt.cbShared.Visible = true; dlgPrompt.cbShared.Enabled = true; dlgPrompt.tbxPath.Visible = true; p_strSharedLabel = "Rename Online"; } if (p_strCaption == "Remove Local") { dlgPrompt.cbShared.Visible = true; dlgPrompt.cbShared.Enabled = false; dlgPrompt.tbxPath.Visible = false; p_strSharedLabel = "Remove Online"; } if (p_strCaption == "Remove Online") { dlgPrompt.cbShared.Visible = true; dlgPrompt.cbShared.Enabled = true; dlgPrompt.tbxPath.Visible = false; p_strSharedLabel = "Remove Online"; } if (p_strCaption == "Remove Backedup Profile") { dlgPrompt.cbShared.Visible = false; dlgPrompt.cbShared.Enabled = true; dlgPrompt.tbxPath.Visible = false; p_strSharedLabel = ""; } dlgPrompt.lbShared.Text = p_strSharedLabel; dlgPrompt.Prompt = p_strPrompt; dlgPrompt.ValidationPattern = p_strValidationPattern; dlgPrompt.ValidationErrorMessage = p_strErrorMessage; if (dlgPrompt.ShowDialog(p_wndOwner) == DialogResult.OK) { return(dlgPrompt); } return(null); }