99using System . Collections . Generic ;
1010using System . Collections . ObjectModel ;
1111using System . Diagnostics ;
12+ using System . Globalization ;
1213using System . IO ;
1314using System . Linq ;
1415using System . Reflection ;
@@ -239,6 +240,8 @@ private string ConvertToInputGestureText(KeyPressedEventArgs e) =>
239240 [ "Ctrl+V" ] = ApplicationCommands . Paste ,
240241 } ;
241242
243+ private Dictionary < string , Action > hotkeyToAction ;
244+
242245 private void DelayAction ( Action action , int milliseconds = 10 )
243246 {
244247 Task . Run ( async ( ) =>
@@ -250,6 +253,23 @@ private void DelayAction(Action action, int milliseconds = 10)
250253
251254 private void KeyboardHookManager_KeyPressed ( object sender , KeyPressedEventArgs e )
252255 {
256+ if ( hotkeyToAction == null )
257+ {
258+ hotkeyToAction = new ( )
259+ {
260+ [ $ "Ctrl+{ Key . Enter } "] = ShowMatches ,
261+ [ $ "Ctrl+{ Key . Space } "] = IsMatch ,
262+ [ "Ctrl+O" ] = OpenRegex ,
263+ [ "Ctrl+S" ] = SaveAs ,
264+ [ "Ctrl+Shift+S" ] = SelectAllMatches ,
265+ [ "Ctrl+E" ] = ExtractAll ,
266+ [ "Ctrl+Shift+E" ] = ExtractAll ,
267+ [ "Ctrl+R" ] = ReplaceAll ,
268+ [ "Ctrl+Shift+R" ] = ReplaceAll ,
269+ [ "Ctrl+Shift+C" ] = ShowInCSharp
270+ } ;
271+ }
272+
253273 try
254274 {
255275 string hotkey = ConvertToInputGestureText ( e ) ;
@@ -264,41 +284,11 @@ private void KeyboardHookManager_KeyPressed(object sender, KeyPressedEventArgs e
264284 command . Execute ( null , focusedElement ) ;
265285 }
266286 }
267- else if ( hotkey . Equals ( $ "Ctrl+{ Key . Enter } ") )
268- {
269- e . Handled = true ;
270- DelayAction ( ShowMatches ) ;
271- }
272- else if ( hotkey . Equals ( $ "Ctrl+{ Key . Space } ") )
273- {
274- e . Handled = true ;
275- DelayAction ( IsMatch ) ;
276- }
277- else if ( hotkey . Equals ( "Ctrl+O" ) )
278- {
279- e . Handled = true ;
280- DelayAction ( OpenRegex ) ;
281- }
282- else if ( hotkey . Equals ( "Ctrl+S" ) )
283- {
284- e . Handled = true ;
285- DelayAction ( SaveAs ) ;
286- }
287- else if ( hotkey . Equals ( "Ctrl+Shift+S" ) )
287+ else if ( hotkeyToAction . ContainsKey ( hotkey ) )
288288 {
289289 e . Handled = true ;
290- DelayAction ( SelectAllMatches ) ;
291- }
292- else if ( hotkey . Equals ( "Ctrl+E" ) || hotkey . Equals ( "Ctrl+Shift+E" ) )
293- {
294- e . Handled = true ;
295- DelayAction ( ExtractAll ) ;
296- }
297- else if ( hotkey . Equals ( "Ctrl+R" ) || hotkey . Equals ( "Ctrl+Shift+R" ) )
298- {
299- e . Handled = true ;
300- DelayAction ( ReplaceAll ) ;
301- }
290+ DelayAction ( hotkeyToAction [ hotkey ] ) ;
291+ }
302292 }
303293 catch { }
304294 }
@@ -2596,7 +2586,7 @@ private void FindLanguageElementTextBox_PreviewKeyDown(object sender, KeyEventAr
25962586 }
25972587 }
25982588
2599- private void Help_MenuItem_Click ( object sender , RoutedEventArgs e )
2589+ private void ShowHelp ( )
26002590 {
26012591 try
26022592 {
@@ -2605,7 +2595,12 @@ private void Help_MenuItem_Click(object sender, RoutedEventArgs e)
26052595 catch { }
26062596 }
26072597
2608- private void ShowInCSharpButton_Click ( object sender , RoutedEventArgs e )
2598+ private void Help_MenuItem_Click ( object sender , RoutedEventArgs e )
2599+ {
2600+ ShowHelp ( ) ;
2601+ }
2602+
2603+ private void ShowInCSharp ( )
26092604 {
26102605 SetToHistory ( 0 ) ;
26112606
@@ -2700,6 +2695,11 @@ private void ShowInCSharpButton_Click(object sender, RoutedEventArgs e)
27002695 SetCurrentTabInCSharpHighlighting ( ) ;
27012696 }
27022697
2698+ private void ShowInCSharpButton_Click ( object sender , RoutedEventArgs e )
2699+ {
2700+ ShowInCSharp ( ) ;
2701+ }
2702+
27032703 private void Hyperlink_RequestNavigate ( object sender , System . Windows . Navigation . RequestNavigateEventArgs e )
27042704 {
27052705 Process . Start ( new ProcessStartInfo ( e . Uri . AbsoluteUri ) ) ;
0 commit comments