Ejemplo n.º 1
0
        // Decodes and handles WM_TOUCH* messages.
        private void DecodeTouch(ref WinApi.TOUCHINPUT touchInput)
        {
            // TOUCHINFO point coordinates and contact size is in 1/100 of a pixel; convert it to pixels.
            // Also convert screen to client coordinates.
            if ((touchInput.dwMask & WinApi.TOUCHINPUTMASKF_CONTACTAREA) != 0)
                ContactSize = new Size(AdjustDpiX(touchInput.cyContact / 100), AdjustDpiY(touchInput.cyContact / 100));

            Id = touchInput.dwID;

            Point p = _ParentHandler.ParentControl.PointToClient(new Point(touchInput.x / 100, touchInput.y / 100));
            Location = p;// new Point(AdjustDpiX(p.X), AdjustDpiY(p.Y));

            Time = touchInput.dwTime;
            TimeSpan ellapse = TimeSpan.FromMilliseconds(Environment.TickCount - touchInput.dwTime);
            AbsoluteTime = DateTime.Now - ellapse;

            Mask = touchInput.dwMask;
            Flags = touchInput.dwFlags;
        }
Ejemplo n.º 2
0
        //Decode the gesture
        private void ParseGesture(Control parentControl, ref WinApi.GESTUREINFO gestureInfo)
        {
            Location = parentControl.PointToClient(new Point(gestureInfo.ptsLocation.x, gestureInfo.ptsLocation.y));

            Center = Location;

            switch (GestureId)
            {
                case WinApi.GID_ROTATE:
                    ushort lastArguments = (ushort)(IsBegin ? 0 : LastEvent.GestureArguments);

                    RotateAngle = WinApi.GID_ROTATE_ANGLE_FROM_ARGUMENT((ushort)(gestureInfo.ullArguments - lastArguments));
                    break;


                case WinApi.GID_ZOOM:
                    Point first = IsBegin ? Location : LastBeginEvent.Location;
                    Center = new Point((Location.X + first.X) / 2, (Location.Y + first.Y) / 2);
                    ZoomFactor = IsBegin ? 1 : (double)gestureInfo.ullArguments / LastEvent.GestureArguments;
                    //DistanceBetweenFingers = WinApi.LoDWord(gestureInfo.ullArguments);
                    break;

                case WinApi.GID_PAN:
                    PanTranslation = IsBegin ? new Size(0, 0) :
                        new Size(Location.X - LastEvent.Location.X, Location.Y - LastEvent.Location.Y);
                    int panVelocity = WinApi.HiDWord((long)(gestureInfo.ullArguments));
                    PanVelocity = new Size(WinApi.LoWord(panVelocity), WinApi.HiWord(panVelocity));
                    //DistanceBetweenFingers = WinApi.LoDWord(gestureInfo.ullArguments);
                    break;
            }

            
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Create new touch event argument instance
 /// </summary>
 /// <param name="hWndWrapper">The target control</param>
 /// <param name="touchInput">one of the inner touch input in the message</param>
 internal TouchEventArgs(TouchHandler parentHandler, float dpiX, float dpiY, ref WinApi.TOUCHINPUT touchInput)
 {
     _ParentHandler = parentHandler;
     _dpiXFactor = 96F / dpiX;
     _dpiYFactor = 96F / dpiY;
     DecodeTouch(ref touchInput);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Create new gesture event instance and decode the gesture info structure
        /// </summary>
        /// <param name="handler">The gesture handler</param>
        /// <param name="gestureInfo">The gesture information</param>
        internal GestureEventArgs(TouchHandler handler, ref WinApi.GESTUREINFO gestureInfo)
        {
            _Flags = gestureInfo.dwFlags;
            GestureId = gestureInfo.dwID;
            GestureArguments = gestureInfo.ullArguments;

            //Get the last event from the handler
            LastEvent = handler.LastEventArgs;

            //Get the last begin event from the handler 
            LastBeginEvent = handler.LastBeginEventArgs;

            ParseGesture(handler.ParentControl, ref gestureInfo);

            //new gesture, clear last and first event fields
            if (IsBegin)
            {
                LastBeginEvent = null;
                LastEvent = null;
            }
        }