mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-29 14:26:20 +00:00
解决多屏幕环境下 获取程序运行所在屏幕的DPI缩放的问题
This commit is contained in:
parent
0fe7d5e598
commit
f1693bce64
22 changed files with 398 additions and 60 deletions
|
@ -3,6 +3,7 @@ using System.Windows.Threading;
|
||||||
using v2rayN.Handler;
|
using v2rayN.Handler;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.Tool;
|
using v2rayN.Tool;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
|
||||||
namespace v2rayN
|
namespace v2rayN
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using System.Windows.Media;
|
using v2rayN.Handler;
|
||||||
using v2rayN.Handler;
|
using FontFamily = System.Windows.Media.FontFamily;
|
||||||
|
|
||||||
namespace v2rayN.Converters
|
namespace v2rayN.Converters
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,8 @@ using System.Windows.Input;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.Resx;
|
using v2rayN.Resx;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||||
|
|
||||||
namespace v2rayN.Handler
|
namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
using Microsoft.Win32;
|
using System.IO;
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.Resx;
|
using v2rayN.Resx;
|
||||||
|
using SaveFileDialog = Microsoft.Win32.SaveFileDialog;
|
||||||
|
|
||||||
namespace v2rayN.Handler
|
namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using MessageBox = System.Windows.MessageBox;
|
||||||
|
|
||||||
namespace v2rayN
|
namespace v2rayN
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,6 @@ using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
@ -28,6 +27,9 @@ using ZXing;
|
||||||
using ZXing.Common;
|
using ZXing.Common;
|
||||||
using ZXing.QrCode;
|
using ZXing.QrCode;
|
||||||
using ZXing.Windows.Compatibility;
|
using ZXing.Windows.Compatibility;
|
||||||
|
using Clipboard = System.Windows.Clipboard;
|
||||||
|
using DataFormats = System.Windows.DataFormats;
|
||||||
|
using IDataObject = System.Windows.IDataObject;
|
||||||
|
|
||||||
namespace v2rayN
|
namespace v2rayN
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using Microsoft.Win32;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using ReactiveUI.Validation.Helpers;
|
using ReactiveUI.Validation.Helpers;
|
||||||
|
@ -10,6 +9,7 @@ using v2rayN.Base;
|
||||||
using v2rayN.Handler;
|
using v2rayN.Handler;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.Resx;
|
using v2rayN.Resx;
|
||||||
|
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||||
|
|
||||||
namespace v2rayN.ViewModels
|
namespace v2rayN.ViewModels
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,12 +3,10 @@ using DynamicData.Binding;
|
||||||
using MaterialDesignColors;
|
using MaterialDesignColors;
|
||||||
using MaterialDesignColors.ColorManipulation;
|
using MaterialDesignColors.ColorManipulation;
|
||||||
using MaterialDesignThemes.Wpf;
|
using MaterialDesignThemes.Wpf;
|
||||||
using Microsoft.Win32;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Splat;
|
using Splat;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
|
@ -21,6 +19,8 @@ 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;
|
||||||
|
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||||
|
|
||||||
namespace v2rayN.ViewModels
|
namespace v2rayN.ViewModels
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
using Microsoft.Win32;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Splat;
|
using Splat;
|
||||||
|
@ -11,6 +10,7 @@ using v2rayN.Mode;
|
||||||
using v2rayN.Resx;
|
using v2rayN.Resx;
|
||||||
using v2rayN.Views;
|
using v2rayN.Views;
|
||||||
using Application = System.Windows.Application;
|
using Application = System.Windows.Application;
|
||||||
|
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||||
|
|
||||||
namespace v2rayN.ViewModels
|
namespace v2rayN.ViewModels
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Reactive.Disposables;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.ViewModels;
|
using v2rayN.ViewModels;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
|
@ -11,10 +12,6 @@ namespace v2rayN.Views
|
||||||
public AddServer2Window(ProfileItem profileItem)
|
public AddServer2Window(ProfileItem profileItem)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.MaxWidth = SystemParameters.WorkArea.Width;
|
|
||||||
this.MaxHeight = SystemParameters.WorkArea.Height;
|
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
this.Loaded += Window_Loaded;
|
this.Loaded += Window_Loaded;
|
||||||
ViewModel = new AddServer2ViewModel(profileItem, this);
|
ViewModel = new AddServer2ViewModel(profileItem, this);
|
||||||
|
@ -44,6 +41,36 @@ namespace v2rayN.Views
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
txtRemarks.Focus();
|
txtRemarks.Focus();
|
||||||
|
|
||||||
|
// 获取当前屏幕的尺寸
|
||||||
|
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||||
|
var screenWidth = screen.WorkingArea.Width;
|
||||||
|
var screenHeight = screen.WorkingArea.Height;
|
||||||
|
var screenTop = screen.WorkingArea.Top;
|
||||||
|
|
||||||
|
// 获取屏幕的 DPI 缩放因素
|
||||||
|
double dpiFactor = 1;
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
dpiFactor = source.CompositionTarget.TransformToDevice.M11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口尺寸不超过当前屏幕的尺寸
|
||||||
|
if (this.Width > screenWidth / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Width = screenWidth / dpiFactor;
|
||||||
|
}
|
||||||
|
if (this.Height > screenHeight / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Height = screenHeight / dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口不要显示在屏幕外面
|
||||||
|
if (this.Top < screenTop / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Top = screenTop / dpiFactor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, System.Windows.RoutedEventArgs e)
|
private void btnCancel_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||||
|
|
|
@ -7,6 +7,7 @@ using v2rayN.Handler;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.Resx;
|
using v2rayN.Resx;
|
||||||
using v2rayN.ViewModels;
|
using v2rayN.ViewModels;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
|
@ -15,10 +16,6 @@ namespace v2rayN.Views
|
||||||
public AddServerWindow(ProfileItem profileItem)
|
public AddServerWindow(ProfileItem profileItem)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.MaxWidth = SystemParameters.WorkArea.Width;
|
|
||||||
this.MaxHeight = SystemParameters.WorkArea.Height;
|
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
this.Loaded += Window_Loaded;
|
this.Loaded += Window_Loaded;
|
||||||
cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged;
|
cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged;
|
||||||
|
@ -176,6 +173,36 @@ namespace v2rayN.Views
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
txtRemarks.Focus();
|
txtRemarks.Focus();
|
||||||
|
|
||||||
|
// 获取当前屏幕的尺寸
|
||||||
|
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||||
|
var screenWidth = screen.WorkingArea.Width;
|
||||||
|
var screenHeight = screen.WorkingArea.Height;
|
||||||
|
var screenTop = screen.WorkingArea.Top;
|
||||||
|
|
||||||
|
// 获取屏幕的 DPI 缩放因素
|
||||||
|
double dpiFactor = 1;
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
dpiFactor = source.CompositionTarget.TransformToDevice.M11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口尺寸不超过当前屏幕的尺寸
|
||||||
|
if (this.Width > screenWidth / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Width = screenWidth / dpiFactor;
|
||||||
|
}
|
||||||
|
if (this.Height > screenHeight / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Height = screenHeight / dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口不要显示在屏幕外面
|
||||||
|
if (this.Top < screenTop / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Top = screenTop / dpiFactor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CmbNetwork_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void CmbNetwork_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Windows;
|
||||||
using v2rayN.Handler;
|
using v2rayN.Handler;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.ViewModels;
|
using v2rayN.ViewModels;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
|
@ -14,13 +15,11 @@ namespace v2rayN.Views
|
||||||
public DNSSettingWindow()
|
public DNSSettingWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.MaxWidth = SystemParameters.WorkArea.Width;
|
|
||||||
this.MaxHeight = SystemParameters.WorkArea.Height;
|
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
_config = LazyConfig.Instance.GetConfig();
|
|
||||||
|
|
||||||
|
this.Loaded += Window_Loaded;
|
||||||
|
|
||||||
|
_config = LazyConfig.Instance.GetConfig();
|
||||||
ViewModel = new DNSSettingViewModel(this);
|
ViewModel = new DNSSettingViewModel(this);
|
||||||
|
|
||||||
Global.domainStrategy4Freedoms.ForEach(it =>
|
Global.domainStrategy4Freedoms.ForEach(it =>
|
||||||
|
@ -41,6 +40,39 @@ namespace v2rayN.Views
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// 获取当前屏幕的尺寸
|
||||||
|
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||||
|
var screenWidth = screen.WorkingArea.Width;
|
||||||
|
var screenHeight = screen.WorkingArea.Height;
|
||||||
|
var screenTop = screen.WorkingArea.Top;
|
||||||
|
|
||||||
|
// 获取屏幕的 DPI 缩放因素
|
||||||
|
double dpiFactor = 1;
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
dpiFactor = source.CompositionTarget.TransformToDevice.M11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口尺寸不超过当前屏幕的尺寸
|
||||||
|
if (this.Width > screenWidth / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Width = screenWidth / dpiFactor;
|
||||||
|
}
|
||||||
|
if (this.Height > screenHeight / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Height = screenHeight / dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口不要显示在屏幕外面
|
||||||
|
if (this.Top < screenTop / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Top = screenTop / dpiFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
|
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Utils.ProcessStart("https://www.v2fly.org/config/dns.html#dnsobject");
|
Utils.ProcessStart("https://www.v2fly.org/config/dns.html#dnsobject");
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using v2rayN.Handler;
|
using v2rayN.Handler;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.Resx;
|
using v2rayN.Resx;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||||
|
using TextBox = System.Windows.Controls.TextBox;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
|
@ -16,11 +18,8 @@ namespace v2rayN.Views
|
||||||
public GlobalHotkeySettingWindow()
|
public GlobalHotkeySettingWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.MaxWidth = SystemParameters.WorkArea.Width;
|
|
||||||
this.MaxHeight = SystemParameters.WorkArea.Height;
|
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
|
this.Loaded += Window_Loaded;
|
||||||
_config = LazyConfig.Instance.GetConfig();
|
_config = LazyConfig.Instance.GetConfig();
|
||||||
_config.globalHotkeys ??= new List<KeyEventItem>();
|
_config.globalHotkeys ??= new List<KeyEventItem>();
|
||||||
|
|
||||||
|
@ -36,6 +35,39 @@ namespace v2rayN.Views
|
||||||
InitData();
|
InitData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// 获取当前屏幕的尺寸
|
||||||
|
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||||
|
var screenWidth = screen.WorkingArea.Width;
|
||||||
|
var screenHeight = screen.WorkingArea.Height;
|
||||||
|
var screenTop = screen.WorkingArea.Top;
|
||||||
|
|
||||||
|
// 获取屏幕的 DPI 缩放因素
|
||||||
|
double dpiFactor = 1;
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
dpiFactor = source.CompositionTarget.TransformToDevice.M11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口尺寸不超过当前屏幕的尺寸
|
||||||
|
if (this.Width > screenWidth / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Width = screenWidth / dpiFactor;
|
||||||
|
}
|
||||||
|
if (this.Height > screenHeight / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Height = screenHeight / dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口不要显示在屏幕外面
|
||||||
|
if (this.Top < screenTop / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Top = screenTop / dpiFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void InitData()
|
private void InitData()
|
||||||
{
|
{
|
||||||
_TextBoxKeyEventItem = new()
|
_TextBoxKeyEventItem = new()
|
||||||
|
|
|
@ -14,6 +14,12 @@ using v2rayN.Handler;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.Resx;
|
using v2rayN.Resx;
|
||||||
using v2rayN.ViewModels;
|
using v2rayN.ViewModels;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
using DataObject = System.Windows.DataObject;
|
||||||
|
using DragDropEffects = System.Windows.DragDropEffects;
|
||||||
|
using DragEventArgs = System.Windows.DragEventArgs;
|
||||||
|
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||||
|
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||||
using Point = System.Windows.Point;
|
using Point = System.Windows.Point;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
|
@ -25,10 +31,7 @@ namespace v2rayN.Views
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.Loaded += Window_Loaded;
|
||||||
this.MaxWidth = SystemParameters.WorkArea.Width;
|
|
||||||
this.MaxHeight = SystemParameters.WorkArea.Height;
|
|
||||||
|
|
||||||
_config = LazyConfig.Instance.GetConfig();
|
_config = LazyConfig.Instance.GetConfig();
|
||||||
|
|
||||||
App.Current.SessionEnding += Current_SessionEnding;
|
App.Current.SessionEnding += Current_SessionEnding;
|
||||||
|
@ -233,6 +236,39 @@ namespace v2rayN.Views
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// 获取当前屏幕的尺寸
|
||||||
|
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||||
|
var screenWidth = screen.WorkingArea.Width;
|
||||||
|
var screenHeight = screen.WorkingArea.Height;
|
||||||
|
var screenTop = screen.WorkingArea.Top;
|
||||||
|
|
||||||
|
// 获取屏幕的 DPI 缩放因素
|
||||||
|
double dpiFactor = 1;
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
dpiFactor = source.CompositionTarget.TransformToDevice.M11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口尺寸不超过当前屏幕的尺寸
|
||||||
|
if (this.Width > screenWidth / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Width = screenWidth / dpiFactor;
|
||||||
|
}
|
||||||
|
if (this.Height > screenHeight / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Height = screenHeight / dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口不要显示在屏幕外面
|
||||||
|
if (this.Top < screenTop / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Top = screenTop / dpiFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Event
|
#region Event
|
||||||
|
|
||||||
private void UpdateViewHandler(EViewAction action)
|
private void UpdateViewHandler(EViewAction action)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using Microsoft.Win32;
|
using ReactiveUI;
|
||||||
using ReactiveUI;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
|
@ -8,6 +7,9 @@ using System.Windows.Media;
|
||||||
using v2rayN.Handler;
|
using v2rayN.Handler;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.ViewModels;
|
using v2rayN.ViewModels;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
using FontFamily = System.Windows.Media.FontFamily;
|
||||||
|
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
|
@ -18,11 +20,8 @@ namespace v2rayN.Views
|
||||||
public OptionSettingWindow()
|
public OptionSettingWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.MaxWidth = SystemParameters.WorkArea.Width;
|
|
||||||
this.MaxHeight = SystemParameters.WorkArea.Height;
|
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
|
this.Loaded += Window_Loaded;
|
||||||
_config = LazyConfig.Instance.GetConfig();
|
_config = LazyConfig.Instance.GetConfig();
|
||||||
|
|
||||||
ViewModel = new OptionSettingViewModel(this);
|
ViewModel = new OptionSettingViewModel(this);
|
||||||
|
@ -184,6 +183,39 @@ namespace v2rayN.Views
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// 获取当前屏幕的尺寸
|
||||||
|
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||||
|
var screenWidth = screen.WorkingArea.Width;
|
||||||
|
var screenHeight = screen.WorkingArea.Height;
|
||||||
|
var screenTop = screen.WorkingArea.Top;
|
||||||
|
|
||||||
|
// 获取屏幕的 DPI 缩放因素
|
||||||
|
double dpiFactor = 1;
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
dpiFactor = source.CompositionTarget.TransformToDevice.M11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口尺寸不超过当前屏幕的尺寸
|
||||||
|
if (this.Width > screenWidth / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Width = screenWidth / dpiFactor;
|
||||||
|
}
|
||||||
|
if (this.Height > screenHeight / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Height = screenHeight / dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口不要显示在屏幕外面
|
||||||
|
if (this.Top < screenTop / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Top = screenTop / dpiFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using UserControl = System.Windows.Controls.UserControl;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Windows;
|
||||||
using v2rayN.Base;
|
using v2rayN.Base;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.ViewModels;
|
using v2rayN.ViewModels;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
|
@ -12,10 +13,6 @@ namespace v2rayN.Views
|
||||||
public RoutingRuleDetailsWindow(RulesItem rulesItem)
|
public RoutingRuleDetailsWindow(RulesItem rulesItem)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.MaxWidth = SystemParameters.WorkArea.Width;
|
|
||||||
this.MaxHeight = SystemParameters.WorkArea.Height;
|
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
this.Loaded += Window_Loaded;
|
this.Loaded += Window_Loaded;
|
||||||
clbProtocol.SelectionChanged += ClbProtocol_SelectionChanged;
|
clbProtocol.SelectionChanged += ClbProtocol_SelectionChanged;
|
||||||
|
@ -63,6 +60,36 @@ namespace v2rayN.Views
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
cmbOutboundTag.Focus();
|
cmbOutboundTag.Focus();
|
||||||
|
|
||||||
|
// 获取当前屏幕的尺寸
|
||||||
|
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||||
|
var screenWidth = screen.WorkingArea.Width;
|
||||||
|
var screenHeight = screen.WorkingArea.Height;
|
||||||
|
var screenTop = screen.WorkingArea.Top;
|
||||||
|
|
||||||
|
// 获取屏幕的 DPI 缩放因素
|
||||||
|
double dpiFactor = 1;
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
dpiFactor = source.CompositionTarget.TransformToDevice.M11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口尺寸不超过当前屏幕的尺寸
|
||||||
|
if (this.Width > screenWidth / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Width = screenWidth / dpiFactor;
|
||||||
|
}
|
||||||
|
if (this.Height > screenHeight / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Height = screenHeight / dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口不要显示在屏幕外面
|
||||||
|
if (this.Top < screenTop / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Top = screenTop / dpiFactor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClbProtocol_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
private void ClbProtocol_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
using Microsoft.Win32;
|
using ReactiveUI;
|
||||||
using ReactiveUI;
|
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.ViewModels;
|
using v2rayN.ViewModels;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||||
|
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
|
@ -13,10 +15,6 @@ namespace v2rayN.Views
|
||||||
public RoutingRuleSettingWindow(RoutingItem routingItem)
|
public RoutingRuleSettingWindow(RoutingItem routingItem)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.MaxWidth = SystemParameters.WorkArea.Width;
|
|
||||||
this.MaxHeight = SystemParameters.WorkArea.Height;
|
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
this.Loaded += Window_Loaded;
|
this.Loaded += Window_Loaded;
|
||||||
this.PreviewKeyDown += RoutingRuleSettingWindow_PreviewKeyDown;
|
this.PreviewKeyDown += RoutingRuleSettingWindow_PreviewKeyDown;
|
||||||
|
@ -67,6 +65,36 @@ namespace v2rayN.Views
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
txtRemarks.Focus();
|
txtRemarks.Focus();
|
||||||
|
|
||||||
|
// 获取当前屏幕的尺寸
|
||||||
|
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||||
|
var screenWidth = screen.WorkingArea.Width;
|
||||||
|
var screenHeight = screen.WorkingArea.Height;
|
||||||
|
var screenTop = screen.WorkingArea.Top;
|
||||||
|
|
||||||
|
// 获取屏幕的 DPI 缩放因素
|
||||||
|
double dpiFactor = 1;
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
dpiFactor = source.CompositionTarget.TransformToDevice.M11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口尺寸不超过当前屏幕的尺寸
|
||||||
|
if (this.Width > screenWidth / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Width = screenWidth / dpiFactor;
|
||||||
|
}
|
||||||
|
if (this.Height > screenHeight / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Height = screenHeight / dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口不要显示在屏幕外面
|
||||||
|
if (this.Top < screenTop / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Top = screenTop / dpiFactor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RoutingRuleSettingWindow_PreviewKeyDown(object sender, KeyEventArgs e)
|
private void RoutingRuleSettingWindow_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
|
|
|
@ -4,6 +4,8 @@ using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.ViewModels;
|
using v2rayN.ViewModels;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
|
@ -12,11 +14,8 @@ namespace v2rayN.Views
|
||||||
public RoutingSettingWindow()
|
public RoutingSettingWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.MaxWidth = SystemParameters.WorkArea.Width;
|
|
||||||
this.MaxHeight = SystemParameters.WorkArea.Height;
|
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
|
this.Loaded += Window_Loaded;
|
||||||
this.Closing += RoutingSettingWindow_Closing;
|
this.Closing += RoutingSettingWindow_Closing;
|
||||||
this.PreviewKeyDown += RoutingSettingWindow_PreviewKeyDown;
|
this.PreviewKeyDown += RoutingSettingWindow_PreviewKeyDown;
|
||||||
lstRoutings.SelectionChanged += lstRoutings_SelectionChanged;
|
lstRoutings.SelectionChanged += lstRoutings_SelectionChanged;
|
||||||
|
@ -71,6 +70,39 @@ namespace v2rayN.Views
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// 获取当前屏幕的尺寸
|
||||||
|
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||||
|
var screenWidth = screen.WorkingArea.Width;
|
||||||
|
var screenHeight = screen.WorkingArea.Height;
|
||||||
|
var screenTop = screen.WorkingArea.Top;
|
||||||
|
|
||||||
|
// 获取屏幕的 DPI 缩放因素
|
||||||
|
double dpiFactor = 1;
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
dpiFactor = source.CompositionTarget.TransformToDevice.M11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口尺寸不超过当前屏幕的尺寸
|
||||||
|
if (this.Width > screenWidth / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Width = screenWidth / dpiFactor;
|
||||||
|
}
|
||||||
|
if (this.Height > screenHeight / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Height = screenHeight / dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口不要显示在屏幕外面
|
||||||
|
if (this.Top < screenTop / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Top = screenTop / dpiFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void RoutingSettingWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
|
private void RoutingSettingWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||||
{
|
{
|
||||||
if (ViewModel?.IsModified == true)
|
if (ViewModel?.IsModified == true)
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Reactive.Disposables;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.ViewModels;
|
using v2rayN.ViewModels;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
|
@ -11,10 +12,6 @@ namespace v2rayN.Views
|
||||||
public SubEditWindow(SubItem subItem)
|
public SubEditWindow(SubItem subItem)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.MaxWidth = SystemParameters.WorkArea.Width;
|
|
||||||
this.MaxHeight = SystemParameters.WorkArea.Height;
|
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
this.Loaded += Window_Loaded;
|
this.Loaded += Window_Loaded;
|
||||||
|
|
||||||
|
@ -44,6 +41,36 @@ namespace v2rayN.Views
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
txtRemarks.Focus();
|
txtRemarks.Focus();
|
||||||
|
|
||||||
|
// 获取当前屏幕的尺寸
|
||||||
|
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||||
|
var screenWidth = screen.WorkingArea.Width;
|
||||||
|
var screenHeight = screen.WorkingArea.Height;
|
||||||
|
var screenTop = screen.WorkingArea.Top;
|
||||||
|
|
||||||
|
// 获取屏幕的 DPI 缩放因素
|
||||||
|
double dpiFactor = 1;
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
dpiFactor = source.CompositionTarget.TransformToDevice.M11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口尺寸不超过当前屏幕的尺寸
|
||||||
|
if (this.Width > screenWidth / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Width = screenWidth / dpiFactor;
|
||||||
|
}
|
||||||
|
if (this.Height > screenHeight / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Height = screenHeight / dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口不要显示在屏幕外面
|
||||||
|
if (this.Top < screenTop / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Top = screenTop / dpiFactor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.ViewModels;
|
using v2rayN.ViewModels;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
|
||||||
namespace v2rayN.Views
|
namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
|
@ -13,11 +14,8 @@ namespace v2rayN.Views
|
||||||
public SubSettingWindow()
|
public SubSettingWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.MaxWidth = SystemParameters.WorkArea.Width;
|
|
||||||
this.MaxHeight = SystemParameters.WorkArea.Height;
|
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
|
this.Loaded += Window_Loaded;
|
||||||
|
|
||||||
ViewModel = new SubSettingViewModel(this);
|
ViewModel = new SubSettingViewModel(this);
|
||||||
this.Closing += SubSettingWindow_Closing;
|
this.Closing += SubSettingWindow_Closing;
|
||||||
|
@ -36,6 +34,39 @@ namespace v2rayN.Views
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// 获取当前屏幕的尺寸
|
||||||
|
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||||
|
var screenWidth = screen.WorkingArea.Width;
|
||||||
|
var screenHeight = screen.WorkingArea.Height;
|
||||||
|
var screenTop = screen.WorkingArea.Top;
|
||||||
|
|
||||||
|
// 获取屏幕的 DPI 缩放因素
|
||||||
|
double dpiFactor = 1;
|
||||||
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
dpiFactor = source.CompositionTarget.TransformToDevice.M11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口尺寸不超过当前屏幕的尺寸
|
||||||
|
if (this.Width > screenWidth / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Width = screenWidth / dpiFactor;
|
||||||
|
}
|
||||||
|
if (this.Height > screenHeight / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Height = screenHeight / dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置窗口不要显示在屏幕外面
|
||||||
|
if (this.Top < screenTop / dpiFactor)
|
||||||
|
{
|
||||||
|
this.Top = screenTop / dpiFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SubSettingWindow_Closing(object? sender, CancelEventArgs e)
|
private void SubSettingWindow_Closing(object? sender, CancelEventArgs e)
|
||||||
{
|
{
|
||||||
if (ViewModel?.IsModified == true)
|
if (ViewModel?.IsModified == true)
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
|
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
|
||||||
<Copyright>Copyright © 2017-2023 (GPLv3)</Copyright>
|
<Copyright>Copyright © 2017-2023 (GPLv3)</Copyright>
|
||||||
<FileVersion>6.27</FileVersion>
|
<FileVersion>6.27</FileVersion>
|
||||||
|
<UseWindowsForms>True</UseWindowsForms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in a new issue