示例#1
0
        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);
                }
            }
        }
示例#2
0
        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);
                }
            }
        }