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:
Jacob Poteet 2024-02-10 13:38:33 -05:00
commit 2074db6f78

View file

@ -747,48 +747,17 @@ namespace CalculatorApp
{ {
int viewId = Utilities.GetWindowId(); int viewId = Utilities.GetWindowId();
if (controlKeyPressed) if (controlKeyPressed && !altPressed)
{ {
if (altPressed) return shiftKeyPressed ? s_VirtualKeyControlShiftChordsForButtons[viewId] : s_VirtualKeyControlChordsForButtons[viewId];
{ }
return null; else if (altPressed && !controlKeyPressed)
} {
else return shiftKeyPressed ? null : s_VirtualKeyAltChordsForButtons[viewId];
{
if (shiftKeyPressed)
{
return s_VirtualKeyControlShiftChordsForButtons[viewId];
}
else
{
return s_VirtualKeyControlChordsForButtons[viewId];
}
}
} }
else else
{ {
if (altPressed) return shiftKeyPressed ? s_VirtualKeyShiftChordsForButtons[viewId] : s_virtualKey[viewId];
{
if (shiftKeyPressed)
{
return null;
}
else
{
return s_VirtualKeyAltChordsForButtons[viewId];
}
}
else
{
if (shiftKeyPressed)
{
return s_VirtualKeyShiftChordsForButtons[viewId];
}
else
{
return s_virtualKey[viewId];
}
}
} }
} }