Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/LineChartView.cs @ 10612

Last change on this file since 10612 was 10573, checked in by sbreuer, 11 years ago
  • refresh LineChartView when PreprocessingData changes
File size: 2.7 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.Windows.Forms;
23using HeuristicLab.Core.Views;
24using HeuristicLab.MainForm;
25
26namespace HeuristicLab.DataPreprocessing.Views {
27
28  [View("Line Chart View")]
29  [Content(typeof(LineChartContent), false)]
30  public partial class LineChartView : ItemView {
31
32    public LineChartView() {
33      InitializeComponent();
34    }
35
36    private void InitDataTable() {
37      ILineChartLogic logic = Content.LineChartLogic;
38      viewHost.Content = logic.GetDataTable();
39    }
40
41    protected override void RegisterContentEvents() {
42      base.RegisterContentEvents();
43      Content.Changed += Content_Changed;
44    }
45
46    protected override void DeregisterContentEvents() {
47      base.DeregisterContentEvents();
48      Content.Changed -= Content_Changed;
49    }
50
51    void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {
52      viewHost.Refresh();
53    }
54
55    public new LineChartContent Content {
56      get { return (LineChartContent)base.Content; }
57      set { base.Content = value; }
58    }
59
60    protected override void OnContentChanged() {
61      base.OnContentChanged();
62      if (Content != null) {
63        InitDataTable();
64        InitVariablesListBox();
65      }
66    }
67
68    private void InitVariablesListBox() {
69      ILineChartLogic logic = Content.LineChartLogic;
70
71      foreach (var variableName in logic.GetVariableNames()) {
72        variablesListBox.Items.Add(variableName, true);
73      }
74    }
75
76    private void variablesListBox_ItemCheck(object sender, ItemCheckEventArgs e) {
77      string item = variablesListBox.Items[e.Index] as string;
78
79
80      if (e.NewValue == CheckState.Checked && !Content.LineChartLogic.VariableIsDisplayed(item))
81        Content.LineChartLogic.AddVariable(item);
82      else if (e.NewValue == CheckState.Unchecked && Content.LineChartLogic.VariableIsDisplayed(item))
83        Content.LineChartLogic.RemoveVariable(item);
84    }
85  }
86}
87
88
Note: See TracBrowser for help on using the repository browser.