From 04415f2d54d35626761ea499bb9f708bf14e64a9 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 6 Dec 2019 23:22:31 +0200 Subject: [PATCH 1/6] fix typo of point parse --- src/Avalonia.Visuals/Point.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Visuals/Point.cs b/src/Avalonia.Visuals/Point.cs index d92f8b0fc4..27ac7a3026 100644 --- a/src/Avalonia.Visuals/Point.cs +++ b/src/Avalonia.Visuals/Point.cs @@ -175,7 +175,7 @@ namespace Avalonia /// Parses a string. /// /// The string. - /// The . + /// The . public static Point Parse(string s) { using (var tokenizer = new StringTokenizer(s, CultureInfo.InvariantCulture, exceptionMessage: "Invalid Point.")) From 30eaf3bc72ac0bc10c44050a4ffe0256f24888dc Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 6 Dec 2019 23:23:33 +0200 Subject: [PATCH 2/6] add vector parse --- src/Avalonia.Visuals/Vector.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Visuals/Vector.cs b/src/Avalonia.Visuals/Vector.cs index 576d2daaaa..d99fbe8e65 100644 --- a/src/Avalonia.Visuals/Vector.cs +++ b/src/Avalonia.Visuals/Vector.cs @@ -4,6 +4,7 @@ using System; using System.Globalization; using Avalonia.Animation.Animators; +using Avalonia.Utilities; using JetBrains.Annotations; namespace Avalonia @@ -85,6 +86,22 @@ namespace Avalonia public static Vector operator /(Vector vector, double scale) => Divide(vector, scale); + /// + /// Parses a string. + /// + /// The string. + /// The . + public static Vector Parse(string s) + { + using (var tokenizer = new StringTokenizer(s, CultureInfo.InvariantCulture, exceptionMessage: "Invalid Vector.")) + { + return new Vector( + tokenizer.ReadDouble(), + tokenizer.ReadDouble() + ); + } + } + /// /// Length of the vector /// @@ -166,9 +183,9 @@ namespace Avalonia } /// - /// Returns the string representation of the point. + /// Returns the string representation of the vector. /// - /// The string representation of the point. + /// The string representation of the vector. public override string ToString() { return string.Format(CultureInfo.InvariantCulture, "{0}, {1}", _x, _y); From 7a66d360f043b179f5c80d86ef9daeeff579f2be Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 6 Dec 2019 23:38:46 +0200 Subject: [PATCH 3/6] add transform parse --- src/Avalonia.Visuals/Media/Transform.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Avalonia.Visuals/Media/Transform.cs b/src/Avalonia.Visuals/Media/Transform.cs index 7a70657ce0..30a07d47ef 100644 --- a/src/Avalonia.Visuals/Media/Transform.cs +++ b/src/Avalonia.Visuals/Media/Transform.cs @@ -28,6 +28,16 @@ namespace Avalonia.Media /// public abstract Matrix Value { get; } + /// + /// Parses a string. + /// + /// The string. + /// The . + public static Transform Parse(string s) + { + return new MatrixTransform(Matrix.Parse(s)); + } + /// /// Raises the event. /// @@ -35,5 +45,14 @@ namespace Avalonia.Media { Changed?.Invoke(this, EventArgs.Empty); } + + /// + /// Returns a String representing this transform matrix instance. + /// + /// The string representation. + public override string ToString() + { + return Value.ToString(); + } } } From 29be26a88240a0bc2b533dd5096495bac10b5305 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 6 Dec 2019 23:48:43 +0200 Subject: [PATCH 4/6] add relativepoint tostring --- src/Avalonia.Visuals/RelativePoint.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Avalonia.Visuals/RelativePoint.cs b/src/Avalonia.Visuals/RelativePoint.cs index 2e8fb16bc1..ebd0ba9351 100644 --- a/src/Avalonia.Visuals/RelativePoint.cs +++ b/src/Avalonia.Visuals/RelativePoint.cs @@ -177,5 +177,16 @@ namespace Avalonia unit); } } + + /// + /// Returns a String representing this RelativePoint instance. + /// + /// The string representation. + public override string ToString() + { + return _unit == RelativeUnit.Absolute ? + _point.ToString() : + string.Format(CultureInfo.InvariantCulture, "{0}%, {1}%", _point.X * 100, _point.Y * 100); + } } } From 1f2b2e965279fb8cdcb57712780f7a6c1d1f90a4 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Mon, 9 Dec 2019 18:15:39 +0200 Subject: [PATCH 5/6] document transform.parse --- src/Avalonia.Visuals/Media/Transform.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Visuals/Media/Transform.cs b/src/Avalonia.Visuals/Media/Transform.cs index 30a07d47ef..8253d11ff1 100644 --- a/src/Avalonia.Visuals/Media/Transform.cs +++ b/src/Avalonia.Visuals/Media/Transform.cs @@ -31,7 +31,7 @@ namespace Avalonia.Media /// /// Parses a string. /// - /// The string. + /// Six comma-delimited double values that describe the new . For details check /// The . public static Transform Parse(string s) { From 78b790e6ebb400efb79a2988052a7b340e51c5dc Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Mon, 9 Dec 2019 18:17:47 +0200 Subject: [PATCH 6/6] document matrix.parse --- src/Avalonia.Visuals/Matrix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Visuals/Matrix.cs b/src/Avalonia.Visuals/Matrix.cs index 92b7dae904..d05dbac574 100644 --- a/src/Avalonia.Visuals/Matrix.cs +++ b/src/Avalonia.Visuals/Matrix.cs @@ -306,7 +306,7 @@ namespace Avalonia /// /// Parses a string. /// - /// The string. + /// Six comma-delimited double values (m11, m12, m21, m22, offsetX, offsetY) that describe the new /// The . public static Matrix Parse(string s) {