1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 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.Windows.Forms;
|
---|
24 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
|
---|
25 | using HeuristicLab.MainForm;
|
---|
26 | using HeuristicLab.MainForm.WindowsForms;
|
---|
27 | using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Problems.DataAnalysis.Views.Symbolic.Symbols {
|
---|
30 | [View("Variable View")]
|
---|
31 | [Content(typeof(Variable), true)]
|
---|
32 | public partial class VariableView : SymbolView {
|
---|
33 | public new Variable Content {
|
---|
34 | get { return (Variable)base.Content; }
|
---|
35 | set { base.Content = value; }
|
---|
36 | }
|
---|
37 |
|
---|
38 | public VariableView() {
|
---|
39 | InitializeComponent();
|
---|
40 | }
|
---|
41 |
|
---|
42 | protected override void RegisterContentEvents() {
|
---|
43 | base.RegisterContentEvents();
|
---|
44 | Content.Changed += new EventHandler(Content_Changed);
|
---|
45 | }
|
---|
46 |
|
---|
47 | protected override void DeregisterContentEvents() {
|
---|
48 | base.DeregisterContentEvents();
|
---|
49 | Content.Changed -= new EventHandler(Content_Changed);
|
---|
50 | }
|
---|
51 |
|
---|
52 | protected override void OnContentChanged() {
|
---|
53 | base.OnContentChanged();
|
---|
54 | UpdateControl();
|
---|
55 | }
|
---|
56 |
|
---|
57 | protected override void SetEnabledStateOfControls() {
|
---|
58 | base.SetEnabledStateOfControls();
|
---|
59 | weightNuTextBox.Enabled = Content != null;
|
---|
60 | weightSigmaTextBox.Enabled = Content != null;
|
---|
61 | weightChangeNuTextBox.Enabled = Content != null;
|
---|
62 | weightChangeSigmaTextBox.Enabled = Content != null;
|
---|
63 | }
|
---|
64 |
|
---|
65 | #region content event handlers
|
---|
66 | private void Content_Changed(object sender, EventArgs e) {
|
---|
67 | UpdateControl();
|
---|
68 | }
|
---|
69 | #endregion
|
---|
70 |
|
---|
71 | #region control event handlers
|
---|
72 | private void weightNuTextBox_TextChanged(object sender, EventArgs e) {
|
---|
73 | double nu;
|
---|
74 | if (double.TryParse(weightNuTextBox.Text, out nu)) {
|
---|
75 | Content.WeightNu = nu;
|
---|
76 | errorProvider.SetError(weightNuTextBox, string.Empty);
|
---|
77 | } else {
|
---|
78 | errorProvider.SetError(weightNuTextBox, "Invalid value");
|
---|
79 | }
|
---|
80 | }
|
---|
81 | private void weightSigmaTextBox_TextChanged(object sender, EventArgs e) {
|
---|
82 | double sigma;
|
---|
83 | if (double.TryParse(weightSigmaTextBox.Text, out sigma) && sigma >= 0.0) {
|
---|
84 | Content.WeightSigma = sigma;
|
---|
85 | errorProvider.SetError(weightSigmaTextBox, string.Empty);
|
---|
86 | } else {
|
---|
87 | errorProvider.SetError(weightSigmaTextBox, "Invalid value");
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | private void weightChangeNuTextBox_TextChanged(object sender, EventArgs e) {
|
---|
92 | double nu;
|
---|
93 | if (double.TryParse(weightChangeNuTextBox.Text, out nu)) {
|
---|
94 | Content.WeightManipulatorNu = nu;
|
---|
95 | errorProvider.SetError(weightChangeNuTextBox, string.Empty);
|
---|
96 | } else {
|
---|
97 | errorProvider.SetError(weightChangeNuTextBox, "Invalid value");
|
---|
98 | }
|
---|
99 | }
|
---|
100 |
|
---|
101 | private void weightChangeSigmaTextBox_TextChanged(object sender, EventArgs e) {
|
---|
102 | double sigma;
|
---|
103 | if (double.TryParse(weightChangeSigmaTextBox.Text, out sigma) && sigma >= 0.0) {
|
---|
104 | Content.WeightManipulatorSigma = sigma;
|
---|
105 | errorProvider.SetError(weightChangeSigmaTextBox, string.Empty);
|
---|
106 | } else {
|
---|
107 | errorProvider.SetError(weightChangeSigmaTextBox, "Invalid value");
|
---|
108 | }
|
---|
109 | }
|
---|
110 | #endregion
|
---|
111 |
|
---|
112 | #region helpers
|
---|
113 | private void UpdateControl() {
|
---|
114 | if (Content == null) {
|
---|
115 | weightNuTextBox.Text = string.Empty;
|
---|
116 | weightSigmaTextBox.Text = string.Empty;
|
---|
117 | weightNuTextBox.Text = string.Empty;
|
---|
118 | weightChangeSigmaTextBox.Text = string.Empty;
|
---|
119 | } else {
|
---|
120 | weightNuTextBox.Text = Content.WeightNu.ToString();
|
---|
121 | weightSigmaTextBox.Text = Content.WeightSigma.ToString();
|
---|
122 | weightChangeNuTextBox.Text = Content.WeightManipulatorNu.ToString();
|
---|
123 | weightChangeSigmaTextBox.Text = Content.WeightManipulatorSigma.ToString();
|
---|
124 | }
|
---|
125 | SetEnabledStateOfControls();
|
---|
126 | }
|
---|
127 | #endregion
|
---|
128 | }
|
---|
129 | }
|
---|