mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Remove System.Windows.Forms.Screen reference
This commit is contained in:
parent
e63941275e
commit
527c27f675
5 changed files with 28 additions and 32 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Media;
|
||||
|
|
@ -30,7 +30,6 @@ using DataObject = System.Windows.DataObject;
|
|||
using Key = System.Windows.Input.Key;
|
||||
using MouseButtons = System.Windows.Forms.MouseButtons;
|
||||
using NotifyIcon = System.Windows.Forms.NotifyIcon;
|
||||
using Screen = System.Windows.Forms.Screen;
|
||||
|
||||
namespace Flow.Launcher
|
||||
{
|
||||
|
|
@ -532,7 +531,7 @@ namespace Flow.Launcher
|
|||
double yRatio = mousePos.Y / maxHeight;
|
||||
|
||||
// Current monitor information
|
||||
var screen = Screen.FromHandle(new WindowInteropHelper(this).Handle);
|
||||
var screen = MonitorInfo.GetNearestDisplayMonitor(new WindowInteropHelper(this).Handle);
|
||||
var workingArea = screen.WorkingArea;
|
||||
var screenLeftTop = Win32Helper.TransformPixelsToDIP(this, workingArea.X, workingArea.Y);
|
||||
|
||||
|
|
@ -954,36 +953,36 @@ namespace Flow.Launcher
|
|||
}
|
||||
}
|
||||
|
||||
private Screen SelectedScreen()
|
||||
private MonitorInfo SelectedScreen()
|
||||
{
|
||||
Screen screen;
|
||||
MonitorInfo screen;
|
||||
switch (_settings.SearchWindowScreen)
|
||||
{
|
||||
case SearchWindowScreens.Cursor:
|
||||
screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
break;
|
||||
case SearchWindowScreens.Primary:
|
||||
screen = Screen.PrimaryScreen;
|
||||
screen = MonitorInfo.GetCursorDisplayMonitor();
|
||||
break;
|
||||
case SearchWindowScreens.Focus:
|
||||
var foregroundWindowHandle = Win32Helper.GetForegroundWindow();
|
||||
screen = Screen.FromHandle(foregroundWindowHandle);
|
||||
screen = MonitorInfo.GetNearestDisplayMonitor(Win32Helper.GetForegroundWindow());
|
||||
break;
|
||||
case SearchWindowScreens.Primary:
|
||||
screen = MonitorInfo.GetPrimaryDisplayMonitor();
|
||||
break;
|
||||
case SearchWindowScreens.Custom:
|
||||
if (_settings.CustomScreenNumber <= Screen.AllScreens.Length)
|
||||
screen = Screen.AllScreens[_settings.CustomScreenNumber - 1];
|
||||
var allScreens = MonitorInfo.GetDisplayMonitors();
|
||||
if (_settings.CustomScreenNumber <= allScreens.Count)
|
||||
screen = allScreens[_settings.CustomScreenNumber - 1];
|
||||
else
|
||||
screen = Screen.AllScreens[0];
|
||||
screen = allScreens[0];
|
||||
break;
|
||||
default:
|
||||
screen = Screen.AllScreens[0];
|
||||
screen = MonitorInfo.GetDisplayMonitors()[0];
|
||||
break;
|
||||
}
|
||||
|
||||
return screen ?? Screen.AllScreens[0];
|
||||
return screen ?? MonitorInfo.GetDisplayMonitors()[0];
|
||||
}
|
||||
|
||||
private double HorizonCenter(Screen screen)
|
||||
private double HorizonCenter(MonitorInfo screen)
|
||||
{
|
||||
var dip1 = Win32Helper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
|
||||
var dip2 = Win32Helper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
|
||||
|
|
@ -991,7 +990,7 @@ namespace Flow.Launcher
|
|||
return left;
|
||||
}
|
||||
|
||||
private double VerticalCenter(Screen screen)
|
||||
private double VerticalCenter(MonitorInfo screen)
|
||||
{
|
||||
var dip1 = Win32Helper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
|
||||
var dip2 = Win32Helper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
|
||||
|
|
@ -999,7 +998,7 @@ namespace Flow.Launcher
|
|||
return top;
|
||||
}
|
||||
|
||||
private double HorizonRight(Screen screen)
|
||||
private double HorizonRight(MonitorInfo screen)
|
||||
{
|
||||
var dip1 = Win32Helper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
|
||||
var dip2 = Win32Helper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
|
||||
|
|
@ -1007,14 +1006,14 @@ namespace Flow.Launcher
|
|||
return left;
|
||||
}
|
||||
|
||||
private double HorizonLeft(Screen screen)
|
||||
private double HorizonLeft(MonitorInfo screen)
|
||||
{
|
||||
var dip1 = Win32Helper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
|
||||
var left = dip1.X + 10;
|
||||
return left;
|
||||
}
|
||||
|
||||
public double VerticalTop(Screen screen)
|
||||
private double VerticalTop(MonitorInfo screen)
|
||||
{
|
||||
var dip1 = Win32Helper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
|
||||
var top = dip1.Y + 10;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Animation;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
|
|
@ -16,7 +15,7 @@ namespace Flow.Launcher
|
|||
public Msg()
|
||||
{
|
||||
InitializeComponent();
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
var screen = MonitorInfo.GetCursorDisplayMonitor();
|
||||
var dipWorkingArea = Win32Helper.TransformPixelsToDIP(this,
|
||||
screen.WorkingArea.Width,
|
||||
screen.WorkingArea.Height);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Animation;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
|
|
@ -16,7 +15,7 @@ namespace Flow.Launcher
|
|||
public MsgWithButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
var screen = MonitorInfo.GetCursorDisplayMonitor();
|
||||
var dipWorkingArea = Win32Helper.TransformPixelsToDIP(this,
|
||||
screen.WorkingArea.Width,
|
||||
screen.WorkingArea.Height);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
|
@ -111,9 +111,9 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
{
|
||||
get
|
||||
{
|
||||
var screens = Screen.AllScreens;
|
||||
var screens = MonitorInfo.GetDisplayMonitors();
|
||||
var screenNumbers = new List<int>();
|
||||
for (int i = 1; i <= screens.Length; i++)
|
||||
for (int i = 1; i <= screens.Count; i++)
|
||||
{
|
||||
screenNumbers.Add(i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ using Flow.Launcher.Infrastructure.UserSettings;
|
|||
using Flow.Launcher.SettingPages.Views;
|
||||
using Flow.Launcher.ViewModel;
|
||||
using ModernWpf.Controls;
|
||||
using Screen = System.Windows.Forms.Screen;
|
||||
|
||||
namespace Flow.Launcher;
|
||||
|
||||
|
|
@ -202,7 +201,7 @@ public partial class SettingWindow
|
|||
|
||||
private static bool IsPositionValid(double top, double left)
|
||||
{
|
||||
foreach (var screen in Screen.AllScreens)
|
||||
foreach (var screen in MonitorInfo.GetDisplayMonitors())
|
||||
{
|
||||
var workingArea = screen.WorkingArea;
|
||||
|
||||
|
|
@ -217,7 +216,7 @@ public partial class SettingWindow
|
|||
|
||||
private double WindowLeft()
|
||||
{
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
var screen = MonitorInfo.GetCursorDisplayMonitor();
|
||||
var dip1 = Win32Helper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
|
||||
var dip2 = Win32Helper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
|
||||
var left = (dip2.X - ActualWidth) / 2 + dip1.X;
|
||||
|
|
@ -226,7 +225,7 @@ public partial class SettingWindow
|
|||
|
||||
private double WindowTop()
|
||||
{
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
var screen = MonitorInfo.GetCursorDisplayMonitor();
|
||||
var dip1 = Win32Helper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
|
||||
var dip2 = Win32Helper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
|
||||
var top = (dip2.Y - ActualHeight) / 2 + dip1.Y - 20;
|
||||
|
|
|
|||
Loading…
Reference in a new issue