public BackgroundTouch(TouchForm tForm) : base() { touchForm = tForm; Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION[] cfg = new Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION[] { new Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION(Win32TouchFunctions.INTERACTION.TAP, Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.TAP | Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.TAP_DOUBLE), new Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION(Win32TouchFunctions.INTERACTION.SECONDARY_TAP, Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.SECONDARY_TAP), new Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION(Win32TouchFunctions.INTERACTION.HOLD, Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.HOLD), new Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION(Win32TouchFunctions.INTERACTION.MANIPULATION, Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.MANIPULATION | Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_SCALING | Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_X | Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_Y) }; Win32TouchFunctions.SetInteractionConfigurationInteractionContext(Context, cfg.Length, cfg); }
public void StopProcessing() { foreach (int pointerID in _activePointers) { Win32TouchFunctions.RemovePointerInteractionContext(_context, pointerID); } _activePointers.Clear(); Win32TouchFunctions.StopInteractionContext(_context); }
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)); } } }
public void RemovePointer(int pointerID) { Win32TouchFunctions.RemovePointerInteractionContext(_context, pointerID); _activePointers.Remove(pointerID); }
public void AddPointer(int pointerID) { Win32TouchFunctions.AddPointerInteractionContext(_context, pointerID); _activePointers.Add(pointerID); }
public void Dispose() { Win32TouchFunctions.DisposeInteractionContext(_context); _context = IntPtr.Zero; }
public BaseTouchHandler() { _context = Win32TouchFunctions.CreateInteractionContext(this, SynchronizationContext.Current); //Win32.SetPropertyInteractionContext(Context, Win32.INTERACTION_CONTEXT_PROPERTY.FILTER_POINTERS, Win32.ICP_FILTER_POINTERS_ON); }
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; }
public TouchForm() : base() { Win32TouchFunctions.EnableMouseInPointer(false); background = new BackgroundTouch(this); }
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); } }
public TouchForm() : base() { Win32TouchFunctions.EnableMouseInPointer(false); }