private void mnuNewScript_Click(object sender, EventArgs e) { using (NewSnippetDialog dialog = new NewSnippetDialog()) { if (dialog.ShowDialog(this) == DialogResult.OK) { string text = string.IsNullOrEmpty(txtCode.Selection.Text) ? txtCode.Text : txtCode.Selection.Text; Snippet script = new Snippet() { Name = dialog.ScriptName, Text = text, Type = CommandType }; script.Save(); LoadSnippets(); } } }