Beispiel #1
0
        protected override Size GetRequiredSize(string s, Font font, int width, GraphicsAPI graphics)
        {
            Point marginsAlignment = base.GetMarginsAlignment(font, graphics);
            Size  size             = (!this.NoClip) ? graphics.MeasureString(s, font, true, width) : graphics.MeasureString(s, font, true, 0);

            return(new Size(size.Width + marginsAlignment.X + 1, size.Height + marginsAlignment.Y + 1));
        }
Beispiel #2
0
        protected virtual Size GetRequiredSize(string s, Font font, int width, GraphicsAPI graphics)
        {
            Point marginsAlignment = this.GetMarginsAlignment(font, graphics);
            Size  size             = graphics.MeasureString(s, font, true, width);

            return(new Size(size.Width + marginsAlignment.X + 1, size.Height + marginsAlignment.Y + 1));
        }
        private Size GetRequiredSize(string s, Font font, GraphicsAPI graphics)
        {
            Point marginOffsets = this.GetMarginOffsets(font, graphics);
            Size  size          = graphics.MeasureString(s, font, true);

            return(new Size(size.Width + marginOffsets.X, size.Height + marginOffsets.Y));
        }
Beispiel #4
0
        protected Point GetMarginsAlignment(Font font, GraphicsAPI graphics)
        {
            Size size = graphics.MeasureString("0", font, true);
            int  x    = (this.AlignmentHorizontal.Style != StringAlignment.Center) ? ((int)Math.Ceiling((double)size.Width * this.AlignmentHorizontal.Margin)) : 0;
            int  y    = (this.AlignmentVertical.Style != StringAlignment.Center) ? ((int)Math.Ceiling((double)size.Height * this.AlignmentVertical.Margin)) : 0;

            return(new Point(x, y));
        }
Beispiel #5
0
        protected Rectangle GetRectangle(string s, Point pt, Font font, GraphicsAPI graphics)
        {
            Point marginsAlignment = this.GetMarginsAlignment(font, graphics);
            Size  size             = graphics.MeasureString(s, font, true);

            size = new Size(size.Width + 1, size.Height + 1);
            int left = (this.AlignmentHorizontal.Style != 0) ? ((this.AlignmentHorizontal.Style != StringAlignment.Far) ? (pt.X - size.Width / 2) : (pt.X + marginsAlignment.X)) : (pt.X - marginsAlignment.X - size.Width);
            int top  = (this.AlignmentVertical.Style != 0) ? ((this.AlignmentVertical.Style != StringAlignment.Far) ? (pt.Y - size.Height / 2) : (pt.Y + marginsAlignment.Y)) : (pt.Y - marginsAlignment.Y - size.Height);

            return(iRectangle.FromLTWH(left, top, size.Width, size.Height));
        }
        private Point GetMarginOffsets(Font font, GraphicsAPI graphics)
        {
            int x = (int)Math.Ceiling((double)graphics.MeasureString("0", font, true).Width *this.Alignment.Margin);

            return(new Point(x, 0));
        }