GoDigram for .NET Framework and .NET Core
Northwoods.Go.Draw Namespace / GoRulerCursor Class
Members Example
In This Topic
    GoRulerCursor Class
    In This Topic
    Provides functionality for drawing cursors (special marks) onto a GoRuler. The Value property can be changed dynamically to have the cursor "follow" the mouse or some object in the view.
    Syntax
    public class GoRulerCursor 
    Example
    This custom-painting cursor displays as a triangle. You can install such cursors on your GoRulers by calling GoRuler.AddCursor.
    public class TriangleCursor : GoRulerCursor {
      public TriangleCursor() {
        this.Size = new Size(10, 20);
        this.ForeColor = Color.Blue;
        this.BackColor = Color.LightBlue;
      }
                
      public override void Paint(Graphics g, GoRuler ruler, float measure) {
        Pen p = new Pen(this.ForeColor, 0);
        Brush b = new SolidBrush(this.BackColor);
                
        Rectangle r = ruler.DisplayRectangle;
        float left = measure - this.Width/2.0f;
        float right = measure + this.Width/2.0f;
                
        PointF[] pts;
        if (ruler.Orientation == Orientation.Horizontal)
          pts = new PointF[] {new PointF(left, r.Y), new PointF(right, r.Y), new PointF(measure, r.Bottom)};
        else
          pts = new PointF[] {new PointF(r.X, left), new PointF(r.X, right), new PointF(r.Right, measure)};
                
        g.FillPolygon(b, pts);
        g.DrawPolygon(p, pts);
                
        b.Dispose();
        p.Dispose();
      }
    }
    See Also