Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ConstrainedTypeValueView.cs @ 8517

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

#1853:

  • created branch for ParameterConfigurationEncoding
  • added CreateExperimentDialog that uses the extracted encoding
File size: 1.9 KB
Line 
1using System;
2using System.Linq;
3using System.Windows.Forms;
4using HeuristicLab.Core.Views;
5using HeuristicLab.MainForm;
6
7namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
8  [View("ConstrainedTypeValueView")]
9  [Content(typeof(ConstrainedTypeValue), IsDefaultView = false)]
10  [Content(typeof(ConstrainedTypeValue<>), IsDefaultView = true)]
11  public sealed partial class ConstrainedTypeValueView : ItemView {
12    public new ConstrainedTypeValue Content {
13      get { return (ConstrainedTypeValue)base.Content; }
14      set { base.Content = value; }
15    }
16
17    public ConstrainedTypeValueView() {
18      InitializeComponent();
19    }
20
21    protected override void DeregisterContentEvents() {
22      Content.ValueChanged -= new EventHandler(Content_ValueChanged);
23      base.DeregisterContentEvents();
24    }
25
26    protected override void RegisterContentEvents() {
27      base.RegisterContentEvents();
28      Content.ValueChanged += new EventHandler(Content_ValueChanged);
29    }
30
31    #region Event Handlers (Content)
32    void Content_ValueChanged(object sender, EventArgs e) {
33      if (InvokeRequired) {
34        Invoke(new EventHandler(Content_ValueChanged), sender, e);
35      } else {
36        this.typeComboBox.SelectedItem = Content.Value;
37      }
38    }
39    #endregion
40
41    protected override void OnContentChanged() {
42      base.OnContentChanged();
43      if (Content == null) {
44        typeComboBox.Items.Clear();
45      } else {
46        typeComboBox.Items.AddRange(Content.ValidTypes.ToArray());
47        Content_ValueChanged(this, EventArgs.Empty);
48      }
49    }
50
51    protected override void SetEnabledStateOfControls() {
52      base.SetEnabledStateOfControls();
53    }
54
55    #region Event Handlers (child controls)
56    private void typeComboBox_SelectedIndexChanged(object sender, EventArgs e) {
57      Content.Value = (Type)typeComboBox.SelectedItem;
58    }
59    #endregion
60  }
61}
Note: See TracBrowser for help on using the repository browser.