From 2c86f7ac51aeec4230b15738a6a79cc6ec14be6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 4 Nov 2015 20:28:14 +0100 Subject: [PATCH 1/9] Update appveyor.yml --- appveyor.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 8f5a9d8294..5c5d8b3246 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,8 +9,11 @@ environment: secure: XOgD5bJUKNOS2kDDgb+affS4pDcslxALh+xvvnr1Koy0PjXlhILsBdNhxRe0KcNm install: -- appveyor DownloadFile http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.26.msi -- start /wait msiexec /i gtk-sharp-2.12.26.msi /qn /norestart + - if not exist gtk-sharp-2.12.26.msi appveyor DownloadFile http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.26.msi + - msiexec /i gtk-sharp-2.12.26.msi /qn /norestart + +cache: + - gtk-sharp-2.12.26.msi configuration: - Release From c444a400b8c3144d7795a8be5e882cd4ce63c31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 4 Nov 2015 20:41:18 +0100 Subject: [PATCH 2/9] Update appveyor.yml --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 5c5d8b3246..1b10d99b4a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,6 +11,7 @@ environment: install: - if not exist gtk-sharp-2.12.26.msi appveyor DownloadFile http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.26.msi - msiexec /i gtk-sharp-2.12.26.msi /qn /norestart + - cmd: set PATH=%programfiles(x86)%\GtkSharp\2.12\bin\;%PATH% cache: - gtk-sharp-2.12.26.msi From 9c28e91758c6b362dd5676123b5e88b29f8e2c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 4 Nov 2015 21:16:48 +0100 Subject: [PATCH 3/9] Fixed Rect Equals comparison --- src/Perspex.SceneGraph/Rect.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Perspex.SceneGraph/Rect.cs b/src/Perspex.SceneGraph/Rect.cs index 2dba97e764..c3d3a95111 100644 --- a/src/Perspex.SceneGraph/Rect.cs +++ b/src/Perspex.SceneGraph/Rect.cs @@ -297,7 +297,8 @@ namespace Perspex { if (obj is Rect) { - return this == (Rect)obj; + var other = (Rect)obj; + return Position == other.Position && Size == other.Size; } return false; From 837300d55ab71a69e3f5d60056681c6331ce3476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 4 Nov 2015 21:17:00 +0100 Subject: [PATCH 4/9] Fixed rounding errors --- src/Perspex.SceneGraph/RelativeRect.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Perspex.SceneGraph/RelativeRect.cs b/src/Perspex.SceneGraph/RelativeRect.cs index 5ededd2e52..66090696cb 100644 --- a/src/Perspex.SceneGraph/RelativeRect.cs +++ b/src/Perspex.SceneGraph/RelativeRect.cs @@ -175,7 +175,7 @@ namespace Perspex if (parts.Count == 4) { var unit = RelativeUnit.Absolute; - var scale = 1.0; + var scale = 1.0m; if (parts[0].EndsWith("%")) { @@ -191,14 +191,14 @@ namespace Perspex parts[2] = parts[2].TrimEnd('%'); parts[3] = parts[3].TrimEnd('%'); unit = RelativeUnit.Relative; - scale = 0.01; + scale = 0.01m; } return new RelativeRect( - double.Parse(parts[0], culture) * scale, - double.Parse(parts[1], culture) * scale, - double.Parse(parts[2], culture) * scale, - double.Parse(parts[3], culture) * scale, + (double)(decimal.Parse(parts[0], culture) * scale), + (double)(decimal.Parse(parts[1], culture) * scale), + (double)(decimal.Parse(parts[2], culture) * scale), + (double)(decimal.Parse(parts[3], culture) * scale), unit); } else From 10f17bbc434195058a6e0f79fe0fbf5ccd223a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Thu, 5 Nov 2015 12:18:01 +0100 Subject: [PATCH 5/9] Do not use decimal --- src/Perspex.SceneGraph/RelativeRect.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Perspex.SceneGraph/RelativeRect.cs b/src/Perspex.SceneGraph/RelativeRect.cs index 66090696cb..5ededd2e52 100644 --- a/src/Perspex.SceneGraph/RelativeRect.cs +++ b/src/Perspex.SceneGraph/RelativeRect.cs @@ -175,7 +175,7 @@ namespace Perspex if (parts.Count == 4) { var unit = RelativeUnit.Absolute; - var scale = 1.0m; + var scale = 1.0; if (parts[0].EndsWith("%")) { @@ -191,14 +191,14 @@ namespace Perspex parts[2] = parts[2].TrimEnd('%'); parts[3] = parts[3].TrimEnd('%'); unit = RelativeUnit.Relative; - scale = 0.01m; + scale = 0.01; } return new RelativeRect( - (double)(decimal.Parse(parts[0], culture) * scale), - (double)(decimal.Parse(parts[1], culture) * scale), - (double)(decimal.Parse(parts[2], culture) * scale), - (double)(decimal.Parse(parts[3], culture) * scale), + double.Parse(parts[0], culture) * scale, + double.Parse(parts[1], culture) * scale, + double.Parse(parts[2], culture) * scale, + double.Parse(parts[3], culture) * scale, unit); } else From 3fc79a8e202ed21889c833eb272ec2925c78119c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Thu, 5 Nov 2015 12:32:38 +0100 Subject: [PATCH 6/9] Create RelativeRectComparer.cs --- .../RelativeRectComparer.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs diff --git a/tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs b/tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs new file mode 100644 index 0000000000..cbde00e36c --- /dev/null +++ b/tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs @@ -0,0 +1,25 @@ +// Copyright (c) The Perspex Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using System; +using System.Collections.Generic; + +namespace Perspex.SceneGraph.UnitTests +{ + public class RelativeRectComparer : IEqualityComparer + { + public bool Equals(RelativeRect a, RelativeRect b) + { + return a.Unit == b.Unit && + Math.Round(a.Rect.X, 3) == Math.Round(b.Rect.X, 3) && + Math.Round(a.Rect.Y, 3) == Math.Round(b.Rect.Y, 3) && + Math.Round(a.Rect.Width, 3) == Math.Round(b.Rect.Width, 3) && + Math.Round(a.Rect.Height, 3) == Math.Round(b.Rect.Height, 3); + } + + public int GetHashCode(Rect obj) + { + throw new NotImplementedException(); + } + } +} From 37855c5690e049dc8704a41885811474bc980fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Thu, 5 Nov 2015 12:33:45 +0100 Subject: [PATCH 7/9] Update RelativeRectTests.cs --- tests/Perspex.SceneGraph.UnitTests/RelativeRectTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Perspex.SceneGraph.UnitTests/RelativeRectTests.cs b/tests/Perspex.SceneGraph.UnitTests/RelativeRectTests.cs index 9ee4e37e3f..625d73e95e 100644 --- a/tests/Perspex.SceneGraph.UnitTests/RelativeRectTests.cs +++ b/tests/Perspex.SceneGraph.UnitTests/RelativeRectTests.cs @@ -8,12 +8,14 @@ namespace Perspex.SceneGraph.UnitTests { public class RelativeRectTests { + private static readonly RelativeRectComparer Compare = new RelativeRectComparer(); + [Fact] public void Parse_Should_Accept_Absolute_Value() { var result = RelativeRect.Parse("4,5,50,60", CultureInfo.InvariantCulture); - Assert.Equal(new RelativeRect(4, 5, 50, 60, RelativeUnit.Absolute), result); + Assert.Equal(new RelativeRect(4, 5, 50, 60, RelativeUnit.Absolute), result, Compare); } [Fact] @@ -21,7 +23,7 @@ namespace Perspex.SceneGraph.UnitTests { var result = RelativeRect.Parse("10%, 20%, 40%, 70%", CultureInfo.InvariantCulture); - Assert.Equal(new RelativeRect(0.1, 0.2, 0.4, 0.7, RelativeUnit.Relative), result); + Assert.Equal(new RelativeRect(0.1, 0.2, 0.4, 0.7, RelativeUnit.Relative), result, Compare); } } } From 8864acb95acfa006f814fb4f90c4c32dece2df3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Thu, 5 Nov 2015 12:39:18 +0100 Subject: [PATCH 8/9] Update Perspex.SceneGraph.UnitTests.csproj --- .../Perspex.SceneGraph.UnitTests.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj b/tests/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj index 7c4daf0867..f76c567f3a 100644 --- a/tests/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj +++ b/tests/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj @@ -72,6 +72,7 @@ + @@ -158,4 +159,4 @@ --> - \ No newline at end of file + From 4ea890e229f29aa67eaef340f8d16d993548c4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Thu, 5 Nov 2015 12:43:57 +0100 Subject: [PATCH 9/9] Update RelativeRectComparer.cs --- tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs b/tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs index cbde00e36c..667e2b4cbb 100644 --- a/tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs +++ b/tests/Perspex.SceneGraph.UnitTests/RelativeRectComparer.cs @@ -17,7 +17,7 @@ namespace Perspex.SceneGraph.UnitTests Math.Round(a.Rect.Height, 3) == Math.Round(b.Rect.Height, 3); } - public int GetHashCode(Rect obj) + public int GetHashCode(RelativeRect obj) { throw new NotImplementedException(); }