Beispiel #1
0
 /// <summary>
 /// Raises RotateBegin event.
 /// </summary>
 /// <param name="e">Provides event arguments.</param>
 protected virtual void OnRotateBegin(GestureEventArgs e)
 {
     EventHandler<GestureEventArgs> handler = RotateBegin;
     if (handler != null)
         handler(this, e);
 }
Beispiel #2
0
 /// <summary>
 /// Raises PressAndTap event.
 /// </summary>
 /// <param name="e">Provides event arguments.</param>
 protected virtual void OnPressAndTap(GestureEventArgs e)
 {
     EventHandler<GestureEventArgs> handler = PressAndTap;
     if (handler != null)
         handler(this, e);
 }
Beispiel #3
0
        /// <summary>
        /// The Windows message handler.
        /// </summary>
        private uint WindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
        {
            if(msg == WinApi.WM_TOUCH && (_HandlerType & eTouchHandlerType.Touch)== eTouchHandlerType.Touch)
            {
                bool handled = false;
                foreach (TouchEventArgs arg in DecodeMessage(hWnd, msg, wParam, lParam, DpiX, DpiY))
                {

                    if (arg.IsTouchDown)
                        OnTouchDown(arg);
                
                    if (arg.IsTouchMove)
                        OnTouchMove(arg);
                
                    if (arg.IsTouchUp)
                        OnTouchUp(arg);

                    handled |= arg.Handled;
                }
                if (handled)
                {
                    WinApi.CloseTouchInputHandle(lParam);
                    return 1;
                }
            }

            // Handle only gesture message
            if (msg != WinApi.WM_GESTURE)
            {
                return WinApi.CallWindowProc(_originalWindowProcId, hWnd, msg, wParam, lParam);
            }

            WinApi.GESTUREINFO gestureInfo = new WinApi.GESTUREINFO();
            gestureInfo.cbSize = (uint)Marshal.SizeOf(typeof(WinApi.GESTUREINFO));

            bool result = WinApi.GetGestureInfo(lParam, ref gestureInfo);

            if (!result)
                throw new Exception("Cannot retrieve gesture information");

            //Decode the gesture info and get the message event argument
            GestureEventArgs eventArgs = new GestureEventArgs(this, ref gestureInfo);
            try
            {
                //Fire the event using the event map
                uint gestureId = GetGestureEventId(gestureInfo.dwID, gestureInfo.dwFlags);
                if (gestureId == GestureEventId.Begin)
                    OnBegin(eventArgs);
                else if (gestureId == GestureEventId.End)
                    OnEnd(eventArgs);
                else if (gestureId == GestureEventId.Pan)
                    OnPan(eventArgs);
                else if (gestureId == GestureEventId.PanBegin)
                    OnPanBegin(eventArgs);
                else if (gestureId == GestureEventId.PanEnd)
                    OnPanEnd(eventArgs);
                else if (gestureId == GestureEventId.PressAndTap)
                    OnPressAndTap(eventArgs);
                else if (gestureId == GestureEventId.Rotate)
                    OnRotate(eventArgs);
                else if (gestureId == GestureEventId.RotateBegin)
                    OnRotateBegin(eventArgs);
                else if (gestureId == GestureEventId.RotateEnd)
                    OnRotateEnd(eventArgs);
                else if (gestureId == GestureEventId.TwoFingerTap)
                    OnTwoFingerTap(eventArgs);
                else if (gestureId == GestureEventId.Zoom)
                    OnZoom(eventArgs);
                else if (gestureId == GestureEventId.ZoomBegin)
                    OnZoomBegin(eventArgs);
                else if (gestureId == GestureEventId.ZoomEnd)
                    OnZoomEnd(eventArgs);
            }
            catch (ArgumentOutOfRangeException) //In case future releases will introduce new event values
            {
            }

            //Keep the last message for relative calculations
            LastEventArgs = eventArgs;

            //Keep the first message for relative calculations
            if (eventArgs.IsBegin)
                LastBeginEventArgs = eventArgs;

            if (eventArgs.Handled)
            {
                WinApi.CloseGestureInfoHandle(lParam);
                return 1;
            }
            else
                return WinApi.CallWindowProc(_originalWindowProcId, hWnd, msg, wParam, lParam);
        }
Beispiel #4
0
 /// <summary>
 /// Raises End event.
 /// </summary>
 /// <param name="e">Provides event arguments.</param>
 protected virtual void OnEnd(GestureEventArgs e)
 {
     EventHandler<GestureEventArgs> handler = End;
     if (handler != null)
         handler(this, e);
 }
Beispiel #5
0
 /// <summary>
 /// Raises TwoFingerTap event.
 /// </summary>
 /// <param name="e">Provides event arguments.</param>
 protected virtual void OnTwoFingerTap(GestureEventArgs e)
 {
     EventHandler<GestureEventArgs> handler = TwoFingerTap;
     if (handler != null)
         handler(this, e);
 }