Hi, All,
I’m working on an application that will display connections (lines/curves) using the canvas, between controls, on a form/panel.
(Proof of concept, learning, practicing for other migrations, not really trying to reinvent the wheel…)
The basic logic is working.
For the “Designer Mode” I would like to have the connections redraw live as a control is moved.
I have this working for control resizing, using the javascript InitScript “this.setUseResizeFrame(false);”
The speed is OK for the very few times this would be needed.
I would like to know how to have the same live events for moving a control.
So far have not found any guidance to achieve that.
I have implemented the startmove, move and endmove event handlers, but the connection redraw is only done after the move is complete.
Any advice will be appreciated.
Thanks,
Geoff
You can use the MouseMove event. Note that MouseMove is a “lazy event”- it is not fired unless you attach to it. https://docs.wisej.com/docs/controls/general/lazy-events#lazy-events
You’ll want to attach to the MouseMove event when you start moving the control (startmove) and detach when you stop moving the control (endmove). Otherwise the event will fire too often, eg when you are moving the mouse around on top of the control and not dragging it.
Code to attach to the MouseMove event for picturebox1:
this.pictureBox1.MouseMove += new Wisej.Web.MouseEventHandler(this.pictureBox1_MouseMove);
MouseMove documentation: https://docs.wisej.com/api/wisej.web/general/control#mousemove
Inside the handler for the MouseMove event (ie pictureBox1_MouseMove), call your code to draw the lines between the controls.
Hope this helps!
Julie
Hi, Julie,
Attached is the actual code, trimmed down to fit the file upload size limit.
I have confirmed that it works in this reduced form.
If you resize a control on the right side of the form, the curves will track ‘live’ – vertical is best.
I need to have the same behaviour when a control on the left side of the form is moved (resize is not implemented on the left side controls).
Thanks,
Geoff
Hello,
Can you please provide a small runnable test case that shows what you have implemented so far, so that we can better assist you?
Thanks,
Julie
Please login first to submit.