mirror of https://github.com/2dust/v2rayN
Remove System.Windows.Forms references
parent
22475e459d
commit
8ad80bb75d
|
@ -1,7 +1,4 @@
|
||||||
|
namespace v2rayN.Mode
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace v2rayN.Mode
|
|
||||||
{
|
{
|
||||||
public enum EViewAction
|
public enum EViewAction
|
||||||
{
|
{
|
||||||
|
|
|
@ -1177,16 +1177,14 @@ namespace v2rayN
|
||||||
|
|
||||||
#region scan screen
|
#region scan screen
|
||||||
|
|
||||||
public static string ScanScreen()
|
public static string ScanScreen(float dpiX, float dpiY)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var screen in System.Windows.Forms.Screen.AllScreens)
|
var left = (int)(SystemParameters.WorkArea.Left);
|
||||||
{
|
var top = (int)(SystemParameters.WorkArea.Top);
|
||||||
var left = screen.Bounds.X;
|
var width = (int)(SystemParameters.WorkArea.Width / dpiX);
|
||||||
var top = screen.Bounds.Y;
|
var height = (int)(SystemParameters.WorkArea.Height / dpiY);
|
||||||
var width = screen.Bounds.Width;
|
|
||||||
var height = screen.Bounds.Height;
|
|
||||||
|
|
||||||
using Bitmap fullImage = new Bitmap(width, height);
|
using Bitmap fullImage = new Bitmap(width, height);
|
||||||
using (Graphics g = Graphics.FromImage(fullImage))
|
using (Graphics g = Graphics.FromImage(fullImage))
|
||||||
|
@ -1220,7 +1218,6 @@ namespace v2rayN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
SaveLog(ex.Message, ex);
|
SaveLog(ex.Message, ex);
|
||||||
|
@ -1228,6 +1225,14 @@ namespace v2rayN
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Tuple<float, float> GetDpiXY(Window window)
|
||||||
|
{
|
||||||
|
IntPtr hWnd = new WindowInteropHelper(window).EnsureHandle();
|
||||||
|
Graphics g = Graphics.FromHwnd(hWnd);
|
||||||
|
|
||||||
|
return new(96 / g.DpiX, 96 / g.DpiY);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ using v2rayN.Mode;
|
||||||
using v2rayN.Resx;
|
using v2rayN.Resx;
|
||||||
using v2rayN.Tool;
|
using v2rayN.Tool;
|
||||||
using v2rayN.Views;
|
using v2rayN.Views;
|
||||||
using Application = System.Windows.Application;
|
|
||||||
|
|
||||||
|
|
||||||
namespace v2rayN.ViewModels
|
namespace v2rayN.ViewModels
|
||||||
|
@ -924,9 +923,10 @@ namespace v2rayN.ViewModels
|
||||||
{
|
{
|
||||||
ShowHideWindow(false);
|
ShowHideWindow(false);
|
||||||
|
|
||||||
|
var dpiXY = Utils.GetDpiXY(Application.Current.MainWindow);
|
||||||
string result = await Task.Run(() =>
|
string result = await Task.Run(() =>
|
||||||
{
|
{
|
||||||
return Utils.ScanScreen();
|
return Utils.ScanScreen(dpiXY.Item1, dpiXY.Item2);
|
||||||
});
|
});
|
||||||
|
|
||||||
ShowHideWindow(true);
|
ShowHideWindow(true);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Splat;
|
using Splat;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
@ -420,11 +419,8 @@ namespace v2rayN.Views
|
||||||
Height = _config.uiItem.mainHeight;
|
Height = _config.uiItem.mainHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
//IntPtr hWnd = new WindowInteropHelper(this).EnsureHandle();
|
var maxWidth = SystemParameters.WorkArea.Width;
|
||||||
//Graphics g = Graphics.FromHwnd(hWnd);
|
var maxHeight = SystemParameters.WorkArea.Height;
|
||||||
//var dip = 96;
|
|
||||||
var maxWidth = SystemParameters.WorkArea.Width;// * dip / g.DpiX;
|
|
||||||
var maxHeight = SystemParameters.WorkArea.Height;// * dip / g.DpiY;
|
|
||||||
if (Width > maxWidth) Width = maxWidth;
|
if (Width > maxWidth) Width = maxWidth;
|
||||||
if (Height > maxHeight) Height = maxHeight;
|
if (Height > maxHeight) Height = maxHeight;
|
||||||
if (_config.uiItem.mainGirdHeight1 > 0 && _config.uiItem.mainGirdHeight2 > 0)
|
if (_config.uiItem.mainGirdHeight1 > 0 && _config.uiItem.mainGirdHeight2 > 0)
|
||||||
|
|
Loading…
Reference in New Issue