//Decode the gesture private void DecodeGesture(IHwndWrapper hWndWrapper, ref GESTUREINFO gestureInfo) { Location = hWndWrapper.PointToClient(new Point(gestureInfo.ptsLocation.x, gestureInfo.ptsLocation.y)); Center = Location; switch (GestureId) { case User32.GID_ROTATE: ushort lastArguments = (ushort)(IsBegin ? 0 : LastEvent.GestureArguments); RotateAngle = User32.GID_ROTATE_ANGLE_FROM_ARGUMENT((ushort)(gestureInfo.ullArguments - lastArguments)); break; case User32.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 = User32.LoDWord(gestureInfo.ullArguments); break; case User32.GID_PAN: PanTranslation = IsBegin ? new Size(0, 0) : new Size(Location.X - LastEvent.Location.X, Location.Y - LastEvent.Location.Y); int panVelocity = User32.HiDWord((long)(gestureInfo.ullArguments)); PanVelocity = new Size(User32.LoWord(panVelocity), User32.HiWord(panVelocity)); //DistanceBetweenFingers = User32.LoDWord(gestureInfo.ullArguments); break; } }
// Decodes and handles WM_TOUCH* messages. private void DecodeTouch(ref 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 & User32.TOUCHINPUTMASKF_CONTACTAREA) != 0) { ContactSize = new Size(AdjustDpiX(touchInput.cyContact / 100), AdjustDpiY(touchInput.cyContact / 100)); } Id = touchInput.dwID; Point p = _hWndWrapper.PointToClient(new Point(touchInput.x / 100, touchInput.y / 100)); Location = 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; }