protected override IOptimizer CreateItem() { if (typeSelectorDialog == null) { typeSelectorDialog = new TypeSelectorDialog(); typeSelectorDialog.Caption = "Select Optimizer"; typeSelectorDialog.TypeSelector.Caption = "Available Optimizers"; typeSelectorDialog.TypeSelector.Configure(typeof(IOptimizer), false, true); } if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { return((IOptimizer)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType()); } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } return(null); }
protected virtual object CreateItem() { if (typeSelectorDialog == null) { typeSelectorDialog = new TypeSelectorDialog { Caption = "Select Item" }; typeSelectorDialog.TypeSelector.Caption = "Available Items"; typeSelectorDialog.TypeSelector.Configure(typeof(IItem), false, true); } if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { return((object)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType()); } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } return(null); }
private void addButton_Click(object sender, EventArgs e) { if (typeSelectorDialog == null) { typeSelectorDialog = new TypeSelectorDialog(); typeSelectorDialog.Caption = "Select Symbol"; typeSelectorDialog.TypeSelector.Caption = "Available Symbols"; typeSelectorDialog.TypeSelector.Configure(typeof(ISymbol), false, false, (t) => { return(!typeof(IReadOnlySymbol).IsAssignableFrom(t)); }); } if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { ISymbol symbol = (ISymbol)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); ChangeDuplicateSymbolNames(symbol); GroupSymbol groupSymbol = null; TreeNode selectedNode = symbolsTreeView.SelectedNode; if (selectedNode != null) { groupSymbol = selectedNode.Tag as GroupSymbol; if (groupSymbol == null && selectedNode.Parent != null) { groupSymbol = selectedNode.Parent.Tag as GroupSymbol; } } if (groupSymbol != null) { groupSymbol.SymbolsCollection.Add(symbol); } else { Content.AddSymbol(symbol); } } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } }
private void newDataButton_Click(object sender, EventArgs e) { if (typeSelectorDialog == null) { typeSelectorDialog = new TypeSelectorDialog(); typeSelectorDialog.Caption = "Select Algorithm"; typeSelectorDialog.TypeSelector.Caption = "Available Algorithms"; typeSelectorDialog.TypeSelector.Configure(typeof(IAlgorithm), false, true); } if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { Content.DataTypeName = typeSelectorDialog.TypeSelector.SelectedType.Name; Content.DataTypeTypeName = typeSelectorDialog.TypeSelector.SelectedType.AssemblyQualifiedName; data = null; dataViewHost.Content = (IContent)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, "Create new algorithm data failed.", ex); } SetEnabledStateOfControls(); } }
private void ShowTypeSelectorDialog(ISelectedType selectedType, string dialogTitle, TextBox textBox) { var view = new SelectedTypeViewModel(selectedType) { DialogTitle = dialogTitle, TextBox = textBox }; var controller = new TypeSelectorController(view); controller.LoadView(); var dialog = new TypeSelectorDialog() { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner, Model = view }; view.SaveViewToModelCallback = controller.SaveView; if (dialog.ShowDialog() != true) { return; } }