/// <summary> /// Called before the PointerPressed event occurs. /// </summary> /// <param name="e"> /// Event data for the event. /// </param> protected override void OnPointerPressed(PointerRoutedEventArgs e) { base.OnPointerPressed(e); if (this.mouseManipulator != null) { return; } this.Focus(FocusState.Pointer); this.CapturePointer(e.Pointer); var position = e.GetCurrentPoint(this).Position; var button = this.GetMouseButton(e); var shift = (e.KeyModifiers & VirtualKeyModifiers.Shift) == VirtualKeyModifiers.Shift; var control = (e.KeyModifiers & VirtualKeyModifiers.Control) == VirtualKeyModifiers.Control; int clickCount = 1; if (MouseButtonHelper.IsDoubleClick(this, position)) { clickCount = 2; } this.mouseManipulator = this.GetManipulator(button, clickCount, shift, control); if (this.mouseManipulator != null) { this.mouseManipulator.Started(this.CreateManipulationEventArgs(e)); e.Handled = true; } e.Handled = true; }
/// <summary> /// Converts <see cref="PointerRoutedEventArgs" /> to <see cref="OxyMouseEventArgs" /> for a mouse down event. /// </summary> /// <param name="e">The <see cref="PointerRoutedEventArgs" /> instance containing the event data.</param> /// <param name="relativeTo">The <see cref="UIElement" /> that the event is relative to.</param> /// <returns>A <see cref="OxyMouseDownEventArgs" /> containing the converted event arguments.</returns> public static OxyMouseDownEventArgs ToMouseDownEventArgs(this PointerRoutedEventArgs e, UIElement relativeTo) { var point = e.GetCurrentPoint(relativeTo); int clickCount = 1; if (MouseButtonHelper.IsDoubleClick(relativeTo, point.Position)) { clickCount = 2; } return(new OxyMouseDownEventArgs { ChangedButton = point.Properties.GetPressedMouseButton(), Position = point.Position.ToScreenPoint(), ModifierKeys = e.GetModifierKeys(), ClickCount = clickCount }); }