private void OnSourceInitialized(object sender, EventArgs e) { _complete = new Throttle(TimeSpan.FromMilliseconds(100), Complete); _source = (HwndSource)PresentationSource.FromVisual(_window); _source.AddHook(WndProc); TouchpadHelper.RegisterInput(_source.Handle); }
private void OnClosed(object sender, EventArgs e) { ManipulationDelta = null; ManipulationCompleted = null; _source?.RemoveHook(WndProc); TouchpadHelper.UnregisterInput(); }
public TouchpadTracker(Window window) { if (!TouchpadHelper.Exists()) { return; } this._window = window ?? throw new ArgumentNullException(nameof(window)); this._window.SourceInitialized += OnSourceInitialized; this._window.Closed += OnClosed; }
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { switch (msg) { case TouchpadHelper.WM_INPUT: var contacts = TouchpadHelper.ParseInput(lParam); if (contacts?.Length > 1) { Check(contacts[0]); handled = true; } break; } return(IntPtr.Zero); }