06-30-2010 08:45 AM
Hi Guys,
in my C# application I visualize an array of plots in a waveform graph, side by side. Each plot is placed in a "slot" of x-axis (see attached picture). What I want to do is drag a plot over the graph and drop it to change its position. I do this by the dodragdrop method called when the mouse down event is fired. And then, when the dragdrop event occurs, I redraw the graph, and all is ok. But, after the dodragdrop call is not possible to drag cursors and the horizontal arrow is not visible when the mouse is across the cursor. The only way to "reset" the graph functionallity is a mouse right click on the plot area.
Why this problem occur ? Any suggestion to solve it ?
Thanks in advance.
07-02-2010 09:58 AM
Hi Garraty,
are you using Measurement Studio?
Can you post a piece of code that shows the problem you see?
Thank you
Serena
07-02-2010 10:56 AM
Hi Serena,
thanks for your reply.
I'm using Measurement Studio 8.5.0.220.
The problem, I think, is in this piece of code:
private void waveformGraph_PlotAreaMouseDown(object sender, MouseEventArgs e)
{
if (waveformGraph.Plots.Count != 0)
{
.....
.....
waveformGraph.DoDragDrop(SeqWavArray[WaveformSelected], DragDropEffects.Move);
}
}
If I comment waveformGraph.DoDragDrop(....) all is ok.
On the contrary, after the execution of this instruction when the mouse is across a cursor, the horizontal arrows are not displayed.
But by a right click of he mouse, all returns ok.
Thank you for any suggestion.
Filippo
07-02-2010 11:47 AM
I must say its a tricky use of WaveformGraphs.
I am trying to imitate what you are trying to do. But I didn't quite understood the cursor part, how it is suppose to work.
Instead of the DragDrop i used mouse up to move plots from one section to the other. There is no animation but it works great for me.
Check the attached code (Form1.cs).
Let me know if this is not what you intended. Also, you could elaborate on the cursor issue that you are concerned with. That will help us in solving the issue that you are facing.
Vijet Patankar
National Instruments
07-05-2010 09:37 AM
Thanks Vijet, for your code.
It works, but I found the same problem with cursors, even if it's less visible than in my case. After selecting a plot, by moving the mouse over a cursor, the mouse cursor don't change to arrows. This occurs after a mouse click, so the problem is less visible that in my code, where I select a plot by clicking in the plot section and not only in the plot.
See the attached print screen obtained with your code, before a selection and after a selection (but without any mouse click after the selection).
Thanks in advance.
Filippo
07-06-2010 01:33 AM
Hi there,
I still have couple of doubts and some suggestions. Let me know if I understood the problem correctly.
I hope this helps. If you still have concerns, feel free to reply. It would be great if you write down step-by-step actions to be performed to re-produce the issue. By step-by-step I mean, something like,
1) The graph has X sections with Y number of sections filled with plots.
1) Click on a section with plot (not on the XYCursor) to select a plot.
2) Without releasing the mouse button, move the mouse to XYCursor on another section...
3) ....
Vijet Patankar
National Instruments
07-06-2010 03:39 AM
Hi,
sorry for my explanation not very clear and thanks for your patience.
The problem is that you are described in your first point, but by relaising the mouse button after selecting a plot.
Step by step:
1) The graph has X sections filled with X plots. Each section is separated from the next section by a XYCursor
2) Click on a section with plot (not on the XYCursor) to select a plot and realease the mouse button.
3) Move the mouse over whatever XYCursor (either over horizontal or vertical cursor line or both) and the mouse cursor wont change to horizontal arrow (or vertical arrow)
4) Click on the graph, but not on a section with plot, to return to a normal behaviour (in your code is sufficient to click not on a plot)
I hope that now is more clear. However, I will make a short version of my project to post it.
Filippo
07-06-2010 04:56 AM
In attachement, there is a short version of my project with 10 plots.
I now realize that to return to a normal behaviour is sufficient to press Control or Shift key(that changes the default interaction mode) or also to change the active window and then return to the apllication window. Also if I debug with a breakpoint in the DragDrop event code, the behaviour is correct.
What I think is that when the DoDragDrop instruction is executed the drag doesn't terminate, also after the execution of DragDrop event. It seems instead, it's terminate, for example, by pressing Control key. Is it possible to terminate programmatically the drag action ?
Filippo
07-08-2010 08:44 AM
Hi Filippo,
The culprit is the DoDragDrop() method. It consumes MouseUp and MouseMove events, meaning MouseUP and MouseMove events are not fired if drag drop is being used. This is not a bug, but thats is how .NET controls work (you can check this behavior with button control).
Internally the XYCursor listens to mouseMove and mouseUp events, but they are not raised because of the DoDragDrop() method. Because of this, the XYCursor are behaving unexpectedly.
However, I modified your code and got this. I did not use XYCursor in the code.
Hope this helps.
Vijet Patankar
National Instruments
07-15-2010 10:35 AM
Hi Vijet,
thank for your code: with few small modifications it's ok for me.
Thank a lot.
Filippo