Exemple #1
0
 private void UpdatePointerForEvent(ReactPointer pointer, MouseButtonEventArgs e)
 {
     var rootPoint = e.GetPosition(_view);
     var viewPoint = e.GetPosition(pointer.ReactView);
     var timestamp = e.Timestamp;
     UpdatePointerForEvent(pointer, rootPoint, viewPoint, timestamp);
 }
        private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            var pointerId = e.Pointer.PointerId;

            if (IndexOfPointerWithId(pointerId) != -1)
            {
                throw new InvalidOperationException("A pointer with this ID already exists.");
            }

            var reactView = GetReactViewTarget(e);

            if (reactView != null && _view.CapturePointer(e.Pointer))
            {
                var reactTag = reactView.GetReactCompoundView().GetReactTagAtPoint(reactView,
                                                                                   e.GetCurrentPoint(reactView).Position);
                var pointer = new ReactPointer();
                pointer.Target     = reactTag;
                pointer.PointerId  = e.Pointer.PointerId;
                pointer.Identifier = ++_pointerIDs;
                pointer.ReactView  = reactView;
                UpdatePointerForEvent(pointer, e);

                var pointerIndex = _pointers.Count;
                _pointers.Add(pointer);
                DispatchTouchEvent(TouchEventType.Start, _pointers, pointerIndex);
            }
        }
Exemple #3
0
        private void UpdatePointerForEvent(ReactPointer pointer, MouseEventArgs e)
        {
            var rootPoint = e.GetPosition(_view);
            var viewPoint = e.GetPosition(pointer.ReactView);

            UpdatePointerForEvent(pointer, rootPoint, viewPoint);
        }
        private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            var pointerId = e.Pointer.PointerId;

            if (IndexOfPointerWithId(pointerId) != -1)
            {
                throw new InvalidOperationException("A pointer with this ID already exists.");
            }

            var originalSource = e.OriginalSource as DependencyObject;
            var rootPoint      = e.GetCurrentPoint(_view);
            var reactView      = GetReactViewTarget(originalSource, rootPoint.Position);

            if (reactView != null && _view.CapturePointer(e.Pointer))
            {
                var viewPoint = e.GetCurrentPoint(reactView);
                var reactTag  = reactView.GetReactCompoundView().GetReactTagAtPoint(reactView, viewPoint.Position);
                var pointer   = new ReactPointer();
                pointer.Target                 = reactTag;
                pointer.PointerId              = e.Pointer.PointerId;
                pointer.Identifier             = ++_pointerIDs;
                pointer.PointerType            = e.Pointer.PointerDeviceType.GetPointerDeviceTypeName();
                pointer.IsLeftButton           = viewPoint.Properties.IsLeftButtonPressed;
                pointer.IsRightButton          = viewPoint.Properties.IsRightButtonPressed;
                pointer.IsMiddleButton         = viewPoint.Properties.IsMiddleButtonPressed;
                pointer.IsHorizontalMouseWheel = viewPoint.Properties.IsHorizontalMouseWheel;
                pointer.IsEraser               = viewPoint.Properties.IsEraser;
                pointer.ReactView              = reactView;
                UpdatePointerForEvent(pointer, rootPoint, viewPoint);

                var pointerIndex = _pointers.Count;
                _pointers.Add(pointer);
                DispatchTouchEvent(TouchEventType.Start, _pointers, pointerIndex);
            }
        }
Exemple #5
0
        private void UpdatePointerForEvent(ReactPointer pointer, TouchEventArgs e)
        {
            var rootPoint = e.GetTouchPoint(_view);
            var viewPoint = e.GetTouchPoint(pointer.ReactView);

            UpdatePointerForEvent(pointer, rootPoint.Position, viewPoint.Position);
        }
        private void UpdatePointerForEvent(ReactPointer pointer, PointerRoutedEventArgs e)
        {
            var rootPoint = e.GetCurrentPoint(_view);
            var viewPoint = e.GetCurrentPoint(pointer.ReactView);

            UpdatePointerForEvent(pointer, rootPoint, viewPoint);
        }
        private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            var pointerId = e.Pointer.PointerId;

            if (IndexOfPointerWithId(pointerId) != -1)
            {
                throw new InvalidOperationException("A pointer with this ID already exists.");
            }

            var reactView = GetReactViewFromView(e.OriginalSource as FrameworkElement);

            if (reactView != null && _view.CapturePointer(e.Pointer))
            {
                var pointer = new ReactPointer();
                pointer.Target     = reactView.GetTag();
                pointer.PointerId  = e.Pointer.PointerId;
                pointer.Identifier = ++_pointerIDs;
                pointer.ReactView  = reactView;
                UpdatePointerForEvent(pointer, e);

                var pointerIndex = _pointers.Count;
                _pointers.Add(pointer);
                DispatchTouchEvent(TouchEventType.Start, _pointers, pointerIndex);
            }
        }
Exemple #8
0
        private void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            var originalSource = e.OriginalSource as DependencyObject;
            var rootPoint = e.GetPosition(_view);
            var reactView = GetReactViewTarget(originalSource, rootPoint);
            if (reactView != null && _view.CaptureMouse())
            {
                var viewPoint = e.GetPosition(reactView);
                var reactTag = reactView.GetReactCompoundView().GetReactTagAtPoint(reactView, viewPoint);
                var pointer = new ReactPointer();
                pointer.Target = reactTag;
                pointer.PointerId = (uint)e.Device.GetHashCode();
                pointer.Identifier = ++_pointerIDs;
                pointer.PointerType = "mouse";
                pointer.IsLeftButton = e.LeftButton == MouseButtonState.Pressed;
                pointer.IsRightButton = e.RightButton == MouseButtonState.Pressed;
                pointer.IsMiddleButton = e.MiddleButton == MouseButtonState.Pressed;
                pointer.IsHorizontalMouseWheel = false;
                pointer.IsEraser = false;
                pointer.ReactView = reactView;
                var timestamp = e.Timestamp;
                UpdatePointerForEvent(pointer, rootPoint, viewPoint, timestamp);

                var pointerIndex = _pointers.Count;
                _pointers.Add(pointer);
                DispatchTouchEvent(TouchEventType.Start, _pointers, pointerIndex);
            }
        }
        private void OnTouchPressed(object sender, TouchEventArgs e)
        {
            var originalSource = e.OriginalSource as DependencyObject;
            var rootPoint      = e.GetTouchPoint(_view);
            var reactView      = GetReactViewTarget(originalSource, rootPoint.Position);

            if (reactView != null && _view.CaptureTouch(e.TouchDevice))
            {
                var viewPoint = rootPoint.Position;
                var reactTag  = reactView.GetReactCompoundView().GetReactTagAtPoint(reactView, viewPoint);
                var pointer   = new ReactPointer();
                pointer.Target                 = reactTag;
                pointer.PointerId              = (uint)rootPoint.TouchDevice.Id;
                pointer.Identifier             = ++_pointerIDs;
                pointer.PointerType            = "touch";
                pointer.IsLeftButton           = false;
                pointer.IsRightButton          = false;
                pointer.IsMiddleButton         = false;
                pointer.IsHorizontalMouseWheel = false;
                pointer.IsEraser               = false;
                pointer.ReactView              = reactView;
                UpdatePointerForEvent(pointer, rootPoint.Position, viewPoint);

                var pointerIndex = _pointers.Count;
                _pointers.Add(pointer);
                DispatchTouchEvent(TouchEventType.Start, _pointers, pointerIndex);
            }
        }
 public PointerEnterExitEvent(TouchEventType touchEventType, int viewTag, ReactPointer pointer, bool sendDirect, bool sendBubbled)
     : base(viewTag)
 {
     _touchEventType = touchEventType;
     _pointer        = pointer;
     _sendDirect     = sendDirect;
     _sendBubbled    = sendBubbled;
 }
Exemple #11
0
        private void UpdatePointerForEvent(ReactPointer pointer, Point rootPoint, Point viewPoint)
        {
            var positionInRoot = rootPoint;
            var positionInView = viewPoint;

            pointer.PageX     = (float)positionInRoot.X;
            pointer.PageY     = (float)positionInRoot.Y;
            pointer.LocationX = (float)positionInView.X;
            pointer.LocationY = (float)positionInView.Y;
        }
        private void UpdatePointerForEvent(ReactPointer pointer, PointerRoutedEventArgs e)
        {
            var viewPoint      = e.GetCurrentPoint(_view);
            var positionInRoot = viewPoint.Position;
            var positionInView = e.GetCurrentPoint(pointer.ReactView).Position;

            pointer.PageX     = (float)positionInRoot.X;
            pointer.PageY     = (float)positionInRoot.Y;
            pointer.LocationX = (float)positionInView.X;
            pointer.LocationY = (float)positionInView.Y;
            pointer.Timestamp = viewPoint.Timestamp / 1000; // Convert microseconds to milliseconds;
        }
        private void UpdatePointerForEvent(ReactPointer pointer, PointerPoint rootPoint, PointerPoint viewPoint)
        {
            var positionInRoot = rootPoint.Position;
            var positionInView = viewPoint.Position;

            pointer.PageX                 = (float)positionInRoot.X;
            pointer.PageY                 = (float)positionInRoot.Y;
            pointer.LocationX             = (float)positionInView.X;
            pointer.LocationY             = (float)positionInView.Y;
            pointer.Timestamp             = rootPoint.Timestamp / 1000; // Convert microseconds to milliseconds;
            pointer.Force                 = rootPoint.Properties.Pressure;
            pointer.IsBarrelButtonPressed = rootPoint.Properties.IsBarrelButtonPressed;
        }
Exemple #14
0
        private void UpdatePointerForEvent(ReactPointer pointer, Point rootPoint, Point viewPoint, int timestamp)
        {
            var positionInRoot = rootPoint;
            var positionInView = viewPoint;

            pointer.PageX = (float)positionInRoot.X;
            pointer.PageY = (float)positionInRoot.Y;
            pointer.LocationX = (float)positionInView.X;
            pointer.LocationY = (float)positionInView.Y;
            pointer.Timestamp = (ulong) timestamp;

            pointer.ShiftKey = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;
            pointer.AltKey = (Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt;
            pointer.CtrlKey = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
        }
Exemple #15
0
        private void UpdatePointerForEvent(ReactPointer pointer, PointerPoint rootPoint, PointerPoint viewPoint)
        {
            var positionInRoot = rootPoint.Position;
            var positionInView = viewPoint.Position;

            pointer.PageX                 = (float)positionInRoot.X;
            pointer.PageY                 = (float)positionInRoot.Y;
            pointer.LocationX             = (float)positionInView.X;
            pointer.LocationY             = (float)positionInView.Y;
            pointer.Timestamp             = rootPoint.Timestamp / 1000; // Convert microseconds to milliseconds;
            pointer.Force                 = rootPoint.Properties.Pressure;
            pointer.IsBarrelButtonPressed = rootPoint.Properties.IsBarrelButtonPressed;

            pointer.ShiftKey = Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);
            pointer.AltKey   = Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Menu).HasFlag(CoreVirtualKeyStates.Down);
            pointer.CtrlKey  = Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
        }
        private void UpdatePointerForEvent(ReactPointer pointer, PointerPoint rootPoint, PointerPoint viewPoint, VirtualKeyModifiers keyModifiers)
        {
            var positionInRoot = rootPoint.Position;
            var positionInView = viewPoint.Position;

            pointer.PageX                 = (float)positionInRoot.X;
            pointer.PageY                 = (float)positionInRoot.Y;
            pointer.LocationX             = (float)positionInView.X;
            pointer.LocationY             = (float)positionInView.Y;
            pointer.Timestamp             = rootPoint.Timestamp / 1000; // Convert microseconds to milliseconds;
            pointer.Force                 = rootPoint.Properties.Pressure;
            pointer.IsBarrelButtonPressed = rootPoint.Properties.IsBarrelButtonPressed;

            pointer.ShiftKey = keyModifiers.HasFlag(VirtualKeyModifiers.Shift);
            pointer.AltKey   = keyModifiers.HasFlag(VirtualKeyModifiers.Menu);
            pointer.CtrlKey  = keyModifiers.HasFlag(VirtualKeyModifiers.Control);
        }
        private ReactPointer CreateReactPointer(UIElement reactView, PointerPoint rootPoint, PointerRoutedEventArgs e, bool detectSubcomponent)
        {
            var viewPoint = e.GetCurrentPoint(reactView);
            var reactTag  = detectSubcomponent ?
                            reactView.GetReactCompoundView().GetReactTagAtPoint(reactView, viewPoint.Position) :
                            reactView.GetTag();
            var pointer = new ReactPointer
            {
                Target                 = reactTag,
                PointerId              = e.Pointer.PointerId,
                Identifier             = ++_pointerIDs,
                PointerType            = e.Pointer.PointerDeviceType.GetPointerDeviceTypeName(),
                IsLeftButton           = viewPoint.Properties.IsLeftButtonPressed,
                IsRightButton          = viewPoint.Properties.IsRightButtonPressed,
                IsMiddleButton         = viewPoint.Properties.IsMiddleButtonPressed,
                IsHorizontalMouseWheel = viewPoint.Properties.IsHorizontalMouseWheel,
                IsEraser               = viewPoint.Properties.IsEraser,
                ReactView              = reactView,
            };

            UpdatePointerForEvent(pointer, rootPoint, viewPoint, e.KeyModifiers);
            return(pointer);
        }