Пример #1
0
        // We create and store the animation information for the current
        // state of the header the first time we need to perform an animation.
        // It's stored so that an initial fade-out animation can be
        // interrupted and resumed from its current state by the fade-in
        // animation.
        private void CreateAnimationInformation()
        {
            if (_animInfo == null)
            {
                int count = _header.Items.Count;

                // We won't animate the currently selected item,
                // so ensure we don't create information for it.
                _animInfo = new HeaderAnimationInfo[count - 1];

                int i = 0;

                foreach (PivotHeaderItem headerItem in _header.Items)
                {
                    if (!headerItem.IsSelected)
                    {
                        _animInfo[i].opacity         = headerItem.Opacity;
                        _animInfo[i].opacityAnimator = new OpacityAnimator(headerItem);
                        _animInfo[i].transform       =
                            TransformAnimator.GetTranslateTransform(headerItem);
                        _animInfo[i].transformAnimator =
                            new TransformAnimator(_animInfo[i].transform);
                        _animInfo[i].originalX = _animInfo[i].transform.X;

                        i++;
                    }
                }
            }
        }
 public static void EnsureAnimator(FrameworkElement targetElement, ref TransformAnimator animator)
 {
     if (animator == null)
     {
         TranslateTransform transform = TransformAnimator.GetTranslateTransform(targetElement);
         if (transform != null)
         {
             animator = new TransformAnimator(transform);
         }
     }
     if (animator == null)
     {
         throw new InvalidOperationException("The animation system could not be prepared for the target element.");
     }
 }
 public static void EnsureAnimator(FrameworkElement targetElement, ref TransformAnimator animator)
 {
     if (animator == null)
     {
         TranslateTransform transform = TransformAnimator.GetTranslateTransform(targetElement);
         if (transform != null)
         {
             animator = new TransformAnimator(transform);
         }
     }
     if (animator == null)
     {
         throw new InvalidOperationException("The animation system could not be prepared for the target element.");
     }
 }