1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Data;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Windows.Forms;
|
---|
9 | using HeuristicLab.MainForm;
|
---|
10 | using HeuristicLab.Collections;
|
---|
11 |
|
---|
12 | namespace HeuristicLab.Core.Views {
|
---|
13 | [Content(typeof(ParameterCollection), true)]
|
---|
14 | [Content(typeof(IObservableKeyedCollection<string, IParameter>), true)]
|
---|
15 | public partial class ParameterCollectionView : NamedItemCollectionView<IParameter> {
|
---|
16 | protected CreateParameterDialog createParameterDialog;
|
---|
17 | /// <summary>
|
---|
18 | /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".
|
---|
19 | /// </summary>
|
---|
20 | public ParameterCollectionView() {
|
---|
21 | InitializeComponent();
|
---|
22 | Caption = "ParameterCollection";
|
---|
23 | itemsGroupBox.Text = "&Parameters";
|
---|
24 | }
|
---|
25 | /// <summary>
|
---|
26 | /// Initializes a new instance of <see cref="VariablesScopeView"/> with
|
---|
27 | /// the given <paramref name="scope"/>.
|
---|
28 | /// </summary>
|
---|
29 | /// <remarks>Calls <see cref="VariablesScopeView()"/>.</remarks>
|
---|
30 | /// <param name="scope">The scope whose variables should be represented visually.</param>
|
---|
31 | public ParameterCollectionView(IObservableKeyedCollection<string, IParameter> parameterCollection)
|
---|
32 | : this() {
|
---|
33 | NamedItemCollection = parameterCollection;
|
---|
34 | }
|
---|
35 |
|
---|
36 | protected override IParameter CreateItem() {
|
---|
37 | if (createParameterDialog == null) createParameterDialog = new CreateParameterDialog();
|
---|
38 |
|
---|
39 | if (createParameterDialog.ShowDialog(this) == DialogResult.OK) {
|
---|
40 | IParameter param = createParameterDialog.Parameter;
|
---|
41 | if (NamedItemCollection.ContainsKey(param.Name))
|
---|
42 | param = (IParameter)Activator.CreateInstance(param.GetType(), GetUniqueName(param.Name), param.Description);
|
---|
43 | return param;
|
---|
44 | } else
|
---|
45 | return null;
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|