mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-21 05:43:10 -07:00
Refactor KeyboardShortcutManager.cs for improved readability and maintainability
The code changes in this commit simplify the logic in the `OnAcceleratorKeyActivated` method of `KeyboardShortcutManager.cs`. - Replaced nested if-else statements with concise conditional expressions - Removed redundant checks for `altPressed` and `controlKeyPressed` - Consolidated return statements based on key combinations
This commit is contained in:
parent
b5e8b207f7
commit
2074db6f78
1 changed files with 7 additions and 38 deletions
|
@ -747,48 +747,17 @@ namespace CalculatorApp
|
|||
{
|
||||
int viewId = Utilities.GetWindowId();
|
||||
|
||||
if (controlKeyPressed)
|
||||
if (controlKeyPressed && !altPressed)
|
||||
{
|
||||
if (altPressed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shiftKeyPressed)
|
||||
{
|
||||
return s_VirtualKeyControlShiftChordsForButtons[viewId];
|
||||
}
|
||||
else
|
||||
{
|
||||
return s_VirtualKeyControlChordsForButtons[viewId];
|
||||
}
|
||||
}
|
||||
return shiftKeyPressed ? s_VirtualKeyControlShiftChordsForButtons[viewId] : s_VirtualKeyControlChordsForButtons[viewId];
|
||||
}
|
||||
else if (altPressed && !controlKeyPressed)
|
||||
{
|
||||
return shiftKeyPressed ? null : s_VirtualKeyAltChordsForButtons[viewId];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (altPressed)
|
||||
{
|
||||
if (shiftKeyPressed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return s_VirtualKeyAltChordsForButtons[viewId];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shiftKeyPressed)
|
||||
{
|
||||
return s_VirtualKeyShiftChordsForButtons[viewId];
|
||||
}
|
||||
else
|
||||
{
|
||||
return s_virtualKey[viewId];
|
||||
}
|
||||
}
|
||||
return shiftKeyPressed ? s_VirtualKeyShiftChordsForButtons[viewId] : s_virtualKey[viewId];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue