@@ -351,10 +351,7 @@ private static unsafe HKL FindEnglishKeyboardLayout()
351
351
fixed ( HKL * h = handles )
352
352
{
353
353
var result = PInvoke . GetKeyboardLayoutList ( count , h ) ;
354
- if ( result == 0 )
355
- {
356
- throw new Win32Exception ( Marshal . GetLastWin32Error ( ) ) ;
357
- }
354
+ if ( result == 0 ) throw new Win32Exception ( Marshal . GetLastWin32Error ( ) ) ;
358
355
}
359
356
360
357
// Look for any English keyboard layout
@@ -364,10 +361,7 @@ private static unsafe HKL FindEnglishKeyboardLayout()
364
361
var langId = ( uint ) hkl . Value & KeyboardLayoutLoWord ;
365
362
366
363
// Check if it's an English layout
367
- if ( EnglishLanguageIds . Contains ( langId ) )
368
- {
369
- return hkl ;
370
- }
364
+ if ( EnglishLanguageIds . Contains ( langId ) ) return hkl ;
371
365
}
372
366
373
367
return HKL . Null ;
@@ -399,16 +393,10 @@ public static unsafe void SwitchToEnglishKeyboardLayout(bool backupPrevious)
399
393
// the IME mode instead of switching to another layout.
400
394
var currentLayout = PInvoke . GetKeyboardLayout ( threadId ) ;
401
395
var currentLayoutCode = ( uint ) currentLayout . Value & KeyboardLayoutLoWord ;
402
- if ( ImeLanguageIds . Contains ( currentLayoutCode ) )
403
- {
404
- return ;
405
- }
396
+ if ( ImeLanguageIds . Contains ( currentLayoutCode ) ) return ;
406
397
407
398
// Backup current keyboard layout
408
- if ( backupPrevious )
409
- {
410
- _previousLayout = currentLayout ;
411
- }
399
+ if ( backupPrevious ) _previousLayout = currentLayout ;
412
400
413
401
// Switch to English layout
414
402
PInvoke . ActivateKeyboardLayout ( enHKL , 0 ) ;
@@ -431,6 +419,7 @@ public static void RestorePreviousKeyboardLayout()
431
419
PInvoke . INPUTLANGCHANGE_FORWARD ,
432
420
_previousLayout . Value
433
421
) ;
422
+
434
423
_previousLayout = HKL . Null ;
435
424
}
436
425
0 commit comments