Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive_Milestone3/sources/HeuristicLab.Core/3.2/VariableInfoView.cs @ 6593

Last change on this file since 6593 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
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
30namespace HeuristicLab.Core {
31  /// <summary>
32  /// The visual representation of <see cref="IVariableInfo"/>.
33  /// </summary>
34  public partial class VariableInfoView : ViewBase {
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>
40    public IVariableInfo VariableInfo {
41      get { return (IVariableInfo)Item; }
42      set { base.Item = value; }
43    }
44
45    /// <summary>
46    /// Initializes a new instance of <see cref="VariableInfoView"/> with caption "Variable Info".
47    /// </summary>
48    public VariableInfoView() {
49      InitializeComponent();
50      Caption = "Variable Info";
51    }
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>
58    public VariableInfoView(IVariableInfo variableInfo)
59      : this() {
60      VariableInfo = variableInfo;
61    }
62
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>
68    protected override void RemoveItemEvents() {
69      VariableInfo.ActualNameChanged -= new EventHandler(VariableInfo_ActualNameChanged);
70      VariableInfo.LocalChanged -= new EventHandler(VariableInfo_LocalChanged);
71      base.RemoveItemEvents();
72    }
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>
77    protected override void AddItemEvents() {
78      base.AddItemEvents();
79      VariableInfo.ActualNameChanged += new EventHandler(VariableInfo_ActualNameChanged);
80      VariableInfo.LocalChanged += new EventHandler(VariableInfo_LocalChanged);
81    }
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>
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.