We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

MouseDrag Zooming with Right Mouse Button

Thread ID:

Created:

Updated:

Platform:

Replies:

116961 Jul 10,2014 02:40 PM Jul 16,2014 08:26 AM WPF 4
loading
Tags: Chart
Kevin Kuebler
Asked On July 10, 2014 02:40 PM

We have a WPF application using the chart control where we want to use the EnableMouseDragZooming feature, but we want it to be bound to the right mouse button instead of the left mouse button (we have some other custom logic bound to the left button). Does anybody know if this is possible?

We actually have a source code license and have modified the code for the chart to do this in the past (on v 8 of the controls) but we are now updating to the latest (v 12.1) and would like to avoid having to modify the source again. Is there a built-in way to support this, or can someone think of a way to achieve it through the public API without having to modify the chart control's source?

Thanks,
Kevin Kuebler

Karthikeyan V [Syncfusion]
Replied On July 14, 2014 11:09 PM

Hi kelvin,

Thanks for using the Syncfusion products.

We have analysed the reported query. We would like to inform you that the requirement achieved by workaround in sample. Please find the sample under the following location. And we do not have any public API to custom the left and right mouse sector zooming.

Please let us know if you require further assistance on this.

Thanks,

Karthikeyan V.


Attachment: ZoomingWithRightButton_b597fa05.zip

Kevin Kuebler
Replied On July 15, 2014 09:44 AM

Hi Karthikeyan,

Thank you for your response and the sample! The right mouse button drag/zooming behavior in the sample works perfectly. However, the left mouse button still invokes the zooming also. Is there a way to disable the left mouse button from invoking the zoom behavior while still using the right button as you have shown in the sample? I tried setting EnableMouseDragZooming = False, which had the effect of preventing the left button from zooming, while the right button would still draw the zoom rectangle but it would not actually invoke the zoom on mouse up.

The reason we want to do this is because we have our own custom behavior that we want to associate with the left mouse button. Thanks again for your help!

Kevin

Kevin Kuebler
Replied On July 15, 2014 10:04 AM

Okay, so I was able to make this work. I have the right mouse zooming behavior from your sample working while also disabling the standard left mouse button behavior. I did this by setting EnableMouseDragZooming to false on the control in the XAML, then in the MouseUp handler I set it to true right before calling ZoomSector.Execute then set it back to false right after the call. I also have to reset the start and end points after the zoom, otherwise a drag with the left button will invoke a zoom if the right button behavior has been used at least once. The code looks like this:

m_chartArea.EnableMouseDragZooming = true;
ChartAreaCommands.ZoomSector.Execute(rect, m_chartArea);
m_chartArea.EnableMouseDragZooming = false;
m_startZoomBarPoint = new Point();
m_endZoomBarPoint = new Point();

So, it's a bit of a hack, but it works. :-)  Let me know if there is a better way to do this, but if not this solution will work for me. Thanks!

Kevin

Karthikeyan V [Syncfusion]
Replied On July 16, 2014 08:26 AM

Hi Kelvin,

Thank for the update.

We have analysed the reported requirement. We have checked your code that the code is also best way to achieve your requirement. But we are suggesting one more solution for this requirement in below code. Please find the code snippet under the following location.

Code Snippet [C#]:

bool isLeftZooming = false;

 

private void area_MouseDown(object sender, MouseButtonEventArgs e)

{

        ChartArea area = sender as ChartArea;

        if (e.ChangedButton == MouseButton.Left && !area.AllowSegmentDragDrop)

        {

            area.AllowSegmentDragDrop = true;

            isLeftZooming = true;

        }

       …….

}

private void area_MouseMove(object sender, MouseEventArgs e)

{

       ChartArea area = sender as ChartArea;

       if (e.LeftButton == MouseButtonState.Pressed && isLeftZooming)

       {

            area.AllowSegmentDragDrop = false;

            isLeftZooming = false;

       }

………

} 

private void area_MouseUp(object sender, MouseButtonEventArgs e)

{

        ChartArea m_chartArea = sender as ChartArea;

        if (e.ChangedButton == MouseButton.Left)

        {

             isLeftZooming = false;

        }

…..

} 

Please let us know if you require further assistance on this.

Thanks,

Karthikeyan V.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;