Free cookie consent management tool by TermsFeed Policy Generator

source: branches/CEDMA-Exporter-715/sources/HeuristicLab.TestFunctions/3.3/TestFunctionInjectorView.cs @ 2716

Last change on this file since 2716 was 1530, checked in by gkronber, 16 years ago

Moved source files of plugins Hive ... Visualization.Test into version-specific sub-folders. #576

File size: 4.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.ComponentModel;
25using System.Drawing;
26using System.Data;
27using System.Text;
28using System.Windows.Forms;
29
30using HeuristicLab.Core;
31using HeuristicLab.Data;
32
33namespace HeuristicLab.TestFunctions {
34  /// <summary>
35  /// Visual representation of a <see cref="TestFunctionInjector"/>.
36  /// </summary>
37  public partial class TestFunctionInjectorView : ViewBase {
38    /// <summary>
39    /// Gets or sets the TestFunctionInjector to represent visually.
40    /// </summary>
41    /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
42    /// No own data storage present.</remarks>
43    public TestFunctionInjector TestFunctionInjector {
44      get { return (TestFunctionInjector)base.Item; }
45      set { base.Item = value; }
46    }
47
48    /// <summary>
49    /// Initializes a new instance of <see cref="TestFunctionInjectorView"/>.
50    /// </summary>
51    public TestFunctionInjectorView() {
52      InitializeComponent();
53    }
54
55    /// <summary>
56    /// Initializes a new instance of <see cref="TestFunctionInjectorView"/> with the given
57    /// <paramref name="testFunctionInjector"/> to display.
58    /// </summary>
59    /// <param name="testFunctionInjector">The injector to represent visually.</param>
60    public TestFunctionInjectorView(TestFunctionInjector testFunctionInjector)
61      : this() {
62      TestFunctionInjector = testFunctionInjector;
63    }
64
65    /// <summary>
66    /// Removes the eventhandler from the underlying controls.
67    /// </summary>
68    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.
69    /// </remarks>
70    protected override void RemoveItemEvents() {
71      maximizationCheckBox.DataBindings.Clear();
72      dimensionTextBox.DataBindings.Clear();
73      lowerBoundTextBox.DataBindings.Clear();
74      upperBoundTextBox.DataBindings.Clear();
75      base.RemoveItemEvents();
76    }
77
78    /// <summary>
79    /// Adds eventhandlers to the underlying controls.
80    /// </summary>
81    /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.
82    /// </remarks>
83    protected override void AddItemEvents() {
84      base.AddItemEvents();
85      maximizationCheckBox.DataBindings.Add("Checked", TestFunctionInjector, "Maximization");
86      dimensionTextBox.DataBindings.Add("Text", TestFunctionInjector, "Dimension");
87      lowerBoundTextBox.DataBindings.Add("Text", TestFunctionInjector, "LowerBound");
88      upperBoundTextBox.DataBindings.Add("Text", TestFunctionInjector, "UpperBound");
89    }
90
91    /// <summary>
92    /// Updates all controls with the latest values.
93    /// </summary>
94    /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks>
95    protected override void UpdateControls() {
96      base.UpdateControls();
97      if (TestFunctionInjector == null) {
98        maximizationCheckBox.Enabled = false;
99        maximizationCheckBox.Checked = false;
100        dimensionTextBox.Enabled = false;
101        dimensionTextBox.Text = "-";
102        lowerBoundTextBox.Enabled = false;
103        lowerBoundTextBox.Text = "-";
104        upperBoundTextBox.Enabled = false;
105        upperBoundTextBox.Text = "-";
106      } else {
107        maximizationCheckBox.Enabled = true;
108        dimensionTextBox.Enabled = true;
109        lowerBoundTextBox.Enabled = true;
110        upperBoundTextBox.Enabled = true;
111      }
112    }
113  }
114}
Note: See TracBrowser for help on using the repository browser.