Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization (trunk integration)/HeuristicLab.Problems.MetaOptimization.Views/3.3/ConstrainedItemListView.cs @ 10355

Last change on this file since 10355 was 8576, checked in by jkarder, 12 years ago

#1853: created branch for MetaOptimization (trunk integration)

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