Ejemplo n.º 1
0
 public void Start()
 {
     Stop();
     checkWorkingAreaThread = new Thread(() =>
     {
         SystemInterop.RECT rect = WorkAreaManager.GetWorkingArea();
         while (true)
         {
             var newRect = WorkAreaManager.GetWorkingArea();
             if (rect.Bottom != newRect.Bottom ||
                 rect.Top != newRect.Top ||
                 rect.Left != newRect.Left ||
                 rect.Right != newRect.Right)
             {
                 if (WorkingAreaChanged != null)
                 {
                     WorkingAreaChanged(this, new EventArgs());
                 }
                 rect = newRect;
             }
             Thread.Sleep(100); // ~10ips
         }
     });
     checkWorkingAreaThread.Start();
     checkWindowsThread = new Thread(() =>
     {
         while (true)
         {
             // Check windows list
             int windowCount = 0;
             WindowInterop.EnumWindows((h, p) =>
             {
                 if (isTaskBarWindow(h))
                 {
                     windowCount++;
                 }
                 return(true);
             }, 0);
             if (windowCount != Windows.Count && WindowListChanged != null)
             {
                 WindowListChanged(this, new EventArgs());
             }
             // Check active window
             IntPtr activeHwnd = WindowInterop.GetForegroundWindow();
             var activeWindow  = new Win32Window(activeHwnd);
             var isDock        = activeWindow.FileName == Process.GetCurrentProcess().MainModule.FileName;
             if (ActiveWindow != activeHwnd && ActiveWindowChanged != null && !isDock)
             {
                 ActiveWindowChanged(activeHwnd, new EventArgs());
             }
             // Check active window location
             if (activeHwnd != IntPtr.Zero && !isDock)
             {
                 WindowInterop.Rect windowRect = new WindowInterop.Rect();
                 WindowInterop.GetWindowRect(activeHwnd, ref windowRect);
                 if (windowRect != ActiveWindowRect && ActiveWindowRectChanged != null)
                 {
                     ActiveWindowRectChanged(this, new WindowRectEventArgs(ActiveWindowRect = windowRect));
                 }
             }
             Thread.Sleep(50); // ~20ips
         }
     });
     checkWindowsThread.Start();
 }
Ejemplo n.º 2
0
        public void SetWorkingArea(bool reserveScrenSpace)
        {
            var reserved = reserveScrenSpace ? 100 : 0;

            WorkAreaManager.SetWorkingArea(0, 0, ScreenHelper.ScreenWidth, ScreenHelper.ScreenHeight - reserved);
        }