예제 #1
0
        private void HideTerminalWithEffects(TerminalWindow terminalWindow)
        {
            SaveTerminalState(terminalWindow);

            // if the window isn't docked then
            if (!terminalWindow.IsDocked())
            {
                HideProcessWindow();
                return;
            }

            Console.WriteLine("Close");

            User32.ShowWindow(process.MainWindowHandle, NCmdShow.SHOW);
            User32.SetForegroundWindow(process.MainWindowHandle);

            var stepSize = (double)config.Height / (double)stepCount;

            for (int i = 1; i <= stepCount; i++)
            {
                User32.MoveWindow(
                    process.MainWindowHandle,
                    terminalWindow.ScreenX,
                    terminalWindow.ScreenY - (int)Math.Round(stepSize * i),
                    terminalWindow.Width,
                    terminalWindow.Height,
                    true
                    );

                Task.Delay(1).GetAwaiter().GetResult();
            }

            HideProcessWindow();
        }
예제 #2
0
        private void handleHotKeyPressed(object e, HotKeyEventArgs a)
        {
            User32.Rect rect = default;
            User32.GetWindowRect(process.MainWindowHandle, ref rect);
            var terminalWindow = new TerminalWindow(rect, GetScreenWithCursor().Bounds);

            var isVisible = terminalWindow.IsVisible();
            var isDocked  = terminalWindow.IsDocked();

            var foregroundWindow = Native.User32.GetForegroundWindow();
            var isForeground     = foregroundWindow == process.MainWindowHandle;

            if (isVisible && isDocked && isForeground)
            {
                HideTerminalWithEffects(terminalWindow);
            }
            else if (isVisible && isDocked)
            {
                User32.SetForegroundWindow(process.MainWindowHandle);
            }
            else
            {
                ShowTerminalWithEffects(terminalWindow);
            }
        }