/// <summary> /// Invoked when an unhandled MouseUp routed event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. /// </summary> /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs" /> that contains the event data. The event data reports that the mouse button was released.</param> protected override void OnPointerReleased(PointerEventArgs e) { base.OnPointerReleased(e); if (e.Handled) { return; } var releasedArgs = (PointerReleasedEventArgs)e; MouseDevice.Instance.Capture(null); e.Handled = ActualController.HandleMouseUp(this, releasedArgs.ToMouseReleasedEventArgs(this)); // Open the context menu var p = e.GetPosition(this).ToScreenPoint(); var d = p.DistanceTo(mouseDownPoint); if (ContextMenu != null) { if (Math.Abs(d) < 1e-8 && releasedArgs.MouseButton == MouseButton.Right) { ContextMenu.DataContext = DataContext; ContextMenu.IsVisible = true; } else { ContextMenu.IsVisible = false; } } }
/// <summary> /// Called on mouse move events. /// </summary> /// <param name="args">An instance that contains the event data.</param> protected override void OnMouseMoved(MouseMovedEventArgs args) { base.OnMouseMoved(args); if (args.Handled) { return; } if (ShowDynamicTooltips) { string tooltip = null; var hitArgs = new HitTestArguments(new ScreenPoint(args.X, args.Y), MouseHitTolerance); foreach (var result in ActualModel.HitTest(hitArgs)) { var plotElement = result.Element as PlotElement; if (plotElement != null && !String.IsNullOrEmpty(plotElement.ToolTip)) { tooltip = String.IsNullOrEmpty(tooltip) ? plotElement.ToolTip : tooltip + Environment.NewLine + plotElement.ToolTip; } } TooltipText = tooltip; } args.Handled = ActualController.HandleMouseMove(this, args.ToOxyMouseEventArgs()); }
/// <summary> /// Invoked when an unhandled MouseUp routed event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. /// </summary> /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs" /> that contains the event data. The event data reports that the mouse button was released.</param> protected override void OnPointerReleased(PointerReleasedEventArgs e) { base.OnPointerReleased(e); if (e.Handled) { return; } var releasedArgs = (PointerReleasedEventArgs)e; ((TopLevel)this.VisualRoot).PlatformImpl.MouseDevice.Capture(null); e.Handled = ActualController.HandleMouseUp(this, releasedArgs.ToMouseReleasedEventArgs(this)); // Open the context menu var p = e.GetPosition(this).ToScreenPoint(); var d = p.DistanceTo(mouseDownPoint); if (ContextMenu != null) { if (Math.Abs(d) < 1e-8 && releasedArgs.GetCurrentPoint(this).Properties.IsRightButtonPressed) { ContextMenu.DataContext = DataContext; ContextMenu.IsVisible = true; } else { ContextMenu.IsVisible = false; } } }
private void HandleTapGesture() { var location = tapGesture.LocationInView(this); ActualController.HandleTouchStarted(this, location.ToTouchEventArgs()); ActualController.HandleTouchCompleted(this, location.ToTouchEventArgs()); }
/// <summary> /// Called on KeyPress event. /// </summary> /// <param name="args">An instance that contains the event data.</param> protected override void OnKeyPressed(KeyEventArgs args) { base.OnKeyPressed(args); if (args.Handled) { return; } args.Handled = ActualController.HandleKeyDown(this, args.ToOxyKeyEventArgs()); }
/// <summary> /// Called when the mouse wheel is scrolled. /// </summary> /// <param name="args">An instance that contains the event data.</param> protected override void OnMouseScrolled(MouseScrolledEventArgs args) { base.OnMouseScrolled(args); if (args.Handled) { return; } args.Handled = ActualController.HandleMouseWheel(this, args.ToOxyMouseWheelEventArgs()); }
/// <summary> /// Called when the mouse button is released. /// </summary> /// <param name="args">An instance that contains the event data.</param> protected override void OnButtonReleased(ButtonEventArgs args) { base.OnButtonReleased(args); if (args.Handled) { return; } args.Handled = ActualController.HandleMouseUp(this, args.ToOxyMouseUpEventArgs()); }
/* * /// <summary> * /// Called when the <see cref="E:System.Windows.UIElement.ManipulationStarted" /> event occurs. * /// </summary> * /// <param name="e">The data for the event.</param> * protected override void OnManipulationStarted(ManipulationStartedEventArgs e) * { * base.OnManipulationStarted(e); * if (e.Handled) * { * return; * } * * e.Handled = ActualController.HandleTouchStarted(this, e.ToTouchEventArgs(this)); * } * * /// <summary> * /// Called when the <see cref="E:System.Windows.UIElement.ManipulationDelta" /> event occurs. * /// </summary> * /// <param name="e">The data for the event.</param> * protected override void OnManipulationDelta(ManipulationDeltaEventArgs e) * { * base.OnManipulationDelta(e); * if (e.Handled) * { * return; * } * * e.Handled = ActualController.HandleTouchDelta(this, e.ToTouchEventArgs(this)); * } * * /// <summary> * /// Called when the <see cref="E:System.Windows.UIElement.ManipulationCompleted" /> event occurs. * /// </summary> * /// <param name="e">The data for the event.</param> * protected override void OnManipulationCompleted(ManipulationCompletedEventArgs e) * { * base.OnManipulationCompleted(e); * if (e.Handled) * { * return; * } * * e.Handled = ActualController.HandleTouchCompleted(this, e.ToTouchEventArgs(this)); * } */ /// <summary> /// Called before the <see cref="E:System.Windows.UIElement.MouseWheel" /> event occurs to provide handling for the event in a derived class without attaching a delegate. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Input.MouseWheelEventArgs" /> that contains the event data.</param> protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { base.OnPointerWheelChanged(e); if (e.Handled || !IsMouseWheelEnabled) { return; } e.Handled = ActualController.HandleMouseWheel(this, e.ToMouseWheelEventArgs(this)); }
/// <summary> /// Invoked when an unhandled <see cref="E:System.Windows.Input.Mouse.MouseLeave" /> attached event is raised on this element. Implement this method to add class handling for this event. /// </summary> /// <param name="e">The <see cref="T:System.Windows.Input.MouseEventArgs" /> that contains the event data.</param> protected override void OnPointerLeave(PointerEventArgs e) { base.OnPointerLeave(e); if (e.Handled) { return; } e.Handled = ActualController.HandleMouseLeave(this, e.ToMouseEventArgs(this)); }
protected override bool OnKey(SciterElement se, SciterXBehaviors.KEY_PARAMS prms) { if (prms.cmd == (uint)SciterXBehaviors.KEY_EVENTS.KEY_DOWN) { Keys key = (Keys)prms.key_code; var args = new OxyKeyEventArgs { ModifierKeys = prms.alt_state.GetModifiers(), Key = key.Convert() }; return(ActualController.HandleKeyDown(this, args)); } return(false); }
/// <summary> /// Invoked when an unhandled MouseUp routed event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. /// </summary> /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs" /> that contains the event data. The event data reports that the mouse button was released.</param> protected override void OnPointerReleased(PointerReleasedEventArgs e) { base.OnPointerReleased(e); if (e.Handled) { return; } e.Pointer.Capture(null); if (e.Pointer.Type == PointerType.Touch) { var position = e.GetPosition(this).ToScreenPoint(); var touchEventArgs = new OxyTouchEventArgs() { ModifierKeys = e.KeyModifiers.ToModifierKeys(), Position = position, DeltaTranslation = new ScreenVector(0, 0), DeltaScale = new ScreenVector(1, 1), }; TouchPositions.Remove(e.Pointer.Id); if (TouchPositions.Count == 0) { e.Handled = ActualController.HandleTouchCompleted(this, touchEventArgs); } } else { e.Handled = ActualController.HandleMouseUp(this, e.ToMouseReleasedEventArgs(this)); // Open the context menu var p = e.GetPosition(this).ToScreenPoint(); var d = p.DistanceTo(mouseDownPoint); if (ContextMenu != null) { if (Math.Abs(d) < 1e-8 && e.InitialPressMouseButton == MouseButton.Right) { ContextMenu.DataContext = DataContext; ContextMenu.IsVisible = true; } else { ContextMenu.IsVisible = false; } } } }
/// <summary> /// Called before the <see cref="E:System.Windows.UIElement.KeyDown" /> event occurs. /// </summary> /// <param name="e">The data for the event.</param> protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); if (e.Handled) { return; } var args = new OxyKeyEventArgs { ModifierKeys = e.Modifiers.ToModifierKeys(), Key = e.Key.Convert() }; e.Handled = ActualController.HandleKeyDown(this, args); }
/// <summary> /// Invoked when an unhandled MouseDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. /// </summary> /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs" /> that contains the event data. This event data reports details about the mouse button that was pressed and the handled state.</param> protected override void OnPointerPressed(PointerPressedEventArgs e) { base.OnPointerPressed(e); if (e.Handled) { return; } Focus(); MouseDevice.Instance.Capture(this); // store the mouse down point, check it when mouse button is released to determine if the context menu should be shown mouseDownPoint = e.GetPosition(this).ToScreenPoint(); e.Handled = ActualController.HandleMouseDown(this, e.ToMouseDownEventArgs(this)); }
private void HandlePanZoomGesture() { switch (panZoomGesture.State) { case UIGestureRecognizerState.Began: ActualController.HandleTouchStarted(this, panZoomGesture.TouchEventArgs); break; case UIGestureRecognizerState.Changed: ActualController.HandleTouchDelta(this, panZoomGesture.TouchEventArgs); break; case UIGestureRecognizerState.Ended: case UIGestureRecognizerState.Cancelled: ActualController.HandleTouchCompleted(this, panZoomGesture.TouchEventArgs); break; } }
/// <summary> /// Invoked when an unhandled MouseDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. /// </summary> /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs" /> that contains the event data. This event data reports details about the mouse button that was pressed and the handled state.</param> protected override void OnPointerPressed(PointerPressedEventArgs e) { base.OnPointerPressed(e); if (e.Handled) { return; } Focus(); e.Pointer.Capture(this); if (e.Pointer.Type == PointerType.Touch) { var position = e.GetPosition(this).ToScreenPoint(); var touchEventArgs = new OxyTouchEventArgs() { ModifierKeys = e.KeyModifiers.ToModifierKeys(), Position = position, DeltaTranslation = new ScreenVector(0, 0), DeltaScale = new ScreenVector(1, 1), }; TouchPositions[e.Pointer.Id] = position; if (TouchPositions.Count == 1) { e.Handled = ActualController.HandleTouchStarted(this, touchEventArgs); } } else { // store the mouse down point, check it when mouse button is released to determine if the context menu should be shown mouseDownPoint = e.GetPosition(this).ToScreenPoint(); e.Handled = ActualController.HandleMouseDown(this, e.ToMouseDownEventArgs(this)); } }
/// <summary> /// Invoked when an unhandled MouseMove attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. /// </summary> /// <param name="e">The <see cref="T:System.Windows.Input.MouseEventArgs" /> that contains the event data.</param> protected override void OnPointerMoved(PointerEventArgs e) { base.OnPointerMoved(e); if (e.Handled) { return; } if (e.Pointer.Type == PointerType.Touch) { var point = e.GetPosition(this).ToScreenPoint(); var oldTouchPoints = TouchPositions.Values.ToArray(); TouchPositions[e.Pointer.Id] = point; var newTouchPoints = TouchPositions.Values.ToArray(); var touchEventArgs = new OxyTouchEventArgs(newTouchPoints, oldTouchPoints); e.Handled = ActualController.HandleTouchDelta(this, touchEventArgs); } else { e.Handled = ActualController.HandleMouseMove(this, e.ToMouseEventArgs(this)); } }
/// <summary> /// Called when the mouse leaves the widget. /// </summary> /// <param name="args">An instance that contains the event data.</param> protected override void OnMouseExited(EventArgs args) { base.OnMouseExited(args); ActualController.HandleMouseLeave(this, new OxyMouseEventArgs()); }
protected override bool OnMouse(SciterElement se, SciterXBehaviors.MOUSE_PARAMS prms) { switch (prms.cmd) { case SciterXBehaviors.MOUSE_EVENTS.MOUSE_ENTER: ActualController.HandleMouseEnter(this, new OxyMouseEventArgs { Position = new ScreenPoint(prms.pos.X, prms.pos.Y), ModifierKeys = prms.alt_state.GetModifiers() }); break; case SciterXBehaviors.MOUSE_EVENTS.MOUSE_LEAVE: ActualController.HandleMouseLeave(this, new OxyMouseEventArgs { Position = new ScreenPoint(prms.pos.X, prms.pos.Y), ModifierKeys = prms.alt_state.GetModifiers() }); break; case SciterXBehaviors.MOUSE_EVENTS.MOUSE_MOVE: ActualController.HandleMouseMove(this, new OxyMouseEventArgs { Position = new ScreenPoint(prms.pos.X, prms.pos.Y), ModifierKeys = prms.alt_state.GetModifiers() }); break; case SciterXBehaviors.MOUSE_EVENTS.MOUSE_DCLICK: case SciterXBehaviors.MOUSE_EVENTS.MOUSE_DOWN: OxyMouseButton button = OxyMouseButton.None; switch (prms.button_state) { case (uint)SciterXBehaviors.MOUSE_BUTTONS.MAIN_MOUSE_BUTTON: button = OxyMouseButton.Left; break; case (uint)SciterXBehaviors.MOUSE_BUTTONS.PROP_MOUSE_BUTTON: button = OxyMouseButton.Right; break; case (uint)SciterXBehaviors.MOUSE_BUTTONS.MIDDLE_MOUSE_BUTTON: button = OxyMouseButton.Middle; break; } ActualController.HandleMouseDown(this, new OxyMouseDownEventArgs { ChangedButton = button, ClickCount = prms.cmd == SciterXBehaviors.MOUSE_EVENTS.MOUSE_DCLICK ? 2 : 1, Position = new ScreenPoint(prms.pos.X, prms.pos.Y), ModifierKeys = prms.alt_state.GetModifiers() }); break; case SciterXBehaviors.MOUSE_EVENTS.MOUSE_UP: ActualController.HandleMouseUp(this, new OxyMouseEventArgs { Position = new ScreenPoint(prms.pos.X, prms.pos.Y), ModifierKeys = prms.alt_state.GetModifiers() }); break; case SciterXBehaviors.MOUSE_EVENTS.MOUSE_WHEEL: ActualController.HandleMouseWheel(this, new OxyMouseWheelEventArgs { Delta = (prms.button_state == 1 ? 1 : -1) * SystemInformation.MouseWheelScrollDelta, Position = new ScreenPoint(prms.pos.X, prms.pos.Y), ModifierKeys = prms.alt_state.GetModifiers() }); break; } return(false); }