Skip to content

Commit 8e7ac87

Browse files
authored
NavCategory | Partial refactor and perf optimization (microsoft#1820)
* Partially refactor NavCategory * Lazy load the states of GraphingMode Category * code cleanup * find_if to any_of * remove Windows.System * resolve warning WMC1507 * resolve comments * fix indentations
1 parent 6a5b93c commit 8e7ac87

23 files changed

+848
-916
lines changed

src/CalcViewModel/ApplicationViewModel.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void ApplicationViewModel::Categories::set(IObservableVector<NavCategoryGroup ^>
7575

7676
void ApplicationViewModel::Initialize(ViewMode mode)
7777
{
78-
if (!NavCategory::IsValidViewMode(mode) || !NavCategory::IsViewModeEnabled(mode))
78+
if (!NavCategoryStates::IsValidViewMode(mode) || !NavCategoryStates::IsViewModeEnabled(mode))
7979
{
8080
mode = ViewMode::Standard;
8181
}
@@ -124,7 +124,7 @@ bool ApplicationViewModel::TryRecoverFromNavigationModeFailure()
124124

125125
void ApplicationViewModel::OnModeChanged()
126126
{
127-
assert(NavCategory::IsValidViewMode(m_mode));
127+
assert(NavCategoryStates::IsValidViewMode(m_mode));
128128
if (NavCategory::IsCalculatorViewMode(m_mode))
129129
{
130130
if (!m_CalculatorViewModel)
@@ -160,15 +160,15 @@ void ApplicationViewModel::OnModeChanged()
160160
}
161161

162162
auto resProvider = AppResourceProvider::GetInstance();
163-
CategoryName = resProvider->GetResourceString(NavCategory::GetNameResourceKey(m_mode));
163+
CategoryName = resProvider->GetResourceString(NavCategoryStates::GetNameResourceKey(m_mode));
164164

165165
// Cast mode to an int in order to save it to app data.
166166
// Save the changed mode, so that the new window launches in this mode.
167167
// Don't save until after we have adjusted to the new mode, so we don't save a mode that fails to load.
168-
ApplicationData::Current->LocalSettings->Values->Insert(ModePropertyName, NavCategory::Serialize(m_mode));
168+
ApplicationData::Current->LocalSettings->Values->Insert(ModePropertyName, NavCategoryStates::Serialize(m_mode));
169169

170170
// Log ModeChange event when not first launch, log WindowCreated on first launch
171-
if (NavCategory::IsValidViewMode(m_PreviousMode))
171+
if (NavCategoryStates::IsValidViewMode(m_PreviousMode))
172172
{
173173
TraceLogger::GetInstance()->LogModeChange(m_mode);
174174
}
@@ -213,7 +213,7 @@ void ApplicationViewModel::SetMenuCategories()
213213
// Use the Categories property instead of the backing variable
214214
// because we want to take advantage of binding updates and
215215
// property setter logic.
216-
Categories = NavCategoryGroup::CreateMenuOptions();
216+
Categories = NavCategoryStates::CreateMenuOptions();
217217
}
218218

219219
void ApplicationViewModel::ToggleAlwaysOnTop(float width, float height)

src/CalcViewModel/Common/CopyPasteManager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ bool CopyPasteManager::HasStringToPaste()
9797

9898
String ^ CopyPasteManager::ValidatePasteExpression(String ^ pastedText, ViewMode mode, NumberBase programmerNumberBase, BitLength bitLengthType)
9999
{
100-
return ValidatePasteExpression(pastedText, mode, NavCategory::GetGroupType(mode), programmerNumberBase, bitLengthType);
100+
return ValidatePasteExpression(pastedText, mode, NavCategoryStates::GetGroupType(mode), programmerNumberBase, bitLengthType);
101101
}
102102

103103
// return "NoOp" if pastedText is invalid else return pastedText

0 commit comments

Comments
 (0)