internal override Matrix3x2 ToMatrix(Point absoluteOrigin) { // Creates native transform which applies multiple transformations in this order: // Scale(ScaleX, ScaleY) // Skew(SkewX, SkewY) // Rotate(Rotation) // Translate(TranslateX, TranslateY) // https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.compositetransform.aspx var centerX = absoluteOrigin.X + CenterX; var centerY = absoluteOrigin.Y + CenterY; var matrix = Matrix3x2.Identity; matrix *= ScaleTransform.GetMatrix(centerX, centerY, ScaleX, ScaleY); matrix *= SkewTransform.GetMatrix(CenterX, CenterY, SkewX, SkewY); matrix *= RotateTransform.GetMatrix(CenterX, CenterY, Rotation); matrix *= TranslateTransform.GetMatrix(TranslateX, TranslateY); return(matrix); }
public ElementAdapter(FrameworkElement el) { element_ = el; /** * copy default property */ if(!double.IsNaN(Element.Width)){ Width = Element.Width; } if (!double.IsNaN(Element.Height)) { Height = Element.Height; } X = Canvas.GetLeft(Element); Y = Canvas.GetTop(Element); Alpha = Element.Opacity; /** * Transform */ ScaleTransform myScaleTransform = new ScaleTransform(); myScaleTransform.ScaleX = 1.0; myScaleTransform.ScaleY = 1.0; RotateTransform myRotateTransform = new RotateTransform(); myRotateTransform.Angle = 0; TranslateTransform myTranslate = new TranslateTransform(); myTranslate.X = 0; myTranslate.X = 0; SkewTransform mySkew = new SkewTransform(); mySkew.AngleX = 0; mySkew.AngleY = 0; transformGroup_ = new TransformGroup(); transformGroup_.Children.Add(myScaleTransform); transformGroup_.Children.Add(myRotateTransform); transformGroup_.Children.Add(myTranslate); transformGroup_.Children.Add(mySkew); element_.RenderTransform = transformGroup_; }