Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 16459 was 9708, checked in by mkommend, 11 years ago

#1837: Merged trunk changes into sliding window gp branch.

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