Changeset 697 for trunk/sources/HeuristicLab.Visualization
- Timestamp:
- 10/21/08 00:44:45 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Visualization
- Files:
-
- 2 added
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/ChartDataRowsModel.cs
r685 r697 7 7 8 8 namespace HeuristicLab.Visualization{ 9 public class ChartDataRowsModel : ChartDataModelBase, IChartDataRowsModel {9 public class ChartDataRowsModel : ChartDataModelBase, IChartDataRowsModel { 10 10 11 11 private readonly ListDictionary dataRows; … … 27 27 } 28 28 29 public event ChartDataRowsModelDataChangedHandler DataChanged; 29 public event ChartDataRowsModelColumnChangedHandler ColumnChanged; 30 31 private void RaiseColumnChanged(ChangeType type, long columnId, double[] values) { 32 if (ColumnChanged != null) { 33 ColumnChanged(type, columnId, values); 34 } 35 } 36 37 public List<ChartDataRowsModelColumn> Columns { 38 get { throw new NotImplementedException(); } 39 } 30 40 } 31 41 } -
trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj
r685 r697 61 61 <Compile Include="ChartDataModelBase.cs" /> 62 62 <Compile Include="ChartDataRowsModel.cs" /> 63 <Compile Include="ChartDataRowsModelDataChangedHandler.cs" /> 63 <Compile Include="ChartDataRowsModelColumn.cs" /> 64 <Compile Include="ChartDataRowsModelColumnChangedHandler.cs" /> 64 65 <Compile Include="ChartDataRowsModelDummy.cs" /> 65 66 <Compile Include="CompositeShape.cs" /> -
trunk/sources/HeuristicLab.Visualization/IChartDataRowsModel.cs
r685 r697 1 namespace HeuristicLab.Visualization { 1 using System.Collections.Generic; 2 3 namespace HeuristicLab.Visualization { 2 4 public interface IChartDataRowsModel { 3 event ChartDataRowsModelDataChangedHandler DataChanged; 5 event ChartDataRowsModelColumnChangedHandler ColumnChanged; 6 List<ChartDataRowsModelColumn> Columns { get; } 4 7 } 5 8 } -
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r684 r697 1 1 using System; 2 using System.Windows.Forms;2 using HeuristicLab.Core; 3 3 4 4 namespace HeuristicLab.Visualization { 5 public partial class LineChart : UserControl{6 private IChartDataRowsModel model;5 public partial class LineChart : ViewBase { 6 private readonly IChartDataRowsModel model; 7 7 8 /// <summary> 9 /// This constructor shouldn't be called. Only required for the designer. 10 /// </summary> 8 11 public LineChart() { 9 12 InitializeComponent(); 10 13 } 11 14 12 public IChartDataRowsModel Model { 13 get { return model; } 14 set { 15 if (value == null) { 16 throw new NullReferenceException("Model cannot be null."); 17 } 15 /// <summary> 16 /// Initializes the chart. 17 /// </summary> 18 /// <param name="model"></param> 19 public LineChart(IChartDataRowsModel model) : this() { 20 if (model == null) { 21 throw new NullReferenceException("Model cannot be null."); 22 } 18 23 19 if (model != null) { 20 throw new InvalidOperationException("Model has already been set."); 21 } 24 this.model = model; 22 25 23 model = value; 26 Reset(); 27 } 24 28 25 model.DataChanged += OnDataChanged; 29 /// <summary> 30 /// Resets the line chart by deleting all shapes and reloading all data from the model. 31 /// </summary> 32 private void Reset() { 33 BeginUpdate(); 34 35 // TODO clear existing shapes 36 37 // reload data from the model and create shapes 38 foreach (ChartDataRowsModelColumn column in model.Columns) { 39 AddColumn(column.ColumnId, column.Values); 40 } 41 42 EndUpdate(); 43 } 44 45 /// <summary> 46 /// Event handler which gets called when data in the model changes. 47 /// </summary> 48 /// <param name="type">Type of change</param> 49 /// <param name="columnId">Id of the changed column</param> 50 /// <param name="values">Values contained within the changed column</param> 51 private void OnDataChanged(ChangeType type, long columnId, double[] values) { 52 switch (type) { 53 case ChangeType.Add: 54 AddColumn(columnId, values); 55 break; 56 case ChangeType.Modify: 57 ModifyColumn(columnId, values); 58 break; 59 case ChangeType.Remove: 60 RemoveColumn(columnId); 61 break; 62 default: 63 throw new ArgumentOutOfRangeException("type"); 26 64 } 27 65 } 28 66 29 private void OnDataChanged(ChangeType type, int dataId, double[] values) { 67 /// <summary> 68 /// Adds a new column to the chart. 69 /// </summary> 70 /// <param name="columnId">Id of the column</param> 71 /// <param name="values">Values of the column</param> 72 private void AddColumn(long columnId, double[] values) { 30 73 throw new NotImplementedException(); 31 74 } 75 76 /// <summary> 77 /// Modifies an existing column of the chart. 78 /// </summary> 79 /// <param name="columnId">Id of the column</param> 80 /// <param name="values">Values of the column</param> 81 private void ModifyColumn(long columnId, double[] values) { 82 throw new NotImplementedException(); 83 } 84 85 /// <summary> 86 /// Removes a column from the chart. 87 /// </summary> 88 /// <param name="columnId">Id of the column</param> 89 private void RemoveColumn(long columnId) { 90 throw new NotImplementedException(); 91 } 92 93 #region Add-/RemoveItemEvents 94 95 protected override void AddItemEvents() { 96 base.AddItemEvents(); 97 model.ColumnChanged += OnDataChanged; 98 } 99 100 protected override void RemoveItemEvents() { 101 base.RemoveItemEvents(); 102 model.ColumnChanged -= OnDataChanged; 103 } 104 105 #endregion 106 107 #region Begin-/EndUpdate 108 109 private int beginUpdateCount = 0; 110 111 public void BeginUpdate() { 112 beginUpdateCount++; 113 } 114 115 public void EndUpdate() { 116 if (beginUpdateCount == 0) { 117 throw new InvalidOperationException("Too many EndUpdates."); 118 } 119 120 beginUpdateCount--; 121 122 if (beginUpdateCount == 0) { 123 Invalidate(); 124 } 125 } 126 127 #endregion 32 128 } 33 129 }
Note: See TracChangeset
for help on using the changeset viewer.