mirror of https://github.com/2dust/v2rayN
code cleanup
parent
a883ba8808
commit
4ff1dc2982
|
@ -35,7 +35,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
_hotkeyTriggerDic.Clear();
|
_hotkeyTriggerDic.Clear();
|
||||||
if (_config.globalHotkeys == null) return;
|
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)
|
if (item.KeyCode != null && item.KeyCode != Key.None)
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ namespace v2rayN.Handler
|
||||||
key = (key << 16) | (int)modifiers;
|
key = (key << 16) | (int)modifiers;
|
||||||
if (!_hotkeyTriggerDic.ContainsKey(key))
|
if (!_hotkeyTriggerDic.ContainsKey(key))
|
||||||
{
|
{
|
||||||
_hotkeyTriggerDic.Add(key, new() { item.eGlobalHotkey });
|
_hotkeyTriggerDic.Add(key, new() { item.eGlobalHotkey });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
public void Load()
|
public void Load()
|
||||||
{
|
{
|
||||||
foreach(var _hotkeyCode in _hotkeyTriggerDic.Keys)
|
foreach (var _hotkeyCode in _hotkeyTriggerDic.Keys)
|
||||||
{
|
{
|
||||||
var hotkeyInfo = GetHotkeyInfo(_hotkeyCode);
|
var hotkeyInfo = GetHotkeyInfo(_hotkeyCode);
|
||||||
bool isSuccess = false;
|
bool isSuccess = false;
|
||||||
|
@ -88,7 +88,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
public void ReLoad()
|
public void ReLoad()
|
||||||
{
|
{
|
||||||
foreach(var hotkey in _hotkeyTriggerDic.Keys)
|
foreach (var hotkey in _hotkeyTriggerDic.Keys)
|
||||||
{
|
{
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
|
@ -122,7 +122,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
private void OnThreadPreProcessMessage(ref MSG msg, ref bool handled)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.Resx;
|
using v2rayN.Resx;
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using Microsoft.Win32.TaskScheduler;
|
using System.Text;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
@ -60,7 +58,7 @@ namespace v2rayN.Views
|
||||||
(sender as TextBox)!.Text = KeyEventItemToString(_TextBoxKeyEventItem[sender]);
|
(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()
|
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.Control) res.Append($"{ModifierKeys.Control}+");
|
||||||
if (item.Shift) res.Append($"{ModifierKeys.Shift}+");
|
if (item.Shift) res.Append($"{ModifierKeys.Shift}+");
|
||||||
if (item.Alt) res.Append($"{ModifierKeys.Alt}+");
|
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}");
|
res.Append($"{item.KeyCode}");
|
||||||
|
|
||||||
return res.ToString();
|
return res.ToString();
|
||||||
}
|
}
|
||||||
private void BindingData()
|
private void BindingData()
|
||||||
{
|
{
|
||||||
foreach(var item in _TextBoxKeyEventItem)
|
foreach (var item in _TextBoxKeyEventItem)
|
||||||
{
|
{
|
||||||
if (item.Value.KeyCode != null && item.Value.KeyCode != Key.None)
|
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)
|
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].Alt = false;
|
||||||
_TextBoxKeyEventItem[k].Control= false;
|
_TextBoxKeyEventItem[k].Control = false;
|
||||||
_TextBoxKeyEventItem[k].Shift = false;
|
_TextBoxKeyEventItem[k].Shift = false;
|
||||||
_TextBoxKeyEventItem[k].KeyCode = Key.None;
|
_TextBoxKeyEventItem[k].KeyCode = Key.None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
FontSize="{DynamicResource StdFontSizeMsg}"
|
FontSize="{DynamicResource StdFontSizeMsg}"
|
||||||
HorizontalScrollBarVisibility="Auto"
|
HorizontalScrollBarVisibility="Auto"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
|
IsReadOnlyCaretVisible="True"
|
||||||
TextAlignment="Left"
|
TextAlignment="Left"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
VerticalScrollBarVisibility="Visible">
|
VerticalScrollBarVisibility="Visible">
|
||||||
|
|
Loading…
Reference in New Issue