Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 2727 was 2727, checked in by swagner, 14 years ago

Operator architecture refactoring (#95)

  • worked on content definitions of views
  • corrected bug in cloning of CombinedOperator
File size: 1.8 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>), false)]
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> content)
32      : this() {
33      Content = content;
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 (Content.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.