示例#1
0
        private void Toggle_Click(object sender, RoutedEventArgs e)
        {
            GridLengthAnimation glaLeft  = new GridLengthAnimation();
            GridLengthAnimation glaRight = new GridLengthAnimation();
            DoubleAnimation     rotation = new DoubleAnimation();

            glaLeft.Duration      = TimeSpan.FromMilliseconds(500);
            glaLeft.BeginTime     = TimeSpan.FromMilliseconds(500);
            glaRight.Duration     = TimeSpan.FromMilliseconds(500);
            glaRight.BeginTime    = TimeSpan.FromMilliseconds(500);
            rotation.Duration     = TimeSpan.FromMilliseconds(500);
            rotation.FillBehavior = FillBehavior.HoldEnd;
            rotation.BeginTime    = TimeSpan.FromMilliseconds(500);

            if (IsLeftOpen == false)
            {
                //To SignIn
                glaLeft.From = new GridLength(1, GridUnitType.Star);
                glaLeft.To   = new GridLength(0, GridUnitType.Star);

                glaRight.From = new GridLength(0, GridUnitType.Star);
                glaRight.To   = new GridLength(1, GridUnitType.Star);

                rotation.From = 0;
                rotation.To   = 180;
            }

            else
            {
                //To SignUp
                glaLeft.From = new GridLength(0, GridUnitType.Star);
                glaLeft.To   = new GridLength(1, GridUnitType.Star);

                glaRight.From = new GridLength(1, GridUnitType.Star);
                glaRight.To   = new GridLength(0, GridUnitType.Star);

                rotation.From = 180;
                rotation.To   = 0;
            }

            Arrow.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, rotation);
            SignInColumn.BeginAnimation(ColumnDefinition.WidthProperty, glaLeft);
            SignUpColumn.BeginAnimation(ColumnDefinition.WidthProperty, glaRight);

            IsLeftOpen = !IsLeftOpen;
        }
示例#2
0
        private void Border_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            GridLengthAnimation glaLeft  = new GridLengthAnimation();
            GridLengthAnimation glaRight = new GridLengthAnimation();
            DoubleAnimation     rotation = new DoubleAnimation();
            DoubleAnimation     appear   = new DoubleAnimation();
            DoubleAnimation     hide     = new DoubleAnimation();

            glaLeft.Duration      = TimeSpan.FromMilliseconds(500);
            glaLeft.BeginTime     = TimeSpan.FromMilliseconds(500);
            glaRight.Duration     = TimeSpan.FromMilliseconds(500);
            glaRight.BeginTime    = TimeSpan.FromMilliseconds(500);
            rotation.Duration     = TimeSpan.FromMilliseconds(500);
            rotation.FillBehavior = FillBehavior.HoldEnd;
            rotation.BeginTime    = TimeSpan.FromMilliseconds(500);
            appear.Duration       = TimeSpan.FromMilliseconds(250);
            appear.FillBehavior   = FillBehavior.HoldEnd;
            appear.BeginTime      = TimeSpan.FromMilliseconds(500);
            appear.BeginTime      = TimeSpan.FromMilliseconds(750);
            appear.From           = 0;
            appear.To             = 1;
            hide.Duration         = TimeSpan.FromMilliseconds(250);
            hide.FillBehavior     = FillBehavior.HoldEnd;
            hide.From             = 1;
            hide.To = 0;

            if (IsLeftOpen == false)
            {
                //To SignIn
                glaLeft.From = new GridLength(1, GridUnitType.Star);
                glaLeft.To   = new GridLength(0, GridUnitType.Star);

                glaRight.From = new GridLength(0, GridUnitType.Star);
                glaRight.To   = new GridLength(1, GridUnitType.Star);

                rotation.From = 225;
                rotation.To   = 45;

                foreach (Border border in Container.Children)
                {
                    if (border.Tag?.ToString() == "SignIn")
                    {
                        border.BeginAnimation(OpacityProperty, hide);
                    }
                    else if (border.Tag?.ToString() == "SignUp")
                    {
                        border.BeginAnimation(OpacityProperty, appear);
                    }
                }
            }

            else
            {
                //To SignUp
                glaLeft.From = new GridLength(0, GridUnitType.Star);
                glaLeft.To   = new GridLength(1, GridUnitType.Star);

                glaRight.From = new GridLength(1, GridUnitType.Star);
                glaRight.To   = new GridLength(0, GridUnitType.Star);

                rotation.From = 45;
                rotation.To   = 225;

                foreach (Border border in Container.Children)
                {
                    if (border.Tag?.ToString() == "SignIn")
                    {
                        border.BeginAnimation(OpacityProperty, appear);
                    }
                    else if (border.Tag?.ToString() == "SignUp")
                    {
                        border.BeginAnimation(OpacityProperty, hide);
                    }
                }
            }

            Arrow.BeginAnimation(RotateTransform.AngleProperty, rotation);
            SignInColumn.BeginAnimation(ColumnDefinition.WidthProperty, glaLeft);
            SignUpColumn.BeginAnimation(ColumnDefinition.WidthProperty, glaRight);

            IsLeftOpen = !IsLeftOpen;
        }