Repository: microsoft/PowerToys
File: src/modules/Workspaces/WorkspacesEditor/MainWindow.xaml.cs (C#)

Code before:
                {
                    if (ApplicationIsInFocus())
                    {
                        Environment.Exit(0);
                    }
                    else
                    {
                        if (WindowState == WindowState.Minimized)
                        {
                            WindowState = WindowState.Normal;
                        }

                        // Get the window handle of the Workspaces Editor window
                        IntPtr handle = new WindowInteropHelper(this).Handle;
                        WindowHelpers.BringToForeground(handle);

                        InvalidateVisual();
                    }
                },
                Application.Current.Dispatcher,
                cancellationToken.Token);
        }

        private bool IsEditorInsideVisibleArea()
        {
            System.Windows.Forms.Screen[] allScreens = System.Windows.Forms.Screen.AllScreens;
            Rectangle commonBounds = allScreens[0].Bounds;
            for (int screenIndex = 1; screenIndex < allScreens.Length; screenIndex++)
            {
                Rectangle rectangle = allScreens[screenIndex].Bounds;
                commonBounds = Rectangle.Union(rectangle, commonBounds);
            }

            Rectangle editorBounds = new Rectangle((int)Properties.Settings.Default.Left, (int)Properties.Settings.Default.Top, (int)Properties.Settings.Default.Width, (int)Properties.Settings.Default.Height);
            return editorBounds.IntersectsWith(commonBounds);
        }

        private void SavePosition()
        {
            if (WindowState == WindowState.Maximized)
            {
                // Use the RestoreBounds as the current values will be 0, 0 and the size of the screen
                Properties.Settings.Default.Top = RestoreBounds.Top;
                Properties.Settings.Default.Left = RestoreBounds.Left;
                Properties.Settings.Default.Height = RestoreBounds.Height;
                Properties.Settings.Default.Width = RestoreBounds.Width;
                Properties.Settings.Default.Maximized = true;
            }
            else
            {
                Properties.Settings.Default.Top = this.Top;

Review comment (refactor):
```suggestion
            System.Windows.Forms.Screen[] allScreens = MonitorHelper.GetDpiUnawareScreens();
```

Code after:
                {
                    if (ApplicationIsInFocus())
                    {
                        Environment.Exit(0);
                    }
                    else
                    {
                        if (WindowState == WindowState.Minimized)
                        {
                            WindowState = WindowState.Normal;
                        }

                        // Get the window handle of the Workspaces Editor window
                        IntPtr handle = new WindowInteropHelper(this).Handle;
                        WindowHelpers.BringToForeground(handle);

                        InvalidateVisual();
                    }
                },
                Application.Current.Dispatcher,
                cancellationToken.Token);
        }

        private bool IsEditorInsideVisibleArea()
        {
            System.Windows.Forms.Screen[] allScreens = MonitorHelper.GetDpiUnawareScreens();
            Rectangle commonBounds = allScreens[0].Bounds;
            for (int screenIndex = 1; screenIndex < allScreens.Length; screenIndex++)
            {
                Rectangle rectangle = allScreens[screenIndex].Bounds;
                commonBounds = Rectangle.Union(rectangle, commonBounds);
            }

            Rectangle editorBounds = new Rectangle((int)Properties.Settings.Default.Left, (int)Properties.Settings.Default.Top, (int)Properties.Settings.Default.Width, (int)Properties.Settings.Default.Height);
            return editorBounds.IntersectsWith(commonBounds);
        }

        private void SavePosition()
        {
            if (WindowState == WindowState.Maximized)
            {
                // Use the RestoreBounds as the current values will be 0, 0 and the size of the screen
                Properties.Settings.Default.Top = RestoreBounds.Top;
                Properties.Settings.Default.Left = RestoreBounds.Left;
                Properties.Settings.Default.Height = RestoreBounds.Height;
                Properties.Settings.Default.Width = RestoreBounds.Width;
                Properties.Settings.Default.Maximized = true;
            }
            else
            {
                Properties.Settings.Default.Top = this.Top;