Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/Symbols/VariableView.cs @ 6675

Last change on this file since 6675 was 5445, checked in by swagner, 14 years ago

Updated year of copyrights (#1406)

File size: 5.2 KB
RevLine 
[3824]1#region License Information
2/* HeuristicLab
[5445]3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[3824]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;
[4068]24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
[3824]25using HeuristicLab.MainForm;
26using HeuristicLab.MainForm.WindowsForms;
27using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
28
[3915]29namespace HeuristicLab.Problems.DataAnalysis.Views.Symbolic.Symbols {
[3824]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
[3904]57    protected override void SetEnabledStateOfControls() {
58      base.SetEnabledStateOfControls();
[5326]59      weightInitializationMuTextBox.Enabled = Content != null;
60      weightInitializationMuTextBox.ReadOnly = ReadOnly;
61      weightInitializationSigmaTextBox.Enabled = Content != null;
62      weightInitializationSigmaTextBox.ReadOnly = ReadOnly;
63      additiveWeightChangeSigmaTextBox.Enabled = Content != null;
64      additiveWeightChangeSigmaTextBox.ReadOnly = ReadOnly;
65      multiplicativeWeightChangeSigmaTextBox.Enabled = Content != null;
66      multiplicativeWeightChangeSigmaTextBox.ReadOnly = ReadOnly;
[3824]67    }
68
69    #region content event handlers
70    private void Content_Changed(object sender, EventArgs e) {
71      UpdateControl();
72    }
73    #endregion
74
75    #region control event handlers
[4990]76    private void weightMuTextBox_TextChanged(object sender, EventArgs e) {
[3824]77      double nu;
[5326]78      if (double.TryParse(weightInitializationMuTextBox.Text, out nu)) {
[4989]79        Content.WeightMu = nu;
[5326]80        errorProvider.SetError(weightInitializationMuTextBox, string.Empty);
[3824]81      } else {
[5326]82        errorProvider.SetError(weightInitializationMuTextBox, "Invalid value");
[3824]83      }
84    }
85    private void weightSigmaTextBox_TextChanged(object sender, EventArgs e) {
86      double sigma;
[5326]87      if (double.TryParse(weightInitializationSigmaTextBox.Text, out sigma) && sigma >= 0.0) {
[3824]88        Content.WeightSigma = sigma;
[5326]89        errorProvider.SetError(weightInitializationSigmaTextBox, string.Empty);
[3824]90      } else {
[5326]91        errorProvider.SetError(weightInitializationSigmaTextBox, "Invalid value");
[3824]92      }
93    }
94
[5326]95    private void additiveWeightChangeSigmaTextBox_TextChanged(object sender, EventArgs e) {
96      double sigma;
97      if (double.TryParse(additiveWeightChangeSigmaTextBox.Text, out sigma) && sigma >= 0.0) {
98        Content.WeightManipulatorSigma = sigma;
99        errorProvider.SetError(additiveWeightChangeSigmaTextBox, string.Empty);
[3824]100      } else {
[5326]101        errorProvider.SetError(additiveWeightChangeSigmaTextBox, "Invalid value");
[3824]102      }
103    }
104
[5326]105    private void multiplicativeWeightChangeSigmaTextBox_TextChanged(object sender, EventArgs e) {
[3824]106      double sigma;
[5326]107      if (double.TryParse(multiplicativeWeightChangeSigmaTextBox.Text, out sigma) && sigma >= 0.0) {
108        Content.MultiplicativeWeightManipulatorSigma = sigma;
109        errorProvider.SetError(multiplicativeWeightChangeSigmaTextBox, string.Empty);
[3824]110      } else {
[5326]111        errorProvider.SetError(multiplicativeWeightChangeSigmaTextBox, "Invalid value");
[3824]112      }
113    }
114    #endregion
115
116    #region helpers
117    private void UpdateControl() {
118      if (Content == null) {
[5326]119        weightInitializationMuTextBox.Text = string.Empty;
120        weightInitializationSigmaTextBox.Text = string.Empty;
121        additiveWeightChangeSigmaTextBox.Text = string.Empty;
122        multiplicativeWeightChangeSigmaTextBox.Text = string.Empty;
[3824]123      } else {
[5326]124        weightInitializationMuTextBox.Text = Content.WeightMu.ToString();
125        weightInitializationSigmaTextBox.Text = Content.WeightSigma.ToString();
126        additiveWeightChangeSigmaTextBox.Text = Content.WeightManipulatorSigma.ToString();
127        multiplicativeWeightChangeSigmaTextBox.Text = Content.MultiplicativeWeightManipulatorSigma.ToString();
[3824]128      }
129      SetEnabledStateOfControls();
130    }
131    #endregion
132  }
133}
Note: See TracBrowser for help on using the repository browser.