Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/ParameterConfigurationViews/ParameterConfigurationView.cs @ 4839

Last change on this file since 4839 was 4839, checked in by cneumuel, 14 years ago

#1215 worked on MetaOptimization

  • split configurations into ValueConfigurations and ParameterConfigurations
File size: 2.6 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.MainForm;
10using HeuristicLab.Core.Views;
11using HeuristicLab.Core;
12using HeuristicLab.Collections;
13
14namespace HeuristicLab.Problems.MetaOptimization.Views {
15  /// <summary>
16  /// The visual representation of a <see cref="ParameterConfiguration"/>.
17  /// </summary>
18  [View("ParameterConfiguration View")]
19  [Content(typeof(IParameterConfiguration), false)]
20  [Content(typeof(ParameterConfiguration), true)]
21  public partial class ParameterConfigurationView : ItemView {
22    /// <summary>
23    /// Gets or sets the variable to represent visually.
24    /// </summary>
25    /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
26    /// No own data storage present.</remarks>
27    public new IParameterConfiguration Content {
28      get { return (IParameterConfiguration)base.Content; }
29      set { base.Content = value; }
30    }
31
32    public ParameterConfigurationView() {
33      InitializeComponent();
34    }
35
36    protected override void OnContentChanged() {
37      base.OnContentChanged();
38      if (Content != null) {
39        this.optimizeCheckBox.Checked = Content.OptimizationEnabled;
40      }
41      SetEnabledStateOfControls();
42    }
43
44    protected override void RegisterContentEvents() {
45      base.RegisterContentEvents();
46      Content.OptimizationEnabledChanged += new EventHandler(Content_OptimizationEnabledChanged);
47    }
48
49    protected override void DeregisterContentEvents() {
50      Content.OptimizationEnabledChanged -= new EventHandler(Content_OptimizationEnabledChanged);
51      base.DeregisterContentEvents();
52    }
53
54    protected override void SetEnabledStateOfControls() {
55      base.SetEnabledStateOfControls();
56      if (Content != null) {
57        if (Content.OptimizationEnabled) {
58          viewHost.ViewType = null;
59          viewHost.Content = Content.ValueConfigurations;
60        } else {
61          viewHost.ViewType = typeof(ValueView);
62          viewHost.Content = Content.ActualValueConfiguration;
63        }
64      } else {
65        viewHost.Content = null;
66      }
67    }
68
69    void Content_OptimizationEnabledChanged(object sender, EventArgs e) {
70      optimizeCheckBox.Checked = Content.OptimizationEnabled;
71      SetEnabledStateOfControls();
72    }
73
74    private void optimizeCheckBox_CheckedChanged(object sender, EventArgs e) {
75      Content.OptimizationEnabled = optimizeCheckBox.Checked;
76      SetEnabledStateOfControls();
77    }
78  }
79}
Note: See TracBrowser for help on using the repository browser.