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