Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/RealGlucoseVariableView.cs @ 16793

Last change on this file since 16793 was 14317, checked in by gkronber, 8 years ago

view for editing time lags for the real glucose value.
clone override

File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 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 HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
24using HeuristicLab.MainForm;
25using HeuristicLab.Problems.GeneticProgramming.GlucosePrediction;
26
27namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
28  [View("RealGlucoseVariable View")]
29  [Content(typeof(RealGlucoseVariableSymbol), true)]
30  public partial class RealGlucoseVariableView : SymbolView {
31    public new RealGlucoseVariableSymbol Content {
32      get { return (RealGlucoseVariableSymbol)base.Content; }
33      set { base.Content = value; }
34    }
35
36    public RealGlucoseVariableView() {
37      InitializeComponent();
38    }
39
40    protected override void RegisterContentEvents() {
41      base.RegisterContentEvents();
42      Content.Changed += new EventHandler(Content_Changed);
43    }
44
45    protected override void DeregisterContentEvents() {
46      base.DeregisterContentEvents();
47      Content.Changed -= new EventHandler(Content_Changed);
48    }
49
50    protected override void OnContentChanged() {
51      base.OnContentChanged();
52      UpdateControl();
53    }
54
55    protected override void SetEnabledStateOfControls() {
56      base.SetEnabledStateOfControls();
57      minRowOffsetTextBox.Enabled = Content != null;
58      minRowOffsetTextBox.ReadOnly = ReadOnly;
59      maxRowOffsetTextBox.Enabled = Content != null;
60      maxRowOffsetTextBox.ReadOnly = ReadOnly;
61    }
62
63    #region content event handlers
64    private void Content_Changed(object sender, EventArgs e) {
65      UpdateControl();
66    }
67    #endregion
68
69    private void minValueTextBox_TextChanged(object sender, EventArgs e) {
70      int min;
71      if (int.TryParse(minRowOffsetTextBox.Text, out min)) {
72        Content.MinRowOffset = min;
73        errorProvider.SetError(minRowOffsetTextBox, string.Empty);
74      } else {
75        errorProvider.SetError(minRowOffsetTextBox, "Invalid value");
76      }
77    }
78    private void maxValueTextBox_TextChanged(object sender, EventArgs e) {
79      int max;
80      if (int.TryParse(maxRowOffsetTextBox.Text, out max)) {
81        Content.MaxRowOffset = max;
82        errorProvider.SetError(maxRowOffsetTextBox, string.Empty);
83      } else {
84        errorProvider.SetError(maxRowOffsetTextBox, "Invalid value");
85      }
86    }
87
88    #region helpers
89    private void UpdateControl() {
90      if (Content == null) {
91        minRowOffsetTextBox.Text = string.Empty;
92        maxRowOffsetTextBox.Text = string.Empty;
93        minRowOffsetTextBox.Text = string.Empty;
94      } else {
95        minRowOffsetTextBox.Text = Content.MinRowOffset.ToString();
96        maxRowOffsetTextBox.Text = Content.MaxRowOffset.ToString();
97      }
98      SetEnabledStateOfControls();
99    }
100    #endregion
101  }
102}
Note: See TracBrowser for help on using the repository browser.