From 454d1b744cf6b468e9590ecf58ff88b9253353b3 Mon Sep 17 00:00:00 2001 From: donandren Date: Wed, 9 Mar 2016 16:12:39 +0200 Subject: [PATCH] ScaleTransform Added --- .../Media/ScaleTransform.cs | 69 +++++++++++++++++++ .../Perspex.SceneGraph.csproj | 1 + 2 files changed, 70 insertions(+) create mode 100644 src/Perspex.SceneGraph/Media/ScaleTransform.cs diff --git a/src/Perspex.SceneGraph/Media/ScaleTransform.cs b/src/Perspex.SceneGraph/Media/ScaleTransform.cs new file mode 100644 index 00000000000..9e0f1ecb3a6 --- /dev/null +++ b/src/Perspex.SceneGraph/Media/ScaleTransform.cs @@ -0,0 +1,69 @@ +// 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; + +namespace Perspex.Media +{ + /// + /// Scale an . + /// + public class ScaleTransform : Transform + { + /// + /// Defines the property. + /// + public static readonly StyledProperty ScaleXProperty = + PerspexProperty.Register(nameof(ScaleX), 1); + + /// + /// Defines the property. + /// + public static readonly StyledProperty ScaleYProperty = + PerspexProperty.Register(nameof(ScaleY), 1); + + /// + /// Initializes a new instance of the class. + /// + public ScaleTransform() + { + this.GetObservable(ScaleXProperty).Subscribe(_ => RaiseChanged()); + this.GetObservable(ScaleYProperty).Subscribe(_ => RaiseChanged()); + } + + /// + /// Initializes a new instance of the class. + /// + /// ScaleX + /// ScaleY + public ScaleTransform(double scaleX, double scaleY) + : this() + { + ScaleX = scaleX; + ScaleY = scaleY; + } + + /// + /// Gets or sets the ScaleX property. + /// + public double ScaleX + { + get { return GetValue(ScaleXProperty); } + set { SetValue(ScaleXProperty, value); } + } + + /// + /// Gets or sets the ScaleY property. + /// + public double ScaleY + { + get { return GetValue(ScaleYProperty); } + set { SetValue(ScaleYProperty, value); } + } + + /// + /// Gets the tranform's . + /// + public override Matrix Value => Matrix.CreateScale(ScaleX, ScaleY); + } +} \ No newline at end of file diff --git a/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj b/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj index 17ee3e98dbc..be199ab423c 100644 --- a/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj +++ b/src/Perspex.SceneGraph/Perspex.SceneGraph.csproj @@ -80,6 +80,7 @@ +