private bool MouseWheel(IMouseDevice device, ulong timestamp, IInputRoot root, Point p, PointerPointProperties props, Vector delta, KeyModifiers inputModifiers, IInputElement?hitTest) { device = device ?? throw new ArgumentNullException(nameof(device)); root = root ?? throw new ArgumentNullException(nameof(root)); var source = _pointer.Captured ?? hitTest; // KeyModifiers.Shift should scroll in horizontal direction. This does not work on every platform. // If Shift-Key is pressed and X is close to 0 we swap the Vector. if (inputModifiers == KeyModifiers.Shift && MathUtilities.IsZero(delta.X)) { delta = new Vector(delta.Y, delta.X); } if (source is not null) { var e = new PointerWheelEventArgs(source, _pointer, root, p, timestamp, props, inputModifiers, delta); source?.RaiseEvent(e); return(e.Handled); } return(false); }
private bool MouseWheel(IMouseDevice device, IInputRoot root, Point p, Vector delta, InputModifiers inputModifiers) { Contract.Requires <ArgumentNullException>(device != null); Contract.Requires <ArgumentNullException>(root != null); var hit = HitTest(root, p); if (hit != null) { var source = GetSource(hit); var e = new PointerWheelEventArgs { Device = this, RoutedEvent = InputElement.PointerWheelChangedEvent, Source = source, Delta = delta, InputModifiers = inputModifiers }; source?.RaiseEvent(e); return(e.Handled); } return(false); }
private bool MouseWheel(IMouseDevice device, ulong timestamp, IInputRoot root, Point p, PointerPointProperties props, Vector delta, KeyModifiers inputModifiers) { Contract.Requires <ArgumentNullException>(device != null); Contract.Requires <ArgumentNullException>(root != null); var hit = HitTest(root, p); if (hit != null) { var source = GetSource(hit); var e = new PointerWheelEventArgs(source, _pointer, root, p, timestamp, props, inputModifiers, delta); source?.RaiseEvent(e); return(e.Handled); } return(false); }
/// <summary> /// Called before the <see cref="PointerWheelChanged"/> event occurs. /// </summary> /// <param name="e">The event args.</param> protected virtual void OnPointerWheelChanged(PointerWheelEventArgs e) { }
/// <inheritdoc/> protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { if (Extent.Height > Viewport.Height || Extent.Width > Viewport.Width) { var scrollable = Child as ILogicalScrollable; bool isLogical = scrollable?.IsLogicalScrollEnabled == true; double x = Offset.X; double y = Offset.Y; if (Extent.Height > Viewport.Height) { double height = isLogical ? scrollable.ScrollSize.Height : 50; y += -e.Delta.Y * height; y = Math.Max(y, 0); y = Math.Min(y, Extent.Height - Viewport.Height); } if (Extent.Width > Viewport.Width) { double width = isLogical ? scrollable.ScrollSize.Width : 50; x += -e.Delta.X * width; x = Math.Max(x, 0); x = Math.Min(x, Extent.Width - Viewport.Width); } Offset = new Vector(x, y); e.Handled = true; } }
private bool MouseWheel(IMouseDevice device, IInputRoot root, Point p, Vector delta, InputModifiers inputModifiers) { var hit = HitTest(root, p); if (hit != null) { var source = GetSource(hit); var e = new PointerWheelEventArgs { Device = this, RoutedEvent = InputElement.PointerWheelChangedEvent, Source = source, Delta = delta, InputModifiers = inputModifiers }; source?.RaiseEvent(e); return e.Handled; } return false; }
private void Border_PointerWheelChanged(object sender, PointerWheelEventArgs e) { if (_element != null) { Point point = e.GetPosition(_element); point = FixInvalidPointPosition(point); ZoomDeltaTo(e.Delta.Y, point); } }