Ejemplo n.º 1
0
 private void StartTracking()
 {
     _hook = (int x, IntPtr wParam, IntPtr lParam) =>
     {
         crosshairAxisX.Top  = Cursor.Position.Y - Config.DesktopTop;
         crosshairAxisY.Left = Cursor.Position.X - Config.DesktopLeft;
         return(WindowsApi.CallNextHookEx(x, WindowsApi.WH_MOUSE_LL, wParam, lParam));
     };
     WindowsApi.SetGlobalMouseHook(_hook);
 }
Ejemplo n.º 2
0
        private void RegisterHotkeys()
        {
            WindowsApi.KeyModifiers modifiers = WindowsApi.KeyModifiers.MOD_CONTROL |
                                                WindowsApi.KeyModifiers.MOD_NOREPEAT;

            _hotkeyIdFullGrid  = this.Handle.ToInt32() ^ (int)modifiers ^ (int)Keys.D1;
            _hotkeyIdCrosshair = this.Handle.ToInt32() ^ (int)modifiers ^ (int)Keys.D2;

            WindowsApi.RegisterHotKey(this.Handle, _hotkeyIdFullGrid, modifiers, Keys.D1);
            WindowsApi.RegisterHotKey(this.Handle, _hotkeyIdCrosshair, modifiers, Keys.D2);
        }
Ejemplo n.º 3
0
 protected override void SetVisibleCore(bool value)
 {
     if (value)
     {
         StartTracking();
     }
     else
     {
         WindowsApi.UnhookMouseHook();
     }
     base.SetVisibleCore(value);
 }
Ejemplo n.º 4
0
 private void UnregisterHotkeys()
 {
     WindowsApi.UnregisterHotKey(this.Handle, _hotkeyIdFullGrid);
     WindowsApi.UnregisterHotKey(this.Handle, _hotkeyIdCrosshair);
 }
Ejemplo n.º 5
0
 public GridWindow()
 {
     InitializeComponent();
     WindowsApi.SetAsOverlay(this);
 }
Ejemplo n.º 6
0
 public CrosshairWindow()
 {
     InitializeComponent();
     WindowsApi.SetAsOverlay(this);
     DrawCrosshair();
 }