private void _mnuAdd_Click(object sender, EventArgs e) { try { ExternalType externalType = (ExternalType)((ToolStripMenuItem)sender).Tag; IExternal external = externalType.CreateExternal(); IExternalPropertiesComponent component = externalType.CreateExternalPropertiesComponent(); component.Load(external); SimpleComponentContainer container = new SimpleComponentContainer(component); if (_component.DesktopWindow.ShowDialogBox(container, Resources.TitleNewExternal) == DialogBoxAction.Ok) { component.Update(external); _component.Externals.Add(external); ListViewItem lvi = CreateItem(external); _listExternals.Items.Add(lvi); lvi.Selected = true; _component.FlagModified(); } } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "An error occured while adding an external application definition."); MessageBox.Show(this, Resources.MessageErrorAddingExternal); } }
private void _btnEdit_Click(object sender, EventArgs e) { if (this.SelectedItem != null) { try { IExternal external = this.SelectedItem.Tag as IExternal; if (external != null) { foreach (ExternalType externalType in _externalTypes) { if (externalType.SupportsExternal(external)) { IExternalPropertiesComponent component = externalType.CreateExternalPropertiesComponent(); component.Load(external); SimpleComponentContainer container = new SimpleComponentContainer(component); if (_component.DesktopWindow.ShowDialogBox(container, string.Format(Resources.TitleEditProperties, external.Label)) == DialogBoxAction.Ok) { component.Update(external); ResetExternalList(); foreach (ListViewItem item in _listExternals.Items) { if (item.Tag == external) { item.Selected = true; break; } } _component.FlagModified(); } break; } } } } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "An error occured while editing an external application definition."); MessageBox.Show(this, Resources.MessageErrorEditingExternal); } } }