This is a migrated thread and some comments may be shown as answers.

PanAndZoomBehavior Mouse Buttons

3 Answers 32 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 1
Markus asked on 29 Oct 2013, 07:38 AM
Hi,
is it possible to put the zoom behavior on the right mouse button and the pan behavior on the center mouse button?

Regards Markus

3 Answers, 1 is accepted

Sort by
0
Markus
Top achievements
Rank 1
answered on 30 Oct 2013, 06:50 AM
Hi,
now I have this:

private const UInt32 MouseEventLeftDown = 0x0002;
private const UInt32 MouseEventLeftUp = 0x0004;
[DllImport("user32", EntryPoint = "mouse_event")]
private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, UInt32 dwExtraInfo);
 
private void chartView_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
 if (e.ChangedButton == System.Windows.Input.MouseButton.Middle)
 {
  PanAndZoom.DragMode = ChartDragMode.Pan;
  mouse_event(MouseEventLeftDown, 0, 0, 0, 0);
 }
}
 
private void chartView_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
 if (e.ChangedButton == System.Windows.Input.MouseButton.Middle)
 {
  mouse_event(MouseEventLeftUp, 0, 0, 0, 0);      
  PanAndZoom.DragMode = ChartDragMode.Zoom;   
 }
}

When I press the middle mouse button the chart is successfully panning. But when I release it there is also a zoom. Why?

Regards Markus
0
Petar Marchev
Telerik team
answered on 30 Oct 2013, 12:24 PM
Hello Markus,

The most likely reason for this is that the mouse wheel is rotated and the MouseWheel event is raised, which in turn zooms the chart in and out. You can change this by setting the MouseWheelMode property of the ChartPanAndZoomBehavior.

Regards,
Petar Marchev
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Markus
Top achievements
Rank 1
answered on 30 Oct 2013, 12:34 PM
Hi,
I noticed that when I release the button, the zoom mode is activated for a bit. So I'm zooming in. Workaround for this is:

[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
 
private void chartView_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
 if (e.ChangedButton == System.Windows.Input.MouseButton.Middle)
 {
  mouse_event(MouseEventLeftUp, 0, 0, 0, 0);      
  PanAndZoom.DragMode = ChartDragMode.Zoom;
  ReleaseCapture();
 }
}

With the ReleaseCapture set, there is no zooming.

Regards Markus
Tags
ChartView
Asked by
Markus
Top achievements
Rank 1
Answers by
Markus
Top achievements
Rank 1
Petar Marchev
Telerik team
Share this question
or