mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
Simplify OnAppPropertyChanged
Use a switch statement instead of else-if
This commit is contained in:
parent
0de7449460
commit
025518a6fc
1 changed files with 57 additions and 48 deletions
|
@ -206,14 +206,15 @@ namespace CalculatorApp
|
|||
|
||||
KeyboardShortcutManager.DisableShortcuts(false);
|
||||
|
||||
if (newValue == ViewMode.Standard)
|
||||
switch (newValue)
|
||||
{
|
||||
case ViewMode.Standard:
|
||||
EnsureCalculator();
|
||||
Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = true;
|
||||
m_calculator.AnimateCalculator(NavCategory.IsConverterViewMode(previousMode));
|
||||
Model.CalculatorViewModel.HistoryVM.ReloadHistory(newValue);
|
||||
}
|
||||
else if (newValue == ViewMode.Scientific)
|
||||
break;
|
||||
case ViewMode.Scientific:
|
||||
{
|
||||
EnsureCalculator();
|
||||
Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = true;
|
||||
|
@ -223,8 +224,9 @@ namespace CalculatorApp
|
|||
}
|
||||
|
||||
Model.CalculatorViewModel.HistoryVM.ReloadHistory(newValue);
|
||||
break;
|
||||
}
|
||||
else if (newValue == ViewMode.Programmer)
|
||||
case ViewMode.Programmer:
|
||||
{
|
||||
Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = false;
|
||||
EnsureCalculator();
|
||||
|
@ -232,8 +234,16 @@ namespace CalculatorApp
|
|||
{
|
||||
m_calculator.AnimateCalculator(NavCategory.IsConverterViewMode(previousMode));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else if (NavCategory.IsDateCalculatorViewMode(newValue))
|
||||
case ViewMode.Graphing:
|
||||
EnsureGraphingCalculator();
|
||||
KeyboardShortcutManager.DisableShortcuts(true);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if (NavCategory.IsDateCalculatorViewMode(newValue))
|
||||
{
|
||||
if (Model.CalculatorViewModel != null)
|
||||
{
|
||||
|
@ -241,11 +251,6 @@ namespace CalculatorApp
|
|||
}
|
||||
EnsureDateCalculator();
|
||||
}
|
||||
else if (newValue == ViewMode.Graphing)
|
||||
{
|
||||
EnsureGraphingCalculator();
|
||||
KeyboardShortcutManager.DisableShortcuts(true);
|
||||
}
|
||||
else if (NavCategory.IsConverterViewMode(newValue))
|
||||
{
|
||||
if (Model.CalculatorViewModel != null)
|
||||
|
@ -260,6 +265,10 @@ namespace CalculatorApp
|
|||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ShowHideControls(newValue);
|
||||
|
||||
UpdateViewState();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue