- Timestamp:
- 03/05/13 16:37:17 (12 years ago)
- Location:
- branches/ImprovingStringConvertibleMatrix
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ImprovingStringConvertibleMatrix
-
Property
svn:ignore
set to
*.suo
-
Property
svn:ignore
set to
-
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/BoolMatrix.cs
r7259 r9286 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using System.Text; 24 26 using HeuristicLab.Common; … … 29 31 [Item("BoolMatrix", "Represents a matrix of boolean values.")] 30 32 [StorableClass] 31 public class BoolMatrix : ValueTypeMatrix<bool> , IStringConvertibleMatrix{33 public class BoolMatrix : ValueTypeMatrix<bool> { 32 34 [StorableConstructor] 33 35 protected BoolMatrix(bool deserializing) : base(deserializing) { } … … 47 49 } 48 50 49 protected virtualbool Validate(string value, out string errorMessage) {51 protected override bool Validate(string value, out string errorMessage) { 50 52 bool val; 51 53 bool valid = bool.TryParse(value, out val); … … 60 62 return valid; 61 63 } 62 protected virtualstring GetValue(int rowIndex, int columIndex) {64 protected override string GetValue(int rowIndex, int columIndex) { 63 65 return this[rowIndex, columIndex].ToString(); 64 66 } 65 protected virtualbool SetValue(string value, int rowIndex, int columnIndex) {67 protected override bool SetValue(string value, int rowIndex, int columnIndex) { 66 68 bool val; 67 69 if (bool.TryParse(value, out val)) { … … 72 74 } 73 75 } 74 75 #region IStringConvertibleMatrix Members 76 int IStringConvertibleMatrix.Rows { 77 get { return Rows; } 78 set { Rows = value; } 76 protected override bool SetValue(IEnumerable<RowColumnValue> rowColumnValues) { 77 if (ReadOnly) throw new NotSupportedException("Item cannot be set. StringMatrix is read-only."); 78 List<Tuple<Position, bool>> newValues = new List<Tuple<Position, bool>>(); 79 bool parsed; 80 foreach (var curValue in rowColumnValues) { 81 if (bool.TryParse(curValue.Value, out parsed)) { 82 newValues.Add(new Tuple<Position, bool>(curValue.Position, parsed)); 83 } else { 84 return false; 85 } 86 } 87 Position pos; 88 foreach (var curValue in newValues) { 89 pos = curValue.Item1; 90 matrix[pos.Row, pos.Column] = curValue.Item2; 91 } 92 OnItemsChanged(rowColumnValues.Select(x => x.Position)); 93 return true; 79 94 } 80 int IStringConvertibleMatrix.Columns {81 get { return Columns; }82 set { Columns = value; }83 }84 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {85 return Validate(value, out errorMessage);86 }87 string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {88 return GetValue(rowIndex, columIndex);89 }90 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {91 return SetValue(value, rowIndex, columnIndex);92 }93 #endregion94 95 } 95 96 } -
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/DoubleMatrix.cs
r7259 r9286 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using System.Text; 24 26 using HeuristicLab.Common; … … 29 31 [Item("DoubleMatrix", "Represents a matrix of double values.")] 30 32 [StorableClass] 31 public class DoubleMatrix : ValueTypeMatrix<double> , IStringConvertibleMatrix{33 public class DoubleMatrix : ValueTypeMatrix<double> { 32 34 [StorableConstructor] 33 35 protected DoubleMatrix(bool deserializing) : base(deserializing) { } … … 47 49 } 48 50 49 protected virtualbool Validate(string value, out string errorMessage) {51 protected override bool Validate(string value, out string errorMessage) { 50 52 double val; 51 53 bool valid = double.TryParse(value, out val); … … 60 62 return valid; 61 63 } 62 protected virtualstring GetValue(int rowIndex, int columIndex) {64 protected override string GetValue(int rowIndex, int columIndex) { 63 65 return this[rowIndex, columIndex].ToString(); 64 66 } 65 protected virtualbool SetValue(string value, int rowIndex, int columnIndex) {67 protected override bool SetValue(string value, int rowIndex, int columnIndex) { 66 68 double val; 67 69 if (double.TryParse(value, out val)) { … … 72 74 } 73 75 } 74 75 #region IStringConvertibleMatrix Members 76 int IStringConvertibleMatrix.Rows { 77 get { return Rows; } 78 set { Rows = value; } 76 protected override bool SetValue(IEnumerable<RowColumnValue> rowColumnValues) { 77 if (ReadOnly) throw new NotSupportedException("Item cannot be set. StringMatrix is read-only."); 78 List<Tuple<Position, double>> newValues = new List<Tuple<Position, double>>(); 79 double parsed; 80 foreach (var curValue in rowColumnValues) { 81 if (double.TryParse(curValue.Value, out parsed)) { 82 newValues.Add(new Tuple<Position, double>(curValue.Position, parsed)); 83 } else { 84 return false; 85 } 86 } 87 Position pos; 88 foreach (var curValue in newValues) { 89 pos = curValue.Item1; 90 matrix[pos.Row, pos.Column] = curValue.Item2; 91 } 92 OnItemsChanged(rowColumnValues.Select(x => x.Position)); 93 return true; 79 94 } 80 int IStringConvertibleMatrix.Columns {81 get { return Columns; }82 set { Columns = value; }83 }84 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {85 return Validate(value, out errorMessage);86 }87 string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {88 return GetValue(rowIndex, columIndex);89 }90 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {91 return SetValue(value, rowIndex, columnIndex);92 }93 #endregion94 95 } 95 96 } -
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj
r8600 r9286 41 41 <DebugType>full</DebugType> 42 42 <Optimize>false</Optimize> 43 <OutputPath> $(SolutionDir)\bin\</OutputPath>43 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 44 44 <DefineConstants>DEBUG;TRACE</DefineConstants> 45 45 <ErrorReport>prompt</ErrorReport> … … 52 52 <DebugType>pdbonly</DebugType> 53 53 <Optimize>true</Optimize> 54 <OutputPath> $(SolutionDir)\bin\</OutputPath>54 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 55 55 <DefineConstants>TRACE</DefineConstants> 56 56 <ErrorReport>prompt</ErrorReport> … … 63 63 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> 64 64 <DebugSymbols>true</DebugSymbols> 65 <OutputPath> $(SolutionDir)\bin\</OutputPath>65 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 66 66 <DefineConstants>DEBUG;TRACE</DefineConstants> 67 67 <DebugType>full</DebugType> … … 71 71 </PropertyGroup> 72 72 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> 73 <OutputPath> $(SolutionDir)\bin\</OutputPath>73 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 74 74 <DefineConstants>TRACE</DefineConstants> 75 75 <DocumentationFile> … … 83 83 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> 84 84 <DebugSymbols>true</DebugSymbols> 85 <OutputPath> $(SolutionDir)\bin\</OutputPath>85 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 86 86 <DefineConstants>DEBUG;TRACE</DefineConstants> 87 87 <DebugType>full</DebugType> … … 91 91 </PropertyGroup> 92 92 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> 93 <OutputPath> $(SolutionDir)\bin\</OutputPath>93 <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath> 94 94 <DefineConstants>TRACE</DefineConstants> 95 95 <DocumentationFile> … … 102 102 </PropertyGroup> 103 103 <ItemGroup> 104 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 105 <Private>False</Private> 106 </Reference> 107 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 108 <Private>False</Private> 109 </Reference> 110 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 111 <Private>False</Private> 112 </Reference> 113 <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 114 <Private>False</Private> 115 </Reference> 116 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 117 <Private>False</Private> 118 </Reference> 104 119 <Reference Include="System" /> 105 120 <Reference Include="System.Core"> … … 146 161 </ItemGroup> 147 162 <ItemGroup> 148 <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">149 <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>150 <Name>HeuristicLab.Common.Resources-3.3</Name>151 <Private>False</Private>152 </ProjectReference>153 <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">154 <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>155 <Name>HeuristicLab.Common-3.3</Name>156 <Private>False</Private>157 </ProjectReference>158 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">159 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>160 <Name>HeuristicLab.Core-3.3</Name>161 <Private>False</Private>162 </ProjectReference>163 <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">164 <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>165 <Name>HeuristicLab.Persistence-3.3</Name>166 <Private>False</Private>167 </ProjectReference>168 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">169 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>170 <Name>HeuristicLab.PluginInfrastructure-3.3</Name>171 <Private>False</Private>172 </ProjectReference>173 </ItemGroup>174 <ItemGroup>175 163 <None Include="HeuristicLab.snk" /> 176 164 <None Include="Properties\AssemblyInfo.cs.frame" /> … … 212 200 --> 213 201 <PropertyGroup> 214 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)202 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 215 203 set ProjectDir=$(ProjectDir) 216 204 set SolutionDir=$(SolutionDir) … … 219 207 call PreBuildEvent.cmd 220 208 </PreBuildEvent> 221 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">209 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 222 210 export ProjectDir=$(ProjectDir) 223 211 export SolutionDir=$(SolutionDir) -
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/IntMatrix.cs
r7259 r9286 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using System.Text; 24 26 using HeuristicLab.Common; … … 29 31 [Item("IntMatrix", "Represents a matrix of integer values.")] 30 32 [StorableClass] 31 public class IntMatrix : ValueTypeMatrix<int> , IStringConvertibleMatrix{33 public class IntMatrix : ValueTypeMatrix<int> { 32 34 [StorableConstructor] 33 35 protected IntMatrix(bool deserializing) : base(deserializing) { } … … 38 40 public IntMatrix(int rows, int columns) : base(rows, columns) { } 39 41 public IntMatrix(int rows, int columns, IEnumerable<string> columnNames) : base(rows, columns, columnNames) { } 40 public IntMatrix(int rows, int columns, IEnumerable<string> columnNames, IEnumerable<string> rowNames) : base(rows, columns, columnNames,rowNames) { }42 public IntMatrix(int rows, int columns, IEnumerable<string> columnNames, IEnumerable<string> rowNames) : base(rows, columns, columnNames, rowNames) { } 41 43 public IntMatrix(int[,] elements) : base(elements) { } 42 public IntMatrix(int[,] elements, IEnumerable<string> columnNames) : base(elements, columnNames) { }43 public IntMatrix(int[,] elements, IEnumerable<string> columnNames, IEnumerable<string> rowNames) : base(elements, columnNames,rowNames) { }44 public IntMatrix(int[,] elements, IEnumerable<string> columnNames) : base(elements, columnNames) { } 45 public IntMatrix(int[,] elements, IEnumerable<string> columnNames, IEnumerable<string> rowNames) : base(elements, columnNames, rowNames) { } 44 46 45 47 public override IDeepCloneable Clone(Cloner cloner) { … … 47 49 } 48 50 49 protected virtualbool Validate(string value, out string errorMessage) {51 protected override bool Validate(string value, out string errorMessage) { 50 52 int val; 51 53 bool valid = int.TryParse(value, out val); … … 60 62 return valid; 61 63 } 62 protected virtualstring GetValue(int rowIndex, int columIndex) {64 protected override string GetValue(int rowIndex, int columIndex) { 63 65 return this[rowIndex, columIndex].ToString(); 64 66 } 65 protected virtualbool SetValue(string value, int rowIndex, int columnIndex) {67 protected override bool SetValue(string value, int rowIndex, int columnIndex) { 66 68 int val; 67 69 if (int.TryParse(value, out val)) { … … 72 74 } 73 75 } 74 75 #region IStringConvertibleMatrix Members 76 int IStringConvertibleMatrix.Rows { 77 get { return Rows; } 78 set { Rows = value; } 76 protected override bool SetValue(IEnumerable<RowColumnValue> rowColumnValues) { 77 if (ReadOnly) throw new NotSupportedException("Item cannot be set. StringMatrix is read-only."); 78 List<Tuple<Position, int>> newValues = new List<Tuple<Position, int>>(); 79 int parsed; 80 foreach (var curValue in rowColumnValues) { 81 if (int.TryParse(curValue.Value, out parsed)) { 82 newValues.Add(new Tuple<Position, int>(curValue.Position, parsed)); 83 } else { 84 return false; 85 } 86 } 87 Position pos; 88 foreach (var curValue in newValues) { 89 pos = curValue.Item1; 90 matrix[pos.Row, pos.Column] = curValue.Item2; 91 } 92 OnItemsChanged(rowColumnValues.Select(x => x.Position)); 93 return true; 79 94 } 80 int IStringConvertibleMatrix.Columns {81 get { return Columns; }82 set { Columns = value; }83 }84 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {85 return Validate(value, out errorMessage);86 }87 string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {88 return GetValue(rowIndex, columIndex);89 }90 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {91 return SetValue(value, rowIndex, columnIndex);92 }93 #endregion94 95 } 95 96 } -
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/Interfaces/IStringConvertibleMatrix.cs
r7259 r9286 37 37 string GetValue(int rowIndex, int columnIndex); 38 38 bool SetValue(string value, int rowIndex, int columnIndex); 39 bool SetValue(RowColumnValue rowColumnValue); 40 bool SetValue(IEnumerable<RowColumnValue> rowColumnValues); 39 41 40 42 event EventHandler ColumnsChanged; … … 43 45 event EventHandler RowNamesChanged; 44 46 event EventHandler SortableViewChanged; 45 event EventHandler<EventArgs< int, int>> ItemChanged;47 event EventHandler<EventArgs<IEnumerable<Position>>> ItemsChanged; 46 48 event EventHandler Reset; 49 } 50 public struct Position { 51 public readonly int Row, Column; 52 public Position(int row, int column) { 53 Row = row; 54 Column = column; 55 } 56 } 57 public struct RowColumnValue { 58 public readonly Position Position; 59 public readonly string Value; 47 60 61 public RowColumnValue(Position position, string value) { 62 Position = position; 63 Value = value; 64 } 48 65 } 49 66 } -
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/StringMatrix.cs
r7259 r9286 128 128 if ((value != null) || (matrix[rowIndex, columnIndex] != string.Empty)) { 129 129 matrix[rowIndex, columnIndex] = value != null ? value : string.Empty; 130 OnItem Changed(rowIndex, columnIndex);130 OnItemsChanged(new List<Position>(1) { new Position(rowIndex, columnIndex) }); 131 131 } 132 132 } … … 250 250 } 251 251 } 252 protected virtual bool SetValue(IEnumerable<RowColumnValue> rowColumnValues) { 253 if (ReadOnly) throw new NotSupportedException("Item cannot be set. StringMatrix is read-only."); 254 if (rowColumnValues.Any(x => x.Value == null)) { return false; } 255 Position pos; 256 foreach (var curValue in rowColumnValues) { 257 pos = curValue.Position; 258 matrix[pos.Row, pos.Column] = curValue.Value; 259 } 260 OnItemsChanged(rowColumnValues.Select(x => x.Position)); 261 return true; 262 } 252 263 253 264 #region events … … 282 293 handler(this, EventArgs.Empty); 283 294 } 284 public event EventHandler<EventArgs< int, int>> ItemChanged;285 protected virtual void OnItem Changed(int rowIndex, int columnIndex) {286 if (Item Changed != null)287 Item Changed(this, new EventArgs<int, int>(rowIndex, columnIndex));295 public event EventHandler<EventArgs<IEnumerable<Position>>> ItemsChanged; 296 protected virtual void OnItemsChanged(IEnumerable<Position> positions) { 297 if (ItemsChanged != null) 298 ItemsChanged(this, new EventArgs<IEnumerable<Position>>(positions)); 288 299 OnToStringChanged(); 289 300 } … … 314 325 return SetValue(value, rowIndex, columnIndex); 315 326 } 327 public bool SetValue(RowColumnValue rowColumnValue) { 328 return SetValue(rowColumnValue.Value, rowColumnValue.Position.Row, rowColumnValue.Position.Column); 329 } 330 bool IStringConvertibleMatrix.SetValue(IEnumerable<RowColumnValue> rowColumnValues) { 331 return SetValue(rowColumnValues); 332 } 316 333 #endregion 317 334 } -
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/ValueTypeMatrix.cs
r7259 r9286 33 33 [Item("ValueTypeMatrix", "An abstract base class for representing matrices of value types.")] 34 34 [StorableClass] 35 public abstract class ValueTypeMatrix<T> : Item, IEnumerable<T> where T : struct {35 public abstract class ValueTypeMatrix<T> : Item, IEnumerable<T>, IStringConvertibleMatrix where T : struct { 36 36 public static new Image StaticItemImage { 37 37 get { return HeuristicLab.Common.Resources.VSImageLibrary.Class; } … … 127 127 if (!value.Equals(matrix[rowIndex, columnIndex])) { 128 128 matrix[rowIndex, columnIndex] = value; 129 OnItem Changed(rowIndex, columnIndex);129 OnItemsChanged(new List<Position>(1) { new Position(rowIndex, columnIndex) }); 130 130 } 131 131 } … … 247 247 handler(this, EventArgs.Empty); 248 248 } 249 public event EventHandler<EventArgs< int, int>> ItemChanged;250 protected virtual void OnItem Changed(int rowIndex, int columnIndex) {251 if (Item Changed != null)252 Item Changed(this, new EventArgs<int, int>(rowIndex, columnIndex));249 public event EventHandler<EventArgs<IEnumerable<Position>>> ItemsChanged; 250 protected virtual void OnItemsChanged(IEnumerable<Position> positions) { 251 if (ItemsChanged != null) 252 ItemsChanged(this, new EventArgs<IEnumerable<Position>>(positions)); 253 253 OnToStringChanged(); 254 254 } … … 260 260 } 261 261 #endregion 262 263 protected abstract bool Validate(string value, out string errorMessage); 264 protected abstract bool SetValue(string value, int rowIndex, int columnIndex); 265 protected abstract string GetValue(int rowIndex, int columIndex); 266 protected abstract bool SetValue(IEnumerable<RowColumnValue> rowColumnValues); 267 268 #region IStringConvertibleMatrix Members 269 int IStringConvertibleMatrix.Rows { 270 get { return Rows; } 271 set { Rows = value; } 272 } 273 int IStringConvertibleMatrix.Columns { 274 get { return Columns; } 275 set { Columns = value; } 276 } 277 278 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 279 return Validate(value, out errorMessage); 280 } 281 string IStringConvertibleMatrix.GetValue(int rowIndex, int columnIndex) { 282 return GetValue(rowIndex, columnIndex); 283 } 284 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) { 285 return SetValue(value, rowIndex, columnIndex); 286 } 287 288 bool IStringConvertibleMatrix.SetValue(RowColumnValue rowColumnValue) { 289 return SetValue(rowColumnValue.Value, rowColumnValue.Position.Row, rowColumnValue.Position.Column); 290 } 291 292 bool IStringConvertibleMatrix.SetValue(IEnumerable<RowColumnValue> rowColumnValues) { 293 return SetValue(rowColumnValues); 294 } 295 #endregion 262 296 } 263 297 }
Note: See TracChangeset
for help on using the changeset viewer.