示例#1
0
        private static void OnIsAnimationEnabledInvalidated(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            Panel panelToAnimate = dependencyObject as Panel;

            if (panelToAnimate == null)
            {
                return;
            }
            if ((bool)e.NewValue)
            {
                if (panelToAnimate.ReadLocalValue(PanelLayoutAnimator.AttachedAnimatorProperty) != DependencyProperty.UnsetValue)
                {
                    return;
                }
                PanelLayoutAnimator panelLayoutAnimator = new PanelLayoutAnimator(panelToAnimate);
                panelToAnimate.SetValue(PanelLayoutAnimator.AttachedAnimatorProperty, (object)panelLayoutAnimator);
            }
            else
            {
                if (panelToAnimate.ReadLocalValue(PanelLayoutAnimator.AttachedAnimatorProperty) == DependencyProperty.UnsetValue)
                {
                    return;
                }
                ((PanelLayoutAnimator)panelToAnimate.ReadLocalValue(PanelLayoutAnimator.AttachedAnimatorProperty)).Detach();
                panelToAnimate.SetValue(PanelLayoutAnimator.AttachedAnimatorProperty, DependencyProperty.UnsetValue);
            }
        }
示例#2
0
        private void PanelLayoutUpdated(object sender, EventArgs e)
        {
            bool flag = false;

            foreach (UIElement uiElement in this._panel.Children)
            {
                Point     point1          = uiElement.TransformToAncestor((Visual)this._panel).Transform(new Point());
                Transform renderTransform = uiElement.RenderTransform;
                Point     point2          = point1;
                if (renderTransform != null)
                {
                    point2 = renderTransform.Inverse.Transform(point2);
                }
                if (uiElement.ReadLocalValue(PanelLayoutAnimator.SavedArrangePositionProperty) != DependencyProperty.UnsetValue)
                {
                    Point point3 = (Point)uiElement.GetValue(PanelLayoutAnimator.SavedArrangePositionProperty);
                    if (!this.AreReallyClose(point3, point2))
                    {
                        Point point4 = renderTransform.Transform(point3);
                        TranslateTransform translateTransform = new TranslateTransform();
                        uiElement.RenderTransform = (Transform)translateTransform;
                        DoubleAnimation doubleAnimation1 = PanelLayoutAnimator.MakeAnimation(point4.X - point2.X, (TimeSpan)uiElement.GetValue(PanelLayoutAnimator.AnimationDurationProperty));
                        DoubleAnimation doubleAnimation2 = PanelLayoutAnimator.MakeAnimation(point4.Y - point2.Y, (TimeSpan)uiElement.GetValue(PanelLayoutAnimator.AnimationDurationProperty));
                        if (!flag)
                        {
                            doubleAnimation1.CurrentTimeInvalidated += new EventHandler(this.AnimationUpdated);
                            flag = true;
                        }
                        translateTransform.BeginAnimation(TranslateTransform.XProperty, (AnimationTimeline)doubleAnimation1);
                        translateTransform.BeginAnimation(TranslateTransform.YProperty, (AnimationTimeline)doubleAnimation2);
                    }
                }
                uiElement.SetValue(PanelLayoutAnimator.SavedArrangePositionProperty, (object)point2);
            }
        }
示例#3
0
 private static void OnIsAnimationEnabledInvalidated(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
 {
     Panel panelToAnimate = dependencyObject as Panel;
     if (panelToAnimate == null)
         return;
     if ((bool)e.NewValue)
     {
         if (panelToAnimate.ReadLocalValue(PanelLayoutAnimator.AttachedAnimatorProperty) != DependencyProperty.UnsetValue)
             return;
         PanelLayoutAnimator panelLayoutAnimator = new PanelLayoutAnimator(panelToAnimate);
         panelToAnimate.SetValue(PanelLayoutAnimator.AttachedAnimatorProperty, (object)panelLayoutAnimator);
     }
     else
     {
         if (panelToAnimate.ReadLocalValue(PanelLayoutAnimator.AttachedAnimatorProperty) == DependencyProperty.UnsetValue)
             return;
         ((PanelLayoutAnimator)panelToAnimate.ReadLocalValue(PanelLayoutAnimator.AttachedAnimatorProperty)).Detach();
         panelToAnimate.SetValue(PanelLayoutAnimator.AttachedAnimatorProperty, DependencyProperty.UnsetValue);
     }
 }