Пример #1
0
        public async Task StartAsync()
        {
            var screens  = ScreenOsService.GetScreens().OrderBy(s => s.Rectangle.Position.Left).ToList();
            var desktops = await DesktopRepository.GetDesktops();

            var desktop = desktops.First();

            foreach (var screen in screens)
            {
                await ScreenRepository.AddOrUpdateScreen(screen);

                desktop.Screen = screen;

                desktop = await DesktopRepository.GetNext(desktop);
            }
            var windows = WindowOsService.GetWindowsSync();

            foreach (var window in windows)
            {
                await WindowRepository.AddOrUpdateWindow(window);
            }
            ForceLayout();
        }
Пример #2
0
        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);
        }