Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// </summary>
 public MainViewModel()
 {
     CloseCommand    = new RelayCommand <Window>(CloseClick);
     HookCommand     = new RelayCommand(HookClick);
     _interceptMouse = new InterceptMouse();
     if (IsInDesignMode)
     {
         return;
     }
     HookClick();
     _interceptMouse.MouseHookLeftButtonDown +=
         (sender, args) =>
     {
         Dispatcher.CurrentDispatcher.InvokeAsync(() =>
         {
             _dv?.Close();
             _dv = null;
             GetPixel(args);
         });
         _interceptMouse.Unhook();
         RaisePropertyChanged(nameof(Hooked));
     };
     _interceptMouse.MouseHookMove +=
         (sender, args) => Dispatcher.CurrentDispatcher.InvokeAsync(() => GetPixel(args));
 }
Exemplo n.º 2
0
 public override void Cleanup()
 {
     // Clean up if needed
     if (_interceptMouse.IsHooked)
     {
         _interceptMouse.Unhook();
     }
     base.Cleanup();
 }