Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/Symbols/VariableConditionView.cs @ 6675

Last change on this file since 6675 was 5467, checked in by gkronber, 14 years ago

#1325: Merged r5060 from branch into trunk.

File size: 7.5 KB
Line 
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
22using System;
23using System.Windows.Forms;
24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
25using HeuristicLab.MainForm;
26using HeuristicLab.MainForm.WindowsForms;
27using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
28
29namespace HeuristicLab.Problems.DataAnalysis.Views.Symbolic.Symbols {
30  [View("Variable View")]
31  [Content(typeof(VariableCondition), true)]
32  public partial class VariableConditionView : SymbolView {
33    public new VariableCondition Content {
34      get { return (VariableCondition)base.Content; }
35      set { base.Content = value; }
36    }
37
38    public VariableConditionView() {
39      InitializeComponent();
40    }
41
42    protected override void RegisterContentEvents() {
43      base.RegisterContentEvents();
44      Content.Changed += new EventHandler(Content_Changed);
45    }
46    protected override void DeregisterContentEvents() {
47      base.DeregisterContentEvents();
48      Content.Changed -= new EventHandler(Content_Changed);
49    }
50    protected override void OnContentChanged() {
51      base.OnContentChanged();
52      UpdateControl();
53    }
54    private void Content_Changed(object sender, EventArgs e) {
55      UpdateControl();
56    }
57
58    protected override void SetEnabledStateOfControls() {
59      base.SetEnabledStateOfControls();
60      thresholdInitializationMuTextBox.Enabled = Content != null;
61      thresholdInitializationMuTextBox.ReadOnly = ReadOnly;
62      thresholdInitializationSigmaTextBox.Enabled = Content != null;
63      thresholdInitializationSigmaTextBox.ReadOnly = ReadOnly;
64      slopeInitializationMuTextBox.Enabled = Content != null;
65      slopeInitializationMuTextBox.ReadOnly = ReadOnly;
66      slopeInitializationSigmaTextBox.Enabled = Content != null;
67      slopeInitializationSigmaTextBox.ReadOnly = ReadOnly;
68
69      thresholdChangeMuTextBox.Enabled = Content != null;
70      thresholdChangeMuTextBox.ReadOnly = ReadOnly;
71      thresholdChangeSigmaTextBox.Enabled = Content != null;
72      thresholdChangeSigmaTextBox.ReadOnly = ReadOnly;
73      slopeChangeMuTextBox.Enabled = Content != null;
74      slopeChangeMuTextBox.ReadOnly = ReadOnly;
75      slopeChangeSigmaTextBox.Enabled = Content != null;
76      slopeChangeSigmaTextBox.ReadOnly = ReadOnly;
77    }
78
79
80
81    private void UpdateControl() {
82      if (Content == null) {
83        thresholdInitializationMuTextBox.Text = string.Empty;
84        thresholdInitializationSigmaTextBox.Text = string.Empty;
85        slopeInitializationMuTextBox.Text = string.Empty;
86        slopeInitializationSigmaTextBox.Text = string.Empty;
87        thresholdChangeMuTextBox.Text = string.Empty;
88        thresholdChangeSigmaTextBox.Text = string.Empty;
89        slopeChangeMuTextBox.Text = string.Empty;
90        slopeChangeSigmaTextBox.Text = string.Empty;
91      } else {
92        thresholdInitializationMuTextBox.Text = Content.ThresholdInitializerMu.ToString();
93        thresholdInitializationSigmaTextBox.Text = Content.ThresholdInitializerSigma.ToString();
94        slopeInitializationMuTextBox.Text = Content.SlopeInitializerMu.ToString();
95        slopeInitializationSigmaTextBox.Text = Content.SlopeInitializerSigma.ToString();
96        thresholdChangeMuTextBox.Text = Content.ThresholdManipulatorMu.ToString();
97        thresholdChangeSigmaTextBox.Text = Content.ThresholdManipulatorSigma.ToString();
98        slopeChangeMuTextBox.Text = Content.SlopeManipulatorMu.ToString();
99        slopeChangeSigmaTextBox.Text = Content.SlopeManipulatorSigma.ToString();
100      }
101      SetEnabledStateOfControls();
102    }
103
104    #region control events
105    private void thresholdMuTextBox_TextChanged(object sender, EventArgs e) {
106      double value;
107      if (double.TryParse(thresholdInitializationMuTextBox.Text, out value)) {
108        Content.ThresholdInitializerMu = value;
109        errorProvider.SetError(thresholdInitializationMuTextBox, string.Empty);
110      } else errorProvider.SetError(thresholdInitializationMuTextBox, "Invalid value");
111    }
112    private void thresholdInitializationSigmaTextBox_TextChanged(object sender, EventArgs e) {
113      double value;
114      if (double.TryParse(thresholdInitializationSigmaTextBox.Text, out value)) {
115        Content.ThresholdInitializerSigma = value;
116        errorProvider.SetError(thresholdInitializationSigmaTextBox, string.Empty);
117      } else errorProvider.SetError(thresholdInitializationSigmaTextBox, "Invalid value");
118    }
119    private void slopeInitializationMuTextBox_TextChanged(object sender, EventArgs e) {
120      double value;
121      if (double.TryParse(slopeInitializationMuTextBox.Text, out value)) {
122        Content.SlopeInitializerMu = value;
123        errorProvider.SetError(slopeInitializationMuTextBox, string.Empty);
124      } else errorProvider.SetError(slopeInitializationMuTextBox, "Invalid value");
125    }
126    private void slopeInitializationSigmaTextBox_TextChanged(object sender, EventArgs e) {
127      double value;
128      if (double.TryParse(slopeInitializationSigmaTextBox.Text, out value)) {
129        Content.SlopeInitializerSigma = value;
130        errorProvider.SetError(slopeInitializationSigmaTextBox, string.Empty);
131      } else errorProvider.SetError(slopeInitializationSigmaTextBox, "Invalid value");
132    }
133
134    private void thresholdChangeMuTextBox_TextChanged(object sender, EventArgs e) {
135      double value;
136      if (double.TryParse(thresholdChangeMuTextBox.Text, out value)) {
137        Content.ThresholdManipulatorMu = value;
138        errorProvider.SetError(thresholdChangeMuTextBox, string.Empty);
139      } else errorProvider.SetError(thresholdChangeMuTextBox, "Invalid value");
140    }
141
142    private void thresholdChangeSigmaTextBox_TextChanged(object sender, EventArgs e) {
143      double value;
144      if (double.TryParse(thresholdChangeSigmaTextBox.Text, out value)) {
145        Content.ThresholdManipulatorSigma = value;
146        errorProvider.SetError(thresholdChangeSigmaTextBox, string.Empty);
147      } else errorProvider.SetError(thresholdChangeSigmaTextBox, "Invalid value");
148    }
149    private void slopeChangeMuTextBox_TextChanged(object sender, EventArgs e) {
150      double value;
151      if (double.TryParse(slopeChangeMuTextBox.Text, out value)) {
152        Content.SlopeManipulatorMu = value;
153        errorProvider.SetError(slopeChangeMuTextBox, string.Empty);
154      } else errorProvider.SetError(slopeChangeMuTextBox, "Invalid value");
155    }
156
157    private void slopeChangeSigmaTextBox_TextChanged(object sender, EventArgs e) {
158      double value;
159      if (double.TryParse(slopeChangeSigmaTextBox.Text, out value)) {
160        Content.SlopeManipulatorSigma = value;
161        errorProvider.SetError(slopeChangeSigmaTextBox, string.Empty);
162      } else errorProvider.SetError(slopeChangeSigmaTextBox, "Invalid value");
163    }
164    #endregion
165
166  }
167}
Note: See TracBrowser for help on using the repository browser.