[8750] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15583] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[8750] | 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.Windows.Forms;
|
---|
| 23 | using HeuristicLab.MainForm;
|
---|
| 24 | using HeuristicLab.Optimization.Views;
|
---|
| 25 |
|
---|
| 26 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
| 27 | [View("TimeSeriesPrognosisResultsView")]
|
---|
| 28 | [Content(typeof(TimeSeriesPrognosisResults), IsDefaultView = true)]
|
---|
| 29 | public partial class TimeSeriesPrognosisResultsView : ResultCollectionView {
|
---|
| 30 | public new TimeSeriesPrognosisResults Content {
|
---|
| 31 | get { return (TimeSeriesPrognosisResults)base.Content; }
|
---|
| 32 | set { base.Content = value; }
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | public override bool Locked {
|
---|
| 36 | get {
|
---|
| 37 | return base.Locked;
|
---|
| 38 | }
|
---|
| 39 | set {
|
---|
| 40 | base.Locked = value;
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | public TimeSeriesPrognosisResultsView() {
|
---|
| 45 | InitializeComponent();
|
---|
| 46 | TrainingHorizonErrorProvider.SetIconAlignment(TrainingHorizonTextBox, ErrorIconAlignment.MiddleLeft);
|
---|
| 47 | TrainingHorizonErrorProvider.SetIconPadding(TrainingHorizonTextBox, 2);
|
---|
| 48 | TestHorizonErrorProvider.SetIconAlignment(TestHorizonTextBox, ErrorIconAlignment.MiddleLeft);
|
---|
| 49 | TestHorizonErrorProvider.SetIconPadding(TestHorizonTextBox, 2);
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | #region Content Events
|
---|
| 53 | protected override void RegisterContentEvents() {
|
---|
| 54 | base.RegisterContentEvents();
|
---|
| 55 | Content.TrainingHorizonChanged += new System.EventHandler(Content_TrainingHorizonChanged);
|
---|
| 56 | Content.TestHorizonChanged += new System.EventHandler(Content_TestHorizonChanged);
|
---|
| 57 | }
|
---|
| 58 | protected override void DeregisterContentEvents() {
|
---|
| 59 | Content.TrainingHorizonChanged -= new System.EventHandler(Content_TrainingHorizonChanged);
|
---|
| 60 | Content.TestHorizonChanged -= new System.EventHandler(Content_TestHorizonChanged);
|
---|
| 61 | base.DeregisterContentEvents();
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | private void Content_TrainingHorizonChanged(object sender, System.EventArgs e) {
|
---|
| 65 | TrainingHorizonTextBox.Text = Content.TrainingHorizon.ToString();
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | private void Content_TestHorizonChanged(object sender, System.EventArgs e) {
|
---|
| 69 | TestHorizonTextBox.Text = Content.TestHorizon.ToString();
|
---|
| 70 | }
|
---|
| 71 | #endregion
|
---|
| 72 |
|
---|
| 73 | protected override void OnContentChanged() {
|
---|
| 74 | base.OnContentChanged();
|
---|
| 75 | if (Content == null) {
|
---|
| 76 | TrainingHorizonTextBox.Text = string.Empty;
|
---|
| 77 | TestHorizonTextBox.Text = string.Empty;
|
---|
| 78 | } else {
|
---|
| 79 | TrainingHorizonTextBox.Text = Content.TrainingHorizon.ToString();
|
---|
| 80 | TestHorizonTextBox.Text = Content.TestHorizon.ToString();
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | protected override void SetEnabledStateOfControls() {
|
---|
| 85 | base.SetEnabledStateOfControls();
|
---|
| 86 | //necessary cause this could be triggered by the base ctor when the controls are not created yet
|
---|
| 87 | if (TrainingHorizonTextBox == null || TestHorizonTextBox == null) return;
|
---|
| 88 | TrainingHorizonTextBox.Enabled = Content != null && !Locked;
|
---|
| 89 | TestHorizonTextBox.Enabled = Content != null && !Locked;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | #region Control events
|
---|
| 93 | private void TrainingHorizonTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
|
---|
| 94 | int trainingHorizon;
|
---|
| 95 | if (!int.TryParse(TrainingHorizonTextBox.Text, out trainingHorizon)) {
|
---|
| 96 | e.Cancel = true;
|
---|
| 97 | TrainingHorizonErrorProvider.SetError(TrainingHorizonTextBox, "Please enter a numeric value.");
|
---|
| 98 | TrainingHorizonTextBox.SelectAll();
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | private void TrainingHorizonTextBox_Validated(object sender, System.EventArgs e) {
|
---|
| 103 | Content.TrainingHorizon = int.Parse(TrainingHorizonTextBox.Text);
|
---|
| 104 | TrainingHorizonErrorProvider.SetError(TrainingHorizonTextBox, string.Empty);
|
---|
| 105 | TrainingHorizonTextBox.Text = Content.TrainingHorizon.ToString();
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | private void TrainingHorizonTextBox_KeyDown(object sender, KeyEventArgs e) {
|
---|
| 109 | if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
|
---|
| 110 | TrainingHorizonLabel.Select(); // select label to validate data
|
---|
| 111 |
|
---|
| 112 | if (e.KeyCode == Keys.Escape) {
|
---|
| 113 | TrainingHorizonTextBox.Text = Content.TrainingHorizon.ToString();
|
---|
| 114 | TrainingHorizonLabel.Select(); // select label to validate data
|
---|
| 115 | }
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | private void TestHorizonTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
|
---|
| 119 | int testHorizon;
|
---|
| 120 | if (!int.TryParse(TestHorizonTextBox.Text, out testHorizon)) {
|
---|
| 121 | e.Cancel = true;
|
---|
| 122 | TestHorizonErrorProvider.SetError(TestHorizonTextBox, "Please enter a numeric value.");
|
---|
| 123 | TestHorizonTextBox.SelectAll();
|
---|
| 124 | }
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | private void TestHorizonTextBox_Validated(object sender, System.EventArgs e) {
|
---|
| 128 | Content.TestHorizon = int.Parse(TestHorizonTextBox.Text);
|
---|
| 129 | TestHorizonErrorProvider.SetError(TestHorizonTextBox, string.Empty);
|
---|
| 130 | TestHorizonTextBox.Text = Content.TestHorizon.ToString();
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | private void TestHorizonTextBox_KeyDown(object sender, KeyEventArgs e) {
|
---|
| 134 | if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
|
---|
| 135 | TestHorizonLabel.Select(); // select label to validate data
|
---|
| 136 |
|
---|
| 137 | if (e.KeyCode == Keys.Escape) {
|
---|
| 138 | TestHorizonTextBox.Text = Content.TestHorizon.ToString();
|
---|
| 139 | TestHorizonLabel.Select(); // select label to validate data
|
---|
| 140 | }
|
---|
| 141 | }
|
---|
| 142 | #endregion
|
---|
| 143 | }
|
---|
| 144 | }
|
---|