Beispiel #1
0
        private async void method()
        {
            for (int i = 0; i < 5; i++)
            {
                await Task.Delay(100);

                if (!Sidebar.IsMouseOver)
                {
                    mouseInside = false;
                    return;
                }
            }

            if (mouseInside)
            {
                DoubleAnimation slideOut = new DoubleAnimation
                {
                    To                = 180,
                    Duration          = TimeSpan.FromSeconds(0.6),
                    DecelerationRatio = 0.9
                };
                slideOut.Completed += (s, ev) => { animationCompleted = true; };
                slideOut.Completed += hideSidebar;
                await Dispatcher.BeginInvoke(
                    new Action(() => Sidebar.BeginAnimation(WidthProperty, slideOut)));
            }
        }
Beispiel #2
0
        private void ToggleMenu(object sender, RoutedEventArgs e)
        {
            if (Sidebar.Width == new GridLength(1, GridUnitType.Star))
            {
                Duration duration = new Duration(TimeSpan.FromMilliseconds(500));

                var animation = new GridLengthAnimation
                {
                    Duration = duration,
                    From     = new GridLength(1, GridUnitType.Star),
                    To       = new GridLength(0, GridUnitType.Star)
                };

                Sidebar.BeginAnimation(ColumnDefinition.WidthProperty, animation);
            }
            else
            {
                Duration duration = new Duration(TimeSpan.FromMilliseconds(500));

                var animation = new GridLengthAnimation
                {
                    Duration = duration,
                    From     = new GridLength(0, GridUnitType.Star),
                    To       = new GridLength(1, GridUnitType.Star)
                };

                Sidebar.BeginAnimation(ColumnDefinition.WidthProperty, animation);
            }
        }
Beispiel #3
0
 private void tg_btn_ham_Checked(object sender, RoutedEventArgs e)
 {
     Sidebar.BeginAnimation(WidthProperty, new DoubleAnimation(50, 200, TimeSpan.FromSeconds(1)));
     if (button1.Content.ToString() == "Reservation")
     {
     }
 }
Beispiel #4
0
        private void tg_btn_ham_Unchecked(object sender, RoutedEventArgs e)
        {
            Sidebar.BeginAnimation(WidthProperty, new DoubleAnimation(200, 50, TimeSpan.FromSeconds(1)));

            if (button1.Content.ToString() == "Reservation")
            {
                //RC.BeginAnimation(WidthProperty, new DoubleAnimation(RC.Width, BerandaWindow.Width - 50, TimeSpan.FromSeconds(1)));
            }
        }
Beispiel #5
0
 void hideSidebar(object sender, EventArgs e)
 {
     if (!mouseInside)
     {
         DoubleAnimation slideOut = new DoubleAnimation
         {
             To                = 50,
             Duration          = TimeSpan.FromSeconds(1),
             DecelerationRatio = 0.9
         };
         Sidebar.BeginAnimation(WidthProperty, slideOut);
         animationCompleted = false;
     }
 }
Beispiel #6
0
        private void Sidebar_OnMouseLeave(object sender, MouseEventArgs e)
        {
            mouseInside = false;
            if (animationCompleted)
            {
                DoubleAnimation slideOut = new DoubleAnimation
                {
                    To                = 50,
                    Duration          = TimeSpan.FromSeconds(0.6),
                    DecelerationRatio = 0.9
                };

                Sidebar.BeginAnimation(WidthProperty, slideOut);
                animationCompleted = false;
            }
        }
Beispiel #7
0
        //Hide and show sidebar menu
        private void ToggleMenu(object sender, RoutedEventArgs e)
        {
            //Codigo para generar un diagrama de Db para tener una foto

            /*using (var ctx = new Models.DbmejiaEntities())
             * {
             *  using (var writer = new XmlTextWriter("./Model.edmx", Encoding.Default))
             *  {
             *      EdmxWriter.WriteEdmx(ctx, writer);
             *  }
             * } */


            if (Sidebar.Width == new GridLength(1, GridUnitType.Star))
            {
                Duration duration = new Duration(TimeSpan.FromMilliseconds(500));

                var animation = new GridLengthAnimation
                {
                    Duration = duration,
                    From     = new GridLength(1, GridUnitType.Star),
                    To       = new GridLength(0, GridUnitType.Star)
                };

                Sidebar.BeginAnimation(ColumnDefinition.WidthProperty, animation);
            }
            else
            {
                Duration duration = new Duration(TimeSpan.FromMilliseconds(500));

                var animation = new GridLengthAnimation
                {
                    Duration = duration,
                    From     = new GridLength(0, GridUnitType.Star),
                    To       = new GridLength(1, GridUnitType.Star)
                };

                Sidebar.BeginAnimation(ColumnDefinition.WidthProperty, animation);
            }
        }