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.MainForm;
|
---|
10 | using HeuristicLab.Core.Views;
|
---|
11 | using HeuristicLab.Core;
|
---|
12 | using HeuristicLab.Collections;
|
---|
13 |
|
---|
14 | namespace 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 | }
|
---|