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