Example #1
0
        static void WindowManager()
        {
            System.Drawing.Rectangle originalWindowRect;
            CoreWindow.GetWindowRect(WindowPointer, out originalWindowRect);
            Console.WriteLine("Original Window: " + originalWindowRect);

            bool isWindowBorderOn = false;

            if (!string.IsNullOrEmpty(ConfigData.HighlighterColor) && ConfigData.HighlighterBorderWidth > 0)
            {
                borderWindowHighlighter =
                    new WindowHighlighter(Color.FromName(ConfigData.HighlighterColor), Color.AliceBlue);
                isWindowBorderOn = true;
            }

            while (true)
            {
                IntPtr    currentWindow = CoreWindow.GetForegroundWindow();
                Rectangle windowRectangle;
                CoreWindow.GetWindowRect(WindowPointer, out windowRectangle);

                windowRectangle.Width  -= windowRectangle.X;
                windowRectangle.Height -= windowRectangle.Y;

                if (isWindowBorderOn)
                {
                    borderWindowHighlighter.Highlight(windowRectangle, false, ConfigData.HighlighterBorderWidth);
                    borderWindowHighlighter.SetLocation(windowRectangle, false);
                }

                if (IsDraggingWindow && currentWindow == WindowPointer)
                {
                    System.Drawing.Point hostCursorPosition = CoreMouse.GetCursorPosition();

                    CoreWindow.MoveWindow(WindowPointer, hostCursorPosition.X, hostCursorPosition.Y,
                                          ConfigData.StaticWidth, ConfigData.StaticHeight, true);

                    Console.WriteLine(hostCursorPosition);
                }

                if (currentWindow != WindowPointer && isWindowBorderOn)
                {
                    borderWindowHighlighter.Hide();
                }
            }
        }
Example #2
0
        public void StartWatch()
        {
            WindowsReStyle();

            if (!UiFoundProcess)
            {
                MessageBox.Show("Could not find the process " + ConfigData.ProcessName,
                                "Windows Frameless Terminal", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            WindowPointer = CoreWindow.FindWindow(ConfigData.ProcessName, null);

            CoreWindow.GetWindowRect(WindowPointer, out CurrentWindowRectangle);

            CoreWindow.SetWindowPos(WindowPointer, 0, CurrentWindowRectangle.X, CurrentWindowRectangle.Y,
                                    CurrentWindowRectangle.Width, CurrentWindowRectangle.Height - 1, 0);

            if (windowManagerThread.IsAlive)
            {
                windowManagerThread.Abort();
            }

            if (WindowPointer != IntPtr.Zero)
            {
                windowManagerThread.Start();
            }

            StartWatchBtn.Content = "Stop Watch";

            uint processId;

            CoreWindow.GetWindowThreadProcessId(WindowPointer, out processId);
            InfoLbl.Content = "Info: PID: " + Convert.ToString(processId);

            SystemSounds.Beep.Play();
        }