Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1837_Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/LaggedVariableView.cs

Last change on this file was 17687, checked in by fbaching, 4 years ago

#1837: merged changes from trunk

  • apply changes from Attic release to all SlidingWindow specific code files (replace StorableClass with StorableType)
File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 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.MainForm;
25using HeuristicLab.MainForm.WindowsForms;
26
27namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
28  [View("LaggedVariable View")]
29  [Content(typeof(LaggedVariable), true)]
30  public partial class LaggedVariableView : VariableView {
31    public new LaggedVariable Content {
32      get { return (LaggedVariable)base.Content; }
33      set { base.Content = value; }
34    }
35
36    public LaggedVariableView() {
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      minTimeOffsetTextBox.Enabled = Content != null;
58      minTimeOffsetTextBox.ReadOnly = ReadOnly;
59      maxTimeOffsetTextBox.Enabled = Content != null;
60      maxTimeOffsetTextBox.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    #region control event handlers
70
71    private void minTimeOffsetTextBox_TextChanged(object sender, EventArgs e) {
72      int timeOffset;
73      if (int.TryParse(minTimeOffsetTextBox.Text, out timeOffset) && timeOffset <= 0) {
74        Content.MinLag = timeOffset;
75        errorProvider.SetError(minTimeOffsetTextBox, string.Empty);
76      } else {
77        errorProvider.SetError(minTimeOffsetTextBox, "Time offset must be negative or zero.");
78      }
79    }
80
81    private void maxTimeOffsetTextBox_TextChanged(object sender, EventArgs e) {
82      int timeOffset;
83      if (int.TryParse(maxTimeOffsetTextBox.Text, out timeOffset) && timeOffset <= 0) {
84        Content.MaxLag = timeOffset;
85        errorProvider.SetError(maxTimeOffsetTextBox, string.Empty);
86      } else {
87        errorProvider.SetError(maxTimeOffsetTextBox, "Time offset must be negative or zero.");
88      }
89    }
90
91    #endregion
92
93    #region helpers
94    private void UpdateControl() {
95      if (Content == null) {
96        minTimeOffsetTextBox.Text = string.Empty;
97        maxTimeOffsetTextBox.Text = string.Empty;
98      } else {
99        minTimeOffsetTextBox.Text = Content.MinLag.ToString();
100        maxTimeOffsetTextBox.Text = Content.MaxLag.ToString();
101      }
102      SetEnabledStateOfControls();
103    }
104    #endregion
105
106  }
107}
Note: See TracBrowser for help on using the repository browser.