Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 9048 was 5275, checked in by gkronber, 14 years ago

Merged changes from trunk to data analysis exploration branch and added fractional distance metric evaluator. #1142

File size: 3.6 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      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 a negative value.");
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 a negative value.");
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.