csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
51 lines
1.6 KiB
// 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
|
|
{
|
|
/// <summary>
|
|
/// Rotates an <see cref="IVisual"/>.
|
|
/// </summary>
|
|
public class RotateTransform : Transform
|
|
{
|
|
/// <summary>
|
|
/// Defines the <see cref="Angle"/> property.
|
|
/// </summary>
|
|
public static readonly PerspexProperty<double> AngleProperty =
|
|
PerspexProperty.Register<RotateTransform, double>("Angle");
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="RotateTransform"/> class.
|
|
/// </summary>
|
|
public RotateTransform()
|
|
{
|
|
GetObservable(AngleProperty).Subscribe(_ => RaiseChanged());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="RotateTransform"/> class.
|
|
/// </summary>
|
|
/// <param name="angle">The angle, in degrees.</param>
|
|
public RotateTransform(double angle)
|
|
: this()
|
|
{
|
|
Angle = angle;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the angle of rotation, in degrees.
|
|
/// </summary>
|
|
public double Angle
|
|
{
|
|
get { return GetValue(AngleProperty); }
|
|
set { SetValue(AngleProperty, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the tranform's <see cref="Matrix"/>.
|
|
/// </summary>
|
|
public override Matrix Value => Matrix.CreateRotation(Matrix.ToRadians(Angle));
|
|
}
|
|
}
|
|
|