private void addButton_Click(object sender, EventArgs e) { if (typeSelectorDialog == null) { typeSelectorDialog = new TypeSelectorDialog(); typeSelectorDialog.Caption = "Select Item"; typeSelectorDialog.TypeSelector.Caption = "Available Items"; typeSelectorDialog.TypeSelector.Configure(typeof(T), false, true); } if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { AddItem((T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType()); } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } }
protected virtual T CreateItem() { if (typeSelectorDialog == null) { typeSelectorDialog = new TypeSelectorDialog(); typeSelectorDialog.Caption = "Select Item"; typeSelectorDialog.TypeSelector.Caption = "Available Items"; typeSelectorDialog.TypeSelector.Configure(typeof(T), false, true); } if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { return((T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType()); } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } return(null); }
protected override IOperator CreateItem() { if (typeSelectorDialog == null) { typeSelectorDialog = new TypeSelectorDialog(); typeSelectorDialog.Caption = "Select Operator"; typeSelectorDialog.TypeSelector.Caption = "Available Operators"; typeSelectorDialog.TypeSelector.Configure(typeof(IOperator), false, true); } if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { return((IOperator)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType()); } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } return(null); }
private void newProblemButton_Click(object sender, EventArgs e) { if (problemTypeSelectorDialog == null) { problemTypeSelectorDialog = new TypeSelectorDialog(); problemTypeSelectorDialog.Caption = "Select Problem"; problemTypeSelectorDialog.TypeSelector.Caption = "Available Problems"; } problemTypeSelectorDialog.TypeSelector.Configure(new List<Type>() { Content.ProblemType, Content.Algorithm.ProblemType }, false, true, true); if (problemTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) { Content.Problem = (IDataAnalysisProblem)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); } }
private void newAlgorithmButton_Click(object sender, EventArgs e) { if (algorithmTypeSelectorDialog == null) { algorithmTypeSelectorDialog = new TypeSelectorDialog(); algorithmTypeSelectorDialog.Caption = "Select Algorithm"; algorithmTypeSelectorDialog.TypeSelector.Caption = "Available Algorithms"; algorithmTypeSelectorDialog.TypeSelector.Configure(typeof(IAlgorithm), false, true); } if (algorithmTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { Content.Algorithm = (IAlgorithm)algorithmTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } }
protected virtual void newProblemButton_Click(object sender, EventArgs e) { if (problemTypeSelectorDialog == null) { problemTypeSelectorDialog = new TypeSelectorDialog(); problemTypeSelectorDialog.Caption = "Select Problem"; problemTypeSelectorDialog.TypeSelector.Caption = "Available Problems"; problemTypeSelectorDialog.TypeSelector.Configure(Content.ProblemType, false, true); } if (problemTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { Content.Problem = (IProblem)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } }
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 addButton_Click(object sender, System.EventArgs e) { if (typeSelectorDialog == null) typeSelectorDialog = new TypeSelectorDialog(); IAlgorithm algorithm = null; if (treeView.SelectedNode != null && (treeView.SelectedNode.Tag is IAlgorithm)) algorithm = (IAlgorithm)treeView.SelectedNode.Tag; if (algorithm == null) { typeSelectorDialog.Caption = "Select Optimizer"; typeSelectorDialog.TypeSelector.Caption = "Available Optimizers"; typeSelectorDialog.TypeSelector.Configure(typeof(IOptimizer), false, true); } else { typeSelectorDialog.Caption = "Select Problem"; typeSelectorDialog.TypeSelector.Caption = "Available Problems"; typeSelectorDialog.TypeSelector.Configure(algorithm.ProblemType, false, true); } if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { if (algorithm == null) { IOptimizer optimizer = (IOptimizer)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); if (treeView.SelectedNode == null) Content.Optimizers.Add(optimizer); else { var batchRun = treeView.SelectedNode.Tag as BatchRun; var experiment = treeView.SelectedNode.Tag as Experiment; if (batchRun != null) batchRun.Optimizer = optimizer; else if (experiment != null) experiment.Optimizers.Add(optimizer); else throw new NotSupportedException("Handling for specific type not implemented" + treeView.SelectedNode.Tag.GetType()); } } else { IProblem problem = (IProblem)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); algorithm.Problem = problem; } } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } }
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; }
protected virtual void setValueButton_Click(object sender, EventArgs e) { if (typeSelectorDialog == null) { typeSelectorDialog = new TypeSelectorDialog(); typeSelectorDialog.Caption = "Select Value"; typeSelectorDialog.TypeSelector.Configure(typeof(IItem), false, true); } if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { Content.Value = (IItem)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } }
private void newOptimizerButton_Click(object sender, EventArgs e) { if (optimizerTypeSelectorDialog == null) { optimizerTypeSelectorDialog = new TypeSelectorDialog(); optimizerTypeSelectorDialog.Caption = "Select Optimizer"; optimizerTypeSelectorDialog.TypeSelector.Caption = "Available Optimizers"; optimizerTypeSelectorDialog.TypeSelector.Configure(typeof(IOptimizer), false, true); } if (optimizerTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { Content.Optimizer = (IOptimizer)optimizerTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } }
private void newDataButton_Click(object sender, EventArgs e) { if (typeSelectorDialog == null) { typeSelectorDialog = new TypeSelectorDialog(); typeSelectorDialog.Caption = "Select Problem"; typeSelectorDialog.TypeSelector.Caption = "Available Problems"; typeSelectorDialog.TypeSelector.Configure(typeof(IProblem), 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 problem data failed.", ex); } SetEnabledStateOfControls(); } }
protected virtual void SetTypeParameter() { if (typeSelectorDialog == null) { typeSelectorDialog = new TypeSelectorDialog(); typeSelectorDialog.Caption = "Select Type of Generic Type Parameter"; } Type param = typeParametersListView.SelectedItems[0].Tag as Type; Type[] constraints = param.GetGenericParameterConstraints(); bool showNotInstantiableTypes = !param.GenericParameterAttributes.HasFlag(GenericParameterAttributes.DefaultConstructorConstraint); typeSelectorDialog.TypeSelector.Configure(constraints, showNotInstantiableTypes, true, true); if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { Type selected = typeSelectorDialog.TypeSelector.SelectedType; Type[] parameters = SelectedType.GetGenericArguments(); parameters[param.GenericParameterPosition] = selected; SelectedType = SelectedType.GetGenericTypeDefinition().MakeGenericType(parameters); typeParametersListView.SelectedItems[0].Text = param.Name + ": " + selected.GetPrettyName(); typeParametersListView.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); } }