public static string Input(IWin32Window handle, string title, string caption) { using (var form = new TextInputForm()) { form.Text = title; form.label1.Text = caption; if (form.ShowDialog(handle) == DialogResult.OK) { return(form.textBox1.Text); } else { return(null); } } }
void SaveCommandLine() { Here: string templateName = TextInputForm.Input(this, String.Format("Save for {0}", commandLoaded.CommandName), "Template description"); if (!CommandsTemplates.Instance.AddTemplate(commandLoaded.CommandName, templateName, textBox.Text, false)) { var r = MessageBox.Show(this, String.Format("Do you want to overwrite existing template ({0})", templateName), "Confirmation", MessageBoxButtons.YesNoCancel); if (r == System.Windows.Forms.DialogResult.Yes) { CommandsTemplates.Instance.AddTemplate(commandLoaded.CommandName, templateName, textBox.Text, true); } else if (r == System.Windows.Forms.DialogResult.No) { goto Here; } } RefreshTemplatesDropdown(); }