// -----------------------------------------------------------------------
//
// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Media
{
using System;
///
/// Translates (moves) an .
///
public class TranslateTransform : Transform
{
///
/// Defines the property.
///
public static readonly PerspexProperty XProperty =
PerspexProperty.Register("X");
///
/// Defines the property.
///
public static readonly PerspexProperty YProperty =
PerspexProperty.Register("Y");
///
/// Initializes a new instance of the class.
///
public TranslateTransform()
{
this.GetObservable(XProperty).Subscribe(_ => this.RaiseChanged());
this.GetObservable(YProperty).Subscribe(_ => this.RaiseChanged());
}
///
/// Initializes a new instance of the class.
///
/// Gets the horizontal offset of the translate.
/// Gets the vertical offset of the translate.
public TranslateTransform(double x, double y)
: this()
{
this.X = x;
this.Y = y;
}
///
/// Gets the horizontal offset of the translate.
///
public double X
{
get { return this.GetValue(XProperty); }
set { this.SetValue(XProperty, value); }
}
///
/// Gets the vertical offset of the translate.
///
public double Y
{
get { return this.GetValue(YProperty); }
set { this.SetValue(YProperty, value); }
}
///
/// Gets the tranform's .
///
public override Matrix Value
{
get { return Matrix.CreateTranslation(this.X, this.Y); }
}
}
}