[4022] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[7259] | 3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[4022] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Windows.Forms;
|
---|
| 24 | using HeuristicLab.MainForm;
|
---|
| 25 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 26 |
|
---|
[5693] | 27 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
|
---|
[4022] | 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;
|
---|
[4435] | 58 | minTimeOffsetTextBox.ReadOnly = ReadOnly;
|
---|
[4022] | 59 | maxTimeOffsetTextBox.Enabled = Content != null;
|
---|
[4435] | 60 | maxTimeOffsetTextBox.ReadOnly = ReadOnly;
|
---|
[4022] | 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;
|
---|
[5926] | 73 | if (int.TryParse(minTimeOffsetTextBox.Text, out timeOffset) && timeOffset <= 0) {
|
---|
[4022] | 74 | Content.MinLag = timeOffset;
|
---|
| 75 | errorProvider.SetError(minTimeOffsetTextBox, string.Empty);
|
---|
| 76 | } else {
|
---|
[5926] | 77 | errorProvider.SetError(minTimeOffsetTextBox, "Time offset must be negative or zero.");
|
---|
[4022] | 78 | }
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | private void maxTimeOffsetTextBox_TextChanged(object sender, EventArgs e) {
|
---|
| 82 | int timeOffset;
|
---|
[5926] | 83 | if (int.TryParse(maxTimeOffsetTextBox.Text, out timeOffset) && timeOffset <= 0) {
|
---|
[4022] | 84 | Content.MaxLag = timeOffset;
|
---|
| 85 | errorProvider.SetError(maxTimeOffsetTextBox, string.Empty);
|
---|
| 86 | } else {
|
---|
[5926] | 87 | errorProvider.SetError(maxTimeOffsetTextBox, "Time offset must be negative or zero.");
|
---|
[4022] | 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 | }
|
---|