diff --git a/v2rayN/v2rayN/Handler/HotkeyHandler.cs b/v2rayN/v2rayN/Handler/HotkeyHandler.cs index 57944dab..a4724571 100644 --- a/v2rayN/v2rayN/Handler/HotkeyHandler.cs +++ b/v2rayN/v2rayN/Handler/HotkeyHandler.cs @@ -26,7 +26,7 @@ namespace v2rayN.Handler public event Action? HotkeyTriggerEvent; public HotkeyHandler() { - _hotkeyTriggerDic = new(); + _hotkeyTriggerDic = new(); ComponentDispatcher.ThreadPreprocessMessage += OnThreadPreProcessMessage; Init(); } @@ -35,7 +35,7 @@ namespace v2rayN.Handler { _hotkeyTriggerDic.Clear(); if (_config.globalHotkeys == null) return; - foreach(var item in _config.globalHotkeys) + foreach (var item in _config.globalHotkeys) { if (item.KeyCode != null && item.KeyCode != Key.None) { @@ -47,7 +47,7 @@ namespace v2rayN.Handler key = (key << 16) | (int)modifiers; if (!_hotkeyTriggerDic.ContainsKey(key)) { - _hotkeyTriggerDic.Add(key, new() { item.eGlobalHotkey }); + _hotkeyTriggerDic.Add(key, new() { item.eGlobalHotkey }); } else { @@ -59,7 +59,7 @@ namespace v2rayN.Handler } public void Load() { - foreach(var _hotkeyCode in _hotkeyTriggerDic.Keys) + foreach (var _hotkeyCode in _hotkeyTriggerDic.Keys) { var hotkeyInfo = GetHotkeyInfo(_hotkeyCode); bool isSuccess = false; @@ -67,7 +67,7 @@ namespace v2rayN.Handler Application.Current.Dispatcher.Invoke(() => { - isSuccess = RegisterHotKey(IntPtr.Zero, _hotkeyCode, hotkeyInfo.fsModifiers, hotkeyInfo.vKey); + isSuccess = RegisterHotKey(IntPtr.Zero, _hotkeyCode, hotkeyInfo.fsModifiers, hotkeyInfo.vKey); }); foreach (var name in hotkeyInfo.Names) { @@ -82,13 +82,13 @@ namespace v2rayN.Handler } UpdateViewEvent?.Invoke(false, msg); } - + } } public void ReLoad() { - foreach(var hotkey in _hotkeyTriggerDic.Keys) + foreach (var hotkey in _hotkeyTriggerDic.Keys) { Application.Current.Dispatcher.Invoke(() => { @@ -122,8 +122,8 @@ namespace v2rayN.Handler } private void OnThreadPreProcessMessage(ref MSG msg, ref bool handled) { - if (msg.message != WmHotkey|| !_hotkeyTriggerDic.ContainsKey((int)msg.lParam)) - { + if (msg.message != WmHotkey || !_hotkeyTriggerDic.ContainsKey((int)msg.lParam)) + { return; } handled = true; diff --git a/v2rayN/v2rayN/Handler/MainFormHandler.cs b/v2rayN/v2rayN/Handler/MainFormHandler.cs index 6f3a47b8..1e96bd8f 100644 --- a/v2rayN/v2rayN/Handler/MainFormHandler.cs +++ b/v2rayN/v2rayN/Handler/MainFormHandler.cs @@ -2,7 +2,6 @@ using System.Drawing; using System.IO; using System.Windows.Forms; -using System.Windows.Input; using System.Windows.Media.Imaging; using v2rayN.Mode; using v2rayN.Resx; diff --git a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs index c067a562..830adcb3 100644 --- a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs @@ -1,6 +1,4 @@ -using Microsoft.Win32.TaskScheduler; -using System.Diagnostics; -using System.Text; +using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -21,7 +19,7 @@ namespace v2rayN.Views this.Owner = Application.Current.MainWindow; _config = LazyConfig.Instance.GetConfig(); _config.globalHotkeys ??= new List(); - + txtGlobalHotkey0.KeyDown += TxtGlobalHotkey_KeyDown; txtGlobalHotkey1.KeyDown += TxtGlobalHotkey_KeyDown; txtGlobalHotkey2.KeyDown += TxtGlobalHotkey_KeyDown; @@ -29,7 +27,7 @@ namespace v2rayN.Views txtGlobalHotkey4.KeyDown += TxtGlobalHotkey_KeyDown; HotkeyHandler.Instance.IsPause = true; - this.Closing += (s, e) => HotkeyHandler.Instance.IsPause = false; + this.Closing += (s, e) => HotkeyHandler.Instance.IsPause = false; Utils.SetDarkBorder(this, _config.uiItem.colorModeDark); InitData(); } @@ -60,7 +58,7 @@ namespace v2rayN.Views (sender as TextBox)!.Text = KeyEventItemToString(_TextBoxKeyEventItem[sender]); } - private KeyEventItem GetKeyEventItemByEGlobalHotkey(List KELsit,EGlobalHotkey eg) + private KeyEventItem GetKeyEventItemByEGlobalHotkey(List KELsit, EGlobalHotkey eg) { return Utils.DeepCopy(KELsit.Find((it) => it.eGlobalHotkey == eg) ?? new() { @@ -79,14 +77,14 @@ namespace v2rayN.Views if (item.Control) res.Append($"{ModifierKeys.Control}+"); if (item.Shift) res.Append($"{ModifierKeys.Shift}+"); if (item.Alt) res.Append($"{ModifierKeys.Alt}+"); - if(item.KeyCode != null && item.KeyCode != Key.None) + if (item.KeyCode != null && item.KeyCode != Key.None) res.Append($"{item.KeyCode}"); return res.ToString(); } private void BindingData() { - foreach(var item in _TextBoxKeyEventItem) + foreach (var item in _TextBoxKeyEventItem) { if (item.Value.KeyCode != null && item.Value.KeyCode != Key.None) { @@ -121,10 +119,10 @@ namespace v2rayN.Views private void btnReset_Click(object sender, RoutedEventArgs e) { - foreach(var k in _TextBoxKeyEventItem.Keys) + foreach (var k in _TextBoxKeyEventItem.Keys) { _TextBoxKeyEventItem[k].Alt = false; - _TextBoxKeyEventItem[k].Control= false; + _TextBoxKeyEventItem[k].Control = false; _TextBoxKeyEventItem[k].Shift = false; _TextBoxKeyEventItem[k].KeyCode = Key.None; } diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index cdd4cf80..3cc634e7 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -150,7 +150,7 @@ namespace v2rayN.Views this.OneWayBind(ViewModel, vm => vm.Servers, v => v.cmbServers.ItemsSource).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedServer, v => v.cmbServers.SelectedItem).DisposeWith(disposables); - this.OneWayBind(ViewModel, vm => vm.BlServers, v => v.cmbServers.Visibility).DisposeWith(disposables); + this.OneWayBind(ViewModel, vm => vm.BlServers, v => v.cmbServers.Visibility).DisposeWith(disposables); //tray menu this.BindCommand(ViewModel, vm => vm.AddServerViaClipboardCmd, v => v.menuAddServerViaClipboard2).DisposeWith(disposables); @@ -192,7 +192,7 @@ namespace v2rayN.Views this.Title = $"{Utils.GetVersion()} - {(IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}"; spEnableTun.Visibility = IsAdministrator ? Visibility.Visible : Visibility.Collapsed; - + if (_config.uiItem.autoHideStartup) { WindowState = WindowState.Minimized; diff --git a/v2rayN/v2rayN/Views/MsgView.xaml b/v2rayN/v2rayN/Views/MsgView.xaml index af464d31..3a413c7b 100644 --- a/v2rayN/v2rayN/Views/MsgView.xaml +++ b/v2rayN/v2rayN/Views/MsgView.xaml @@ -48,6 +48,7 @@ FontSize="{DynamicResource StdFontSizeMsg}" HorizontalScrollBarVisibility="Auto" IsReadOnly="True" + IsReadOnlyCaretVisible="True" TextAlignment="Left" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible">