Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/Symbols/LaggedVariableView.cs @ 4631

Last change on this file since 4631 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 3.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.MainForm;
25using HeuristicLab.MainForm.WindowsForms;
26using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
27
28namespace HeuristicLab.Problems.DataAnalysis.Views.Symbolic.Symbols {
29  [View("LaggedVariable View")]
30  [Content(typeof(LaggedVariable), true)]
31  public partial class LaggedVariableView : VariableView {
32    public new LaggedVariable Content {
33      get { return (LaggedVariable)base.Content; }
34      set { base.Content = value; }
35    }
36
37    public LaggedVariableView() {
38      InitializeComponent();
39    }
40
41    protected override void RegisterContentEvents() {
42      base.RegisterContentEvents();
43      Content.Changed += new EventHandler(Content_Changed);
44    }
45
46    protected override void DeregisterContentEvents() {
47      base.DeregisterContentEvents();
48      Content.Changed -= new EventHandler(Content_Changed);
49    }
50
51    protected override void OnContentChanged() {
52      base.OnContentChanged();
53      UpdateControl();
54    }
55
56    protected override void SetEnabledStateOfControls() {
57      base.SetEnabledStateOfControls();
58      minTimeOffsetTextBox.Enabled = Content != null;
59      maxTimeOffsetTextBox.Enabled = Content != null;
60    }
61
62    #region content event handlers
63    private void Content_Changed(object sender, EventArgs e) {
64      UpdateControl();
65    }
66    #endregion
67
68    #region control event handlers
69
70    private void minTimeOffsetTextBox_TextChanged(object sender, EventArgs e) {
71      int timeOffset;
72      if (int.TryParse(minTimeOffsetTextBox.Text, out timeOffset) && timeOffset < 0) {
73        Content.MinLag = timeOffset;
74        errorProvider.SetError(minTimeOffsetTextBox, string.Empty);
75      } else {
76        errorProvider.SetError(minTimeOffsetTextBox, "Time offset must be a negative value.");
77      }
78    }
79
80    private void maxTimeOffsetTextBox_TextChanged(object sender, EventArgs e) {
81      int timeOffset;
82      if (int.TryParse(maxTimeOffsetTextBox.Text, out timeOffset) && timeOffset < 0) {
83        Content.MaxLag = timeOffset;
84        errorProvider.SetError(maxTimeOffsetTextBox, string.Empty);
85      } else {
86        errorProvider.SetError(maxTimeOffsetTextBox, "Time offset must be a negative value.");
87      }
88    }
89
90    #endregion
91
92    #region helpers
93    private void UpdateControl() {
94      if (Content == null) {
95        minTimeOffsetTextBox.Text = string.Empty;
96        maxTimeOffsetTextBox.Text = string.Empty;
97      } else {
98        minTimeOffsetTextBox.Text = Content.MinLag.ToString();
99        maxTimeOffsetTextBox.Text = Content.MaxLag.ToString();
100      }
101      SetEnabledStateOfControls();
102    }
103    #endregion
104
105  }
106}
Note: See TracBrowser for help on using the repository browser.