code cleanup

pull/3492/head^2
2dust 2023-03-07 20:24:51 +08:00
parent a883ba8808
commit 4ff1dc2982
5 changed files with 20 additions and 22 deletions

View File

@ -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)
{
@ -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;
@ -88,7 +88,7 @@ namespace v2rayN.Handler
public void ReLoad()
{
foreach(var hotkey in _hotkeyTriggerDic.Keys)
foreach (var hotkey in _hotkeyTriggerDic.Keys)
{
Application.Current.Dispatcher.Invoke(() =>
{
@ -122,7 +122,7 @@ 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;
}

View File

@ -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;

View File

@ -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;
@ -60,7 +58,7 @@ namespace v2rayN.Views
(sender as TextBox)!.Text = KeyEventItemToString(_TextBoxKeyEventItem[sender]);
}
private KeyEventItem GetKeyEventItemByEGlobalHotkey(List<KeyEventItem> KELsit,EGlobalHotkey eg)
private KeyEventItem GetKeyEventItemByEGlobalHotkey(List<KeyEventItem> 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;
}

View File

@ -48,6 +48,7 @@
FontSize="{DynamicResource StdFontSizeMsg}"
HorizontalScrollBarVisibility="Auto"
IsReadOnly="True"
IsReadOnlyCaretVisible="True"
TextAlignment="Left"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Visible">