|
To unregister, you'll have to add a method to MouseTouchDevice.
The RegisterEvents method looks like this:
public static void RegisterEvents(FrameworkElement root)
{
root.PreviewMouseDown += MouseDown;
root.PreviewMouseMove += MouseMove;
root.PreviewMouseUp += MouseUp;
}
You'll want to add this method into the MouseTouchDevice class:
public static
void UnregisterEvents(FrameworkElement root)
{
root.PreviewMouseDown -= MouseDown;
root.PreviewMouseMove -= MouseMove;
root.PreviewMouseUp -= MouseUp;
}
If you need to know whether a click is left or right click, then you may not want to use MouseTouchDevice after all. If you must, though, then you add a property like:
public MouseDevice MouseDevice { get; private set; }
then in the MouseTouchDevice.MouseDown method, save e.MouseDevice to the property:
this.MouseDevice = e.MouseDevice;
If you wanted to only promote left mouse clicks to touch, or some other rules, you could add a check for the e.MouseDevice.LeftButton or e.MouseDevice.RightButton in the MouseDown method first. You'd have to do some testing though to make sure it behaves
as you desire if the user left clicks for touch promotion then also right clicks while the left button is still down, and other scenarios.
Hope that gives you enough information to get going!
|