Last change
on this file since 10743 was
8576,
checked in by jkarder, 12 years ago
|
#1853: created branch for MetaOptimization (trunk integration)
|
File size:
1.4 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Windows.Forms;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.Core.Views;
|
---|
5 | using HeuristicLab.Encodings.ParameterConfigurationEncoding;
|
---|
6 | using HeuristicLab.MainForm;
|
---|
7 | using HeuristicLab.PluginInfrastructure;
|
---|
8 |
|
---|
9 | namespace 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.