コード例 #1
0
        private static void OnAnimateToChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var progressBar = d as ProgressBar;

            if (progressBar.Value == (double)e.NewValue)
            {
                return;
            }
            AnimationUtils.BeginAnimation(progressBar, ProgressBar.ValueProperty, (double)e.NewValue, GetAnimationDuration(progressBar), GetAnimationEase(progressBar));
        }
コード例 #2
0
        private static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var drawer = d as Drawer;

            switch (drawer.Placement)
            {
            case DrawerPlacement.Left:
            case DrawerPlacement.Right:
                if (double.IsNaN(drawer.MaxWidth))
                {
                    throw new Exception("Drawer Exception : value of MaxWidth property can not be Auto.");
                }
                if (!drawer.IsLoaded || drawer.AnimationDuration.TotalMilliseconds == 0)
                {
                    if ((bool)e.NewValue)
                    {
                        drawer.Width = drawer.MaxWidth;
                    }
                    else
                    {
                        drawer.Width = 0;
                    }
                }
                else
                {
                    if ((bool)e.NewValue)
                    {
                        if (double.IsNaN(drawer.Width))
                        {
                            drawer.Width = drawer.ActualWidth;
                        }
                        AnimationUtils.BeginAnimation(drawer, WidthProperty, drawer.MaxWidth, drawer.AnimationDuration, drawer.AnimationEase);
                    }
                    else
                    {
                        if (double.IsNaN(drawer.Width))
                        {
                            drawer.Width = drawer.ActualWidth;
                        }
                        AnimationUtils.BeginAnimation(drawer, WidthProperty, 0, drawer.AnimationDuration, drawer.AnimationEase);
                    }
                }
                break;

            case DrawerPlacement.Top:
            case DrawerPlacement.Bottom:
                if (double.IsNaN(drawer.MaxWidth))
                {
                    throw new Exception("Drawer Exception : value of MaxHeight property can not be Auto.");
                }
                if (!drawer.IsLoaded || drawer.AnimationDuration.TotalMilliseconds == 0)
                {
                    if ((bool)e.NewValue)
                    {
                        drawer.Height = drawer.MaxHeight;
                    }
                    else
                    {
                        drawer.Height = 0;
                    }
                }
                else
                {
                    if ((bool)e.NewValue)
                    {
                        if (double.IsNaN(drawer.Height))
                        {
                            drawer.Height = drawer.ActualHeight;
                        }
                        AnimationUtils.BeginAnimation(drawer, HeightProperty, drawer.MaxHeight, drawer.AnimationDuration, drawer.AnimationEase);
                    }
                    else
                    {
                        if (double.IsNaN(drawer.Height))
                        {
                            drawer.Height = drawer.ActualHeight;
                        }
                        AnimationUtils.BeginAnimation(drawer, HeightProperty, 0, drawer.AnimationDuration, drawer.AnimationEase);
                    }
                }
                break;
            }
        }