Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.TestFunctions/3.3/TestFunctionInjectorView.cs @ 2546

Last change on this file since 2546 was 2546, checked in by swagner, 14 years ago

Continued work on Optimizer and on adapting all views to the new MainForm concept (#770)

File size: 4.4 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;
32using HeuristicLab.Core.Views;
33using HeuristicLab.MainForm;
34
35namespace HeuristicLab.TestFunctions {
36  /// <summary>
37  /// Visual representation of a <see cref="TestFunctionInjector"/>.
38  /// </summary>
39  [Content(typeof(TestFunctionInjector), true)]
40  public partial class TestFunctionInjectorView : ItemViewBase {
41    /// <summary>
42    /// Gets or sets the TestFunctionInjector to represent visually.
43    /// </summary>
44    /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
45    /// No own data storage present.</remarks>
46    public TestFunctionInjector TestFunctionInjector {
47      get { return (TestFunctionInjector)base.Item; }
48      set { base.Item = value; }
49    }
50
51    /// <summary>
52    /// Initializes a new instance of <see cref="TestFunctionInjectorView"/>.
53    /// </summary>
54    public TestFunctionInjectorView() {
55      InitializeComponent();
56    }
57
58    /// <summary>
59    /// Initializes a new instance of <see cref="TestFunctionInjectorView"/> with the given
60    /// <paramref name="testFunctionInjector"/> to display.
61    /// </summary>
62    /// <param name="testFunctionInjector">The injector to represent visually.</param>
63    public TestFunctionInjectorView(TestFunctionInjector testFunctionInjector)
64      : this() {
65      TestFunctionInjector = testFunctionInjector;
66    }
67
68    /// <summary>
69    /// Removes the eventhandler from the underlying controls.
70    /// </summary>
71    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.
72    /// </remarks>
73    protected override void RemoveItemEvents() {
74      maximizationCheckBox.DataBindings.Clear();
75      dimensionTextBox.DataBindings.Clear();
76      lowerBoundTextBox.DataBindings.Clear();
77      upperBoundTextBox.DataBindings.Clear();
78      base.RemoveItemEvents();
79    }
80
81    /// <summary>
82    /// Adds eventhandlers to the underlying controls.
83    /// </summary>
84    /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.
85    /// </remarks>
86    protected override void AddItemEvents() {
87      base.AddItemEvents();
88      maximizationCheckBox.DataBindings.Add("Checked", TestFunctionInjector, "Maximization");
89      dimensionTextBox.DataBindings.Add("Text", TestFunctionInjector, "Dimension");
90      lowerBoundTextBox.DataBindings.Add("Text", TestFunctionInjector, "LowerBound");
91      upperBoundTextBox.DataBindings.Add("Text", TestFunctionInjector, "UpperBound");
92    }
93
94    /// <summary>
95    /// Updates all controls with the latest values.
96    /// </summary>
97    /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks>
98    protected override void UpdateControls() {
99      base.UpdateControls();
100      if (TestFunctionInjector == null) {
101        maximizationCheckBox.Enabled = false;
102        maximizationCheckBox.Checked = false;
103        dimensionTextBox.Enabled = false;
104        dimensionTextBox.Text = "-";
105        lowerBoundTextBox.Enabled = false;
106        lowerBoundTextBox.Text = "-";
107        upperBoundTextBox.Enabled = false;
108        upperBoundTextBox.Text = "-";
109      } else {
110        maximizationCheckBox.Enabled = true;
111        dimensionTextBox.Enabled = true;
112        lowerBoundTextBox.Enabled = true;
113        upperBoundTextBox.Enabled = true;
114      }
115    }
116  }
117}
Note: See TracBrowser for help on using the repository browser.