Changeset 9401 for branches/ImprovingStringConvertibleMatrix
- Timestamp:
- 04/29/13 11:36:00 (12 years ago)
- Location:
- branches/ImprovingStringConvertibleMatrix
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs
r9308 r9401 53 53 54 54 protected override void DeregisterContentEvents() { 55 Content. ColumnNamesChanged -= new EventHandler(Content_ColumnNamesChanged);55 Content.ElementNamesChanged -= new EventHandler(Content_ElementNamesChanged); 56 56 Content.Reset -= new EventHandler(Content_Reset); 57 57 Content.ItemsChanged -= new EventHandler<ArrayValuesChangedEventArgs>(Content_ItemsChanged); … … 63 63 Content.ItemsChanged += new EventHandler<ArrayValuesChangedEventArgs>(Content_ItemsChanged); 64 64 Content.Reset += new EventHandler(Content_Reset); 65 Content. ColumnNamesChanged -= new EventHandler(Content_ColumnNamesChanged);65 Content.ElementNamesChanged -= new EventHandler(Content_ElementNamesChanged); 66 66 } 67 67 … … 106 106 protected virtual void UpdateRowHeaders() { 107 107 for (int i = 0; i < dataGridView.RowCount; i++) { 108 if (i < Content. ColumnNames.Count())109 dataGridView.Rows[i].HeaderCell.Value = Content. ColumnNames.ElementAt(i);108 if (i < Content.ElementNames.Count()) 109 dataGridView.Rows[i].HeaderCell.Value = Content.ElementNames.ElementAt(i); 110 110 else 111 dataGridView.Rows[i].HeaderCell.Value = " Column" + (i + 1);111 dataGridView.Rows[i].HeaderCell.Value = "Element " + (i + 1); 112 112 } 113 113 } … … 124 124 } 125 125 } 126 private void Content_ ColumnNamesChanged(object sender, EventArgs e) {126 private void Content_ElementNamesChanged(object sender, EventArgs e) { 127 127 if (InvokeRequired) 128 Invoke(new EventHandler(Content_ ColumnNamesChanged), sender, e);128 Invoke(new EventHandler(Content_ElementNamesChanged), sender, e); 129 129 else 130 130 UpdateRowHeaders(); -
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/Interfaces/IStringConvertibleArray.cs
r9308 r9401 27 27 public interface IStringConvertibleArray : IContent { 28 28 int Length { get; set; } 29 IEnumerable<string> ColumnNames { get; set; }29 IEnumerable<string> ElementNames { get; set; } 30 30 31 31 bool ReadOnly { get; } … … 37 37 bool SetValues(IEnumerable<ArrayValue<string>> arrayValues); 38 38 39 event EventHandler ColumnNamesChanged;39 event EventHandler ElementNamesChanged; 40 40 event EventHandler<ArrayValuesChangedEventArgs> ItemsChanged; 41 41 event EventHandler Reset; -
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/StringArray.cs
r9308 r9401 42 42 43 43 [Storable] 44 protected List<string> columnNames;45 public virtual IEnumerable<string> ColumnNames {46 get { return this. columnNames; }44 protected List<string> elementNames; 45 public virtual IEnumerable<string> ElementNames { 46 get { return this.elementNames; } 47 47 set { 48 if (ReadOnly) throw new NotSupportedException(" ColumnNames cannot be set. ValueTypeArray is read-only.");48 if (ReadOnly) throw new NotSupportedException("ElementNames cannot be set. ValueTypeArray is read-only."); 49 49 if (value == null || value.Count() == 0) 50 columnNames = new List<string>();50 elementNames = new List<string>(); 51 51 else if (value.Count() != Length) 52 throw new ArgumentException("A column name must be specified for each column.");52 throw new ArgumentException("An element name must be specified for each element."); 53 53 else 54 columnNames = new List<string>(value);55 On ColumnNamesChanged();54 elementNames = new List<string>(value); 55 OnElementNamesChanged(); 56 56 } 57 57 } … … 63 63 if (value != Length) { 64 64 Array.Resize<string>(ref array, value); 65 while ( columnNames.Count > value)66 columnNames.RemoveAt(columnNames.Count - 1);67 while ( columnNames.Count < value)68 columnNames.Add("Column " + columnNames.Count);69 On ColumnNamesChanged();65 while (elementNames.Count > value) 66 elementNames.RemoveAt(elementNames.Count - 1); 67 while (elementNames.Count < value) 68 elementNames.Add("Element " + elementNames.Count); 69 OnElementNamesChanged(); 70 70 OnReset(); 71 71 } … … 93 93 [StorableHook(HookType.AfterDeserialization)] 94 94 private void AfterDeserialization() { 95 if ( columnNames == null) {96 columnNames = new List<string>(array.Length);97 while ( columnNames.Count < array.Length)98 columnNames.Add("Column " + columnNames.Count);95 if (elementNames == null) { 96 elementNames = new List<string>(array.Length); 97 while (elementNames.Count < array.Length) 98 elementNames.Add("Element " + elementNames.Count); 99 99 } 100 100 } … … 105 105 : base(original, cloner) { 106 106 this.array = (string[])original.array.Clone(); 107 this. columnNames = new List<string>(original.columnNames);107 this.elementNames = new List<string>(original.elementNames); 108 108 this.readOnly = original.readOnly; 109 109 } 110 110 public StringArray() { 111 111 array = new string[0]; 112 columnNames = new List<string>();112 elementNames = new List<string>(); 113 113 readOnly = false; 114 114 } … … 117 117 for (int i = 0; i < array.Length; i++) 118 118 array[i] = string.Empty; 119 columnNames = new List<string>();119 elementNames = new List<string>(); 120 120 readOnly = false; 121 121 } … … 125 125 for (int i = 0; i < array.Length; i++) 126 126 array[i] = elements[i] == null ? string.Empty : elements[i]; 127 columnNames = new List<string>();127 elementNames = new List<string>(); 128 128 readOnly = false; 129 129 } … … 194 194 } 195 195 196 public event EventHandler ColumnNamesChanged;197 protected virtual void On ColumnNamesChanged() {198 EventHandler handler = ColumnNamesChanged;196 public event EventHandler ElementNamesChanged; 197 protected virtual void OnElementNamesChanged() { 198 EventHandler handler = ElementNamesChanged; 199 199 if (handler != null) 200 200 handler(this, EventArgs.Empty); -
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/ValueTypeArray.cs
r9308 r9401 42 42 43 43 [Storable] 44 protected List<string> columnNames;45 public virtual IEnumerable<string> ColumnNames {46 get { return this. columnNames; }44 protected List<string> elementNames; 45 public virtual IEnumerable<string> ElementNames { 46 get { return this.elementNames; } 47 47 set { 48 if (ReadOnly) throw new NotSupportedException(" ColumnNames cannot be set. ValueTypeArray is read-only.");48 if (ReadOnly) throw new NotSupportedException("ElementNames cannot be set. ValueTypeArray is read-only."); 49 49 if (value == null || value.Count() == 0) 50 columnNames = new List<string>();50 elementNames = new List<string>(); 51 51 else if (value.Count() != Length) 52 throw new ArgumentException("A column name must be specified for each column.");52 throw new ArgumentException("An element name must be specified for each element."); 53 53 else 54 columnNames = new List<string>(value);55 On ColumnNamesChanged();54 elementNames = new List<string>(value); 55 OnElementNamesChanged(); 56 56 } 57 57 } … … 65 65 if (value != Length) { 66 66 Array.Resize<T>(ref array, value); 67 while ( columnNames.Count > value)68 columnNames.RemoveAt(columnNames.Count - 1);69 while ( columnNames.Count < value)70 columnNames.Add("Column " + columnNames.Count);71 On ColumnNamesChanged();67 while (elementNames.Count > value) 68 elementNames.RemoveAt(elementNames.Count - 1); 69 while (elementNames.Count < value) 70 elementNames.Add("Element " + elementNames.Count); 71 OnElementNamesChanged(); 72 72 OnReset(); 73 73 } … … 106 106 [StorableHook(HookType.AfterDeserialization)] 107 107 private void AfterDeserialization() { 108 if ( columnNames == null) {109 columnNames = new List<string>(array.Length);110 while ( columnNames.Count < array.Length)111 columnNames.Add("Column " + columnNames.Count);108 if (elementNames == null) { 109 elementNames = new List<string>(array.Length); 110 while (elementNames.Count < array.Length) 111 elementNames.Add("Element " + elementNames.Count); 112 112 } 113 113 } … … 118 118 : base(original, cloner) { 119 119 this.array = (T[])original.array.Clone(); 120 this. columnNames = new List<string>(original.columnNames);120 this.elementNames = new List<string>(original.elementNames); 121 121 this.readOnly = original.readOnly; 122 122 } 123 123 protected ValueTypeArray() { 124 124 array = new T[0]; 125 columnNames = new List<string>();125 elementNames = new List<string>(); 126 126 readOnly = false; 127 127 } 128 128 protected ValueTypeArray(int length) { 129 129 array = new T[length]; 130 columnNames = new List<string>(length);130 elementNames = new List<string>(length); 131 131 readOnly = false; 132 132 } … … 134 134 if (elements == null) throw new ArgumentNullException(); 135 135 array = (T[])elements.Clone(); 136 columnNames = new List<string>(elements.Length);136 elementNames = new List<string>(elements.Length); 137 137 readOnly = false; 138 138 } … … 164 164 } 165 165 166 public event EventHandler ColumnNamesChanged;167 protected virtual void On ColumnNamesChanged() {168 EventHandler handler = ColumnNamesChanged;166 public event EventHandler ElementNamesChanged; 167 protected virtual void OnElementNamesChanged() { 168 EventHandler handler = ElementNamesChanged; 169 169 if (handler != null) 170 170 handler(this, EventArgs.Empty);
Note: See TracChangeset
for help on using the changeset viewer.