Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Core.Views/3.3/ParameterCollectionView.cs @ 2710

Last change on this file since 2710 was 2676, checked in by swagner, 15 years ago

Operator architecture refactoring (#95)

  • continued work on adapting and refactoring HeuristicLab.Data according to the changes in HeuristicLab.Core
  • unified visual appearance of views
File size: 1.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using HeuristicLab.MainForm;
10using HeuristicLab.Collections;
11
12namespace 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}
Note: See TracBrowser for help on using the repository browser.