- Timestamp:
- 07/23/13 15:12:10 (11 years ago)
- Location:
- stable
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 9657,9692,9695
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs
r9456 r9737 53 53 54 54 protected override void DeregisterContentEvents() { 55 Content.ElementNamesChanged -= new EventHandler(Content_ElementNamesChanged); 55 56 Content.ItemChanged -= new EventHandler<EventArgs<int>>(Content_ItemChanged); 56 57 Content.Reset -= new EventHandler(Content_Reset); … … 62 63 Content.ItemChanged += new EventHandler<EventArgs<int>>(Content_ItemChanged); 63 64 Content.Reset += new EventHandler(Content_Reset); 65 Content.ElementNamesChanged += new EventHandler(Content_ElementNamesChanged); 64 66 } 65 67 … … 96 98 dataGridView.Columns[0].Width = dataGridView.Columns[0].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true); 97 99 } 100 UpdateRowHeaders(); 101 dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders); 98 102 dataGridView.Enabled = true; 103 } 104 105 protected virtual void UpdateRowHeaders() { 106 int i = 0; 107 foreach (string elementName in Content.ElementNames) { 108 dataGridView.Rows[i].HeaderCell.Value = elementName; 109 i++; 110 } 111 for (; i < dataGridView.RowCount; i++) { 112 dataGridView.Rows[i].HeaderCell.Value = string.Empty; 113 } 114 } 115 116 private void Content_ElementNamesChanged(object sender, EventArgs e) { 117 if (InvokeRequired) 118 Invoke(new EventHandler(Content_ElementNamesChanged), sender, e); 119 else 120 UpdateRowHeaders(); 99 121 } 100 122 -
stable/HeuristicLab.Data/3.3/Interfaces/IStringConvertibleArray.cs
r9456 r9737 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using HeuristicLab.Common; 24 25 … … 26 27 public interface IStringConvertibleArray : IContent { 27 28 int Length { get; set; } 29 IEnumerable<string> ElementNames { get; set; } 28 30 29 31 bool ReadOnly { get; } … … 33 35 bool SetValue(string value, int index); 34 36 37 event EventHandler ElementNamesChanged; 35 38 event EventHandler<EventArgs<int>> ItemChanged; 36 39 event EventHandler Reset; -
stable/HeuristicLab.Data/3.3/StringArray.cs
r9456 r9737 43 43 protected string[] array; 44 44 45 [Storable] 46 protected List<string> elementNames; 47 public virtual IEnumerable<string> ElementNames { 48 get { return this.elementNames; } 49 set { 50 if (ReadOnly) throw new NotSupportedException("ElementNames cannot be set. ValueTypeArray is read-only."); 51 if (value == null || !value.Any()) 52 elementNames = new List<string>(); 53 else if (value.Count() > Length) 54 throw new ArgumentException("The number of element names must not exceed the array length."); 55 else 56 elementNames = new List<string>(value); 57 OnElementNamesChanged(); 58 } 59 } 60 45 61 public virtual int Length { 46 62 get { return array.Length; } … … 49 65 if (value != Length) { 50 66 Array.Resize<string>(ref array, value); 67 while (elementNames.Count > value) 68 elementNames.RemoveAt(elementNames.Count - 1); 69 OnElementNamesChanged(); 51 70 OnReset(); 52 71 } … … 72 91 } 73 92 93 [StorableHook(HookType.AfterDeserialization)] 94 private void AfterDeserialization() { 95 if (elementNames == null) { elementNames = new List<string>(); } 96 } 97 74 98 [StorableConstructor] 75 99 protected StringArray(bool deserializing) : base(deserializing) { } … … 78 102 this.array = (string[])original.array.Clone(); 79 103 this.readOnly = original.readOnly; 104 this.elementNames = new List<string>(original.elementNames); 80 105 } 81 106 public StringArray() { 82 107 array = new string[0]; 83 108 readOnly = false; 109 elementNames = new List<string>(); 84 110 } 85 111 public StringArray(int length) { … … 88 114 array[i] = string.Empty; 89 115 readOnly = false; 116 elementNames = new List<string>(); 90 117 } 91 118 public StringArray(string[] elements) { … … 95 122 array[i] = elements[i] == null ? string.Empty : elements[i]; 96 123 readOnly = false; 124 elementNames = new List<string>(); 97 125 } 98 126 … … 153 181 } 154 182 183 public event EventHandler ElementNamesChanged; 184 protected virtual void OnElementNamesChanged() { 185 EventHandler handler = ElementNamesChanged; 186 if (handler != null) 187 handler(this, EventArgs.Empty); 188 } 189 155 190 public event EventHandler<EventArgs<int>> ItemChanged; 156 191 protected virtual void OnItemChanged(int index) { -
stable/HeuristicLab.Data/3.3/ValueTypeArray.cs
r9456 r9737 43 43 protected T[] array; 44 44 45 [Storable] 46 protected List<string> elementNames; 47 public virtual IEnumerable<string> ElementNames { 48 get { return this.elementNames; } 49 set { 50 if (ReadOnly) throw new NotSupportedException("ElementNames cannot be set. ValueTypeArray is read-only."); 51 if (value == null || !value.Any()) 52 elementNames = new List<string>(); 53 else if (value.Count() > Length) 54 throw new ArgumentException("The number of element names must not exceed the array length."); 55 else 56 elementNames = new List<string>(value); 57 OnElementNamesChanged(); 58 } 59 } 60 45 61 public virtual int Length { 46 62 get { return array.Length; } … … 51 67 if (value != Length) { 52 68 Array.Resize<T>(ref array, value); 69 while (elementNames.Count > value) 70 elementNames.RemoveAt(elementNames.Count - 1); 71 OnElementNamesChanged(); 53 72 OnReset(); 54 73 } … … 73 92 } 74 93 94 [StorableHook(HookType.AfterDeserialization)] 95 private void AfterDeserialization() { 96 if (elementNames == null) { elementNames = new List<string>(); } 97 } 98 75 99 [StorableConstructor] 76 100 protected ValueTypeArray(bool deserializing) : base(deserializing) { } … … 79 103 this.array = (T[])original.array.Clone(); 80 104 this.readOnly = original.readOnly; 105 this.elementNames = new List<string>(original.elementNames); 81 106 } 82 107 protected ValueTypeArray() { 83 108 array = new T[0]; 84 109 readOnly = false; 110 elementNames = new List<string>(); 85 111 } 86 112 protected ValueTypeArray(int length) { 87 113 array = new T[length]; 88 114 readOnly = false; 115 elementNames = new List<string>(); 89 116 } 90 117 protected ValueTypeArray(T[] elements) { … … 92 119 array = (T[])elements.Clone(); 93 120 readOnly = false; 121 elementNames = new List<string>(); 94 122 } 95 123 … … 125 153 } 126 154 155 public event EventHandler ElementNamesChanged; 156 protected virtual void OnElementNamesChanged() { 157 EventHandler handler = ElementNamesChanged; 158 if (handler != null) 159 handler(this, EventArgs.Empty); 160 } 161 127 162 public event EventHandler<EventArgs<int>> ItemChanged; 128 163 protected virtual void OnItemChanged(int index) {
Note: See TracChangeset
for help on using the changeset viewer.