/// <summary> /// Gets the rectangle of object in screen coordinates /// </summary> /// <param name="g">Current Graphics object, use it for MeasureStringWidth or something else</param> /// <param name="view_scale">Current view scale of chart</param> public virtual RectangleF GetScreenRect(Graphics g, double view_scale) { var rr = GetRealRect(g, view_scale); var lb = Chart.ToScreenPoint(new DPoint(rr.X, rr.Y)); var sz = Chart.ToScreenSize(new DSize(rr.Width, rr.Height)); return(new RectangleF(lb.X, lb.Y, sz.Width, sz.Height)); }
/// <summary> /// Draw text on the center of rect object /// </summary> /// <param name="g">Graphics object to draw string</param> /// <param name="text">Text to draw on object</param> protected virtual void DrawStringCenter(Graphics g, string text) { if (text != null && text != string.Empty) { var c = Chart.ToScreenPoint(Center); var tsz = g.MeasureString(text, Font); g.DrawString(text, Font, TextBrush, c.X - tsz.Width / 2, c.Y - tsz.Height / 2); } }