コード例 #1
0
        public static TResult TouchNotificationSwitch <TResult>(TouchNotification notification, TResult defaultResult,
                                                                Func <TouchDownNotification, TResult> onDown,
                                                                Func <TouchMoveNotification, TResult> onMove,
                                                                Func <TouchUpNotification, TResult> onUp)
            where TResult : class
        {
            switch (notification.Kind)
            {
            case TouchNotificationKind.TouchDown:
                return(onDown?.Invoke((TouchDownNotification)notification) ?? defaultResult);

            case TouchNotificationKind.TouchUp:
                return(onUp?.Invoke((TouchUpNotification)notification) ?? defaultResult);

            case TouchNotificationKind.TouchMove:
                return(onMove?.Invoke((TouchMoveNotification)notification) ?? defaultResult);

            default:
                return(defaultResult);
            }
        }
コード例 #2
0
        private void HandleTouchNotification(TouchNotification n, CallerInfo caller)
        {
            var position   = GetPositionInViewport(n, caller);
            var touchEvent = new CefTouchEvent()
            {
                Id = n.Id,
                //Modifiers = (CefEventFlags)((int)(FKeyboard.Modifiers) >> 15),
                PointerType   = CefPointerType.Touch,
                Pressure      = 1f,
                RadiusX       = n.ContactArea.X,
                RadiusY       = n.ContactArea.Y,
                RotationAngle = 0,
                Type          = GetTouchType(n.Kind),
                X             = position.X,
                Y             = position.Y
            };

            webRenderer.BrowserHost.SendTouchEvent(touchEvent);

            CefTouchEventType GetTouchType(TouchNotificationKind kind)
            {
                switch (kind)
                {
                case TouchNotificationKind.TouchDown:
                    return(CefTouchEventType.Pressed);

                case TouchNotificationKind.TouchUp:
                    return(CefTouchEventType.Released);

                case TouchNotificationKind.TouchMove:
                    return(CefTouchEventType.Moved);

                default:
                    return(CefTouchEventType.Cancelled);
                }
            }
        }