예제 #1
0
        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);
        }
예제 #2
0
        private void OnClosed(object sender, EventArgs e)
        {
            ManipulationDelta     = null;
            ManipulationCompleted = null;

            _source?.RemoveHook(WndProc);

            TouchpadHelper.UnregisterInput();
        }
예제 #3
0
        public TouchpadTracker(Window window)
        {
            if (!TouchpadHelper.Exists())
            {
                return;
            }

            this._window = window ?? throw new ArgumentNullException(nameof(window));
            this._window.SourceInitialized += OnSourceInitialized;
            this._window.Closed            += OnClosed;
        }
예제 #4
0
 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);
 }