Exemple #1
0
 public void Draw(Graphics g)
 {
     if (graphBitmap == null)
     {
         return;
     }
     if (hoverXValue.HasValue && hoverXValue.Value >= graph.XAxisMinValue && hoverXValue.Value <= graph.XAxisMaxValue)
     {
         Graphics hoverGraphics = Graphics.FromImage(hoverBitmap);
         hoverGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
         hoverGraphics.Clear(BackColor);
         hoverGraphics.DrawImage(graphBitmap, 0, 0);
         PointF centerF = new PointF(graph.ValueToX(hoverXValue.Value),
                                     graph.ValueToY(graph.GetYValueFromXValue(hoverXValue.Value)));
         Point center = new Point((int)centerF.X, (int)centerF.Y);
         center.Y = Math.Max(graph.GraphDrawingRectangle.Top, Math.Min(graph.GraphDrawingRectangle.Bottom, center.Y));
         SizeF      size = new SizeF(10, 10);
         RectangleF rect = new RectangleF(center.X - size.Width / 2, center.Y - size.Height / 2, size.Width, size.Height);
         hoverGraphics.DrawLine(haircrossPen, center, new Point(center.X, graph.GraphDrawingRectangle.Bottom));
         hoverGraphics.DrawLine(haircrossPen, new Point(graph.GraphDrawingRectangle.Left, center.Y), new Point(graph.GraphDrawingRectangle.Right, center.Y));
         haircrossMarker.Draw(hoverGraphics, new PointD(center.X, center.Y), 1);
         g.DrawImage(hoverBitmap, 0, 0);
         hoverGraphics.Dispose();
     }
     else
     {
         g.DrawImage(graphBitmap, new Point(0, 0));
     }
 }