System.Drawing.RectangleF.FromLTRB C# (CSharp) Method

FromLTRB() public static method

Creates a new with the specified location and size.

public static FromLTRB ( float left, float top, float right, float bottom ) : RectangleF
left float
top float
right float
bottom float
return RectangleF
        public static RectangleF FromLTRB(float left, float top, float right, float bottom) =>
            new RectangleF(left, top, right - left, bottom - top);

Same methods

RectangleF::FromLTRB ( float left, float top, float right, float bottom ) : System.Drawing.RectangleF

Usage Example

Example #1
0
        // Re-calculate the extents of a region
        private static void CalculateExtents(Region reg)
        {
            if (reg.rects.Length == 0)
            {
                reg.extent = RectangleF.Empty;
                return;
            }

            /* Since rectStart is the first rectangle in the region, it must have the
             * smallest top and since rectEnd is the last rectangle in the region,
             * it must have the largest bottom, because of banding.
             */
            RectangleF rectStart = reg.rects[0];
            float      left      = rectStart.Left;
            float      top       = rectStart.Top;
            RectangleF rectEnd   = reg.rects[reg.rects.Length - 1];
            float      right     = rectEnd.Right;
            float      bottom    = rectEnd.Bottom;

            for (int i = 0; i < reg.rects.Length; i++)
            {
                RectangleF rect = reg.rects[i];
                if (rect.Left < left)
                {
                    left = rect.Left;
                }
                if (rect.Right > right)
                {
                    right = rect.Right;
                }
            }
            reg.extent = RectangleF.FromLTRB(left, top, right, bottom);
        }
All Usage Examples Of System.Drawing.RectangleF::FromLTRB