Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableConditionView.cs

Last change on this file was 5809, checked in by mkommend, 14 years ago

#1418: Reintegrated branch into trunk.

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