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()
                });
            }
        }
        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()
                });
            }
        }
Exemple #3
0
        public SizeToFitPageViewModel()
        {
            EffectOn.Value = false;

            LabelHeight.Value = 40f;

            TextToggle.Subscribe(x => {
                if (!x)
                {
                    LabelText.Value = "ShortTextEnd";
                }
                else
                {
                    LabelText.Value = "LongTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextEnd";
                }
            });

            HeightToggle.Subscribe(x => {
                if (x)
                {
                    LabelHeight.Value = 400f;
                }
                else
                {
                    LabelHeight.Value = 40f;
                }
            });

            WidthToggle.Subscribe(x => {
                if (x)
                {
                    LabelWidth.Value = 320f;
                }
                else
                {
                    LabelWidth.Value = 150f;
                }
            });

            FontToggle.Subscribe(x => {
                if (x)
                {
                    FontSize.Value = 28f;
                }
                else
                {
                    FontSize.Value = 14f;
                }
            });


            ExpandToggle.Subscribe(x => {
                CanExpand.Value = x;
            });
            ExpandToggle.Value = true;

            HAlignCommand.Subscribe(_ => {
                if (TextAlign.Value == TextAlignment.Start)
                {
                    TextAlign.Value = TextAlignment.Center;
                }
                else if (TextAlign.Value == TextAlignment.Center)
                {
                    TextAlign.Value = TextAlignment.End;
                }
                else if (TextAlign.Value == TextAlignment.End)
                {
                    TextAlign.Value = TextAlignment.Start;
                }
            });

            VAlignCommand.Subscribe(_ => {
                if (VTextAlign.Value == TextAlignment.Start)
                {
                    VTextAlign.Value = TextAlignment.Center;
                }
                else if (VTextAlign.Value == TextAlignment.Center)
                {
                    VTextAlign.Value = TextAlignment.End;
                }
                else if (VTextAlign.Value == TextAlignment.End)
                {
                    VTextAlign.Value = TextAlignment.Start;
                }
            });
        }