VekiPeki Posted January 13, 2010 Report Share Posted January 13, 2010 I am trying to implement a custom zoom solution for ChartFX, and the code looks something like this: private Point startPoint = Point.Empty;// On mouse down, save the starting pointvoid chart_MouseDownEvent(object sender, _ChartEvents_MouseDownEvent e){ startPoint = new Point(e.args.X, e.args.Y);}// On mouse up, zoom to coordinatesvoid chart_MouseUpEvent(object sender, _ChartEvents_MouseUpEvent e){ if (e.args.Button != ButtonLeft) return; // override regular functionality e.args.Handled = true; Point endPoint = new Point(e.args.X, e.args.Y); Axis xAxis = chart.AxisX; Axis yAxis = chart.AxisY; double minX = xAxis.PixelToValue(startPoint.X); double maxX = xAxis.PixelToValue(endPoint.X); double minY = yAxis.PixelToValue(startPoint.Y); double maxY = yAxis.PixelToValue(endPoint.Y); if (!axChart1.Zoom) axChart1.Zoom = true; xAxis.Zoom(Math.Min(minX, maxX), Math.Max(minX, maxX)); yAxis.Zoom(Math.Min(minY, maxY), Math.Max(minY, maxY));} The problem is that, after I handle the event, zoom selection dashed rectangle remains visible (and active as I move the mouse). I bypassed the standard functionality (I did set the Handled property to true), but it seems like it still remains in this "in-the-middle-of-zoom" mode. Does anyone have any experience with implementing custom zoom functionality? Maybe someone has encountered this before. Thanks a lot! Quote Link to comment Share on other sites More sharing options...
Frank Posted January 13, 2010 Report Share Posted January 13, 2010 By setting: e.args.Handled = true; You are preventing everything that was going to be done on that event from executing. In this case this includes clearing the flag that says the selection rectangle is vissible. In order to make this work, you also set the Handled property to true in the MouseDown event and handle the draing of the selection rectangle in your MouseMove/PostPaint event handlers. Another option is that instead of zooming-in right away when you get the call to MouseUp, let the library take its course and perform the regular zoom, then by using a timer or a PostBack message thta gets fired on MouseUp, adjust it according to your needs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.