Set a cursor in pre-connecting a wire

Hello, all.

I want to draw a wire like what Galapagos has.
My poor skill doesn’t enable even a small part of drawing it.
Now I need your help in setting a cursor to connect a wire.

I wrote code to draw it through subscribing events of the canvas as follows:

        protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
        {
            canvas.MouseMove -= this.Canvas_MouseMove;
            canvas.KeyDown -= this.Canvas_KeyDown;
            canvas.KeyUp -= this.Canvas_KeyUp;
            canvas.MouseMove += this.Canvas_MouseMove;
            canvas.KeyDown += this.Canvas_KeyDown;
            canvas.KeyUp += this.Canvas_KeyUp;

            base.Render(canvas, graphics, channel);
        }

First, when distance between a cursor and my custom grip point is smaller than 10, the cursor is attached.

        protected virtual void Canvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (!(sender is GH_Canvas))
                return;

            GH_Canvas canvas = (GH_Canvas)sender;

            Point cursorInPretenseCanvas = e.Location - (Size)canvas.Viewport.Target;
            PointF cursorInZoomCanvas = new PointF(cursorInPretenseCanvas.X / canvas.Viewport.Zoom, cursorInPretenseCanvas.Y / canvas.Viewport.Zoom);
            PointF grip = new PointF((this.Bounds.Left + this.Bounds.Right) / 2, this.Bounds.Bottom);
            double distance = Math.Sqrt(Math.Pow(grip.X - cursorInZoomCanvas.X, 2) + Math.Pow(grip.Y - cursorInZoomCanvas.Y, 2));

            if (distance < 10)
            {
                if(this.CursorName == null)
                    this.CursorName = "GH_NewWire";
                Instances.CursorServer.AttachCursor(canvas, this.CursorName);
            }
        }

Second, I want the ShiftKey and the ControlKey change a cursor type.
The CursorName property remembers which key I put down.

        protected virtual void Canvas_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyCode == Keys.ShiftKey)
                this.CursorName = "GH_AddWire";
            else if(e.KeyCode == Keys.ControlKey)
                this.CursorName = "GH_RemoveWire";
        }
        protected virtual void Canvas_KeyUp(object sender, KeyEventArgs e)
        {
            this.CursorName = "GH_NewWire";
        }
        public string CursorName { get; set; }

This code enables change a cursor type when no keys are put, but otherwise it works oddly.

I attach a file of full code.
CompWireAttributes.cs (2.2 KB)

Regards,