private void Draw(GraphicsAPI graphics, Font font, Brush brush, string s, Rectangle r) { Point point = new Point((r.Left + r.Right) / 2, (r.Top + r.Bottom) / 2); DrawStringFormat stringFormat = this.StringFormat; Point marginOffsets = this.GetMarginOffsets(font, graphics); if (this.Alignment.Style == StringAlignment.Near) { r.Offset(marginOffsets.X, 0); } else if (this.Alignment.Style == StringAlignment.Far) { r.Offset(-marginOffsets.X, 0); } GraphicsState gstate = graphics.Save(); graphics.TranslateTransform((float)point.X, (float)point.Y); if (this.Flipped) { graphics.ScaleTransform(-1f, -1f); } graphics.TranslateTransform((float)(-point.X), (float)(-point.Y)); graphics.DrawString(s, font, brush, r, stringFormat); graphics.Restore(gstate); }
protected void Draw(GraphicsAPI graphics, Font font, Brush brush, string s, Rectangle r) { Point marginsAlignment = this.GetMarginsAlignment(font, graphics); if (this.AlignmentHorizontal.Style == StringAlignment.Near) { r.Offset(marginsAlignment.X, 0); } else if (this.AlignmentHorizontal.Style == StringAlignment.Far) { r.Offset(-marginsAlignment.X, 0); } if (this.AlignmentVertical.Style == StringAlignment.Near) { r.Offset(0, marginsAlignment.Y); } else if (this.AlignmentVertical.Style == StringAlignment.Far) { r.Offset(0, -marginsAlignment.Y); } graphics.DrawString(s, font, brush, r, this.StringFormat); }