Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ConstrainedItemListView.cs @ 15287

Last change on this file since 15287 was 8517, checked in by jkarder, 12 years ago

#1853:

  • created branch for ParameterConfigurationEncoding
  • added CreateExperimentDialog that uses the extracted encoding
File size: 1.3 KB
Line 
1using System;
2using System.Windows.Forms;
3using HeuristicLab.Core;
4using HeuristicLab.Core.Views;
5using HeuristicLab.MainForm;
6using HeuristicLab.PluginInfrastructure;
7
8namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
9  [View("Constrained Item List View")]
10  [Content(typeof(ConstrainedItemList<>), IsDefaultView = true)]
11  public sealed partial class ConstrainedItemListView<T> : ItemListView<T> where T : class, IItem {
12    public new ConstrainedItemList<T> Content {
13      get { return (ConstrainedItemList<T>)base.Content; }
14      set { base.Content = value; }
15    }
16
17    public ConstrainedItemListView() {
18      InitializeComponent();
19    }
20
21    protected override T CreateItem() {
22      if (typeSelectorDialog == null) {
23        typeSelectorDialog = new TypeSelectorDialog();
24        typeSelectorDialog.Caption = "Select Item";
25        typeSelectorDialog.TypeSelector.Caption = "Available Items";
26        typeSelectorDialog.TypeSelector.Configure(Content.Type, false, true);
27      }
28
29      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
30        try {
31          return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
32        }
33        catch (Exception ex) {
34          ErrorHandling.ShowErrorDialog(this, ex);
35        }
36      }
37      return null;
38    }
39  }
40}
Note: See TracBrowser for help on using the repository browser.