|
|
@ -18,10 +18,6 @@ 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;
|
|
|
|
using ZXing;
|
|
|
|
|
|
|
|
using ZXing.Common;
|
|
|
|
|
|
|
|
using ZXing.QrCode;
|
|
|
|
|
|
|
|
using ZXing.Windows.Compatibility;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace v2rayN
|
|
|
|
namespace v2rayN
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -950,66 +946,6 @@ namespace v2rayN
|
|
|
|
|
|
|
|
|
|
|
|
#endregion TempPath
|
|
|
|
#endregion TempPath
|
|
|
|
|
|
|
|
|
|
|
|
#region scan screen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string ScanScreen(float dpiX, float dpiY)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var left = (int)(SystemParameters.WorkArea.Left);
|
|
|
|
|
|
|
|
var top = (int)(SystemParameters.WorkArea.Top);
|
|
|
|
|
|
|
|
var width = (int)(SystemParameters.WorkArea.Width / dpiX);
|
|
|
|
|
|
|
|
var height = (int)(SystemParameters.WorkArea.Height / dpiY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using Bitmap fullImage = new Bitmap(width, height);
|
|
|
|
|
|
|
|
using (Graphics g = Graphics.FromImage(fullImage))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g.CopyFromScreen(left, top, 0, 0, fullImage.Size, CopyPixelOperation.SourceCopy);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int maxTry = 10;
|
|
|
|
|
|
|
|
for (int i = 0; i < maxTry; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int marginLeft = (int)((double)fullImage.Width * 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);
|
|
|
|
|
|
|
|
Bitmap target = new(width, height);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double imageScale = (double)width / (double)cropRect.Width;
|
|
|
|
|
|
|
|
using (Graphics g = Graphics.FromImage(target))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g.DrawImage(fullImage, new Rectangle(0, 0, target.Width, target.Height),
|
|
|
|
|
|
|
|
cropRect,
|
|
|
|
|
|
|
|
GraphicsUnit.Pixel);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BitmapLuminanceSource source = new(target);
|
|
|
|
|
|
|
|
BinaryBitmap bitmap = new(new HybridBinarizer(source));
|
|
|
|
|
|
|
|
QRCodeReader reader = new();
|
|
|
|
|
|
|
|
Result result = reader.decode(bitmap);
|
|
|
|
|
|
|
|
if (result != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string ret = result.Text;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Logging.SaveLog(ex.Message, ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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 scan screen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 开机自动启动等
|
|
|
|
#region 开机自动启动等
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|