Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/ConstrainedItemListView.cs @ 5144

Last change on this file since 5144 was 5110, checked in by cneumuel, 13 years ago

#1215

  • optional parameter values now can be null
  • problem type can now be set specifically
  • values are constrained to the encoding of the Problem
  • moved repetitions parameter to MetaOptimizationProblem
File size: 1.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Linq;
7using System.Text;
8using HeuristicLab.Core.Views;
9using HeuristicLab.Core;
10using HeuristicLab.MainForm;
11using System.Windows.Forms;
12using HeuristicLab.PluginInfrastructure;
13
14namespace HeuristicLab.Problems.MetaOptimization.Views {
15  [View("Constrained Item List View")]
16  [Content(typeof(ConstrainedItemList<>), IsDefaultView = true)]
17  public sealed partial class ConstrainedItemListView<T> : ItemListView<T> where T : class, IItem {
18    public new ConstrainedItemList<T> Content {
19      get { return (ConstrainedItemList<T>)base.Content; }
20      set { base.Content = value; }
21    }
22
23    public ConstrainedItemListView() {
24      InitializeComponent();
25    }
26
27    protected override T CreateItem() {
28      if (typeSelectorDialog == null) {
29        typeSelectorDialog = new TypeSelectorDialog();
30        typeSelectorDialog.Caption = "Select Item";
31        typeSelectorDialog.TypeSelector.Caption = "Available Items";
32        typeSelectorDialog.TypeSelector.Configure(Content.Type, false, true);
33      }
34
35      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
36        try {
37          return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
38        }
39        catch (Exception ex) {
40          ErrorHandling.ShowErrorDialog(this, ex);
41        }
42      }
43      return null;
44    }
45  }
46}
Note: See TracBrowser for help on using the repository browser.