Example #1
0
        /// <summary>
        /// Arranges the content of a <see cref="T:System.Windows.Controls.Decorator"/> element.
        /// </summary>
        /// <param name="arrangeSize">The <see cref="T:System.Windows.Size"/> this element uses to arrange its child content.</param>
        /// <returns>
        /// The <see cref="T:System.Windows.Size"/> that represents the arranged size of this <see cref="T:System.Windows.Controls.Decorator"/> element and its child.
        /// </returns>
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            UIElement child = Child;

            if (child != null)
            {
                double percent = AnimationProgress;
                HorizontalRevealMode horizontalReveal = HorizontalReveal;
                VerticalRevealMode   verticalReveal   = VerticalReveal;

                double childWidth  = child.DesiredSize.Width;
                double childHeight = child.DesiredSize.Height;

                if (this.UseDesiredSize)
                {
                    double x = CalculateLeft(childWidth, percent, horizontalReveal);
                    double y = CalculateTop(childHeight, percent, verticalReveal);
                    child.Arrange(new Rect(x, y, childWidth, childHeight));
                }
                else
                {
                    child.Arrange(new Rect(0, 0, arrangeSize.Width, arrangeSize.Height));
                }

                childWidth  = child.RenderSize.Width;
                childHeight = child.RenderSize.Height;
                double width  = CalculateWidth(childWidth, percent, horizontalReveal);
                double height = CalculateHeight(childHeight, percent, verticalReveal);
                return(new Size(width, height));
            }

            return(new Size());
        }
Example #2
0
        /// <summary>
        ///     Calculates the height.
        /// </summary>
        /// <param name="originalHeight">Height of the original.</param>
        /// <param name="percent">The percent.</param>
        /// <param name="reveal">The reveal.</param>
        /// <returns></returns>
        private static double CalculateHeight(double originalHeight, double percent, VerticalRevealMode reveal)
        {
            if (reveal == VerticalRevealMode.None)
            {
                return(originalHeight);
            }

            return(originalHeight * percent);
        }
Example #3
0
 /// <summary>
 ///     Calculates the top.
 /// </summary>
 /// <param name="height">The height.</param>
 /// <param name="percent">The percent.</param>
 /// <param name="reveal">The reveal.</param>
 /// <returns></returns>
 private static double CalculateTop(double height, double percent, VerticalRevealMode reveal)
 {
     if (reveal == VerticalRevealMode.FromBottomToTop)
     {
         return((percent - 1.0) * height);
     }
     if (reveal == VerticalRevealMode.FromCenterToEdge)
     {
         return((percent - 1.0) * height * 0.5);
     }
     return(0.0);
 }
Example #4
0
 private static double CalculateHeight(double originalHeight, double percent, VerticalRevealMode reveal)
 {
     if (reveal == VerticalRevealMode.None)
     {
         return originalHeight;
     }
     else
     {
         return originalHeight * percent;
     }
 }
Example #5
0
 private static double CalculateTop(double height, double percent, VerticalRevealMode reveal)
 {
     if (reveal == VerticalRevealMode.FromBottomToTop)
     {
         return (percent - 1.0) * height;
     }
     else if (reveal == VerticalRevealMode.FromCenterToEdge)
     {
         return (percent - 1.0) * height * 0.5;
     }
     else
     {
         return 0.0;
     }
 }