1 | using System.Windows.Forms;
|
---|
2 | using HeuristicLab.Collections;
|
---|
3 | using HeuristicLab.MainForm;
|
---|
4 |
|
---|
5 | namespace HeuristicLab.Core.Views {
|
---|
6 | [View("OperatorCollection View")]
|
---|
7 | [Content(typeof(OperatorCollection), true)]
|
---|
8 | [Content(typeof(IObservableCollection<IOperator>), false)]
|
---|
9 | public partial class OperatorCollectionView : ItemCollectionView<IOperator> {
|
---|
10 | protected TypeSelectorDialog typeSelectorDialog;
|
---|
11 |
|
---|
12 | /// <summary>
|
---|
13 | /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".
|
---|
14 | /// </summary>
|
---|
15 | public OperatorCollectionView() {
|
---|
16 | InitializeComponent();
|
---|
17 | Caption = "Operator Collection";
|
---|
18 | itemsGroupBox.Text = "Operators";
|
---|
19 | }
|
---|
20 | /// <summary>
|
---|
21 | /// Initializes a new instance of <see cref="VariablesScopeView"/> with
|
---|
22 | /// the given <paramref name="scope"/>.
|
---|
23 | /// </summary>
|
---|
24 | /// <remarks>Calls <see cref="VariablesScopeView()"/>.</remarks>
|
---|
25 | /// <param name="scope">The scope whose variables should be represented visually.</param>
|
---|
26 | public OperatorCollectionView(IObservableCollection<IOperator> content)
|
---|
27 | : this() {
|
---|
28 | Content = content;
|
---|
29 | }
|
---|
30 |
|
---|
31 | protected override IOperator CreateItem() {
|
---|
32 | if (typeSelectorDialog == null) {
|
---|
33 | typeSelectorDialog = new TypeSelectorDialog();
|
---|
34 | typeSelectorDialog.TypeSelector.Caption = "Available Operators";
|
---|
35 | typeSelectorDialog.TypeSelector.Configure(typeof(IOperator), false, false);
|
---|
36 | }
|
---|
37 |
|
---|
38 | if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
|
---|
39 | return (IOperator)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
|
---|
40 | else
|
---|
41 | return null;
|
---|
42 | }
|
---|
43 | }
|
---|
44 | }
|
---|