Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization (trunk integration)/HeuristicLab.Problems.MetaOptimization.Views/3.3/ConstrainedTypeValueView.cs

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

#1853: created branch for MetaOptimization (trunk integration)

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