public void AnimateOut(Size imageSize, Image imageOriginal, Image imageFit, bool?clockwiseRotation, Action completionCallback = null) { CompositeTransform renderTransform = ((UIElement)imageFit).RenderTransform as CompositeTransform; if (imageOriginal == null || renderTransform.ScaleX != 1.0) { this.AnimateFlyout(completionCallback, renderTransform); } else { Size childSize = new Size(((FrameworkElement)imageFit).ActualWidth, ((FrameworkElement)imageFit).ActualHeight); Rect fill = RectangleUtils.ResizeToFill(RectangleUtils.ResizeToFill(new Size(((FrameworkElement)imageOriginal).ActualWidth, ((FrameworkElement)imageOriginal).ActualHeight), imageSize), childSize); Rect rect = ((UIElement)imageOriginal).TransformToVisual((UIElement)imageFit).TransformBounds(fill); if (clockwiseRotation.HasValue) { rect = RectangleUtils.Rotate90(rect); } CompositeTransform compositeTransform1 = RectangleUtils.TransformRect(new Rect(new Point(), childSize), rect, true); renderTransform.CenterX = (((FrameworkElement)imageFit).Width / 2.0); renderTransform.CenterY = (((FrameworkElement)imageFit).Height / 2.0); // ISSUE: explicit reference operation double num1 = ((FrameworkElement)imageFit).Width / ((Rect)@fill).Width; double num2 = this.GetDeltaYCrop(imageOriginal); if (((FrameworkElement)imageOriginal).ActualHeight < num2) { num2 = ((FrameworkElement)imageOriginal).ActualHeight; } Rect target = new Rect(-((Rect)@fill).X * num1, (-((Rect)@fill).Y + num2) * num1, ((FrameworkElement)imageOriginal).ActualWidth * num1, (((FrameworkElement)imageOriginal).ActualHeight - num2) * num1); // ISSUE: explicit reference operation // ISSUE: explicit reference operation if (((Rect)@target).Width < 10.0 || ((Rect)@target).Height < 10.0) { this.AnimateFlyout(completionCallback, renderTransform); } else { RectangleGeometry rectangleGeometry = new RectangleGeometry(); Rect source = new Rect(0.0, 0.0, ((FrameworkElement)imageFit).Width, ((FrameworkElement)imageFit).Height); rectangleGeometry.Rect = source; ((UIElement)imageFit).Clip = ((Geometry)rectangleGeometry); CompositeTransform compositeTransform2 = new CompositeTransform(); ((Geometry)rectangleGeometry).Transform = ((Transform)compositeTransform2); CompositeTransform compositeTransform3 = RectangleUtils.TransformRect(source, target, false); ((DependencyObject)compositeTransform2).Animate(0.0, compositeTransform3.TranslateY, CompositeTransform.TranslateYProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); ((DependencyObject)compositeTransform2).Animate(0.0, compositeTransform3.TranslateX, CompositeTransform.TranslateXProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); ((DependencyObject)compositeTransform2).Animate(1.0, compositeTransform3.ScaleX, CompositeTransform.ScaleXProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); ((DependencyObject)compositeTransform2).Animate(1.0, compositeTransform3.ScaleY, CompositeTransform.ScaleYProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); if (clockwiseRotation.HasValue) { ((DependencyObject)renderTransform).Animate(renderTransform.Rotation, clockwiseRotation.Value ? renderTransform.Rotation + 90.0 : renderTransform.Rotation - 90.0, CompositeTransform.RotationProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); } ((DependencyObject)renderTransform).Animate(renderTransform.TranslateX, renderTransform.TranslateX + compositeTransform1.TranslateX, CompositeTransform.TranslateXProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); ((DependencyObject)renderTransform).Animate(renderTransform.TranslateY, renderTransform.TranslateY + compositeTransform1.TranslateY, CompositeTransform.TranslateYProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); ((DependencyObject)renderTransform).Animate(renderTransform.ScaleX, compositeTransform1.ScaleX, CompositeTransform.ScaleXProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); ((DependencyObject)renderTransform).Animate(renderTransform.ScaleY, compositeTransform1.ScaleY, CompositeTransform.ScaleYProperty, this._animationDurationMs, new int?(0), this._easingFunction, completionCallback); } } }
public void AnimateOut(Size imageSize, Image imageOriginal, Image imageFit, bool?clockwiseRotation, Action completionCallback = null) { CompositeTransform compositeTransform1 = imageFit.RenderTransform as CompositeTransform; if (imageOriginal == null || compositeTransform1.ScaleX != 1.0) { this.AnimateFlyout(completionCallback, compositeTransform1); } else { Size size = new Size(imageFit.ActualWidth, imageFit.ActualHeight); Rect fill = RectangleUtils.ResizeToFill(RectangleUtils.ResizeToFill(new Size(imageOriginal.ActualWidth, imageOriginal.ActualHeight), imageSize), size); Rect rect = imageOriginal.TransformToVisual((UIElement)imageFit).TransformBounds(fill); if (clockwiseRotation.HasValue) { rect = RectangleUtils.Rotate90(rect); } CompositeTransform compositeTransform2 = RectangleUtils.TransformRect(new Rect(new Point(), size), rect, true); compositeTransform1.CenterX = imageFit.Width / 2.0; compositeTransform1.CenterY = imageFit.Height / 2.0; double num1 = imageFit.Width / fill.Width; double num2 = this.GetDeltaYCrop(imageOriginal); if (imageOriginal.ActualHeight < num2) { num2 = imageOriginal.ActualHeight; } Rect target1 = new Rect(-fill.X * num1, (-fill.Y + num2) * num1, imageOriginal.ActualWidth * num1, (imageOriginal.ActualHeight - num2) * num1); if (target1.Width < 10.0 || target1.Height < 10.0) { this.AnimateFlyout(completionCallback, compositeTransform1); } else { RectangleGeometry rectangleGeometry = new RectangleGeometry(); Rect source = new Rect(0.0, 0.0, imageFit.Width, imageFit.Height); rectangleGeometry.Rect = source; imageFit.Clip = (Geometry)rectangleGeometry; CompositeTransform target2 = new CompositeTransform(); rectangleGeometry.Transform = (Transform)target2; CompositeTransform compositeTransform3 = RectangleUtils.TransformRect(source, target1, false); target2.Animate(0.0, compositeTransform3.TranslateY, (object)CompositeTransform.TranslateYProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); target2.Animate(0.0, compositeTransform3.TranslateX, (object)CompositeTransform.TranslateXProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); target2.Animate(1.0, compositeTransform3.ScaleX, (object)CompositeTransform.ScaleXProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); target2.Animate(1.0, compositeTransform3.ScaleY, (object)CompositeTransform.ScaleYProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); if (clockwiseRotation.HasValue) { compositeTransform1.Animate(compositeTransform1.Rotation, clockwiseRotation.Value ? compositeTransform1.Rotation + 90.0 : compositeTransform1.Rotation - 90.0, (object)CompositeTransform.RotationProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); } compositeTransform1.Animate(compositeTransform1.TranslateX, compositeTransform1.TranslateX + compositeTransform2.TranslateX, (object)CompositeTransform.TranslateXProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); compositeTransform1.Animate(compositeTransform1.TranslateY, compositeTransform1.TranslateY + compositeTransform2.TranslateY, (object)CompositeTransform.TranslateYProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); compositeTransform1.Animate(compositeTransform1.ScaleX, compositeTransform2.ScaleX, (object)CompositeTransform.ScaleXProperty, this._animationDurationMs, new int?(0), this._easingFunction, null); compositeTransform1.Animate(compositeTransform1.ScaleY, compositeTransform2.ScaleY, (object)CompositeTransform.ScaleYProperty, this._animationDurationMs, new int?(0), this._easingFunction, completionCallback); } } }
public static CompositeTransform TransformRect(Rect source, Rect target, bool inSourceCenterCoord = false) { if (source.Width == 0.0 || source.Height == 0.0 || (target.Width == 0.0 || target.Height == 0.0)) { return(new CompositeTransform()); } if (inSourceCenterCoord) { return(RectangleUtils.TransformRect(new Rect(source.X - source.Width / 2.0, source.Y - source.Height / 2.0, source.Width, source.Height), new Rect(target.X - source.Width / 2.0, target.Y - source.Height / 2.0, target.Width, target.Height), false)); } CompositeTransform compositeTransform = new CompositeTransform(); compositeTransform.ScaleX = target.Width / source.Width; compositeTransform.ScaleY = target.Height / source.Height; compositeTransform.TranslateX = target.X - source.X * compositeTransform.ScaleX; compositeTransform.TranslateY = target.Y - source.Y * compositeTransform.ScaleY; return(compositeTransform); }
public static CompositeTransform TransformRect(Rect source, Rect target, bool inSourceCenterCoord = false) { // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation if (((Rect)@source).Width == 0.0 || ((Rect)@source).Height == 0.0 || (((Rect)@target).Width == 0.0 || ((Rect)@target).Height == 0.0)) { return(new CompositeTransform()); } if (inSourceCenterCoord) { // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation // ISSUE: explicit reference operation return(RectangleUtils.TransformRect(new Rect(((Rect)@source).X - ((Rect)@source).Width / 2.0, ((Rect)@source).Y - ((Rect)@source).Height / 2.0, ((Rect)@source).Width, ((Rect)@source).Height), new Rect(((Rect)@target).X - ((Rect)@source).Width / 2.0, ((Rect)@target).Y - ((Rect)@source).Height / 2.0, ((Rect)@target).Width, ((Rect)@target).Height), false)); } CompositeTransform compositeTransform = new CompositeTransform(); // ISSUE: explicit reference operation // ISSUE: explicit reference operation compositeTransform.ScaleX = (((Rect)@target).Width / ((Rect)@source).Width); // ISSUE: explicit reference operation // ISSUE: explicit reference operation compositeTransform.ScaleY = (((Rect)@target).Height / ((Rect)@source).Height); // ISSUE: explicit reference operation // ISSUE: explicit reference operation compositeTransform.TranslateX = (((Rect)@target).X - ((Rect)@source).X * compositeTransform.ScaleX); // ISSUE: explicit reference operation // ISSUE: explicit reference operation compositeTransform.TranslateY = (((Rect)@target).Y - ((Rect)@source).Y * compositeTransform.ScaleY); return(compositeTransform); }
public void AnimateIn(Size imageSize, Image imageOriginal, Image imageFit, Action completionCallback = null, int startTime = 0) { if (imageOriginal == null) { completionCallback(); } else { Size childSize = new Size(((FrameworkElement)imageFit).Width, ((FrameworkElement)imageFit).Height); Rect fill = RectangleUtils.ResizeToFill(RectangleUtils.ResizeToFill(new Size(((FrameworkElement)imageOriginal).ActualWidth, ((FrameworkElement)imageOriginal).ActualHeight), imageSize), childSize); Rect target = ((UIElement)imageOriginal).TransformToVisual((UIElement)imageFit).TransformBounds(fill); ((UIElement)imageFit).RenderTransform = ((Transform)RectangleUtils.TransformRect(new Rect(new Point(), childSize), target, false)); GeneralTransform visual = ((UIElement)imageOriginal).TransformToVisual((UIElement)imageFit); double num = this.GetDeltaYCrop(imageOriginal); if (((FrameworkElement)imageOriginal).ActualHeight < num) { num = ((FrameworkElement)imageOriginal).ActualHeight; } Rect rect1 = new Rect(0.0, num, ((FrameworkElement)imageOriginal).ActualWidth, ((FrameworkElement)imageOriginal).ActualHeight - num); Rect source = visual.TransformBounds(rect1); CompositeTransform compositeTransform1 = new CompositeTransform(); Image image = imageFit; RectangleGeometry rectangleGeometry = new RectangleGeometry(); Rect rect2 = source; rectangleGeometry.Rect = rect2; CompositeTransform compositeTransform2 = compositeTransform1; ((Geometry)rectangleGeometry).Transform = ((Transform)compositeTransform2); ((UIElement)image).Clip = ((Geometry)rectangleGeometry); CompositeTransform compositeTransform3 = RectangleUtils.TransformRect(source, new Rect(new Point(), childSize), false); ((DependencyObject)compositeTransform1).Animate(0.0, compositeTransform3.TranslateY, CompositeTransform.TranslateYProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); ((DependencyObject)compositeTransform1).Animate(0.0, compositeTransform3.TranslateX, CompositeTransform.TranslateXProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); ((DependencyObject)compositeTransform1).Animate(1.0, compositeTransform3.ScaleX, CompositeTransform.ScaleXProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); ((DependencyObject)compositeTransform1).Animate(1.0, compositeTransform3.ScaleY, CompositeTransform.ScaleYProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); CompositeTransform renderTransform = ((UIElement)imageFit).RenderTransform as CompositeTransform; ((DependencyObject)renderTransform).Animate(renderTransform.TranslateX, 0.0, CompositeTransform.TranslateXProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, completionCallback); ((DependencyObject)renderTransform).Animate(renderTransform.TranslateY, 0.0, CompositeTransform.TranslateYProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); ((DependencyObject)renderTransform).Animate(renderTransform.ScaleX, 1.0, CompositeTransform.ScaleXProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); ((DependencyObject)renderTransform).Animate(renderTransform.ScaleY, 1.0, CompositeTransform.ScaleYProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); } }
public void AnimateIn(Size imageSize, Image imageOriginal, Image imageFit, Action completionCallback = null, int startTime = 0) { if (imageOriginal == null) { completionCallback(); } else { Size size = new Size(imageFit.Width, imageFit.Height); Rect fill = RectangleUtils.ResizeToFill(RectangleUtils.ResizeToFill(new Size(imageOriginal.ActualWidth, imageOriginal.ActualHeight), imageSize), size); Rect target1 = imageOriginal.TransformToVisual((UIElement)imageFit).TransformBounds(fill); imageFit.RenderTransform = (Transform)RectangleUtils.TransformRect(new Rect(new Point(), size), target1, false); GeneralTransform visual = imageOriginal.TransformToVisual((UIElement)imageFit); double y = this.GetDeltaYCrop(imageOriginal); if (imageOriginal.ActualHeight < y) { y = imageOriginal.ActualHeight; } Rect rect = new Rect(0.0, y, imageOriginal.ActualWidth, imageOriginal.ActualHeight - y); Rect source = visual.TransformBounds(rect); CompositeTransform target2 = new CompositeTransform(); Image image = imageFit; RectangleGeometry rectangleGeometry = new RectangleGeometry(); rectangleGeometry.Rect = source; CompositeTransform compositeTransform1 = target2; rectangleGeometry.Transform = (Transform)compositeTransform1; image.Clip = (Geometry)rectangleGeometry; CompositeTransform compositeTransform2 = RectangleUtils.TransformRect(source, new Rect(new Point(), size), false); target2.Animate(0.0, compositeTransform2.TranslateY, (object)CompositeTransform.TranslateYProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); target2.Animate(0.0, compositeTransform2.TranslateX, (object)CompositeTransform.TranslateXProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); target2.Animate(1.0, compositeTransform2.ScaleX, (object)CompositeTransform.ScaleXProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); target2.Animate(1.0, compositeTransform2.ScaleY, (object)CompositeTransform.ScaleYProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); CompositeTransform target3 = imageFit.RenderTransform as CompositeTransform; target3.Animate(target3.TranslateX, 0.0, (object)CompositeTransform.TranslateXProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, completionCallback); target3.Animate(target3.TranslateY, 0.0, (object)CompositeTransform.TranslateYProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); target3.Animate(target3.ScaleX, 1.0, (object)CompositeTransform.ScaleXProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); target3.Animate(target3.ScaleY, 1.0, (object)CompositeTransform.ScaleYProperty, this._animationDurationMs, new int?(startTime), this._easingFunction, null); } }