private void DrawText(FRPaintEventArgs e, string text, Brush brush, float x, float y, HorAlign hAlign, VertAlign vAlign) { Graphics g = e.Graphics; Font font = RadialUtils.GetFont(e, Parent, Font); SizeF strSize = RadialUtils.GetStringSize(e, Parent, Font, text); float dx = 0; float dy = 0; if (hAlign == HorAlign.Middle) { dx = -strSize.Width / 2; } else if (hAlign == HorAlign.Left) { dx = 0; } else if (hAlign == HorAlign.Right) { dx = -strSize.Width; } if (vAlign == VertAlign.Bottom) { dy = -strSize.Height; } else if (vAlign == VertAlign.Middle) { dy = -strSize.Height / 2; } else if (vAlign == VertAlign.Top) { dy = 0; } g.DrawString(text, font, brush, x + dx, y + dy); }
public override void Draw(FRPaintEventArgs e) { if ((Parent as RadialGauge).Type == RadialGaugeType.Circle) { base.Draw(e); float x = (Parent.AbsLeft + Parent.Border.Width / 2) * e.ScaleX; float y = (Parent.AbsTop + Parent.Border.Width / 2) * e.ScaleY; float dx = (Parent.Width - Parent.Border.Width) * e.ScaleX - 1; float dy = (Parent.Height - Parent.Border.Width) * e.ScaleY - 1; PointF lblPt = new PointF(x + dx / 2, y + dy - ((Parent.Scale as RadialScale).AvrTick.Y - y)); SizeF txtSize = RadialUtils.GetStringSize(e, Parent, Font, Text); Font font = RadialUtils.GetFont(e, Parent, Font); Brush brush = e.Cache.GetBrush(Color); e.Graphics.DrawString(Text, font, brush, lblPt.X - txtSize.Width / 2, lblPt.Y - txtSize.Height / 2); } }