public void ProcessPointerFrames(int pointerID, int frameID) { if (_lastFrameID != frameID) { _lastFrameID = frameID; int entriesCount = 0; int pointerCount = 0; if (!Win32TouchFunctions.GetPointerFrameInfoHistory(pointerID, ref entriesCount, ref pointerCount, IntPtr.Zero)) { Win32TouchFunctions.CheckLastError(); } Win32TouchFunctions.POINTER_INFO[] piArr = new Win32TouchFunctions.POINTER_INFO[entriesCount * pointerCount]; if (!Win32TouchFunctions.GetPointerFrameInfoHistory(pointerID, ref entriesCount, ref pointerCount, piArr)) { Win32TouchFunctions.CheckLastError(); } IntPtr hr = Win32TouchFunctions.ProcessPointerFramesInteractionContext(_context, entriesCount, pointerCount, piArr); if (Win32TouchFunctions.FAILED(hr)) { Debug.WriteLine("ProcessPointerFrames failed: " + Win32TouchFunctions.GetMessageForHR(hr)); } } }
protected override void WndProc(ref Message m) { switch (m.Msg) { case Win32TouchFunctions.WM_POINTERDOWN: case Win32TouchFunctions.WM_POINTERUP: case Win32TouchFunctions.WM_POINTERUPDATE: case Win32TouchFunctions.WM_POINTERCAPTURECHANGED: break; default: base.WndProc(ref m); return; } int pointerID = Win32TouchFunctions.GET_POINTER_ID(m.WParam); Win32TouchFunctions.POINTER_INFO pi = new Win32TouchFunctions.POINTER_INFO(); if (!Win32TouchFunctions.GetPointerInfo(pointerID, ref pi)) { Win32TouchFunctions.CheckLastError(); } switch (m.Msg) { case Win32TouchFunctions.WM_POINTERDOWN: { if ((pi.PointerFlags & Win32TouchFunctions.POINTER_FLAGS.PRIMARY) != 0) { this.Capture = true; } Point pt = PointToClient(pi.PtPixelLocation.ToPoint()); background.AddPointer(pointerID); background.ProcessPointerFrames(pointerID, pi.FrameID); } break; case Win32TouchFunctions.WM_POINTERUP: if ((pi.PointerFlags & Win32TouchFunctions.POINTER_FLAGS.PRIMARY) != 0) { this.Capture = false; } if (background.ActivePointers.Contains(pointerID)) { background.ProcessPointerFrames(pointerID, pi.FrameID); background.RemovePointer(pointerID); } break; case Win32TouchFunctions.WM_POINTERUPDATE: if (background.ActivePointers.Contains(pointerID)) { background.ProcessPointerFrames(pointerID, pi.FrameID); } break; case Win32TouchFunctions.WM_POINTERCAPTURECHANGED: this.Capture = false; if (background.ActivePointers.Contains(pointerID)) { background.StopProcessing(); } break; } m.Result = IntPtr.Zero; }
protected override void WndProc(ref Message m) { switch (m.Msg) { case Win32TouchFunctions.WM_POINTERDOWN: case Win32TouchFunctions.WM_POINTERUP: case Win32TouchFunctions.WM_POINTERUPDATE: case Win32TouchFunctions.WM_POINTERCAPTURECHANGED: break; default: base.WndProc(ref m); return; } int pointerID = Win32TouchFunctions.GET_POINTER_ID(m.WParam); Win32TouchFunctions.POINTER_INFO pi = new Win32TouchFunctions.POINTER_INFO(); if (!Win32TouchFunctions.GetPointerInfo(pointerID, ref pi)) { Win32TouchFunctions.CheckLastError(); } switch (m.Msg) { case Win32TouchFunctions.WM_POINTERDOWN: { if ((pi.PointerFlags & Win32TouchFunctions.POINTER_FLAGS.PRIMARY) != 0) { this.Capture = true; } Point pt = PointToClient(pi.PtPixelLocation.ToPoint()); background.AddPointer(pointerID); background.ProcessPointerFrames(pointerID, pi.FrameID); } break; case Win32TouchFunctions.WM_POINTERUP: if ((pi.PointerFlags & Win32TouchFunctions.POINTER_FLAGS.PRIMARY) != 0) { this.Capture = false; } if ( background.ActivePointers.Contains(pointerID)) { background.ProcessPointerFrames(pointerID, pi.FrameID); background.RemovePointer(pointerID); } break; case Win32TouchFunctions.WM_POINTERUPDATE: if (background.ActivePointers.Contains(pointerID)) { background.ProcessPointerFrames(pointerID, pi.FrameID); } break; case Win32TouchFunctions.WM_POINTERCAPTURECHANGED: this.Capture = false; if (background.ActivePointers.Contains(pointerID)) { background.StopProcessing(); } break; } m.Result = IntPtr.Zero; }
protected override void WndProc(ref Message m) { try { switch (m.Msg) { case Win32TouchFunctions.WM_POINTERDOWN: case Win32TouchFunctions.WM_POINTERUP: case Win32TouchFunctions.WM_POINTERUPDATE: case Win32TouchFunctions.WM_POINTERCAPTURECHANGED: break; default: base.WndProc(ref m); return; } int pointerID = Win32TouchFunctions.GET_POINTER_ID(m.WParam); Win32TouchFunctions.POINTER_INFO pi = new Win32TouchFunctions.POINTER_INFO(); if (!Win32TouchFunctions.GetPointerInfo(pointerID, ref pi)) { Win32TouchFunctions.CheckLastError(); } DrawPoint pt = PointToClient(pi.PtPixelLocation.ToPoint()); switch (m.Msg) { case Win32TouchFunctions.WM_POINTERDOWN: { if ((pi.PointerFlags & Win32TouchFunctions.POINTER_FLAGS.PRIMARY) != 0) { this.Capture = true; } var pointerDown = PointerDown; if (pointerDown != null) { pointerDown(new object(), new TouchEventArgs(pointerID, new Point(pt.X, pt.Y))); } } break; case Win32TouchFunctions.WM_POINTERUP: if ((pi.PointerFlags & Win32TouchFunctions.POINTER_FLAGS.PRIMARY) != 0) { this.Capture = false; } var pointerUp = PointerUp; if (pointerUp != null) { pointerUp(new object(), new TouchEventArgs(pointerID, new Point(pt.X, pt.Y))); } break; case Win32TouchFunctions.WM_POINTERUPDATE: var pointerUpdate = PointerUpdate; if (pointerUpdate != null) { pointerUpdate(new object(), new TouchEventArgs(pointerID, new Point(pt.X, pt.Y))); } break; case Win32TouchFunctions.WM_POINTERCAPTURECHANGED: this.Capture = false; var pointerLostCapture = PointerLostCapture; if (pointerLostCapture != null) { pointerLostCapture(new object(), new TouchEventArgs(pointerID, new Point(pt.X, pt.Y))); } break; } m.Result = IntPtr.Zero; } catch (Exception e) { Log.Warning(e.Message); } }