void EditEvent(object sender, System.EventArgs e) { int i = GetCurrentIndex(); if (i != -1) { ListViewItem item = ((ListView)ControlDictionary["templateListView"]).SelectedItems[0]; CodeTemplate template = (CodeTemplate)item.Tag; template = new CodeTemplate(template.Shortcut, template.Description, template.Text); using (EditTemplateDialog etd = new EditTemplateDialog(template)) { if (etd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { item.Tag = template; StoreTemplateGroup(); } } BuildListView(); } }
void AddEvent(object sender, System.EventArgs e) { CodeTemplate newTemplate = new CodeTemplate(); using (EditTemplateDialog etd = new EditTemplateDialog(newTemplate)) { if (etd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { CurrentTemplateGroup.Templates.Add(newTemplate); ((ListView)ControlDictionary["templateListView"]).SelectedItems.Clear(); BuildListView(); ((ListView)ControlDictionary["templateListView"]).Select(); } } }