Remove some System.Windows.Forms references

pull/3611/head
2dust 2 years ago
parent 65fda407dc
commit 23c7d7fb46

@ -18,7 +18,7 @@ using System.Security.Principal;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Web; using System.Web;
using System.Windows.Forms; using System.Windows;
using System.Windows.Interop; using System.Windows.Interop;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
@ -667,12 +667,12 @@ namespace v2rayN
/// <returns></returns> /// <returns></returns>
public static string GetExePath() public static string GetExePath()
{ {
return Application.ExecutablePath; return Environment.ProcessPath;
} }
public static string StartupPath() public static string StartupPath()
{ {
return Application.StartupPath; return AppDomain.CurrentDomain.BaseDirectory;
} }
public static string? RegReadValue(string path, string name, string def) public static string? RegReadValue(string path, string name, string def)
@ -1181,17 +1181,17 @@ namespace v2rayN
{ {
try try
{ {
foreach (Screen screen in Screen.AllScreens) foreach (var screen in System.Windows.Forms.Screen.AllScreens)
{ {
using Bitmap fullImage = new Bitmap(screen.Bounds.Width, var left = screen.Bounds.X;
screen.Bounds.Height); var top = screen.Bounds.Y;
var width = screen.Bounds.Width;
var height = screen.Bounds.Height;
using Bitmap fullImage = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(fullImage)) using (Graphics g = Graphics.FromImage(fullImage))
{ {
g.CopyFromScreen(screen.Bounds.X, g.CopyFromScreen(left, top, 0, 0, fullImage.Size, CopyPixelOperation.SourceCopy);
screen.Bounds.Y,
0, 0,
fullImage.Size,
CopyPixelOperation.SourceCopy);
} }
int maxTry = 10; int maxTry = 10;
for (int i = 0; i < maxTry; i++) for (int i = 0; i < maxTry; i++)
@ -1199,9 +1199,9 @@ namespace v2rayN
int marginLeft = (int)((double)fullImage.Width * i / 2.5 / maxTry); int marginLeft = (int)((double)fullImage.Width * i / 2.5 / maxTry);
int marginTop = (int)((double)fullImage.Height * i / 2.5 / maxTry); int marginTop = (int)((double)fullImage.Height * i / 2.5 / maxTry);
Rectangle cropRect = new(marginLeft, marginTop, fullImage.Width - marginLeft * 2, fullImage.Height - marginTop * 2); Rectangle cropRect = new(marginLeft, marginTop, fullImage.Width - marginLeft * 2, fullImage.Height - marginTop * 2);
Bitmap target = new(screen.Bounds.Width, screen.Bounds.Height); Bitmap target = new(width, height);
double imageScale = (double)screen.Bounds.Width / (double)cropRect.Width; double imageScale = (double)width / (double)cropRect.Width;
using (Graphics g = Graphics.FromImage(target)) using (Graphics g = Graphics.FromImage(target))
{ {
g.DrawImage(fullImage, new Rectangle(0, 0, target.Width, target.Height), g.DrawImage(fullImage, new Rectangle(0, 0, target.Width, target.Height),

Loading…
Cancel
Save