mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
resolve warning WMC1507
This commit is contained in:
parent
4704792a87
commit
84c0c4a041
7 changed files with 24 additions and 22 deletions
|
@ -289,28 +289,28 @@ static std::vector<NavCategoryInitializer> s_categoryManifest = [] {
|
||||||
return res;
|
return res;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
bool NavCategory::IsCalculatorViewMode(ViewMode mode)
|
bool NavCategory::IsCalculatorViewMode(ViewModeType mode)
|
||||||
{
|
{
|
||||||
// Historically, Calculator modes are Standard, Scientific, and Programmer.
|
// Historically, Calculator modes are Standard, Scientific, and Programmer.
|
||||||
return !IsDateCalculatorViewMode(mode) && !IsGraphingCalculatorViewMode(mode) && IsModeInCategoryGroup(mode, CategoryGroupType::Calculator);
|
return !IsDateCalculatorViewMode(mode) && !IsGraphingCalculatorViewMode(mode) && IsModeInCategoryGroup(mode, CategoryGroupType::Calculator);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavCategory::IsGraphingCalculatorViewMode(ViewMode mode)
|
bool NavCategory::IsGraphingCalculatorViewMode(ViewModeType mode)
|
||||||
{
|
{
|
||||||
return mode == ViewMode::Graphing;
|
return mode == ViewModeType::Graphing;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavCategory::IsDateCalculatorViewMode(ViewMode mode)
|
bool NavCategory::IsDateCalculatorViewMode(ViewModeType mode)
|
||||||
{
|
{
|
||||||
return mode == ViewMode::Date;
|
return mode == ViewModeType::Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavCategory::IsConverterViewMode(ViewMode mode)
|
bool NavCategory::IsConverterViewMode(ViewModeType mode)
|
||||||
{
|
{
|
||||||
return IsModeInCategoryGroup(mode, CategoryGroupType::Converter);
|
return IsModeInCategoryGroup(mode, CategoryGroupType::Converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavCategory::IsModeInCategoryGroup(ViewMode mode, CategoryGroupType type)
|
bool NavCategory::IsModeInCategoryGroup(ViewModeType mode, CategoryGroupType type)
|
||||||
{
|
{
|
||||||
return std::any_of(
|
return std::any_of(
|
||||||
s_categoryManifest.cbegin(),
|
s_categoryManifest.cbegin(),
|
||||||
|
|
|
@ -91,23 +91,25 @@ namespace CalculatorApp::ViewModel
|
||||||
[Windows::UI::Xaml::Data::Bindable]
|
[Windows::UI::Xaml::Data::Bindable]
|
||||||
public ref class NavCategory sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
public ref class NavCategory sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
using ViewModeType = ::CalculatorApp::ViewModel::Common::ViewMode;
|
||||||
public:
|
public:
|
||||||
OBSERVABLE_OBJECT();
|
OBSERVABLE_OBJECT();
|
||||||
PROPERTY_R(Platform::String ^, Name);
|
PROPERTY_R(Platform::String ^, Name);
|
||||||
PROPERTY_R(Platform::String ^, AutomationName);
|
PROPERTY_R(Platform::String ^, AutomationName);
|
||||||
PROPERTY_R(Platform::String ^, Glyph);
|
PROPERTY_R(Platform::String ^, Glyph);
|
||||||
PROPERTY_R(ViewMode, Mode);
|
PROPERTY_R(ViewModeType, ViewMode);
|
||||||
PROPERTY_R(Platform::String ^, AccessKey);
|
PROPERTY_R(Platform::String ^, AccessKey);
|
||||||
PROPERTY_R(bool, SupportsNegative);
|
PROPERTY_R(bool, SupportsNegative);
|
||||||
PROPERTY_RW(bool, IsEnabled);
|
PROPERTY_RW(bool, IsEnabled);
|
||||||
|
|
||||||
property Platform::String
|
property Platform::String
|
||||||
^ AutomationId { Platform::String ^ get() { return m_Mode.ToString(); } }
|
^ AutomationId { Platform::String ^ get() { return m_ViewMode.ToString(); } }
|
||||||
|
|
||||||
static bool IsCalculatorViewMode(ViewMode mode);
|
static bool IsCalculatorViewMode(ViewModeType mode);
|
||||||
static bool IsGraphingCalculatorViewMode(ViewMode mode);
|
static bool IsGraphingCalculatorViewMode(ViewModeType mode);
|
||||||
static bool IsDateCalculatorViewMode(ViewMode mode);
|
static bool IsDateCalculatorViewMode(ViewModeType mode);
|
||||||
static bool IsConverterViewMode(ViewMode mode);
|
static bool IsConverterViewMode(ViewModeType mode);
|
||||||
|
|
||||||
internal : NavCategory(
|
internal : NavCategory(
|
||||||
Platform::String ^ name,
|
Platform::String ^ name,
|
||||||
|
@ -115,7 +117,7 @@ namespace CalculatorApp::ViewModel
|
||||||
Platform::String ^ glyph,
|
Platform::String ^ glyph,
|
||||||
Platform::String ^ accessKey,
|
Platform::String ^ accessKey,
|
||||||
Platform::String ^ mode,
|
Platform::String ^ mode,
|
||||||
ViewMode viewMode,
|
ViewModeType viewMode,
|
||||||
bool supportsNegative,
|
bool supportsNegative,
|
||||||
bool isEnabled)
|
bool isEnabled)
|
||||||
: m_Name(name)
|
: m_Name(name)
|
||||||
|
@ -123,14 +125,14 @@ namespace CalculatorApp::ViewModel
|
||||||
, m_Glyph(glyph)
|
, m_Glyph(glyph)
|
||||||
, m_AccessKey(accessKey)
|
, m_AccessKey(accessKey)
|
||||||
, m_modeString(mode)
|
, m_modeString(mode)
|
||||||
, m_Mode(viewMode)
|
, m_ViewMode(viewMode)
|
||||||
, m_SupportsNegative(supportsNegative)
|
, m_SupportsNegative(supportsNegative)
|
||||||
, m_IsEnabled(isEnabled)
|
, m_IsEnabled(isEnabled)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool IsModeInCategoryGroup(ViewMode mode, CategoryGroupType groupType);
|
static bool IsModeInCategoryGroup(ViewModeType mode, CategoryGroupType groupType);
|
||||||
|
|
||||||
Platform::String ^ m_modeString;
|
Platform::String ^ m_modeString;
|
||||||
};
|
};
|
||||||
|
|
|
@ -152,7 +152,7 @@ void UnitConverterDataLoader::GetCategories(_In_ shared_ptr<vector<UCM::Category
|
||||||
for (auto const& category : converterCategory->Categories)
|
for (auto const& category : converterCategory->Categories)
|
||||||
{
|
{
|
||||||
/* Id, CategoryName, SupportsNegative */
|
/* Id, CategoryName, SupportsNegative */
|
||||||
categoriesList->emplace_back(NavCategoryStates::Serialize(category->Mode), category->Name->Data(), category->SupportsNegative);
|
categoriesList->emplace_back(NavCategoryStates::Serialize(category->ViewMode), category->Name->Data(), category->SupportsNegative);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -415,11 +415,11 @@ namespace CalculatorApp
|
||||||
|
|
||||||
foreach (NavCategory option in calculatorOptions.Categories)
|
foreach (NavCategory option in calculatorOptions.Categories)
|
||||||
{
|
{
|
||||||
if (!NavCategoryStates.IsViewModeEnabled(option.Mode))
|
if (!NavCategoryStates.IsViewModeEnabled(option.ViewMode))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ViewMode mode = option.Mode;
|
ViewMode mode = option.ViewMode;
|
||||||
var item = JumpListItem.CreateWithArguments(((int)mode).ToString(), "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode));
|
var item = JumpListItem.CreateWithArguments(((int)mode).ToString(), "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode));
|
||||||
item.Description = "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode);
|
item.Description = "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode);
|
||||||
item.Logo = new Uri("ms-appx:///Assets/" + mode.ToString() + ".png");
|
item.Logo = new Uri("ms-appx:///Assets/" + mode.ToString() + ".png");
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
</Style>
|
</Style>
|
||||||
<DataTemplate x:Key="NavViewCategoryItemDataTemplate" x:DataType="vmcom:NavCategory">
|
<DataTemplate x:Key="NavViewCategoryItemDataTemplate" x:DataType="vmcom:NavCategory">
|
||||||
<muxc:NavigationViewItem Content="{x:Bind Name}"
|
<muxc:NavigationViewItem Content="{x:Bind Name}"
|
||||||
Tag="{x:Bind Mode}"
|
Tag="{x:Bind ViewMode}"
|
||||||
AccessKey="{x:Bind AccessKey}"
|
AccessKey="{x:Bind AccessKey}"
|
||||||
IsEnabled="{x:Bind IsEnabled, Mode=OneWay}"
|
IsEnabled="{x:Bind IsEnabled, Mode=OneWay}"
|
||||||
Style="{StaticResource NavViewItemStyle}"
|
Style="{StaticResource NavViewItemStyle}"
|
||||||
|
|
|
@ -152,7 +152,7 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
if(x is NavCategory category)
|
if(x is NavCategory category)
|
||||||
{
|
{
|
||||||
return category.Mode == ViewMode.Graphing;
|
return category.ViewMode == ViewMode.Graphing;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -407,7 +407,7 @@ namespace CalculatorUnitTests
|
||||||
VERIFY_IS_GREATER_THAN(categories->Size, index);
|
VERIFY_IS_GREATER_THAN(categories->Size, index);
|
||||||
|
|
||||||
NavCategory ^ category = categories->GetAt(index);
|
NavCategory ^ category = categories->GetAt(index);
|
||||||
VERIFY_ARE_EQUAL(expectedMode, category->Mode);
|
VERIFY_ARE_EQUAL(expectedMode, category->ViewMode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue