Ejemplo n.º 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));
        }
        private void BeginArrangeAnimation()
        {
            BeginAnimation(PercentProperty, null);
            foreach (UIElement child in InternalChildren)
            {
                var currentOffset = GetCurrentOffset(child);
                if (!double.IsNaN(currentOffset))
                {
                    SetLastOffset(child, GetCurrentOffset(child));
                }
            }
            var animation = new DoubleAnimation()
            {
                From           = 0,
                To             = 100,
                Duration       = AnimationDuration,
                EasingFunction = AnimationUtils.CreateEasingFunction(AnimationEase),
            };

            BeginAnimation(PercentProperty, animation);
        }
Ejemplo n.º 3
0
        private void UpdateChildren(bool useAnimation)
        {
            var targetX = (CurrentIndex - 1) * DesiredSize.Width;
            var targetY = (CurrentIndex - 1) * DesiredSize.Height;
            var targetPositionOffset = new Rect(targetX, targetY, 0, 0);

            if (!IsLoaded || !useAnimation || AnimationDuration.TotalMilliseconds == 0)
            {
                PositionOffset = targetPositionOffset;
            }
            else
            {
                var animation = new RectAnimation()
                {
                    To             = targetPositionOffset,
                    Duration       = AnimationDuration,
                    EasingFunction = AnimationUtils.CreateEasingFunction(AnimationEase),
                };
                BeginAnimation(PositionOffsetProperty, animation);
            }
        }
Ejemplo n.º 4
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;
            }
        }