public static RectangleD AlignSizeInRect(RectangleD rect, SizeD size, StiHorAlignment horAlignment, StiVertAlignment vertAlignment)
        {
            double x = 0;
            double y = 0;

            if (horAlignment == StiHorAlignment.Left)
            {
                x = rect.X;
            }
            if (horAlignment == StiHorAlignment.Center)
            {
                x = rect.X + (rect.Width - size.Width) / 2;
            }
            if (horAlignment == StiHorAlignment.Right)
            {
                x = rect.Right - size.Width;
            }

            if (vertAlignment == StiVertAlignment.Top)
            {
                y = rect.Y;
            }
            if (vertAlignment == StiVertAlignment.Center)
            {
                y = rect.Y + (rect.Height - size.Height) / 2;
            }
            if (vertAlignment == StiVertAlignment.Bottom)
            {
                y = rect.Bottom - size.Height;
            }

            return(new RectangleD(x, y, size.Width, size.Height));
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the StiRange class with the specified location and size.
 /// </summary>
 public StiRange(string text, SizeD size, bool newLineForm)
 {
     this.Pos         = new PointD(0, 0);
     this.Text        = text;
     this.Size        = size;
     this.Line        = 0;
     this.IsStart     = false;
     this.IsEnd       = false;
     this.NewLineForm = newLineForm;
 }
        public static RectangleD AlignSizeInRect(RectangleD rect, SizeD size, ContentAlignment alignment)
        {
            double x = 0;
            double y = 0;

            if (alignment == ContentAlignment.BottomLeft ||
                alignment == ContentAlignment.MiddleLeft ||
                alignment == ContentAlignment.TopLeft)
            {
                x = rect.X;
            }

            if (alignment == ContentAlignment.BottomCenter ||
                alignment == ContentAlignment.MiddleCenter ||
                alignment == ContentAlignment.TopCenter)
            {
                x = rect.X + (rect.Width - size.Width) / 2;
            }

            if (alignment == ContentAlignment.BottomRight ||
                alignment == ContentAlignment.MiddleRight ||
                alignment == ContentAlignment.TopRight)
            {
                x = rect.Right - size.Width;
            }

            if (alignment == ContentAlignment.TopLeft ||
                alignment == ContentAlignment.TopCenter ||
                alignment == ContentAlignment.TopRight)
            {
                y = rect.Y;
            }

            if (alignment == ContentAlignment.MiddleLeft ||
                alignment == ContentAlignment.MiddleCenter ||
                alignment == ContentAlignment.MiddleRight)
            {
                y = rect.Y + (rect.Height - size.Height) / 2;
            }

            if (alignment == ContentAlignment.BottomLeft ||
                alignment == ContentAlignment.BottomCenter ||
                alignment == ContentAlignment.BottomRight)
            {
                y = rect.Bottom - size.Height;
            }

            return(new RectangleD(x, y, size.Width, size.Height));
        }