Changeset 13695 for trunk/sources
- Timestamp:
- 03/14/16 14:57:02 (9 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs
r13570 r13695 80 80 lengthTextBox.Enabled = Content != null; 81 81 dataGridView.Enabled = Content != null; 82 lengthTextBox.ReadOnly = ReadOnly ;82 lengthTextBox.ReadOnly = ReadOnly || (Content != null && !Content.Resizable); 83 83 dataGridView.ReadOnly = ReadOnly; 84 84 } -
trunk/sources/HeuristicLab.Data/3.3/BoolArray.cs
r12012 r13695 28 28 [Item("BoolArray", "Represents an array of boolean values.")] 29 29 [StorableClass] 30 public class BoolArray : ValueTypeArray<bool>, IStringConvertibleArray{30 public class BoolArray : StringConvertibleArray<bool> { 31 31 [StorableConstructor] 32 32 protected BoolArray(bool deserializing) : base(deserializing) { } … … 42 42 } 43 43 44 protected virtualbool Validate(string value, out string errorMessage) {44 protected override bool Validate(string value, out string errorMessage) { 45 45 bool val; 46 46 bool valid = bool.TryParse(value, out val); … … 55 55 return valid; 56 56 } 57 protected virtualstring GetValue(int index) {57 protected override string GetValue(int index) { 58 58 return this[index].ToString(); 59 59 } 60 protected virtualbool SetValue(string value, int index) {60 protected override bool SetValue(string value, int index) { 61 61 bool val; 62 62 if (bool.TryParse(value, out val)) { … … 67 67 } 68 68 } 69 70 #region IStringConvertibleArray Members71 int IStringConvertibleArray.Length {72 get { return Length; }73 set { Length = value; }74 }75 bool IStringConvertibleArray.Validate(string value, out string errorMessage) {76 return Validate(value, out errorMessage);77 }78 string IStringConvertibleArray.GetValue(int index) {79 return GetValue(index);80 }81 bool IStringConvertibleArray.SetValue(string value, int index) {82 return SetValue(value, index);83 }84 #endregion85 69 } 86 70 } -
trunk/sources/HeuristicLab.Data/3.3/DoubleArray.cs
r12432 r13695 28 28 [Item("DoubleArray", "Represents an array of double values.")] 29 29 [StorableClass] 30 public class DoubleArray : ValueTypeArray<double>, IStringConvertibleArray{30 public class DoubleArray : StringConvertibleArray<double> { 31 31 [StorableConstructor] 32 32 protected DoubleArray(bool deserializing) : base(deserializing) { } … … 42 42 } 43 43 44 protected virtualbool Validate(string value, out string errorMessage) {44 protected override bool Validate(string value, out string errorMessage) { 45 45 double val; 46 46 bool valid = double.TryParse(value, out val); … … 55 55 return valid; 56 56 } 57 protected virtualstring GetValue(int index) {57 protected override string GetValue(int index) { 58 58 return this[index].ToString("r"); 59 59 } 60 protected virtualbool SetValue(string value, int index) {60 protected override bool SetValue(string value, int index) { 61 61 double val; 62 62 if (double.TryParse(value, out val)) { … … 67 67 } 68 68 } 69 70 #region IStringConvertibleArray Members71 int IStringConvertibleArray.Length {72 get { return Length; }73 set { Length = value; }74 }75 bool IStringConvertibleArray.Validate(string value, out string errorMessage) {76 return Validate(value, out errorMessage);77 }78 string IStringConvertibleArray.GetValue(int index) {79 return GetValue(index);80 }81 bool IStringConvertibleArray.SetValue(string value, int index) {82 return SetValue(value, index);83 }84 #endregion85 69 } 86 70 } -
trunk/sources/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj
r12037 r13695 124 124 <Compile Include="ComparisonType.cs" /> 125 125 <Compile Include="EnumValue.cs" /> 126 <Compile Include="Interfaces\IValueTypeArray.cs" /> 126 127 <Compile Include="Path Types\DirectoryValue.cs" /> 127 128 <Compile Include="Path Types\FileValue.cs" /> … … 148 149 <Compile Include="Properties\AssemblyInfo.cs" /> 149 150 <Compile Include="StringArray.cs" /> 151 <Compile Include="StringConvertibleArray.cs" /> 150 152 <Compile Include="StringMatrix.cs" /> 151 153 <Compile Include="StringValue.cs" /> -
trunk/sources/HeuristicLab.Data/3.3/IntArray.cs
r12012 r13695 28 28 [Item("IntArray", "Represents an array of integer values.")] 29 29 [StorableClass] 30 public class IntArray : ValueTypeArray<int>, IStringConvertibleArray{30 public class IntArray : StringConvertibleArray<int> { 31 31 [StorableConstructor] 32 32 protected IntArray(bool deserializing) : base(deserializing) { } … … 42 42 } 43 43 44 protected virtualbool Validate(string value, out string errorMessage) {44 protected override bool Validate(string value, out string errorMessage) { 45 45 int val; 46 46 bool valid = int.TryParse(value, out val); … … 55 55 return valid; 56 56 } 57 protected virtualstring GetValue(int index) {57 protected override string GetValue(int index) { 58 58 return this[index].ToString(); 59 59 } 60 protected virtualbool SetValue(string value, int index) {60 protected override bool SetValue(string value, int index) { 61 61 int val; 62 62 if (int.TryParse(value, out val)) { … … 67 67 } 68 68 } 69 70 #region IStringConvertibleArray Members71 int IStringConvertibleArray.Length {72 get { return Length; }73 set { Length = value; }74 }75 bool IStringConvertibleArray.Validate(string value, out string errorMessage) {76 return Validate(value, out errorMessage);77 }78 string IStringConvertibleArray.GetValue(int index) {79 return GetValue(index);80 }81 bool IStringConvertibleArray.SetValue(string value, int index) {82 return SetValue(value, index);83 }84 #endregion85 69 } 86 70 } -
trunk/sources/HeuristicLab.Data/3.3/Interfaces/IStringConvertibleArray.cs
r12012 r13695 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 22 using HeuristicLab.Common; 25 23 26 24 namespace HeuristicLab.Data { 27 public interface IStringConvertibleArray : IContent { 28 int Length { get; set; } 29 IEnumerable<string> ElementNames { get; set; } 30 31 bool ReadOnly { get; } 32 25 public interface IStringConvertibleArray : IContent, IValueTypeArray { 33 26 bool Validate(string value, out string errorMessage); 34 27 string GetValue(int index); 35 28 bool SetValue(string value, int index); 36 37 event EventHandler ElementNamesChanged;38 event EventHandler<EventArgs<int>> ItemChanged;39 event EventHandler Reset;40 29 } 41 30 } -
trunk/sources/HeuristicLab.Data/3.3/StringArray.cs
r12012 r13695 61 61 public virtual int Length { 62 62 get { return array.Length; } 63 protectedset {63 set { 64 64 if (ReadOnly) throw new NotSupportedException("Length cannot be set. StringArray is read-only."); 65 65 if (value != Length) { … … 72 72 } 73 73 } 74 [Storable] 75 protected bool resizable = true; 76 public bool Resizable { 77 get { return resizable; } 78 set { 79 if (resizable != value) { 80 resizable = value; 81 OnResizableChanged(); 82 } 83 } 84 } 85 74 86 public virtual string this[int index] { 75 87 get { return array[index]; } … … 102 114 this.array = (string[])original.array.Clone(); 103 115 this.readOnly = original.readOnly; 116 this.resizable = original.resizable; 104 117 this.elementNames = new List<string>(original.elementNames); 105 118 } … … 107 120 array = new string[0]; 108 121 readOnly = false; 122 resizable = true; 109 123 elementNames = new List<string>(); 110 124 } … … 114 128 array[i] = string.Empty; 115 129 readOnly = false; 130 resizable = true; 116 131 elementNames = new List<string>(); 117 132 } … … 122 137 array[i] = elements[i] == null ? string.Empty : elements[i]; 123 138 readOnly = false; 139 resizable = true; 124 140 elementNames = new List<string>(); 125 141 } … … 133 149 readOnlyStringArray.readOnly = true; 134 150 return readOnlyStringArray; 151 } 152 IValueTypeArray IValueTypeArray.AsReadOnly() { 153 return AsReadOnly(); 135 154 } 136 155 … … 155 174 return array.Cast<string>().GetEnumerator(); 156 175 } 157 158 176 IEnumerator IEnumerable.GetEnumerator() { 159 177 return GetEnumerator(); … … 181 199 } 182 200 201 public event EventHandler ResizableChanged; 202 protected virtual void OnResizableChanged() { 203 EventHandler handler = ResizableChanged; 204 if (handler != null) 205 handler(this, EventArgs.Empty); 206 } 183 207 public event EventHandler ElementNamesChanged; 184 208 protected virtual void OnElementNamesChanged() { … … 187 211 handler(this, EventArgs.Empty); 188 212 } 189 190 213 public event EventHandler<EventArgs<int>> ItemChanged; 191 214 protected virtual void OnItemChanged(int index) { … … 203 226 204 227 #region IStringConvertibleArray Members 205 int IStringConvertibleArray.Length {206 get { return Length; }207 set { Length = value; }208 }209 228 bool IStringConvertibleArray.Validate(string value, out string errorMessage) { 210 229 return Validate(value, out errorMessage); -
trunk/sources/HeuristicLab.Data/3.3/ValueTypeArray.cs
r12012 r13695 33 33 [Item("ValueTypeArray", "An abstract base class for representing arrays of value types.")] 34 34 [StorableClass] 35 public abstract class ValueTypeArray<T> : Item, I Enumerable<T> where T : struct {35 public abstract class ValueTypeArray<T> : Item, IValueTypeArray<T> where T : struct { 36 36 private const int maximumToStringLength = 100; 37 37 … … 75 75 #endregion 76 76 } 77 78 [Storable] 79 protected bool resizable = true; 80 public bool Resizable { 81 get { return resizable; } 82 set { 83 if (resizable != value) { 84 resizable = value; 85 OnResizableChanged(); 86 } 87 } 88 } 89 90 77 91 public virtual T this[int index] { 78 92 get { return array[index]; } … … 103 117 this.array = (T[])original.array.Clone(); 104 118 this.readOnly = original.readOnly; 119 this.resizable = original.resizable; 105 120 this.elementNames = new List<string>(original.elementNames); 106 121 } … … 108 123 array = new T[0]; 109 124 readOnly = false; 125 resizable = true; 110 126 elementNames = new List<string>(); 111 127 } … … 113 129 array = new T[length]; 114 130 readOnly = false; 131 resizable = true; 115 132 elementNames = new List<string>(); 116 133 } … … 119 136 array = (T[])elements.Clone(); 120 137 readOnly = false; 138 resizable = true; 121 139 elementNames = new List<string>(); 122 140 } 123 141 124 public virtual ValueTypeArray<T>AsReadOnly() {142 public virtual IValueTypeArray AsReadOnly() { 125 143 ValueTypeArray<T> readOnlyValueTypeArray = (ValueTypeArray<T>)this.Clone(); 126 144 readOnlyValueTypeArray.readOnly = true; … … 153 171 } 154 172 173 public event EventHandler ResizableChanged; 174 protected virtual void OnResizableChanged() { 175 EventHandler handler = ResizableChanged; 176 if (handler != null) 177 handler(this, EventArgs.Empty); 178 } 155 179 public event EventHandler ElementNamesChanged; 156 180 protected virtual void OnElementNamesChanged() {
Note: See TracChangeset
for help on using the changeset viewer.