示例#1
0
        /// <summary>
        /// Utility function. Calculate the required size adding using the anchor informations of the available area.
        /// </summary>
        /// <param name="currentSize"></param>
        /// <param name="contentAnchor"></param>
        /// <param name="contentSize"></param>
        /// <returns></returns>
        public static SizeF CalculateSizeWithContent(SizeF currentSize, AnchorArea contentAnchor, SizeF contentSize)
        {
            if (contentAnchor != null && (contentAnchor.HasLeft || contentAnchor.HasRight))
            {
                currentSize.Width += contentSize.Width;
            }
            else
            {
                if (contentSize.Width > currentSize.Width)
                {
                    currentSize.Width = contentSize.Width;
                }
            }

            if (contentAnchor != null && (contentAnchor.HasTop || contentAnchor.HasBottom))
            {
                currentSize.Height += contentSize.Height;
            }
            else
            {
                if (contentSize.Height > currentSize.Height)
                {
                    currentSize.Height = contentSize.Height;
                }
            }

            return(currentSize);
        }
示例#2
0
        /// <summary>
        /// Add the anchor informations to the element content size
        /// </summary>
        /// <returns></returns>
        public static SizeF CalculateSizeWithAnchor(SizeF contentSize, AnchorArea contentAnchor, SizeF clientSize)
        {
            if (contentAnchor == null)
            {
                return(contentSize);
            }

            if (contentAnchor.HasLeft && contentAnchor.HasRight)
            {
                if (clientSize.IsEmpty == false)
                {
                    contentSize.Width = clientSize.Width - (contentAnchor.Left + contentAnchor.Right);
                }
            }
            else if (contentAnchor.HasLeft)
            {
                contentSize.Width += contentAnchor.Left;
            }
            else if (contentAnchor.HasRight)
            {
                contentSize.Width += contentAnchor.Right;
            }

            if (contentSize.Width < 0)
            {
                contentSize.Width = 0;
            }

            if (contentAnchor.HasTop && contentAnchor.HasBottom)
            {
                if (clientSize.IsEmpty == false)
                {
                    contentSize.Height = clientSize.Height - (contentAnchor.Top + contentAnchor.Bottom);
                }
            }
            else if (contentAnchor.HasTop)
            {
                contentSize.Height += contentAnchor.Top;
            }
            else if (contentAnchor.HasBottom)
            {
                contentSize.Height += contentAnchor.Bottom;
            }

            if (contentSize.Height < 0)
            {
                contentSize.Height = 0;
            }

            return(contentSize);
        }
示例#3
0
        /// <summary>
        /// Utility function. Calculates the remaining empty area of a specified area and a given content.
        /// </summary>
        /// <param name="parentArea"></param>
        /// <param name="contentAnchor"></param>
        /// <param name="contentArea"></param>
        /// <returns></returns>
        public static RectangleF CalculateRemainingArea(RectangleF parentArea, AnchorArea contentAnchor, RectangleF contentArea)
        {
            if (contentAnchor != null)
            {
                float left, top, height, width;

                if (contentAnchor.HasTop && !contentAnchor.HasBottom)
                {
                    top    = contentArea.Bottom;
                    height = parentArea.Height - contentArea.Height;
                }
                else if (contentAnchor.HasBottom && !contentAnchor.HasTop)
                {
                    top    = parentArea.Top;
                    height = parentArea.Height - contentArea.Height;
                }
                else
                {
                    top    = parentArea.Top;
                    height = parentArea.Height;
                }

                if (contentAnchor.HasLeft && !contentAnchor.HasRight)
                {
                    left  = contentArea.Right;
                    width = parentArea.Width - contentArea.Width;
                }
                else if (contentAnchor.HasRight && !contentAnchor.HasLeft)
                {
                    left  = parentArea.Left;
                    width = parentArea.Width - contentArea.Width;
                }
                else
                {
                    left  = parentArea.Left;
                    width = parentArea.Width;
                }

                RectangleF newArea = new RectangleF(left, top, width, height);
                newArea.Intersect(parentArea);

                return(newArea);
            }
            else
            {
                return(parentArea);
            }
        }
示例#4
0
        protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize)
        {
            SizeF clienSize = new SizeF(0, 0);

            //In this case the elements are drawed one over the another so to measure I must simply take the greatest
            if (ElementsDrawMode == ElementsDrawMode.Covering)
            {
                foreach (IVisualElement element in GetElements())
                {
                    SizeF elementSize = element.Measure(measure, Size.Empty, maxSize);

                    //[email protected] : using the wrapper for CalculateSizeWithAnchor
                    //instead of directly the method, so that for MultiImagesViews
                    elementSize = CalculateContentSizeWithAnchor(elementSize, element.AnchorArea, maxSize);

                    if (elementSize.Width > clienSize.Width)
                    {
                        clienSize.Width = elementSize.Width;
                    }
                    if (elementSize.Height > clienSize.Height)
                    {
                        clienSize.Height = elementSize.Height;
                    }
                }
            }
            //In this case the elements are drawed considering an alignment, so to measure I must consider the anchor area of the element and add the size to the if the alignment is set. This code reflect the drawing code
            else if (ElementsDrawMode == ElementsDrawMode.Align)
            {
                AnchorArea previousAnchor = null;
                foreach (IVisualElement element in GetElements())
                {
                    SizeF elementSize = element.Measure(measure, Size.Empty, maxSize);

                    elementSize = CalculateContentSizeWithAnchor(elementSize, element.AnchorArea, maxSize);

                    clienSize = CalculateSizeWithContent(clienSize, previousAnchor, elementSize);

                    previousAnchor = element.AnchorArea;
                }
            }
            else
            {
                throw new ApplicationException("DrawMode not supported");
            }

            return(GetExtent(measure, clienSize));
        }
示例#5
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public CheckBoxBase()
 {
     AnchorArea = new AnchorArea(float.NaN, float.NaN, float.NaN, float.NaN, true, true);
 }
示例#6
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public SortIndicator()
 {
     AnchorArea = new AnchorArea(float.NaN, float.NaN, 0, float.NaN, false, true);
 }
示例#7
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public CheckBoxBase()
 {
     AnchorArea = new AnchorArea(float.NaN, float.NaN, float.NaN, float.NaN, true, true);
 }
示例#8
0
 /// <summary>
 /// [email protected]: Added a wrapper to the method CalculateContentSizeWithAnchor
 /// to meet the custom requirement of uigrid to have aligned contents in ElementsDrawMode.Covering. The method is overridden in
 /// MultiImageView to correct the behaviour of text alignment when it has both anchor.Left and anchor.right.
 /// </summary>
 /// <param name="contentSize"></param>
 /// <param name="contentAnchor"></param>
 /// <param name="clientSize"></param>
 /// <returns></returns>
 protected virtual SizeF CalculateContentSizeWithAnchor(SizeF contentSize, AnchorArea contentAnchor, SizeF clientSize)
 {
     return(CalculateSizeWithAnchor(contentSize, contentAnchor, clientSize));
 }
示例#9
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public RadioButtonBase()
 {
     AnchorArea = new AnchorArea(float.NaN, float.NaN, float.NaN, float.NaN, true, true);
 }
示例#10
0
        /// <summary>
        /// Add the anchor informations to the element content size
        /// </summary>
        /// <returns></returns>
        public static SizeF CalculateSizeWithAnchor(SizeF contentSize, AnchorArea contentAnchor, SizeF clientSize)
        {
            if (contentAnchor == null)
                return contentSize;

            if (contentAnchor.HasLeft && contentAnchor.HasRight)
            {
                if (clientSize.IsEmpty == false)
                    contentSize.Width = clientSize.Width - (contentAnchor.Left + contentAnchor.Right);
            }
            else if (contentAnchor.HasLeft)
                contentSize.Width += contentAnchor.Left;
            else if (contentAnchor.HasRight)
                contentSize.Width += contentAnchor.Right;

            if (contentSize.Width < 0)
                contentSize.Width = 0;

            if (contentAnchor.HasTop && contentAnchor.HasBottom)
            {
                if (clientSize.IsEmpty == false)
                    contentSize.Height = clientSize.Height - (contentAnchor.Top + contentAnchor.Bottom);
            }
            else if (contentAnchor.HasTop)
                contentSize.Height += contentAnchor.Top;
            else if (contentAnchor.HasBottom)
                contentSize.Height += contentAnchor.Bottom;

            if (contentSize.Height < 0)
                contentSize.Height = 0;

            return contentSize;
        }
示例#11
0
        /// <summary>
        /// Utility function. Calculate the required size adding using the anchor informations of the available area.
        /// </summary>
        /// <param name="currentSize"></param>
        /// <param name="contentAnchor"></param>
        /// <param name="contentSize"></param>
        /// <returns></returns>
        public static SizeF CalculateSizeWithContent(SizeF currentSize, AnchorArea contentAnchor, SizeF contentSize)
        {
            if (contentAnchor != null && (contentAnchor.HasLeft || contentAnchor.HasRight))
                currentSize.Width += contentSize.Width;
            else
            {
                if (contentSize.Width > currentSize.Width)
                    currentSize.Width = contentSize.Width;
            }

            if (contentAnchor != null && (contentAnchor.HasTop || contentAnchor.HasBottom))
                currentSize.Height += contentSize.Height;
            else
            {
                if (contentSize.Height > currentSize.Height)
                    currentSize.Height = contentSize.Height;
            }

            return currentSize;
        }
示例#12
0
        /// <summary>
        /// Utility function. Calculates the remaining empty area of a specified area and a given content.
        /// </summary>
        /// <returns></returns>
        public static RectangleF CalculateRemainingArea(RectangleF parentArea, AnchorArea contentAnchor, RectangleF contentArea)
        {
            if (contentAnchor != null)
            {
                float left, top, height, width;

                if (contentAnchor.HasTop && !contentAnchor.HasBottom)
                {
                    top = contentArea.Bottom;
                    height = parentArea.Height - contentArea.Height;
                }
                else if (contentAnchor.HasBottom && !contentAnchor.HasTop)
                {
                    top = parentArea.Top;
                    height = parentArea.Height - contentArea.Height;
                }
                else
                {
                    top = parentArea.Top;
                    height = parentArea.Height;
                }

                if (contentAnchor.HasLeft && !contentAnchor.HasRight)
                {
                    left = contentArea.Right;
                    width = parentArea.Width - contentArea.Width;
                }
                else if (contentAnchor.HasRight && !contentAnchor.HasLeft)
                {
                    left = parentArea.Left;
                    width = parentArea.Width - contentArea.Width;
                }
                else
                {
                    left = parentArea.Left;
                    width = parentArea.Width;
                }

                RectangleF newArea = new RectangleF(left, top, width, height);
                newArea.Intersect(parentArea);

                return newArea;
            }
            else
                return parentArea;
        }
示例#13
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public SortIndicator()
 {
     AnchorArea = new AnchorArea(float.NaN, float.NaN, 0, float.NaN, false, true);
 }