#region License Information
/* HeuristicLab
* Copyright (C) 2002-2010 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.Collections.Generic;
using System.ComponentModel;
using HeuristicLab.Collections;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Analysis {
///
/// A row of data values.
///
[Item("DataRow", "A row of data values.")]
[StorableClass]
public sealed class DataRow : NamedItem {
private DataRowVisualProperties visualProperties;
public DataRowVisualProperties VisualProperties {
get { return visualProperties; }
set {
if (visualProperties != value) {
if (value == null) throw new ArgumentNullException("VisualProperties");
if (visualProperties != null) visualProperties.PropertyChanged -= new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
visualProperties = value;
visualProperties.PropertyChanged += new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
OnVisualPropertiesChanged();
}
}
}
private ObservableList values;
public ObservableList Values {
get { return values; }
}
#region Persistence Properties
[Storable(Name = "VisualProperties")]
private DataRowVisualProperties StorableVisualProperties {
get { return VisualProperties; }
set { VisualProperties = value; }
}
[Storable(Name = "values")]
private IEnumerable StorableValues {
get { return values; }
set { values = new ObservableList(value); }
}
#endregion
#region Storing & Cloning
[StorableConstructor]
private DataRow(bool deserializing) : base(deserializing) { }
private DataRow(DataRow original, Cloner cloner)
: base(original, cloner) {
this.VisualProperties = (DataRowVisualProperties)cloner.Clone(original.visualProperties);
this.values = new ObservableList(original.values);
}
public override IDeepCloneable Clone(Cloner cloner) {
return new DataRow(this, cloner);
}
#endregion
public DataRow()
: base() {
VisualProperties = new DataRowVisualProperties();
values = new ObservableList();
}
public DataRow(string name)
: base(name) {
VisualProperties = new DataRowVisualProperties();
values = new ObservableList();
}
public DataRow(string name, string description)
: base(name, description) {
VisualProperties = new DataRowVisualProperties();
values = new ObservableList();
}
public DataRow(string name, string description, DataRowVisualProperties visualProperties)
: base(name, description) {
VisualProperties = visualProperties;
values = new ObservableList();
}
// BackwardsCompatibility3.3
#region Backwards compatible code, remove with 3.4
[StorableHook(HookType.AfterDeserialization)]
private void AfterDeserialization() {
if (VisualProperties == null) VisualProperties = new DataRowVisualProperties();
}
#endregion
public event EventHandler VisualPropertiesChanged;
private void OnVisualPropertiesChanged() {
EventHandler handler = VisualPropertiesChanged;
if (handler != null) handler(this, EventArgs.Empty);
}
private void VisualProperties_PropertyChanged(object sender, PropertyChangedEventArgs e) {
OnVisualPropertiesChanged();
}
}
}