9
9
using System . Collections . Generic ;
10
10
using System . Collections . ObjectModel ;
11
11
using System . Diagnostics ;
12
+ using System . Globalization ;
12
13
using System . IO ;
13
14
using System . Linq ;
14
15
using System . Reflection ;
@@ -239,6 +240,8 @@ private string ConvertToInputGestureText(KeyPressedEventArgs e) =>
239
240
[ "Ctrl+V" ] = ApplicationCommands . Paste ,
240
241
} ;
241
242
243
+ private Dictionary < string , Action > hotkeyToAction ;
244
+
242
245
private void DelayAction ( Action action , int milliseconds = 10 )
243
246
{
244
247
Task . Run ( async ( ) =>
@@ -250,6 +253,23 @@ private void DelayAction(Action action, int milliseconds = 10)
250
253
251
254
private void KeyboardHookManager_KeyPressed ( object sender , KeyPressedEventArgs e )
252
255
{
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
+
253
273
try
254
274
{
255
275
string hotkey = ConvertToInputGestureText ( e ) ;
@@ -264,41 +284,11 @@ private void KeyboardHookManager_KeyPressed(object sender, KeyPressedEventArgs e
264
284
command . Execute ( null , focusedElement ) ;
265
285
}
266
286
}
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 ) )
288
288
{
289
289
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
+ }
302
292
}
303
293
catch { }
304
294
}
@@ -2596,7 +2586,7 @@ private void FindLanguageElementTextBox_PreviewKeyDown(object sender, KeyEventAr
2596
2586
}
2597
2587
}
2598
2588
2599
- private void Help_MenuItem_Click ( object sender , RoutedEventArgs e )
2589
+ private void ShowHelp ( )
2600
2590
{
2601
2591
try
2602
2592
{
@@ -2605,7 +2595,12 @@ private void Help_MenuItem_Click(object sender, RoutedEventArgs e)
2605
2595
catch { }
2606
2596
}
2607
2597
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 ( )
2609
2604
{
2610
2605
SetToHistory ( 0 ) ;
2611
2606
@@ -2700,6 +2695,11 @@ private void ShowInCSharpButton_Click(object sender, RoutedEventArgs e)
2700
2695
SetCurrentTabInCSharpHighlighting ( ) ;
2701
2696
}
2702
2697
2698
+ private void ShowInCSharpButton_Click ( object sender , RoutedEventArgs e )
2699
+ {
2700
+ ShowInCSharp ( ) ;
2701
+ }
2702
+
2703
2703
private void Hyperlink_RequestNavigate ( object sender , System . Windows . Navigation . RequestNavigateEventArgs e )
2704
2704
{
2705
2705
Process . Start ( new ProcessStartInfo ( e . Uri . AbsoluteUri ) ) ;
0 commit comments