Exemplo n.º 1
0
        private async void ImageRotate_Click(object sender, RoutedEventArgs e)
        {
            PhotoDisplaySupport Item = PhotoCollection[Flip.SelectedIndex];

            if (Flip.ContainerFromItem(Item) is DependencyObject Container && Container.FindChildOfType <ScrollViewer>() is ScrollViewer Viewer)
            {
                Storyboard Story = new Storyboard();

                switch (Item.RotateAngle % 360)
                {
                case 0:
                case 180:
                {
                    DoubleAnimation WidthAnimation = new DoubleAnimation
                    {
                        From     = Flip.ActualWidth,
                        To       = Flip.ActualHeight,
                        Duration = TimeSpan.FromMilliseconds(500),
                        EnableDependentAnimation = true,
                        EasingFunction           = new CircleEase {
                            EasingMode = EasingMode.EaseOut
                        }
                    };

                    Storyboard.SetTarget(WidthAnimation, Viewer);
                    Storyboard.SetTargetProperty(WidthAnimation, "Width");

                    Story.Children.Add(WidthAnimation);

                    await Task.WhenAll(Story.BeginAsync(), Viewer.Rotate(Item.RotateAngle += 90).StartAsync()).ConfigureAwait(true);

                    break;
                }

                case 90:
                case 270:
                {
                    DoubleAnimation HeightAnimation = new DoubleAnimation
                    {
                        From     = Flip.ActualHeight,
                        To       = Flip.ActualWidth,
                        Duration = TimeSpan.FromMilliseconds(500),
                        EnableDependentAnimation = true,
                        EasingFunction           = new CircleEase {
                            EasingMode = EasingMode.EaseOut
                        }
                    };

                    Storyboard.SetTarget(HeightAnimation, Viewer);
                    Storyboard.SetTargetProperty(HeightAnimation, "Width");

                    Story.Children.Add(HeightAnimation);

                    await Task.WhenAll(Story.BeginAsync(), Viewer.Rotate(Item.RotateAngle += 90).StartAsync()).ConfigureAwait(true);

                    break;
                }
                }
            }
        }
Exemplo n.º 2
0
        private async void ImageRotate_Click(object sender, RoutedEventArgs e)
        {
            PhotoDisplaySupport Item   = PhotoCollection[Flip.SelectedIndex];
            ScrollViewer        Viewer = Flip.ContainerFromItem(Item).FindChildOfType <ScrollViewer>();

            Viewer.RenderTransformOrigin = new Point(0.5, 0.5);
            await Viewer.Rotate(Item.RotateAngle += 90).StartAsync().ConfigureAwait(false);
        }
Exemplo n.º 3
0
        private void Flip_SelectionChanged1(object sender, SelectionChangedEventArgs e)
        {
            if (Flip.SelectedIndex == -1)
            {
                return;
            }

            if (LastSelectIndex > Flip.SelectedIndex)
            {
                _ = Flip.ContainerFromItem(Flip.SelectedIndex + 1).FindChildOfType <ScrollViewer>()?.ChangeView(null, null, 1);
            }
            else
            {
                if (Flip.SelectedIndex > 0)
                {
                    _ = Flip.ContainerFromIndex(Flip.SelectedIndex - 1).FindChildOfType <ScrollViewer>()?.ChangeView(null, null, 1);
                }
            }

            Behavior.InitAnimation(InitOption.AroundImage);

            LastSelectIndex = Flip.SelectedIndex;
        }
Exemplo n.º 4
0
        private async void ImageRotate_Click(object sender, RoutedEventArgs e)
        {
            PhotoDisplaySupport Item = PhotoCollection[Flip.SelectedIndex];

            if (Flip.ContainerFromItem(Item) is DependencyObject Container && Container.FindChildOfType <ScrollViewer>() is ScrollViewer Viewer)
            {
                switch (Item.RotateAngle % 360)
                {
                case 0:
                case 180:
                {
                    DoubleAnimation WidthAnimation = new DoubleAnimation
                    {
                        From     = Flip.ActualWidth,
                        To       = Flip.ActualHeight,
                        Duration = TimeSpan.FromMilliseconds(500),
                        EnableDependentAnimation = true,
                        EasingFunction           = new CubicEase {
                            EasingMode = EasingMode.EaseOut
                        }
                    };

                    Storyboard.SetTarget(WidthAnimation, Viewer);
                    Storyboard.SetTargetProperty(WidthAnimation, "Width");

                    Vector2 StartRotationCenter = new Vector2(Convert.ToSingle(Flip.ActualWidth / 2), Convert.ToSingle(Flip.ActualHeight / 2));
                    Vector2 EndRotationCenter   = new Vector2(Convert.ToSingle(Flip.ActualHeight / 2), Convert.ToSingle(Flip.ActualHeight / 2));

                    await AnimationBuilder.Create()
                    .CenterPoint(EndRotationCenter, StartRotationCenter, duration: TimeSpan.FromMilliseconds(500), easingType: EasingType.Cubic, easingMode: EasingMode.EaseOut)
                    .ExternalAnimation(WidthAnimation)
                    .RotationInDegrees(Item.RotateAngle += 90, duration: TimeSpan.FromMilliseconds(500), easingType: EasingType.Cubic, easingMode: EasingMode.EaseOut)
                    .StartAsync(Viewer);

                    break;
                }

                case 90:
                case 270:
                {
                    DoubleAnimation HeightAnimation = new DoubleAnimation
                    {
                        From     = Flip.ActualHeight,
                        To       = Flip.ActualWidth,
                        Duration = TimeSpan.FromMilliseconds(500),
                        EnableDependentAnimation = true,
                        EasingFunction           = new CubicEase {
                            EasingMode = EasingMode.EaseOut
                        }
                    };

                    Storyboard.SetTarget(HeightAnimation, Viewer);
                    Storyboard.SetTargetProperty(HeightAnimation, "Width");

                    Vector2 StartRotationCenter = new Vector2(Convert.ToSingle(Flip.ActualHeight / 2), Convert.ToSingle(Flip.ActualHeight / 2));
                    Vector2 EndRotationCenter   = new Vector2(Convert.ToSingle(Flip.ActualWidth / 2), Convert.ToSingle(Flip.ActualHeight / 2));

                    await AnimationBuilder.Create()
                    .CenterPoint(EndRotationCenter, StartRotationCenter, duration: TimeSpan.FromMilliseconds(500), easingType: EasingType.Cubic, easingMode: EasingMode.EaseOut)
                    .ExternalAnimation(HeightAnimation)
                    .RotationInDegrees(Item.RotateAngle += 90, duration: TimeSpan.FromMilliseconds(500), easingType: EasingType.Cubic, easingMode: EasingMode.EaseOut)
                    .StartAsync(Viewer);

                    break;
                }
                }
            }
        }