#region License Information
/* HeuristicLab
* Copyright (C) 2002-2011 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.Windows.Forms;
using HeuristicLab.Collections;
using HeuristicLab.Core.Views;
using HeuristicLab.MainForm;
using HeuristicLab.MainForm.WindowsForms;
namespace HeuristicLab.Analysis.Views {
[View("Histogram View")]
[Content(typeof(Histogram), IsDefaultView = true)]
public partial class HistogramView : NamedItemView {
public new Histogram Content {
get { return (Histogram)base.Content; }
set { base.Content = value; }
}
public HistogramView() {
InitializeComponent();
}
protected override void DeregisterContentEvents() {
Content.Values.ItemsAdded -= new CollectionItemsChangedEventHandler(Content_Values_ItemsAdded);
Content.Values.ItemsRemoved -= new CollectionItemsChangedEventHandler(Content_Values_ItemsRemoved);
Content.Values.CollectionReset -= new CollectionItemsChangedEventHandler(Content_Values_CollectionReset);
base.DeregisterContentEvents();
}
protected override void RegisterContentEvents() {
base.RegisterContentEvents();
Content.Values.ItemsAdded += new CollectionItemsChangedEventHandler(Content_Values_ItemsAdded);
Content.Values.ItemsRemoved += new CollectionItemsChangedEventHandler(Content_Values_ItemsRemoved);
Content.Values.CollectionReset += new CollectionItemsChangedEventHandler(Content_Values_CollectionReset);
}
#region Event Handlers (Content)
private void Content_Values_ItemsAdded(object sender, CollectionItemsChangedEventArgs e) {
histogramControl.AddPoints(e.Items);
}
private void Content_Values_ItemsRemoved(object sender, CollectionItemsChangedEventArgs e) {
histogramControl.ClearPoints();
histogramControl.AddPoints(Content.Values);
}
private void Content_Values_CollectionReset(object sender, CollectionItemsChangedEventArgs e) {
histogramControl.ClearPoints();
histogramControl.AddPoints(Content.Values);
}
#endregion
protected override void OnContentChanged() {
base.OnContentChanged();
histogramControl.ClearPoints();
if (Content != null) {
histogramControl.AddPoints(Content.Values);
}
}
protected override void SetEnabledStateOfControls() {
base.SetEnabledStateOfControls();
histogramControl.Enabled = Content != null;
}
#region Event Handlers (child controls)
#endregion
}
}