Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/Symbols/TimeLagView.cs @ 5955

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

Updated year of copyrights (#1406)

File size: 3.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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;
27using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
28
29namespace HeuristicLab.Problems.DataAnalysis.Views.Symbolic.Symbols {
30  [View("LaggedSymbol View")]
31  [Content(typeof(LaggedSymbol), true)]
32  public partial class LaggedSymbolView : SymbolView {
33    public new LaggedSymbol Content {
34      get { return (LaggedSymbol)base.Content; }
35      set { base.Content = value; }
36    }
37
38    public LaggedSymbolView() {
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
57    protected override void SetEnabledStateOfControls() {
58      base.SetEnabledStateOfControls();
59      minTimeOffsetTextBox.Enabled = Content != null;
60      minTimeOffsetTextBox.ReadOnly = ReadOnly;
61      maxTimeOffsetTextBox.Enabled = Content != null;
62      maxTimeOffsetTextBox.ReadOnly = ReadOnly;
63    }
64
65    #region content event handlers
66    private void Content_Changed(object sender, EventArgs e) {
67      UpdateControl();
68    }
69    #endregion
70
71    #region control event handlers
72
73    private void minTimeOffsetTextBox_TextChanged(object sender, EventArgs e) {
74      int timeOffset;
75      if (int.TryParse(minTimeOffsetTextBox.Text, out timeOffset) && timeOffset < 0) {
76        Content.MinLag = timeOffset;
77        errorProvider.SetError(minTimeOffsetTextBox, string.Empty);
78      } else {
79        errorProvider.SetError(minTimeOffsetTextBox, "Time offset must be a negative value.");
80      }
81    }
82
83    private void maxTimeOffsetTextBox_TextChanged(object sender, EventArgs e) {
84      int timeOffset;
85      if (int.TryParse(maxTimeOffsetTextBox.Text, out timeOffset) && timeOffset < 0) {
86        Content.MaxLag = timeOffset;
87        errorProvider.SetError(maxTimeOffsetTextBox, string.Empty);
88      } else {
89        errorProvider.SetError(maxTimeOffsetTextBox, "Time offset must be a negative value.");
90      }
91    }
92
93    #endregion
94
95    #region helpers
96    private void UpdateControl() {
97      if (Content == null) {
98        minTimeOffsetTextBox.Text = string.Empty;
99        maxTimeOffsetTextBox.Text = string.Empty;
100      } else {
101        minTimeOffsetTextBox.Text = Content.MinLag.ToString();
102        maxTimeOffsetTextBox.Text = Content.MaxLag.ToString();
103      }
104      SetEnabledStateOfControls();
105    }
106    #endregion
107
108  }
109}
Note: See TracBrowser for help on using the repository browser.