public static SkiTouch Get( long id, SKTouchAction type, SKMouseButton mouseButton, SKTouchDeviceType deviceType, SKPoint location, bool inContact, int wheelDelta ) { if (!_cachedTouches.TryTake(out var result)) { result = new SkiTouch(); } if (mouseButton == SKMouseButton.Unknown && (inContact || type == SKTouchAction.Released || type == SKTouchAction.Cancelled)) { // Unknown mouse button presses are not currently handled (extra mouse buttons), // so update them to act as a hover type = SKTouchAction.Moved; inContact = false; } result.Id = id; result.ActionType = type; result.MouseButton = mouseButton; result.DeviceType = deviceType; result.PointPixels = location; result.InContact = inContact; result.WheelDelta = wheelDelta; return(result); }
// processing private bool CommonHandler(object sender, SKTouchAction touchActionType, InputEventArgs evt) { if (onTouchAction == null || scalePixels == null) { return(false); } var view = sender as FrameworkElement; // bail out if this view is not part the view hierarchy anymore if (PresentationSource.FromVisual(view) == null) { return(false); } var id = GetId(evt); var action = GetTouchAction(touchActionType, view, evt); var mouse = GetMouseButton(evt); var device = GetTouchDevice(evt); var windowsPoint = GetPosition(evt, view); var skPoint = scalePixels(windowsPoint.X, windowsPoint.Y); var inContact = GetContact(evt); var wheelDelta = evt is MouseWheelEventArgs wheelEvt ? wheelEvt.Delta : 0; var args = new SKTouchEventArgs(id, action, mouse, device, skPoint, inContact, wheelDelta); onTouchAction(args); return(args.Handled); }
private bool CommonHandler(object sender, SKTouchAction touchActionType, PointerRoutedEventArgs evt) { if (onTouchAction == null || scalePixels == null) { return(false); } var view = sender as FrameworkElement; var id = evt.Pointer.PointerId; var pointerPoint = evt.GetCurrentPoint(view); var windowsPoint = pointerPoint.Position; var skPoint = scalePixels(windowsPoint.X, windowsPoint.Y); var mouse = GetMouseButton(pointerPoint); var device = GetTouchDevice(evt); var wheelDelta = pointerPoint?.Properties?.MouseWheelDelta ?? 0; var args = new SKTouchEventArgs(id, touchActionType, mouse, device, skPoint, evt.Pointer.IsInContact, wheelDelta); onTouchAction(args); return(args.Handled); }
public SKTouchEventArgs(long id, SKTouchAction type, SKPoint location, bool inContact) : this(id, type, SKMouseButton.Left, SKTouchDeviceType.Touch, location, inContact) { }
private void RaiseTouch(object sender, MouseEventArgs e, SKTouchAction action) { var view = sender as FrameworkElement; var pointerPoint = e.MouseDevice.GetPosition(view); var skPoint = GetScaledCoord(pointerPoint.X, pointerPoint.Y); var args = new SKTouchEventArgs(e.Timestamp, action, SKMouseButton.Left, SKTouchDeviceType.Mouse, skPoint, true); ((ISKCanvasViewController)Element).OnTouch(args); }
public SKTouchEventArgs(long id, SKTouchAction type, SKMouseButton mouseButton, SKTouchDeviceType deviceType, SKPoint location, bool inContact) { Id = id; ActionType = type; DeviceType = deviceType; MouseButton = mouseButton; Location = location; InContact = inContact; }
public SKTouchEventArgs(long id, SKTouchAction type, SKMouseButton mouseButton, SKTouchDeviceType deviceType, SKPoint location, bool inContact, int wheelDelta, float pressure) { Id = id; ActionType = type; DeviceType = deviceType; MouseButton = mouseButton; Location = location; InContact = inContact; WheelDelta = wheelDelta; Pressure = pressure; }
private void RaiseTouch(object sender, PointerRoutedEventArgs e, SKTouchAction action) { var pointerPoint = e.GetCurrentPoint(Control); //var windowsPoint = view.PointToScreen(pointerPoint); var skPoint = Element.IgnorePixelScaling ? new SKPoint((float)pointerPoint.Position.X, (float)pointerPoint.Position.Y) : new SKPoint((float)(pointerPoint.Position.X * Control.Dpi), (float)(pointerPoint.Position.Y * Control.Dpi)); var args = new SKTouchEventArgs(e.Pointer.PointerId, action, SKMouseButton.Left, SKTouchDeviceType.Mouse, skPoint, true); ((ISKCanvasViewController)Element).OnTouch(args); }
private void RaiseTouch(object sender, PointerRoutedEventArgs e, SKTouchAction action) { var pointerPoint = e.GetCurrentPoint(Control); var scaleX = Control.CanvasSize.Width / Control.Width; var scaleY = Control.CanvasSize.Height / Control.Height; //var windowsPoint = view.PointToScreen(pointerPoint); var skPoint = true ? new SKPoint((float)pointerPoint.Position.X, (float)pointerPoint.Position.Y) : new SKPoint((float)(pointerPoint.Position.X * scaleX), (float)(pointerPoint.Position.Y * scaleY)); var args = new SKTouchEventArgs(e.Pointer.PointerId, action, SKMouseButton.Left, SKTouchDeviceType.Mouse, skPoint, true); ((SKGLScrollView)Element).RaiseTouch(args); }
private void PostEvent(SKTouchAction action) { if (handler.onTouchAction == null || handler.scalePixels == null) { return; } var p = handler.gestureLayer.EvasCanvas.Pointer; var coords = handler.scalePixels(p.X, p.Y); var inContact = (action == SKTouchAction.Pressed || action == SKTouchAction.Moved) ? true : false; handler.onTouchAction(new SKTouchEventArgs(currentId, action, coords, inContact)); }
private bool FireEvent(SKTouchAction actionType, UITouch touch, bool inContact) { if (onTouchAction == null || scalePixels == null) { return(false); } var id = touch.Handle.ToInt64(); var cgPoint = touch.LocationInView(View); var point = new SKPoint((float)scalePixels(cgPoint.X), (float)scalePixels(cgPoint.Y)); var args = new SKTouchEventArgs(id, actionType, point, inContact); onTouchAction(args); return(args.Handled); }
private bool FireEvent(SKTouchAction actionType, SKMouseButton mouse, SKTouchDeviceType device, NSEvent mouseEvent, bool inContact) { if (onTouchAction == null || scalePixels == null) { return(false); } var id = mouseEvent.ButtonNumber; var cgPoint = LocationInView(View); // flip the Y coordinate for macOS cgPoint.Y = View.Bounds.Height - cgPoint.Y; var point = new SKPoint((float)scalePixels(cgPoint.X), (float)scalePixels(cgPoint.Y)); var args = new SKTouchEventArgs(id, actionType, mouse, device, point, inContact); onTouchAction(args); return(args.Handled); }
private bool CommonHandler(object sender, SKTouchAction touchActionType, MouseEventArgs evt) { if (onTouchAction == null || scalePixels == null) { return(false); } var view = sender as Control; var id = 0L; // evt.Pointer.PointerId; var windowsPoint = evt.Location; var skPoint = new SKPoint((float)windowsPoint.X, (float)windowsPoint.Y); var mouse = GetMouseButton(evt.Button); var device = SKTouchDeviceType.Mouse; // GetTouchDevice(evt); var args = new SKTouchEventArgs(id, touchActionType, mouse, device, skPoint, false /*evt.Pointer.IsInContact*/); onTouchAction(args); return(args.Handled); }
// processing private bool CommonHandler(object sender, SKTouchAction touchActionType, InputEventArgs evt) { if (onTouchAction == null || scalePixels == null) { return(false); } var view = sender as FrameworkElement; var id = GetId(evt); var action = GetTouchAction(touchActionType, view, evt); var mouse = GetMouseButton(evt); var device = GetTouchDevice(evt); var windowsPoint = GetPosition(evt, view); var skPoint = scalePixels(windowsPoint.X, windowsPoint.Y); var inContact = GetContact(evt); var args = new SKTouchEventArgs(id, action, mouse, device, skPoint, inContact); onTouchAction(args); return(args.Handled); }
// processing private bool CommonHandler(object sender, SKTouchAction touchActionType, MouseEventArgs evt) { if (onTouchAction == null || scalePixels == null) { return(false); } var view = sender as Control; var id = 1; var action = touchActionType; var mouse = GetMouseButton(evt); var device = SKTouchDeviceType.Mouse; var windowsPoint = evt.Location; var skPoint = scalePixels(windowsPoint.X, windowsPoint.Y); var inContact = GetContact(evt); var args = new SKTouchEventArgs(id, action, mouse, device, skPoint, inContact); onTouchAction(args); return(args.Handled); }
private SKTouchAction GetTouchAction(SKTouchAction touchActionType, FrameworkElement view, InputEventArgs evt) { if (evt is TouchEventArgs touchEvent) { var action = touchEvent.GetTouchPoint(view).Action; switch (action) { case TouchAction.Down: touchActionType = SKTouchAction.Pressed; break; case TouchAction.Move: touchActionType = SKTouchAction.Moved; break; case TouchAction.Up: touchActionType = SKTouchAction.Released; break; } } return(touchActionType); }
// processing private bool CommonHandler(object sender, SKTouchAction touchActionType, Event evt) { if (onTouchAction == null || scalePixels == null) { return(false); } var view = sender as Widget; var id = GetId(evt); var action = touchActionType; var mouse = GetMouseButton(evt); var device = GetTouchDevice(evt); var windowsPoint = GetPosition(evt); var skPoint = scalePixels(windowsPoint.X, windowsPoint.Y); var inContact = GetContact(evt); var wheelDelta = GetWheelDelta(evt); var args = new SKTouchEventArgs(id, action, mouse, device, skPoint, inContact, wheelDelta); onTouchAction(args); return(args.Handled); }
public SKTouchEventArgs(long id, SKTouchAction type, SKMouseButton mouseButton, SKTouchDeviceType deviceType, SKPoint location, bool inContact) : this(id, type, mouseButton, deviceType, location, inContact, 0) { }
public TouchPoint() { x = y = 0; type = SKTouchAction.Cancelled; }
public TouchPoint(int x, int y, SKTouchAction type) { this.x = x; this.y = y; this.type = type; }
public ElementTouchEventArgs(DrawableElement element, SKTouchAction type) { Element = element; Type = type; }
public void SimulateSkTouchAction(SKTouchAction action, float x, float y) { HandleTouch(this, new SKTouchEventArgs(0, action, new SKPoint(x, y), inContact: true)); }