#region License Information
/* HeuristicLab
* Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms.DataVisualization.Charting;
using HeuristicLab.Core.Views;
using HeuristicLab.MainForm;
namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
[View("Sliding Window View")]
[Content(typeof(SlidingWindowData), IsDefaultView = true)]
public partial class SlidingWindowDataView : ItemView {
private const string TARGETVARIABLE_SERIES_NAME = "Target Variable";
private const string ESTIMATEDVAlUES_SERIES_NAME = "Estimated Values";
public new SlidingWindowData Content {
get { return (SlidingWindowData)base.Content; }
set { base.Content = value; }
}
public SlidingWindowDataView() {
InitializeComponent();
chart.CustomizeAllChartAreas();
chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
chart.ChartAreas[0].AxisX.IsStartedFromZero = true;
chart.ChartAreas[0].CursorX.Interval = 1;
chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
chart.ChartAreas[0].CursorY.Interval = 0;
StripLine stripLine = new StripLine();
stripLine.BackColor = Color.Gold;
stripLine.Font = new Font("Times New Roman", 12, FontStyle.Bold);
stripLine.Text = "Sliding Window";
chart.ChartAreas[0].AxisX.StripLines.Add(stripLine);
}
protected override void RegisterContentEvents() {
base.RegisterContentEvents();
Content.SlidingWindowPosition.ValueChanged += new EventHandler(SlidingWindowPosition_ValueChanged);
Content.EstimatedValuesChanged += new EventHandler(EstimatedValuesChanged);
}
protected override void DeregisterContentEvents() {
Content.SlidingWindowPosition.ValueChanged -= new EventHandler(SlidingWindowPosition_ValueChanged);
Content.EstimatedValuesChanged -= new EventHandler(EstimatedValuesChanged);
base.DeregisterContentEvents();
}
protected override void OnContentChanged() {
base.OnContentChanged();
RedrawChart();
}
private void SlidingWindowPosition_ValueChanged(object sender, EventArgs e) {
if (InvokeRequired) Invoke((Action