Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Core/3.2/VariableInfoView.cs @ 2508

Last change on this file since 2508 was 1529, checked in by gkronber, 16 years ago

Moved source files of plugins AdvancedOptimizationFrontEnd ... Grid into version-specific sub-folders. #576

File size: 5.0 KB
RevLine 
[2]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
30namespace HeuristicLab.Core {
[776]31  /// <summary>
32  /// The visual representation of <see cref="IVariableInfo"/>.
33  /// </summary>
[2]34  public partial class VariableInfoView : ViewBase {
[776]35    /// <summary>
36    /// Gets or sets the variable information to represent visually.
37    /// </summary>
38    /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
39    /// No own data storage present.</remarks>
[2]40    public IVariableInfo VariableInfo {
41      get { return (IVariableInfo)Item; }
42      set { base.Item = value; }
43    }
44
[776]45    /// <summary>
46    /// Initializes a new instance of <see cref="VariableInfoView"/> with caption "Variable Info".
47    /// </summary>
[2]48    public VariableInfoView() {
49      InitializeComponent();
50      Caption = "Variable Info";
51    }
[776]52    /// <summary>
53    /// Initializes a new instance of <see cref="VariableInfoView"/>
54    /// with the given <paramref name="variableInfo"/>.
55    /// </summary>
56    /// <remarks>Calls <see cref="VariableInfoView()"/>.</remarks>
57    /// <param name="variableInfo">The variable info to represent visually.</param>
[2]58    public VariableInfoView(IVariableInfo variableInfo)
59      : this() {
60      VariableInfo = variableInfo;
61    }
62
[776]63    /// <summary>
64    /// Removes the eventhandlers from the underlying <see cref="IVariableInfo"/>.
65    /// </summary>
66    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class
67    /// <see cref="ViewBase"/>.</remarks>
[2]68    protected override void RemoveItemEvents() {
69      VariableInfo.ActualNameChanged -= new EventHandler(VariableInfo_ActualNameChanged);
70      VariableInfo.LocalChanged -= new EventHandler(VariableInfo_LocalChanged);
71      base.RemoveItemEvents();
72    }
[776]73    /// <summary>
74    /// Adds eventhandlers to the underlying <see cref="IVariableInfo"/>.
75    /// </summary>
76    /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
[2]77    protected override void AddItemEvents() {
78      base.AddItemEvents();
79      VariableInfo.ActualNameChanged += new EventHandler(VariableInfo_ActualNameChanged);
80      VariableInfo.LocalChanged += new EventHandler(VariableInfo_LocalChanged);
81    }
[776]82    /// <summary>
83    /// Updates all controls with the latest data of the model.
84    /// </summary>
85    /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks>
[2]86    protected override void UpdateControls() {
87      base.UpdateControls();
88      Caption = "Variable Info";
89      if (VariableInfo == null) {
90        actualNameTextBox.Enabled = false;
91        formalNameTextBox.Enabled = false;
92        dataTypeTextBox.Enabled = false;
93        kindTextBox.Enabled = false;
94        localCheckBox.Enabled = false;
95        descriptionTextBox.Enabled = false;
96      } else {
97        Caption = VariableInfo.ActualName + " (" + VariableInfo.GetType().Name + ")";
98        actualNameTextBox.Text = VariableInfo.ActualName;
99        actualNameTextBox.Enabled = true;
100        formalNameTextBox.Text = VariableInfo.FormalName;
101        formalNameTextBox.Enabled = true;
102        dataTypeTextBox.Text = VariableInfo.DataType.FullName;
103        dataTypeTextBox.Enabled = true;
104        kindTextBox.Text = VariableInfo.Kind.ToString();
105        kindTextBox.Enabled = true;
106        localCheckBox.Checked = VariableInfo.Local;
107        localCheckBox.Enabled = true;
108        descriptionTextBox.Text = VariableInfo.Description;
109        descriptionTextBox.Enabled = true;
110      }
111    }
112
113    private void VariableInfo_ActualNameChanged(object sender, EventArgs e) {
114      actualNameTextBox.Text = VariableInfo.ActualName;
115    }
116    private void VariableInfo_LocalChanged(object sender, EventArgs e) {
117      localCheckBox.Checked = VariableInfo.Local;
118    }
119
120    private void actualNameTextBox_Validated(object sender, EventArgs e) {
121      VariableInfo.ActualName = actualNameTextBox.Text;
122    }
123    private void localCheckBox_CheckedChanged(object sender, EventArgs e) {
124      VariableInfo.Local = localCheckBox.Checked;
125    }
126  }
127}
Note: See TracBrowser for help on using the repository browser.