Пример #1
0
        private async void ToggleExpand(object sender, RoutedEventArgs e)
        {
            var panel = Window.Current.Content.FindControl <DropShadowPanel>("NowPlaying");

            if (panel == null)
            {
                return;
            }

            // If the main content is hidden, we want to expand
            if (MainContent.Opacity == 0.0f)
            {
                var myDoubleAnimation = new DoubleAnimation
                {
                    To                       = 1500,
                    From                     = 430,
                    Duration                 = new Duration(TimeSpan.FromMilliseconds(250)),
                    EasingFunction           = new CubicEase(),
                    EnableDependentAnimation = true
                };

                Storyboard.SetTarget(myDoubleAnimation, panel);
                Storyboard.SetTargetProperty(myDoubleAnimation, "MaxWidth");

                var storyboard = new Storyboard();
                storyboard.Children.Add(myDoubleAnimation);

                await Task.WhenAll(new[]
                {
                    MainContent.Fade(1.0f, 250, 0, EasingType.Quadratic).StartAsync(),
                    ExpandToggle.Rotate(0, 9f, 9f, 250, 0, EasingType.Quadratic).StartAsync(),
                    storyboard.BeginAsync()
                });
            }
            else
            {
                var myDoubleAnimation = new DoubleAnimation
                {
                    To                       = 430,
                    From                     = 1500,
                    Duration                 = new Duration(TimeSpan.FromMilliseconds(250)),
                    EasingFunction           = new CubicEase(),
                    EnableDependentAnimation = true
                };

                Storyboard.SetTarget(myDoubleAnimation, panel);
                Storyboard.SetTargetProperty(myDoubleAnimation, "MaxWidth");

                var storyboard = new Storyboard();
                storyboard.Children.Add(myDoubleAnimation);

                await Task.WhenAll(new[]
                {
                    MainContent.Fade(0.0f, 250, 0, EasingType.Bounce).StartAsync(),
                    ExpandToggle.Rotate(178, 9f, 9f, 250, 0, EasingType.Quadratic).StartAsync(),
                    storyboard.BeginAsync()
                });
            }
        }
Пример #2
0
        private async Task ToggleExpandAsync()
        {
            if (!(App.Shell?.GetName("NowPlaying") is DropShadowPanel panel))
            {
                return;
            }

            // If the main content is hidden, we want to expand
            if (MainContent.Opacity == 0.0f)
            {
                var myDoubleAnimation = new DoubleAnimation
                {
                    To                       = 1500,
                    From                     = 450,
                    Duration                 = new Duration(TimeSpan.FromMilliseconds(250)),
                    EasingFunction           = new CubicEase(),
                    EnableDependentAnimation = true
                };

                Storyboard.SetTarget(myDoubleAnimation, panel);
                Storyboard.SetTargetProperty(myDoubleAnimation, "MaxWidth");

                var storyboard = new Storyboard();
                storyboard.Children.Add(myDoubleAnimation);

                await Task.WhenAll(new Task[]
                {
                    MainContent.Fade(1.0f, 250, 0, EasingType.Quadratic).StartAsync(),
                    ExpandToggle.Rotate(0, 9f, 9f, 250, 0, EasingType.Quadratic).StartAsync(),
                    storyboard.BeginAsync()
                });
            }
            else
            {
                var myDoubleAnimation = new DoubleAnimation
                {
                    To                       = 450,
                    From                     = 1500,
                    Duration                 = new Duration(TimeSpan.FromMilliseconds(250)),
                    EasingFunction           = new CubicEase(),
                    EnableDependentAnimation = true
                };

                Storyboard.SetTarget(myDoubleAnimation, panel);
                Storyboard.SetTargetProperty(myDoubleAnimation, "MaxWidth");

                var storyboard = new Storyboard();
                storyboard.Children.Add(myDoubleAnimation);

                await Task.WhenAll(new Task[]
                {
                    MainContent.Fade(0.0f, 250, 0, EasingType.Bounce).StartAsync(),
                    ExpandToggle.Rotate(178, 9f, 9f, 250, 0, EasingType.Quadratic).StartAsync(),
                    storyboard.BeginAsync()
                });
            }
        }