Env.: VS2008 / Vista / .NET 2.0 / TChart 3.5.3274.30664
Hi,
My chart support zooming + a cursor tool.
When user clicks the chart, I set the cursor tool position at the mouse position.
I initially handled the click in the ClickBaground() event. But it appears that when this event is subscribed, mouse-based Zoom no longer works. Right?
So I switched to using the Click() event. Which lets zoom work but is not good yet: Click() also fires when I do a Zoom or Undo zoom. And since it fires _before_ the Zoomed() or Undone_Zoom() event, I can't filter it out.
How can I solve this issue?
TIA,
Click and Undone_Zoom events collision
-
- Newbie
- Posts: 22
- Joined: Tue Dec 16, 2008 12:00 am
Hi TIA,
Have you tried the combination of OnMouseDown and OnUndoZoom? This could be achieved by doing something like this:
Yes you are right. Enabling OnClickBackground event, the zoom is disabled.serge wautier wrote:I initially handled the click in the ClickBaground() event. But it appears that when this event is subscribed, mouse-based Zoom no longer works. Right?
Have you tried the combination of OnMouseDown and OnUndoZoom? This could be achieved by doing something like this:
Code: Select all
Points points1;
CursorTool cursor1;
bool moveCursor;
private void InitializeChart()
{
chartController1.Chart = tChart1;
tChart1.Aspect.View3D = false;
points1 = new Points(tChart1.Chart);
points1.FillSampleValues(25);
cursor1 = new CursorTool(tChart1.Chart);
moveCursor = true;
tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
}
void tChart1_UndoneZoom(object sender, EventArgs e)
{
moveCursor = true;
}
void tChart1_MouseDown(object sender, MouseEventArgs e)
{
if (moveCursor)
{
cursor1.XValue = tChart1.Axes.Bottom.CalcPosPoint(e.X);
cursor1.YValue = tChart1.Axes.Left.CalcPosPoint(e.Y);
moveCursor = false;
}
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 22
- Joined: Tue Dec 16, 2008 12:00 am
Yeray,
I'm not quite sure what the outcome of your logic would achieve.
Especially since MouseDown comes before Zoom, UndoneZoom et al.
Anyway, I found a solution based on the fact that MouseUp() is synchronous with Zoomed() and UndoneZoom() (fired during same WM_LBUTTONUP message) and fires *AFTER* Zoomed() and UndoneZoom(), as opposed to click, which fires *before* those 2.
Cheers,
Serge.
I'm not quite sure what the outcome of your logic would achieve.
Especially since MouseDown comes before Zoom, UndoneZoom et al.
Anyway, I found a solution based on the fact that MouseUp() is synchronous with Zoomed() and UndoneZoom() (fired during same WM_LBUTTONUP message) and fires *AFTER* Zoomed() and UndoneZoom(), as opposed to click, which fires *before* those 2.
Cheers,
Serge.
Hi Serge,
My code was thought to move the cursor to the start position of the zoom rectangle. Of course, it was an incomplete sample that only pretended to show you the direction of a possible solution and I'd like to apologize if I confused you.
Anyway, I'm happy to see that you found it.
My code was thought to move the cursor to the start position of the zoom rectangle. Of course, it was an incomplete sample that only pretended to show you the direction of a possible solution and I'd like to apologize if I confused you.
Anyway, I'm happy to see that you found it.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |