From 119508a4e36e1adc849ec3281af769fe7e965072 Mon Sep 17 00:00:00 2001 From: NintenHero <37460517+MichaelHinrichs@users.noreply.github.com> Date: Mon, 25 Sep 2023 04:45:50 -0400 Subject: [PATCH 1/2] Use a switch --- v2rayN/v2rayN/Views/MainWindow.xaml.cs | 50 ++++++++++++-------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index b7ea9afb..4d5483a5 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -322,33 +322,29 @@ namespace v2rayN.Views { if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { - if (e.Key == Key.V) + switch (e.key) { - ViewModel?.AddServerViaClipboard(); - } - else if (e.Key == Key.P) - { - ViewModel?.ServerSpeedtest(ESpeedActionType.Ping); - } - else if (e.Key == Key.O) - { - ViewModel?.ServerSpeedtest(ESpeedActionType.Tcping); - } - else if (e.Key == Key.R) - { - ViewModel?.ServerSpeedtest(ESpeedActionType.Realping); - } - else if (e.Key == Key.S) - { - _ = ViewModel?.ScanScreenTaskAsync(); - } - else if (e.Key == Key.T) - { - ViewModel?.ServerSpeedtest(ESpeedActionType.Speedtest); - } - else if (e.Key == Key.E) - { - ViewModel?.ServerSpeedtest(ESpeedActionType.Mixedtest); + case Key.V + ViewModel?.AddServerViaClipboard(); + break; + case Key.P + ViewModel?.ServerSpeedtest(ESpeedActionType.Ping); + break; + case Key.O + ViewModel?.ServerSpeedtest(ESpeedActionType.Tcping); + break; + case Key.R + ViewModel?.ServerSpeedtest(ESpeedActionType.Realping); + break; + case Key.S + _ = ViewModel?.ScanScreenTaskAsync(); + break; + case Key.T + ViewModel?.ServerSpeedtest(ESpeedActionType.Speedtest); + break; + case Key.E + ViewModel?.ServerSpeedtest(ESpeedActionType.Mixedtest); + break; } } else @@ -648,4 +644,4 @@ namespace v2rayN.Views #endregion Drag and Drop } -} \ No newline at end of file +} From 85e8d9479e582f0fa16351626b7d7c086fdc92ac Mon Sep 17 00:00:00 2001 From: NintenHero <37460517+MichaelHinrichs@users.noreply.github.com> Date: Mon, 25 Sep 2023 10:05:56 -0500 Subject: [PATCH 2/2] Fix switch --- v2rayN/v2rayN/Views/MainWindow.xaml.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index 4d5483a5..d2d5fab9 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -324,25 +324,25 @@ namespace v2rayN.Views { switch (e.key) { - case Key.V + case Key.V: ViewModel?.AddServerViaClipboard(); break; - case Key.P + case Key.P: ViewModel?.ServerSpeedtest(ESpeedActionType.Ping); break; - case Key.O + case Key.O: ViewModel?.ServerSpeedtest(ESpeedActionType.Tcping); break; - case Key.R + case Key.R: ViewModel?.ServerSpeedtest(ESpeedActionType.Realping); break; - case Key.S + case Key.S: _ = ViewModel?.ScanScreenTaskAsync(); break; - case Key.T + case Key.T: ViewModel?.ServerSpeedtest(ESpeedActionType.Speedtest); break; - case Key.E + case Key.E: ViewModel?.ServerSpeedtest(ESpeedActionType.Mixedtest); break; }