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 width.
        /// </summary>
        /// <param name="originalWidth">Width of the original.</param>
        /// <param name="percent">The percent.</param>
        /// <param name="reveal">The reveal.</param>
        /// <returns></returns>
        private static double CalculateWidth(double originalWidth, double percent, HorizontalRevealMode reveal)
        {
            if (reveal == HorizontalRevealMode.None)
            {
                return(originalWidth);
            }

            return(originalWidth * percent);
        }
Example #3
0
        /// <summary>
        ///     Calculates the left.
        /// </summary>
        /// <param name="width">The width.</param>
        /// <param name="percent">The percent.</param>
        /// <param name="reveal">The reveal.</param>
        /// <returns></returns>
        private static double CalculateLeft(double width, double percent, HorizontalRevealMode reveal)
        {
            if (reveal == HorizontalRevealMode.FromRightToLeft)
            {
                return((percent - 1.0) * width);
            }

            if (reveal == HorizontalRevealMode.FromCenterToEdge)
            {
                return((percent - 1.0) * width * 0.5);
            }

            return(0.0);
        }
Example #4
0
 private static double CalculateWidth(double originalWidth, double percent, HorizontalRevealMode reveal)
 {
     if (reveal == HorizontalRevealMode.None)
     {
         return originalWidth;
     }
     else
     {
         return originalWidth * percent;
     }
 }
Example #5
0
 private static double CalculateLeft(double width, double percent, HorizontalRevealMode reveal)
 {
     if (reveal == HorizontalRevealMode.FromRightToLeft)
     {
         return (percent - 1.0) * width;
     }
     else if (reveal == HorizontalRevealMode.FromCenterToEdge)
     {
         return (percent - 1.0) * width * 0.5;
     }
     else
     {
         return 0.0;
     }
 }