Changeset 3767
- Timestamp:
- 05/11/10 14:23:31 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Analysis.Views/3.3/HeuristicLab.Analysis.Views-3.3.csproj
r3437 r3767 121 121 <Name>HeuristicLab.Core-3.3</Name> 122 122 </ProjectReference> 123 <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj"> 124 <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project> 125 <Name>HeuristicLab.Data-3.3</Name> 126 </ProjectReference> 123 127 <ProjectReference Include="..\..\HeuristicLab.MainForm.WindowsForms\3.3\HeuristicLab.MainForm.WindowsForms-3.3.csproj"> 124 128 <Project>{AB687BBE-1BFE-476B-906D-44237135431D}</Project> -
trunk/sources/HeuristicLab.Analysis/3.3/DataTable.cs
r3710 r3767 21 21 22 22 using System.Drawing; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Data; 28 using System; 29 using System.Collections.Generic; 30 using HeuristicLab.Collections; 26 31 27 32 namespace HeuristicLab.Analysis { … … 31 36 [Item("DataTable", "A table of data values.")] 32 37 [StorableClass] 33 public sealed class DataTable : NamedItem {38 public sealed class DataTable : NamedItem, IStringConvertibleMatrix { 34 39 public override Image ItemImage { 35 40 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Performance.ToBitmap(); } … … 45 50 : base() { 46 51 rows = new NamedItemCollection<DataRow>(); 52 this.RegisterRowsEvents(); 47 53 } 48 54 public DataTable(string name) 49 55 : base(name) { 50 56 rows = new NamedItemCollection<DataRow>(); 57 this.RegisterRowsEvents(); 51 58 } 52 59 public DataTable(string name, string description) 53 60 : base(name, description) { 54 61 rows = new NamedItemCollection<DataRow>(); 62 this.RegisterRowsEvents(); 63 } 64 65 private void RegisterRowsEvents() { 66 rows.ItemsAdded += new CollectionItemsChangedEventHandler<DataRow>(rows_ItemsAdded); 67 rows.ItemsRemoved += new CollectionItemsChangedEventHandler<DataRow>(rows_ItemsRemoved); 68 rows.ItemsReplaced += new CollectionItemsChangedEventHandler<DataRow>(rows_ItemsReplaced); 69 rows.CollectionReset += new CollectionItemsChangedEventHandler<DataRow>(rows_CollectionReset); 70 } 71 private void rows_ItemsAdded(object sender, CollectionItemsChangedEventArgs<DataRow> e) { 72 foreach (DataRow row in e.Items) 73 this.RegisterRowEvents(row); 74 this.OnColumnNamesChanged(); 75 this.OnReset(); 76 } 77 private void rows_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<DataRow> e) { 78 foreach (DataRow row in e.Items) 79 this.DeregisterRowEvents(row); 80 this.OnColumnNamesChanged(); 81 this.OnReset(); 82 } 83 private void rows_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<DataRow> e) { 84 foreach (DataRow row in e.OldItems) 85 this.DeregisterRowEvents(row); 86 foreach (DataRow row in e.Items) 87 this.RegisterRowEvents(row); 88 this.OnColumnNamesChanged(); 89 this.OnReset(); 90 } 91 private void rows_CollectionReset(object sender, CollectionItemsChangedEventArgs<DataRow> e) { 92 foreach (DataRow row in e.OldItems) 93 this.DeregisterRowEvents(row); 94 foreach (DataRow row in e.Items) 95 this.RegisterRowEvents(row); 96 this.OnColumnNamesChanged(); 97 this.OnReset(); 98 } 99 100 private void RegisterRowEvents(DataRow row) { 101 row.Values.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsAdded); 102 row.Values.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsMoved); 103 row.Values.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsRemoved); 104 row.Values.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsReplaced); 105 row.Values.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_CollectionReset); 106 } 107 private void DeregisterRowEvents(DataRow row) { 108 row.Values.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsAdded); 109 row.Values.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsMoved); 110 row.Values.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsRemoved); 111 row.Values.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsReplaced); 112 row.Values.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_CollectionReset); 113 } 114 115 private void Values_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) { 116 this.OnReset(); 117 } 118 private void Values_ItemsMoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) { 119 this.OnReset(); 120 } 121 private void Values_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) { 122 this.OnReset(); 123 } 124 private void Values_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) { 125 this.OnReset(); 126 } 127 private void Values_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) { 128 this.OnReset(); 55 129 } 56 130 … … 61 135 return clone; 62 136 } 137 138 #region IStringConvertibleMatrix Members 139 140 int IStringConvertibleMatrix.Rows { 141 get { return rows.Max(r => r.Values.Count); } 142 set { throw new NotSupportedException(); } 143 } 144 int IStringConvertibleMatrix.Columns { 145 get { return rows.Count; } 146 set { throw new NotSupportedException(); } 147 } 148 IEnumerable<string> IStringConvertibleMatrix.ColumnNames { 149 get { return rows.Select(r => r.Name); } 150 set { throw new NotSupportedException(); } 151 } 152 IEnumerable<string> IStringConvertibleMatrix.RowNames { 153 get { return new List<string>(); } 154 set { throw new NotSupportedException(); } 155 } 156 157 bool IStringConvertibleMatrix.SortableView { 158 get { return true; } 159 set { throw new NotSupportedException(); } 160 } 161 bool IStringConvertibleMatrix.ReadOnly { 162 get { return true; } 163 } 164 165 string IStringConvertibleMatrix.GetValue(int rowIndex, int columnIndex) { 166 if (columnIndex < rows.Count) { 167 string columnName = ((IStringConvertibleMatrix)this).ColumnNames.ElementAt(columnIndex); 168 if (rows.ContainsKey(columnName) && rowIndex < rows[columnName].Values.Count) 169 return rows[columnName].Values[rowIndex].ToString(); 170 } 171 return string.Empty; 172 } 173 174 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 175 throw new NotSupportedException(); 176 } 177 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) { 178 throw new NotSupportedException(); 179 } 180 181 public event EventHandler<EventArgs<int, int>> ItemChanged; 182 private void OnItemChanged(int rowIndex, int columnIndex) { 183 if (ItemChanged != null) 184 ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex)); 185 OnToStringChanged(); 186 } 187 public event EventHandler Reset; 188 private void OnReset() { 189 if (Reset != null) 190 Reset(this, EventArgs.Empty); 191 OnToStringChanged(); 192 } 193 public event EventHandler ColumnNamesChanged; 194 private void OnColumnNamesChanged() { 195 EventHandler handler = ColumnNamesChanged; 196 if (handler != null) 197 handler(this, EventArgs.Empty); 198 } 199 public event EventHandler RowNamesChanged; 200 private void OnRowNamesChanged() { 201 EventHandler handler = RowNamesChanged; 202 if (handler != null) 203 handler(this, EventArgs.Empty); 204 } 205 public event EventHandler SortableViewChanged; 206 private void OnSortableViewChanged() { 207 EventHandler handler = SortableViewChanged; 208 if (handler != null) 209 handler(this, EventArgs.Empty); 210 } 211 212 #endregion 63 213 } 64 214 } -
trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs
r3717 r3767 153 153 public IItem GetValue(IRun run, string columnName) { 154 154 IItem value = null; 155 156 157 158 155 if (run.Parameters.ContainsKey(columnName)) 156 value = run.Parameters[columnName]; 157 else if (run.Results.ContainsKey(columnName)) 158 value = run.Results[columnName]; 159 159 return value; 160 160 } … … 242 242 handler(this, EventArgs.Empty); 243 243 } 244 245 244 public event EventHandler SortableViewChanged; 246 245 protected virtual void OnSortableViewChanged() {
Note: See TracChangeset
for help on using the changeset viewer.