Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/ValueConfigurationViews/ValueConfigurationCheckedItemList.cs @ 5087

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

#1215

  • enabled multiple problems
  • enabled n repetitions
  • improved results output
  • reduced memory footprint significantly
  • removed viewhost icons for less screen space waste
File size: 3.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using HeuristicLab.Core.Views;
9using HeuristicLab.MainForm;
10using HeuristicLab.Core;
11using System.Windows.Forms;
12using HeuristicLab.PluginInfrastructure;
13using HeuristicLab.Collections;
14
15namespace HeuristicLab.Problems.MetaOptimization.Views {
16  [View("ValueConfigurationList View")]
17  [Content(typeof(ICheckedValueConfigurationCollection), IsDefaultView = true)]
18  public sealed partial class ValueConfigurationCheckedItemCollectionView : CheckedItemCollectionView<IValueConfiguration> {
19    public new ICheckedValueConfigurationCollection Content {
20      get { return (ICheckedValueConfigurationCollection)base.Content; }
21      set { base.Content = value; }
22    }
23
24    public ValueConfigurationCheckedItemCollectionView() {
25      InitializeComponent();
26      this.viewHost.ViewsLabelVisible = false;
27    }
28
29    protected override void DeregisterContentEvents() {
30      Content.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(Content_ItemsRemoved);
31      base.DeregisterContentEvents();
32    }
33
34    protected override void RegisterContentEvents() {
35      base.RegisterContentEvents();
36      Content.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(Content_ItemsRemoved);
37    }
38
39    #region Event Handlers (Content)
40    private new void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IValueConfiguration> e) {
41      if (InvokeRequired) {
42        Invoke(new EventHandler<CollectionItemsChangedEventArgs<IValueConfiguration>>(Content_ItemsRemoved), sender, e);
43      } else {
44        base.Content_ItemsRemoved(sender, e);
45        SetEnabledStateOfControls();
46      }
47    }
48    #endregion
49
50    protected override void OnContentChanged() {
51      base.OnContentChanged();
52      if (Content != null) {
53        SetEnabledStateOfControls();
54      } else {
55      }
56    }
57
58    protected override void SetEnabledStateOfControls() {
59      base.SetEnabledStateOfControls();
60      if(Content != null) this.removeButton.Enabled = Content.Count > Content.MinItemCount;
61    }
62
63    protected override void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
64      base.itemsListView_SelectedIndexChanged(sender, e);
65      this.removeButton.Enabled = removeButton.Enabled && (Content.Count > Content.MinItemCount);
66    }
67
68    #region Event Handlers (child controls)
69    #endregion
70
71    protected override IValueConfiguration CreateItem() {
72      if (typeSelectorDialog == null) {
73        typeSelectorDialog = new TypeSelectorDialog();
74        typeSelectorDialog.Caption = "Select Item";
75        typeSelectorDialog.TypeSelector.Caption = "Available Items";
76        typeSelectorDialog.TypeSelector.Configure(Content.ValueDataType, false, true);
77      }
78
79      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
80        try {
81          IItem value = (IItem)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
82          return new ValueConfiguration(value, value.GetType());
83        }
84        catch (Exception ex) {
85          ErrorHandling.ShowErrorDialog(this, ex);
86        }
87      }
88      return null;
89    }
90  }
91}
Note: See TracBrowser for help on using the repository browser.