1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Data;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Windows.Forms;
|
---|
9 | using HeuristicLab.Encodings.ParameterConfigurationEncoding;
|
---|
10 | using HeuristicLab.MainForm;
|
---|
11 | using HeuristicLab.Core.Views;
|
---|
12 |
|
---|
13 | namespace 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 | }
|
---|