private void DispatchOnScreen(List <IWindow> windows, IScreen screen)
        {
            var windowsCount = windows.Count;

            if (windowsCount > 0)
            {
                var totalWidth = screen.Rectangle.Size.Width;
                var width      = (totalWidth - (windowsCount - 1) * 10) / windowsCount;

                for (int windowIndex = 0; windowIndex < windowsCount; windowIndex++)
                {
                    var left      = screen.Rectangle.Position.Left + (width + 10) * windowIndex;
                    var top       = screen.Rectangle.Position.Top;
                    var height    = screen.Rectangle.Size.Height;
                    var rectangle = new Rectangle(width, height, left, top);
                    var window    = windows[windowIndex];
                    WindowOsServiceImpl.MoveSync(window, rectangle);

                    this.LogLine("Moving window {0} to {1}", window.ToRepr(), rectangle.Canonical);
                }
            }
        }
        public void MultiFocusTest()
        {
            TraceFile.SetName("MultiFocusTest");

            AddAction(KeyModifier.Alt, "S", "Quit", () => RunService.Stop());

            var testWindows      = GetTestWindows.ToList();
            var testWindowsCount = testWindows.Count;
            int currentPosition  = -1;

            var     screens = ScreenOsService.GetScreens();
            IScreen screen  = screens.Last();

            foreach (var testWindow in testWindows)
            {
                this.LogLine("Window : {0}", testWindow.ToRepr());
            }

            var trayWindows = GetTrayWindows;

            trayWindows = trayWindows.Where(w => RectangleService.Intersect(w.RectangleCurrent, screen.Rectangle) != null);

            foreach (var trayWindowItem in trayWindows)
            {
                this.LogLine("Tray Window : {0}", trayWindowItem.ToRepr());
            }
            var trayWindow = trayWindows.First();

            void focusNext()
            {
                currentPosition++;
                currentPosition %= testWindowsCount;
                this.LogLine("  -> Focusing {0}]", testWindows[currentPosition].ToRepr());
                WindowOsServiceImpl.FocusWindowSync(testWindows[currentPosition]);
            }

            void focusPrev()
            {
                currentPosition += testWindowsCount;
                currentPosition--;
                currentPosition %= testWindowsCount;
                this.LogLine("  -> Focusing {0}]", testWindows[currentPosition].ToRepr());
                WindowOsServiceImpl.FocusWindowSync(testWindows[currentPosition]);
            }

            void moveToNewPosition(int newPosition)
            {
                var currentWindow = testWindows[currentPosition];

                testWindows.Remove(currentWindow);
                testWindows.Insert(newPosition, currentWindow);

                this.LogLine("  -> Moving {0}]", currentWindow.ToRepr());

                DispatchOnScreen(testWindows, screen);
                currentPosition = newPosition;
                WindowOsServiceImpl.FocusWindowSync(currentWindow);
            }

            void moveToNext()
            {
                var newPosition = (currentPosition + 1) % testWindowsCount;

                moveToNewPosition(newPosition);
            }

            void moveToPrev()
            {
                var newPosition = (currentPosition + testWindowsCount - 1) % testWindowsCount;

                moveToNewPosition(newPosition);
            }

            AddAction(KeyModifier.Alt, "Left", "FocusPrev", focusPrev);
            AddAction(KeyModifier.Alt, "Right", "FocusNext", focusNext);
            AddAction(KeyModifier.Alt, "J", "MoveToPrev", moveToPrev);
            AddAction(KeyModifier.Alt, "K", "MoveToNext", moveToNext);

            DispatchOnScreen(testWindows, screen);

            WindowOsServiceImpl.HideSync(trayWindow);
            focusNext();
            RunService.Run();

            foreach (var testWindow in testWindows)
            {
                WindowOsServiceImpl.UnmanageSync(testWindow);
            }
            WindowOsServiceImpl.ShowSync(trayWindow);
        }