From f6ed5ed40c3e1c4bebd1b82a77d1fcf016f2d19a Mon Sep 17 00:00:00 2001 From: Daniel Belcher Date: Thu, 2 May 2019 12:50:35 -0700 Subject: [PATCH] - BinPack(Arguments|Parameters): false --- .clang-format | 4 +- src/CalcManager/CEngine/calc.cpp | 5 +- src/CalcManager/CalculatorHistory.cpp | 3 +- src/CalcManager/CalculatorHistory.h | 3 +- src/CalcManager/Header Files/CalcEngine.h | 5 +- .../Header Files/IHistoryDisplay.h | 3 +- src/CalcManager/Ratpack/ratpak.h | 3 +- src/CalcManager/UnitConverter.h | 10 +- .../Common/AlwaysSelectedCollectionView.h | 8 +- .../Automation/NarratorAnnouncement.cpp | 21 +- .../Common/Automation/NarratorAnnouncement.h | 5 +- .../Common/Automation/NarratorNotifier.h | 3 +- .../Common/Automation/NotificationHost.cpp | 4 +- src/CalcViewModel/Common/CopyPasteManager.h | 28 +- src/CalcViewModel/Common/DateCalculator.h | 8 +- .../Common/LocalizationService.cpp | 51 +- .../Common/LocalizationService.h | 8 +- .../Common/LocalizationSettings.h | 12 +- src/CalcViewModel/Common/NavCategory.cpp | 181 ++++- src/CalcViewModel/Common/NavCategory.h | 17 +- src/CalcViewModel/Common/TraceActivity.h | 7 +- src/CalcViewModel/Common/Utils.cpp | 3 +- src/CalcViewModel/Common/Utils.h | 7 +- .../Common/ValidatingConverters.h | 16 +- .../DataLoaders/CurrencyDataLoader.cpp | 11 +- .../DataLoaders/CurrencyDataLoader.h | 4 +- .../DataLoaders/UnitConverterDataLoader.cpp | 750 ++++++++++++------ .../DataLoaders/UnitConverterDataLoader.h | 14 +- src/CalcViewModel/DateCalculatorViewModel.cpp | 3 +- src/CalcViewModel/HistoryItemViewModel.cpp | 7 +- src/CalcViewModel/HistoryItemViewModel.h | 6 +- src/CalcViewModel/HistoryViewModel.cpp | 8 +- .../StandardCalculatorViewModel.cpp | 7 +- src/CalcViewModel/UnitConverterViewModel.cpp | 8 +- src/CalcViewModel/UnitConverterViewModel.h | 5 +- src/Calculator/App.xaml.cpp | 4 +- .../Common/AlwaysSelectedCollectionView.h | 8 +- .../BitFlipAutomationNameConverter.h | 8 +- .../Converters/BooleanNegationConverter.h | 5 +- .../Converters/BooleanToVisibilityConverter.h | 10 +- .../ItemSizeToVisibilityConverter.h | 10 +- .../Converters/RadixToStringConverter.h | 5 +- .../Converters/VisibilityNegationConverter.h | 5 +- src/Calculator/Views/Calculator.xaml.h | 6 +- .../CalculatorProgrammerBitFlipPanel.xaml.h | 4 +- .../CalculatorScientificOperators.xaml.cpp | 3 +- src/Calculator/Views/DateCalculator.xaml.cpp | 3 +- src/Calculator/Views/DateCalculator.xaml.h | 9 +- src/Calculator/Views/MainPage.xaml.h | 3 +- .../Views/SupplementaryResults.xaml.h | 8 +- src/CalculatorUnitTests/CalcEngineTests.cpp | 26 +- .../CopyPasteManagerTest.cpp | 40 +- src/CalculatorUnitTests/DateUtils.h | 6 +- .../StandardViewModelUnitTests.cpp | 3 +- src/CalculatorUnitTests/UnitConverterTest.cpp | 70 +- 55 files changed, 1050 insertions(+), 424 deletions(-) diff --git a/.clang-format b/.clang-format index 083543c8..bf821c51 100644 --- a/.clang-format +++ b/.clang-format @@ -15,8 +15,8 @@ AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: true -BinPackArguments: true -BinPackParameters: true +BinPackArguments: false +BinPackParameters: false BreakBeforeBinaryOperators: NonAssignment BreakBeforeBraces: Allman BreakBeforeInheritanceComma: false diff --git a/src/CalcManager/CEngine/calc.cpp b/src/CalcManager/CEngine/calc.cpp index 64d1edca..c71d2927 100644 --- a/src/CalcManager/CEngine/calc.cpp +++ b/src/CalcManager/CEngine/calc.cpp @@ -59,7 +59,10 @@ void CCalcEngine::InitialOneTimeOnlySetup(CalculationManager::IResourceProvider& // ////////////////////////////////////////////////// CCalcEngine::CCalcEngine( - bool fPrecedence, bool fIntegerMode, CalculationManager::IResourceProvider* const pResourceProvider, __in_opt ICalcDisplay* pCalcDisplay, + bool fPrecedence, + bool fIntegerMode, + CalculationManager::IResourceProvider* const pResourceProvider, + __in_opt ICalcDisplay* pCalcDisplay, __in_opt shared_ptr pHistoryDisplay) : m_fPrecedence(fPrecedence) , m_fIntegerMode(fIntegerMode) diff --git a/src/CalcManager/CalculatorHistory.cpp b/src/CalcManager/CalculatorHistory.cpp index 675f9a9d..dcc2dacd 100644 --- a/src/CalcManager/CalculatorHistory.cpp +++ b/src/CalcManager/CalculatorHistory.cpp @@ -12,7 +12,8 @@ CalculatorHistory::CalculatorHistory(size_t maxSize) : m_maxHistorySize(maxSize) } unsigned int CalculatorHistory::AddToHistory( - _In_ shared_ptr>> const& tokens, _In_ shared_ptr>> const& commands, + _In_ shared_ptr>> const& tokens, + _In_ shared_ptr>> const& commands, _In_ wstring_view result) { unsigned int addedIndex; diff --git a/src/CalcManager/CalculatorHistory.h b/src/CalcManager/CalculatorHistory.h index 7f6ec0fe..75b74255 100644 --- a/src/CalcManager/CalculatorHistory.h +++ b/src/CalcManager/CalculatorHistory.h @@ -32,7 +32,8 @@ namespace CalculationManager CalculatorHistory(const size_t maxSize); unsigned int AddToHistory( _In_ std::shared_ptr>> const& spTokens, - _In_ std::shared_ptr>> const& spCommands, std::wstring_view result); + _In_ std::shared_ptr>> const& spCommands, + std::wstring_view result); std::vector> const& GetHistory(); std::shared_ptr const& GetHistoryItem(unsigned int uIdx); void ClearHistory(); diff --git a/src/CalcManager/Header Files/CalcEngine.h b/src/CalcManager/Header Files/CalcEngine.h index 8c4569d3..03a5437e 100644 --- a/src/CalcManager/Header Files/CalcEngine.h +++ b/src/CalcManager/Header Files/CalcEngine.h @@ -55,7 +55,10 @@ class CCalcEngine { public: CCalcEngine( - bool fPrecedence, bool fIntegerMode, CalculationManager::IResourceProvider* const pResourceProvider, __in_opt ICalcDisplay* pCalcDisplay, + bool fPrecedence, + bool fIntegerMode, + CalculationManager::IResourceProvider* const pResourceProvider, + __in_opt ICalcDisplay* pCalcDisplay, __in_opt std::shared_ptr pHistoryDisplay); void ProcessCommand(OpCode wID); void DisplayError(uint32_t nError); diff --git a/src/CalcManager/Header Files/IHistoryDisplay.h b/src/CalcManager/Header Files/IHistoryDisplay.h index 8721caf0..7e2a9019 100644 --- a/src/CalcManager/Header Files/IHistoryDisplay.h +++ b/src/CalcManager/Header Files/IHistoryDisplay.h @@ -10,5 +10,6 @@ public: virtual ~IHistoryDisplay(){}; virtual unsigned int AddToHistory( _In_ std::shared_ptr>> const& tokens, - _In_ std::shared_ptr>> const& commands, _In_ std::wstring_view result) = 0; + _In_ std::shared_ptr>> const& commands, + _In_ std::wstring_view result) = 0; }; diff --git a/src/CalcManager/Ratpack/ratpak.h b/src/CalcManager/Ratpack/ratpak.h index 447905c1..2e7c973c 100644 --- a/src/CalcManager/Ratpack/ratpak.h +++ b/src/CalcManager/Ratpack/ratpak.h @@ -357,7 +357,8 @@ extern PNUMBER _createnum(_In_ uint32_t size); // returns an empty number struct extern PNUMBER nRadixxtonum(_In_ PNUMBER a, uint32_t radix, int32_t precision); extern PNUMBER gcd(_In_ PNUMBER a, _In_ PNUMBER b); extern PNUMBER StringToNumber( - std::wstring_view numberString, uint32_t radix, + std::wstring_view numberString, + uint32_t radix, int32_t precision); // takes a text representation of a number and returns a number. // takes a text representation of a number as a mantissa with sign and an exponent with sign. diff --git a/src/CalcManager/UnitConverter.h b/src/CalcManager/UnitConverter.h index 482a7a84..7d3cf136 100644 --- a/src/CalcManager/UnitConverter.h +++ b/src/CalcManager/UnitConverter.h @@ -30,7 +30,12 @@ namespace UnitConversionManager } Unit( - int id, std::wstring currencyName, std::wstring countryName, std::wstring abbreviation, bool isRtlLanguage, bool isConversionSource, + int id, + std::wstring currencyName, + std::wstring countryName, + std::wstring abbreviation, + bool isRtlLanguage, + bool isConversionSource, bool isConversionTarget) : id(id), abbreviation(abbreviation), isConversionSource(isConversionSource), isConversionTarget(isConversionTarget), isWhimsical(false) { @@ -157,7 +162,8 @@ namespace UnitConversionManager typedef std::tuple, UnitConversionManager::Unit, UnitConversionManager::Unit> CategorySelectionInitializer; typedef std::unordered_map< - UnitConversionManager::Unit, std::unordered_map, + UnitConversionManager::Unit, + std::unordered_map, UnitConversionManager::UnitHash> UnitToUnitToConversionDataMap; typedef std::unordered_map, UnitConversionManager::CategoryHash> diff --git a/src/CalcViewModel/Common/AlwaysSelectedCollectionView.h b/src/CalcViewModel/Common/AlwaysSelectedCollectionView.h index 5759f5fe..8d01815f 100644 --- a/src/CalcViewModel/Common/AlwaysSelectedCollectionView.h +++ b/src/CalcViewModel/Common/AlwaysSelectedCollectionView.h @@ -265,7 +265,9 @@ namespace CalculatorApp private: virtual Platform::Object ^ Convert( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName /*targetType*/, + Platform::Object ^ /*parameter*/, Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert { auto result = dynamic_cast(value); @@ -278,7 +280,9 @@ namespace CalculatorApp virtual Platform::Object ^ ConvertBack( - Platform::Object ^ /*value*/, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, + Platform::Object ^ /*value*/, + Windows::UI::Xaml::Interop::TypeName /*targetType*/, + Platform::Object ^ /*parameter*/, Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack { return Windows::UI::Xaml::DependencyProperty::UnsetValue; diff --git a/src/CalcViewModel/Common/Automation/NarratorAnnouncement.cpp b/src/CalcViewModel/Common/Automation/NarratorAnnouncement.cpp index 9a8ff5ed..9ca8660d 100644 --- a/src/CalcViewModel/Common/Automation/NarratorAnnouncement.cpp +++ b/src/CalcViewModel/Common/Automation/NarratorAnnouncement.cpp @@ -26,7 +26,10 @@ namespace CalculatorApp::Common::Automation } NarratorAnnouncement::NarratorAnnouncement( - String ^ announcement, String ^ activityId, AutomationNotificationKind kind, AutomationNotificationProcessing processing) + String ^ announcement, + String ^ activityId, + AutomationNotificationKind kind, + AutomationNotificationProcessing processing) : m_announcement(announcement), m_activityId(activityId), m_kind(kind), m_processing(processing) { } @@ -95,14 +98,18 @@ NarratorAnnouncement ^ CalculatorAnnouncement::GetHistoryClearedAnnouncement(Str NarratorAnnouncement ^ CalculatorAnnouncement::GetCategoryNameChangedAnnouncement(String ^ announcement) { return ref new NarratorAnnouncement( - announcement, CalculatorActivityIds::CategoryNameChanged, AutomationNotificationKind::ActionCompleted, + announcement, + CalculatorActivityIds::CategoryNameChanged, + AutomationNotificationKind::ActionCompleted, AutomationNotificationProcessing::ImportantMostRecent); } NarratorAnnouncement ^ CalculatorAnnouncement::GetUpdateCurrencyRatesAnnouncement(String ^ announcement) { return ref new NarratorAnnouncement( - announcement, CalculatorActivityIds::UpdateCurrencyRates, AutomationNotificationKind::ActionCompleted, + announcement, + CalculatorActivityIds::UpdateCurrencyRates, + AutomationNotificationKind::ActionCompleted, AutomationNotificationProcessing::ImportantMostRecent); } @@ -115,13 +122,17 @@ NarratorAnnouncement ^ CalculatorAnnouncement::GetDisplayCopiedAnnouncement(Stri NarratorAnnouncement ^ CalculatorAnnouncement::GetOpenParenthesisCountChangedAnnouncement(String ^ announcement) { return ref new NarratorAnnouncement( - announcement, CalculatorActivityIds::OpenParenthesisCountChanged, AutomationNotificationKind::ActionCompleted, + announcement, + CalculatorActivityIds::OpenParenthesisCountChanged, + AutomationNotificationKind::ActionCompleted, AutomationNotificationProcessing::ImportantMostRecent); } NarratorAnnouncement ^ CalculatorAnnouncement::GetNoRightParenthesisAddedAnnouncement(String ^ announcement) { return ref new NarratorAnnouncement( - announcement, CalculatorActivityIds::NoParenthesisAdded, AutomationNotificationKind::ActionCompleted, + announcement, + CalculatorActivityIds::NoParenthesisAdded, + AutomationNotificationKind::ActionCompleted, AutomationNotificationProcessing::ImportantMostRecent); } diff --git a/src/CalcViewModel/Common/Automation/NarratorAnnouncement.h b/src/CalcViewModel/Common/Automation/NarratorAnnouncement.h index 14a1e3fb..c4c0c526 100644 --- a/src/CalcViewModel/Common/Automation/NarratorAnnouncement.h +++ b/src/CalcViewModel/Common/Automation/NarratorAnnouncement.h @@ -59,7 +59,10 @@ public friend class CalculatorAnnouncement; NarratorAnnouncement( - Platform::String ^ announcement, Platform::String ^ activityId, AutomationNotificationKind kind, AutomationNotificationProcessing processing); + Platform::String ^ announcement, + Platform::String ^ activityId, + AutomationNotificationKind kind, + AutomationNotificationProcessing processing); Platform::String ^ m_announcement; Platform::String ^ m_activityId; diff --git a/src/CalcViewModel/Common/Automation/NarratorNotifier.h b/src/CalcViewModel/Common/Automation/NarratorNotifier.h index 2743e12b..55bed4e7 100644 --- a/src/CalcViewModel/Common/Automation/NarratorNotifier.h +++ b/src/CalcViewModel/Common/Automation/NarratorNotifier.h @@ -41,7 +41,8 @@ public private: static void OnAnnouncementChanged( - _In_ Windows::UI::Xaml::DependencyObject ^ dependencyObject, _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ eventArgs); + _In_ Windows::UI::Xaml::DependencyObject ^ dependencyObject, + _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ eventArgs); static Windows::UI::Xaml::DependencyProperty ^ s_announcementProperty; diff --git a/src/CalcViewModel/Common/Automation/NotificationHost.cpp b/src/CalcViewModel/Common/Automation/NotificationHost.cpp index 097a17de..8a1fea96 100644 --- a/src/CalcViewModel/Common/Automation/NotificationHost.cpp +++ b/src/CalcViewModel/Common/Automation/NotificationHost.cpp @@ -35,7 +35,9 @@ void NotificationHost::Announce(NarratorAnnouncement ^ announcement) if (peer != nullptr) { peer->RaiseNotificationEvent( - GetWindowsNotificationKind(announcement->Kind), GetWindowsNotificationProcessing(announcement->Processing), announcement->Announcement, + GetWindowsNotificationKind(announcement->Kind), + GetWindowsNotificationProcessing(announcement->Processing), + announcement->Announcement, announcement->ActivityId); } } diff --git a/src/CalcViewModel/Common/CopyPasteManager.h b/src/CalcViewModel/Common/CopyPasteManager.h index 1dad52cd..b393dab5 100644 --- a/src/CalcViewModel/Common/CopyPasteManager.h +++ b/src/CalcViewModel/Common/CopyPasteManager.h @@ -27,7 +27,10 @@ namespace CalculatorApp public: static void CopyToClipboard(Platform::String ^ stringToCopy); static concurrency::task GetStringToPaste( - CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::CategoryGroupType modeType, int programmerNumberBase = -1, int bitLengthType = -1); + CalculatorApp::Common::ViewMode mode, + CalculatorApp::Common::CategoryGroupType modeType, + int programmerNumberBase = -1, + int bitLengthType = -1); static bool HasStringToPaste() { return ClipboardTextFormat() >= 0; @@ -41,21 +44,32 @@ namespace CalculatorApp ^ ValidatePasteExpression(Platform::String ^ pastedText, CalculatorApp::Common::ViewMode mode, int programmerNumberBase, int bitLengthType); static Platform::String ^ ValidatePasteExpression( - Platform::String ^ pastedText, CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::CategoryGroupType modeType, - int programmerNumberBase, int bitLengthType); + Platform::String ^ pastedText, + CalculatorApp::Common::ViewMode mode, + CalculatorApp::Common::CategoryGroupType modeType, + int programmerNumberBase, + int bitLengthType); static std::vector ExtractOperands(const std::wstring& pasteExpression, CalculatorApp::Common::ViewMode mode, int programmerNumberBase = -1, int bitLengthType = -1); static bool ExpressionRegExMatch( - std::vector operands, CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::CategoryGroupType modeType, - int programmerNumberBase = -1, int bitLengthType = -1); + std::vector operands, + CalculatorApp::Common::ViewMode mode, + CalculatorApp::Common::CategoryGroupType modeType, + int programmerNumberBase = -1, + int bitLengthType = -1); static std::pair GetMaxOperandLengthAndValue( - CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::CategoryGroupType modeType, int programmerNumberBase = -1, int bitLengthType = -1); + CalculatorApp::Common::ViewMode mode, + CalculatorApp::Common::CategoryGroupType modeType, + int programmerNumberBase = -1, + int bitLengthType = -1); static std::wstring SanitizeOperand(const std::wstring& operand); static bool TryOperandToULL(const std::wstring& operand, int numberBase, unsigned long long int& result); static size_t OperandLength( - const std::wstring& operand, CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::CategoryGroupType modeType, + const std::wstring& operand, + CalculatorApp::Common::ViewMode mode, + CalculatorApp::Common::CategoryGroupType modeType, int programmerNumberBase = -1); static size_t StandardScientificOperandLength(const std::wstring& operand); static size_t ProgrammerOperandLength(const std::wstring& operand, int numberBase); diff --git a/src/CalcViewModel/Common/DateCalculator.h b/src/CalcViewModel/Common/DateCalculator.h index 25d34f0c..e71f02f1 100644 --- a/src/CalcViewModel/Common/DateCalculator.h +++ b/src/CalcViewModel/Common/DateCalculator.h @@ -47,9 +47,13 @@ namespace CalculatorApp bool __nothrow AddDuration(_In_ Windows::Foundation::DateTime startDate, _In_ const DateDifference& duration, _Out_ Windows::Foundation::DateTime* endDate); bool __nothrow SubtractDuration( - _In_ Windows::Foundation::DateTime startDate, _In_ const DateDifference& duration, _Out_ Windows::Foundation::DateTime* endDate); + _In_ Windows::Foundation::DateTime startDate, + _In_ const DateDifference& duration, + _Out_ Windows::Foundation::DateTime* endDate); void __nothrow GetDateDifference( - _In_ Windows::Foundation::DateTime date1, _In_ Windows::Foundation::DateTime date2, _In_ DateUnit outputFormat, + _In_ Windows::Foundation::DateTime date1, + _In_ Windows::Foundation::DateTime date2, + _In_ DateUnit outputFormat, _Out_ DateDifference* difference); private: diff --git a/src/CalcViewModel/Common/LocalizationService.cpp b/src/CalcViewModel/Common/LocalizationService.cpp index 6f429651..848360ee 100644 --- a/src/CalcViewModel/Common/LocalizationService.cpp +++ b/src/CalcViewModel/Common/LocalizationService.cpp @@ -434,28 +434,41 @@ unordered_map LocalizationService::GetTokenToReadableNameMap() // change given that the engine heavily relies on perfect ordering of certain elements. // To compromise, we'll declare a map from engine resource key to automation name from the // standard project resources. - static vector> s_parenEngineKeyResourceMap = { - // Sine permutations - make_pair(L"67", L"SineDegrees"), make_pair(L"73", L"SineRadians"), - make_pair(L"79", L"SineGradians"), make_pair(L"70", L"InverseSineDegrees"), - make_pair(L"76", L"InverseSineRadians"), make_pair(L"82", L"InverseSineGradians"), - make_pair(L"25", L"HyperbolicSine"), make_pair(L"85", L"InverseHyperbolicSine"), + static vector> s_parenEngineKeyResourceMap = { // Sine permutations + make_pair(L"67", L"SineDegrees"), + make_pair(L"73", L"SineRadians"), + make_pair(L"79", L"SineGradians"), + make_pair(L"70", L"InverseSineDegrees"), + make_pair(L"76", L"InverseSineRadians"), + make_pair(L"82", L"InverseSineGradians"), + make_pair(L"25", L"HyperbolicSine"), + make_pair(L"85", L"InverseHyperbolicSine"), - // Cosine permutations - make_pair(L"68", L"CosineDegrees"), make_pair(L"74", L"CosineRadians"), - make_pair(L"80", L"CosineGradians"), make_pair(L"71", L"InverseCosineDegrees"), - make_pair(L"77", L"InverseCosineRadians"), make_pair(L"83", L"InverseCosineGradians"), - make_pair(L"26", L"HyperbolicCosine"), make_pair(L"86", L"InverseHyperbolicCosine"), + // Cosine permutations + make_pair(L"68", L"CosineDegrees"), + make_pair(L"74", L"CosineRadians"), + make_pair(L"80", L"CosineGradians"), + make_pair(L"71", L"InverseCosineDegrees"), + make_pair(L"77", L"InverseCosineRadians"), + make_pair(L"83", L"InverseCosineGradians"), + make_pair(L"26", L"HyperbolicCosine"), + make_pair(L"86", L"InverseHyperbolicCosine"), - // Tangent permutations - make_pair(L"69", L"TangentDegrees"), make_pair(L"75", L"TangentRadians"), - make_pair(L"81", L"TangentGradians"), make_pair(L"72", L"InverseTangentDegrees"), - make_pair(L"78", L"InverseTangentRadians"), make_pair(L"84", L"InverseTangentGradians"), - make_pair(L"27", L"HyperbolicTangent"), make_pair(L"87", L"InverseHyperbolicTangent"), + // Tangent permutations + make_pair(L"69", L"TangentDegrees"), + make_pair(L"75", L"TangentRadians"), + make_pair(L"81", L"TangentGradians"), + make_pair(L"72", L"InverseTangentDegrees"), + make_pair(L"78", L"InverseTangentRadians"), + make_pair(L"84", L"InverseTangentGradians"), + make_pair(L"27", L"HyperbolicTangent"), + make_pair(L"87", L"InverseHyperbolicTangent"), - // Miscellaneous Scientific functions - make_pair(L"94", L"Factorial"), make_pair(L"35", L"DegreeMinuteSecond"), - make_pair(L"28", L"NaturalLog"), make_pair(L"91", L"Square") + // Miscellaneous Scientific functions + make_pair(L"94", L"Factorial"), + make_pair(L"35", L"DegreeMinuteSecond"), + make_pair(L"28", L"NaturalLog"), + make_pair(L"91", L"Square") }; static vector> s_noParenEngineKeyResourceMap = { // Programmer mode functions diff --git a/src/CalcViewModel/Common/LocalizationService.h b/src/CalcViewModel/Common/LocalizationService.h index ace64558..73b088b5 100644 --- a/src/CalcViewModel/Common/LocalizationService.h +++ b/src/CalcViewModel/Common/LocalizationService.h @@ -45,7 +45,9 @@ namespace CalculatorApp static Windows::Globalization::DateTimeFormatting::DateTimeFormatter ^ GetRegionalSettingsAwareDateTimeFormatter(_In_ Platform::String ^ format); static Windows::Globalization::DateTimeFormatting::DateTimeFormatter ^ GetRegionalSettingsAwareDateTimeFormatter( - _In_ Platform::String ^ format, _In_ Platform::String ^ calendarIdentifier, _In_ Platform::String ^ clockIdentifier); + _In_ Platform::String ^ format, + _In_ Platform::String ^ calendarIdentifier, + _In_ Platform::String ^ clockIdentifier); static Windows::Globalization::NumberFormatting::CurrencyFormatter ^ GetRegionalSettingsAwareCurrencyFormatter(); @@ -61,7 +63,9 @@ namespace CalculatorApp // Attached property callbacks static void OnFontTypePropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, LanguageFontType oldValue, LanguageFontType newValue); static void OnFontWeightPropertyChanged( - Windows::UI::Xaml::DependencyObject ^ target, Windows::UI::Text::FontWeight oldValue, Windows::UI::Text::FontWeight newValue); + Windows::UI::Xaml::DependencyObject ^ target, + Windows::UI::Text::FontWeight oldValue, + Windows::UI::Text::FontWeight newValue); static void OnFontSizePropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, double oldValue, double newValue); static void UpdateFontFamilyAndSize(Windows::UI::Xaml::DependencyObject ^ target); diff --git a/src/CalcViewModel/Common/LocalizationSettings.h b/src/CalcViewModel/Common/LocalizationSettings.h index 327dd6bc..1b350154 100644 --- a/src/CalcViewModel/Common/LocalizationSettings.h +++ b/src/CalcViewModel/Common/LocalizationSettings.h @@ -61,7 +61,9 @@ namespace CalculatorApp // Get locale info for List Separator, eg. comma is used in many locales wchar_t listSeparatorString[4] = L""; result = ::GetLocaleInfoEx( - LOCALE_NAME_USER_DEFAULT, LOCALE_SLIST, listSeparatorString, + LOCALE_NAME_USER_DEFAULT, + LOCALE_SLIST, + listSeparatorString, static_cast(std::size(listSeparatorString))); // Max length of the expected return value is 4 if (result == 0) { @@ -70,7 +72,9 @@ namespace CalculatorApp int currencyTrailingDigits = 0; result = GetLocaleInfoEx( - m_resolvedName.c_str(), LOCALE_ICURRDIGITS | LOCALE_RETURN_NUMBER, (LPWSTR)¤cyTrailingDigits, + m_resolvedName.c_str(), + LOCALE_ICURRDIGITS | LOCALE_RETURN_NUMBER, + (LPWSTR)¤cyTrailingDigits, sizeof(currencyTrailingDigits) / sizeof(WCHAR)); if (result == 0) { @@ -81,7 +85,9 @@ namespace CalculatorApp // A value of 0 indicates the symbol follows the currency value. int currencySymbolPrecedence = 1; result = GetLocaleInfoEx( - LOCALE_NAME_USER_DEFAULT, LOCALE_IPOSSYMPRECEDES | LOCALE_RETURN_NUMBER, (LPWSTR)¤cySymbolPrecedence, + LOCALE_NAME_USER_DEFAULT, + LOCALE_IPOSSYMPRECEDES | LOCALE_RETURN_NUMBER, + (LPWSTR)¤cySymbolPrecedence, sizeof(currencySymbolPrecedence) / sizeof(WCHAR)); // As CalcEngine only supports the first character of the decimal separator, diff --git a/src/CalcViewModel/Common/NavCategory.cpp b/src/CalcViewModel/Common/NavCategory.cpp index 8d786f2b..19667485 100644 --- a/src/CalcViewModel/Common/NavCategory.cpp +++ b/src/CalcViewModel/Common/NavCategory.cpp @@ -49,42 +49,142 @@ static constexpr int CURRENCY_ID = 16; // ^^^ THESE CONSTANTS SHOULD NEVER CHANGE ^^^ // The order of items in this list determines the order of items in the menu. -static constexpr array s_categoryManifest = { - NavCategoryInitializer{ ViewMode::Standard, STANDARD_ID, L"Standard", L"StandardMode", L"\uE8EF", CategoryGroupType::Calculator, MyVirtualKey::Number1, - SUPPORTS_ALL }, - NavCategoryInitializer{ ViewMode::Scientific, SCIENTIFIC_ID, L"Scientific", L"ScientificMode", L"\uF196", CategoryGroupType::Calculator, - MyVirtualKey::Number2, SUPPORTS_ALL }, - NavCategoryInitializer{ ViewMode::Programmer, PROGRAMMER_ID, L"Programmer", L"ProgrammerMode", L"\uECCE", CategoryGroupType::Calculator, - MyVirtualKey::Number3, SUPPORTS_ALL }, - NavCategoryInitializer{ ViewMode::Date, DATE_ID, L"Date", L"DateCalculationMode", L"\uE787", CategoryGroupType::Calculator, MyVirtualKey::Number4, - SUPPORTS_ALL }, - NavCategoryInitializer{ ViewMode::Currency, CURRENCY_ID, L"Currency", L"CategoryName_Currency", L"\uEB0D", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY }, - NavCategoryInitializer{ ViewMode::Volume, VOLUME_ID, L"Volume", L"CategoryName_Volume", L"\uF1AA", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY }, - NavCategoryInitializer{ ViewMode::Length, LENGTH_ID, L"Length", L"CategoryName_Length", L"\uECC6", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY }, - NavCategoryInitializer{ ViewMode::Weight, WEIGHT_ID, L"Weight and Mass", L"CategoryName_Weight", L"\uF4C1", CategoryGroupType::Converter, - MyVirtualKey::None, POSITIVE_ONLY }, - NavCategoryInitializer{ ViewMode::Temperature, TEMPERATURE_ID, L"Temperature", L"CategoryName_Temperature", L"\uE7A3", CategoryGroupType::Converter, - MyVirtualKey::None, SUPPORTS_NEGATIVE }, - NavCategoryInitializer{ ViewMode::Energy, ENERGY_ID, L"Energy", L"CategoryName_Energy", L"\uECAD", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY }, - NavCategoryInitializer{ ViewMode::Area, AREA_ID, L"Area", L"CategoryName_Area", L"\uE809", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY }, - NavCategoryInitializer{ ViewMode::Speed, SPEED_ID, L"Speed", L"CategoryName_Speed", L"\uEADA", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY }, - NavCategoryInitializer{ ViewMode::Time, TIME_ID, L"Time", L"CategoryName_Time", L"\uE917", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY }, - NavCategoryInitializer{ ViewMode::Power, POWER_ID, L"Power", L"CategoryName_Power", L"\uE945", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY }, - NavCategoryInitializer{ ViewMode::Data, DATA_ID, L"Data", L"CategoryName_Data", L"\uF20F", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY }, - NavCategoryInitializer{ ViewMode::Pressure, PRESSURE_ID, L"Pressure", L"CategoryName_Pressure", L"\uEC4A", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY }, - NavCategoryInitializer{ ViewMode::Angle, ANGLE_ID, L"Angle", L"CategoryName_Angle", L"\uF515", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY } -}; +static constexpr array s_categoryManifest = { NavCategoryInitializer{ ViewMode::Standard, + STANDARD_ID, + L"Standard", + L"StandardMode", + L"\uE8EF", + CategoryGroupType::Calculator, + MyVirtualKey::Number1, + SUPPORTS_ALL }, + NavCategoryInitializer{ ViewMode::Scientific, + SCIENTIFIC_ID, + L"Scientific", + L"ScientificMode", + L"\uF196", + CategoryGroupType::Calculator, + MyVirtualKey::Number2, + SUPPORTS_ALL }, + NavCategoryInitializer{ ViewMode::Programmer, + PROGRAMMER_ID, + L"Programmer", + L"ProgrammerMode", + L"\uECCE", + CategoryGroupType::Calculator, + MyVirtualKey::Number3, + SUPPORTS_ALL }, + NavCategoryInitializer{ ViewMode::Date, + DATE_ID, + L"Date", + L"DateCalculationMode", + L"\uE787", + CategoryGroupType::Calculator, + MyVirtualKey::Number4, + SUPPORTS_ALL }, + NavCategoryInitializer{ ViewMode::Currency, + CURRENCY_ID, + L"Currency", + L"CategoryName_Currency", + L"\uEB0D", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY }, + NavCategoryInitializer{ ViewMode::Volume, + VOLUME_ID, + L"Volume", + L"CategoryName_Volume", + L"\uF1AA", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY }, + NavCategoryInitializer{ ViewMode::Length, + LENGTH_ID, + L"Length", + L"CategoryName_Length", + L"\uECC6", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY }, + NavCategoryInitializer{ ViewMode::Weight, + WEIGHT_ID, + L"Weight and Mass", + L"CategoryName_Weight", + L"\uF4C1", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY }, + NavCategoryInitializer{ ViewMode::Temperature, + TEMPERATURE_ID, + L"Temperature", + L"CategoryName_Temperature", + L"\uE7A3", + CategoryGroupType::Converter, + MyVirtualKey::None, + SUPPORTS_NEGATIVE }, + NavCategoryInitializer{ ViewMode::Energy, + ENERGY_ID, + L"Energy", + L"CategoryName_Energy", + L"\uECAD", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY }, + NavCategoryInitializer{ ViewMode::Area, + AREA_ID, + L"Area", + L"CategoryName_Area", + L"\uE809", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY }, + NavCategoryInitializer{ ViewMode::Speed, + SPEED_ID, + L"Speed", + L"CategoryName_Speed", + L"\uEADA", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY }, + NavCategoryInitializer{ ViewMode::Time, + TIME_ID, + L"Time", + L"CategoryName_Time", + L"\uE917", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY }, + NavCategoryInitializer{ ViewMode::Power, + POWER_ID, + L"Power", + L"CategoryName_Power", + L"\uE945", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY }, + NavCategoryInitializer{ ViewMode::Data, + DATA_ID, + L"Data", + L"CategoryName_Data", + L"\uF20F", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY }, + NavCategoryInitializer{ ViewMode::Pressure, + PRESSURE_ID, + L"Pressure", + L"CategoryName_Pressure", + L"\uEC4A", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY }, + NavCategoryInitializer{ ViewMode::Angle, + ANGLE_ID, + L"Angle", + L"CategoryName_Angle", + L"\uF515", + CategoryGroupType::Converter, + MyVirtualKey::None, + POSITIVE_ONLY } }; // This function should only be used when storing the mode to app data. int NavCategory::Serialize(ViewMode mode) @@ -290,8 +390,13 @@ NavCategoryGroup::NavCategoryGroup(const NavCategoryGroupInitializer& groupIniti LocalizationStringUtil::GetLocalizedString(navCategoryItemAutomationNameFormat->Data(), categoryName->Data(), m_Name->Data()).c_str()); m_Categories->Append(ref new NavCategory( - categoryName, categoryAutomationName, StringReference(categoryInitializer.glyph), resProvider.GetResourceString(nameResourceKey + "AccessKey"), - groupMode, categoryInitializer.viewMode, categoryInitializer.supportsNegative)); + categoryName, + categoryAutomationName, + StringReference(categoryInitializer.glyph), + resProvider.GetResourceString(nameResourceKey + "AccessKey"), + groupMode, + categoryInitializer.viewMode, + categoryInitializer.supportsNegative)); } } } diff --git a/src/CalcViewModel/Common/NavCategory.h b/src/CalcViewModel/Common/NavCategory.h index 1cae89e9..7ce48787 100644 --- a/src/CalcViewModel/Common/NavCategory.h +++ b/src/CalcViewModel/Common/NavCategory.h @@ -59,7 +59,13 @@ namespace CalculatorApp struct NavCategoryInitializer { constexpr NavCategoryInitializer( - ViewMode mode, int id, wchar_t const* name, wchar_t const* nameKey, wchar_t const* glyph, CategoryGroupType group, MyVirtualKey vKey, + ViewMode mode, + int id, + wchar_t const* name, + wchar_t const* nameKey, + wchar_t const* glyph, + CategoryGroupType group, + MyVirtualKey vKey, bool categorySupportsNegative) : viewMode(mode) , serializationId(id) @@ -163,8 +169,13 @@ namespace CalculatorApp static ViewMode GetViewModeForVirtualKey(MyVirtualKey virtualKey); internal : NavCategory( - Platform::String ^ name, Platform::String ^ automationName, Platform::String ^ glyph, Platform::String ^ accessKey, - Platform::String ^ mode, ViewMode viewMode, bool supportsNegative) + Platform::String ^ name, + Platform::String ^ automationName, + Platform::String ^ glyph, + Platform::String ^ accessKey, + Platform::String ^ mode, + ViewMode viewMode, + bool supportsNegative) : m_name(name) , m_automationName(automationName) , m_glyph(glyph) diff --git a/src/CalcViewModel/Common/TraceActivity.h b/src/CalcViewModel/Common/TraceActivity.h index 9b5b0bfe..4f5967dd 100644 --- a/src/CalcViewModel/Common/TraceActivity.h +++ b/src/CalcViewModel/Common/TraceActivity.h @@ -16,7 +16,8 @@ namespace CalculatorApp } TraceActivity( - winrt::Windows::Foundation::Diagnostics::LoggingChannel channel, std::wstring_view activityName, + winrt::Windows::Foundation::Diagnostics::LoggingChannel channel, + std::wstring_view activityName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) : m_channel(channel), m_activityName(activityName), m_fields(fields), m_activity(nullptr) { @@ -24,7 +25,9 @@ namespace CalculatorApp // or level for START and STOP events because they always use the activity's // keyword and level. m_activity = m_channel.StartActivity( - m_activityName, m_fields, winrt::Windows::Foundation::Diagnostics::LoggingLevel::Verbose, + m_activityName, + m_fields, + winrt::Windows::Foundation::Diagnostics::LoggingLevel::Verbose, winrt::Windows::Foundation::Diagnostics::LoggingOptions(WINEVENT_KEYWORD_RESPONSE_TIME)); } diff --git a/src/CalcViewModel/Common/Utils.cpp b/src/CalcViewModel/Common/Utils.cpp index f3d20684..8ad60816 100644 --- a/src/CalcViewModel/Common/Utils.cpp +++ b/src/CalcViewModel/Common/Utils.cpp @@ -93,7 +93,8 @@ wstring Utils::RemoveUnwantedCharsFromWstring(wstring input, wchar_t* unwantedCh } void Utils::SerializeCommandsAndTokens( - _In_ shared_ptr>> const& tokens, _In_ shared_ptr>> const& commands, + _In_ shared_ptr>> const& tokens, + _In_ shared_ptr>> const& commands, DataWriter ^ writer) { unsigned int commandsSize; diff --git a/src/CalcViewModel/Common/Utils.h b/src/CalcViewModel/Common/Utils.h index 6ce841a2..45eeefe2 100644 --- a/src/CalcViewModel/Common/Utils.h +++ b/src/CalcViewModel/Common/Utils.h @@ -386,7 +386,8 @@ namespace Utils void RunOnUIThreadNonblocking(std::function&& function, _In_ Windows::UI::Core::CoreDispatcher ^ currentDispatcher); void SerializeCommandsAndTokens( _In_ std::shared_ptr>> const& tokens, - _In_ std::shared_ptr>> const& commands, Windows::Storage::Streams::DataWriter ^ writer); + _In_ std::shared_ptr>> const& commands, + Windows::Storage::Streams::DataWriter ^ writer); const std::shared_ptr>> DeserializeCommands(Windows::Storage::Streams::DataReader ^ reader); const std::shared_ptr>> DeserializeTokens(Windows::Storage::Streams::DataReader ^ reader); @@ -395,7 +396,9 @@ namespace Utils bool IsDateTimeOlderThan(Windows::Foundation::DateTime dateTime, const long long duration); concurrency::task WriteFileToFolder( - Windows::Storage::IStorageFolder ^ folder, Platform::String ^ fileName, Platform::String ^ contents, + Windows::Storage::IStorageFolder ^ folder, + Platform::String ^ fileName, + Platform::String ^ contents, Windows::Storage::CreationCollisionOption collisionOption); concurrency::task ReadFileFromFolder(Windows::Storage::IStorageFolder ^ folder, Platform::String ^ fileName); } diff --git a/src/CalcViewModel/Common/ValidatingConverters.h b/src/CalcViewModel/Common/ValidatingConverters.h index ba58b112..bc168502 100644 --- a/src/CalcViewModel/Common/ValidatingConverters.h +++ b/src/CalcViewModel/Common/ValidatingConverters.h @@ -18,7 +18,9 @@ namespace CalculatorApp private: virtual Platform::Object ^ Convert( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName /*targetType*/, + Platform::Object ^ /*parameter*/, Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert { // Pass through as we don't want to change the value from the source @@ -27,7 +29,9 @@ namespace CalculatorApp virtual Platform::Object ^ ConvertBack( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName /*targetType*/, + Platform::Object ^ /*parameter*/, Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack { if (value) @@ -50,7 +54,9 @@ namespace CalculatorApp private: virtual Platform::Object ^ Convert( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName /*targetType*/, + Platform::Object ^ /*parameter*/, Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert { // Pass through as we don't want to change the value from the source @@ -59,7 +65,9 @@ namespace CalculatorApp virtual Platform::Object ^ ConvertBack( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName /*targetType*/, + Platform::Object ^ /*parameter*/, Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack { // The value to be valid has to be a boxed int32 value diff --git a/src/CalcViewModel/DataLoaders/CurrencyDataLoader.cpp b/src/CalcViewModel/DataLoaders/CurrencyDataLoader.cpp index 8ae5c4f3..b2c68dcf 100644 --- a/src/CalcViewModel/DataLoaders/CurrencyDataLoader.cpp +++ b/src/CalcViewModel/DataLoaders/CurrencyDataLoader.cpp @@ -46,8 +46,10 @@ static constexpr auto CACHE_LANGCODE_KEY = L"CURRENCY_CONVERTER_LANGCODE"; static constexpr auto CACHE_DELIMITER = L"%"; static constexpr auto STATIC_DATA_FILENAME = L"CURRENCY_CONVERTER_STATIC_DATA.txt"; -static constexpr array STATIC_DATA_PROPERTIES = { wstring_view{ L"CountryCode", 11 }, wstring_view{ L"CountryName", 11 }, - wstring_view{ L"CurrencyCode", 12 }, wstring_view{ L"CurrencyName", 12 }, +static constexpr array STATIC_DATA_PROPERTIES = { wstring_view{ L"CountryCode", 11 }, + wstring_view{ L"CountryName", 11 }, + wstring_view{ L"CurrencyCode", 12 }, + wstring_view{ L"CurrencyName", 12 }, wstring_view{ L"CurrencySymbol", 14 } }; static constexpr auto ALL_RATIOS_DATA_FILENAME = L"CURRENCY_CONVERTER_ALL_RATIOS_DATA.txt"; @@ -460,7 +462,10 @@ task CurrencyDataLoader::TryLoadDataFromWebOverrideAsync() #pragma optimize("", on) bool CurrencyDataLoader::TryParseWebResponses( - _In_ String ^ staticDataJson, _In_ String ^ allRatiosJson, _Inout_ vector& staticData, _Inout_ CurrencyRatioMap& allRatiosData) + _In_ String ^ staticDataJson, + _In_ String ^ allRatiosJson, + _Inout_ vector& staticData, + _Inout_ CurrencyRatioMap& allRatiosData) { return TryParseStaticData(staticDataJson, staticData) && TryParseAllRatiosData(allRatiosJson, allRatiosData); } diff --git a/src/CalcViewModel/DataLoaders/CurrencyDataLoader.h b/src/CalcViewModel/DataLoaders/CurrencyDataLoader.h index 16032de0..c3daedb8 100644 --- a/src/CalcViewModel/DataLoaders/CurrencyDataLoader.h +++ b/src/CalcViewModel/DataLoaders/CurrencyDataLoader.h @@ -89,7 +89,9 @@ namespace CalculatorApp concurrency::task TryFinishLoadFromCacheAsync(); bool TryParseWebResponses( - _In_ Platform::String ^ staticDataJson, _In_ Platform::String ^ allRatiosJson, _Inout_ std::vector& staticData, + _In_ Platform::String ^ staticDataJson, + _In_ Platform::String ^ allRatiosJson, + _Inout_ std::vector& staticData, _Inout_ CurrencyRatioMap& allRatiosData); bool TryParseStaticData(_In_ Platform::String ^ rawJson, _Inout_ std::vector& staticData); bool TryParseAllRatiosData(_In_ Platform::String ^ rawJson, _Inout_ CurrencyRatioMap& allRatiosData); diff --git a/src/CalcViewModel/DataLoaders/UnitConverterDataLoader.cpp b/src/CalcViewModel/DataLoaders/UnitConverterDataLoader.cpp index 1771e751..0b222c28 100644 --- a/src/CalcViewModel/DataLoaders/UnitConverterDataLoader.cpp +++ b/src/CalcViewModel/DataLoaders/UnitConverterDataLoader.cpp @@ -183,34 +183,65 @@ void UnitConverterDataLoader::GetUnits(_In_ unordered_map energyUnits; - energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_BritishThermalUnit, GetLocalizedStringName(L"UnitName_BritishThermalUnit"), - GetLocalizedStringName(L"UnitAbbreviation_BritishThermalUnit"), 7 }); + energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_BritishThermalUnit, + GetLocalizedStringName(L"UnitName_BritishThermalUnit"), + GetLocalizedStringName(L"UnitAbbreviation_BritishThermalUnit"), + 7 }); energyUnits.push_back( OrderedUnit{ UnitConverterUnits::Energy_Calorie, GetLocalizedStringName(L"UnitName_Calorie"), GetLocalizedStringName(L"UnitAbbreviation_Calorie"), 4 }); - energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_ElectronVolt, GetLocalizedStringName(L"UnitName_Electron-Volt"), - GetLocalizedStringName(L"UnitAbbreviation_Electron-Volt"), 1 }); - energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_FootPound, GetLocalizedStringName(L"UnitName_Foot-Pound"), - GetLocalizedStringName(L"UnitAbbreviation_Foot-Pound"), 6 }); - energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Joule, GetLocalizedStringName(L"UnitName_Joule"), - GetLocalizedStringName(L"UnitAbbreviation_Joule"), 2, true, false, false }); - energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Kilocalorie, GetLocalizedStringName(L"UnitName_Kilocalorie"), - GetLocalizedStringName(L"UnitAbbreviation_Kilocalorie"), 5, false, true, false }); - energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Kilojoule, GetLocalizedStringName(L"UnitName_Kilojoule"), - GetLocalizedStringName(L"UnitAbbreviation_Kilojoule"), 3 }); - energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Battery, GetLocalizedStringName(L"UnitName_Battery"), - GetLocalizedStringName(L"UnitAbbreviation_Battery"), 8, false, false, true }); - energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Banana, GetLocalizedStringName(L"UnitName_Banana"), - GetLocalizedStringName(L"UnitAbbreviation_Banana"), 9, false, false, true }); - energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_SliceOfCake, GetLocalizedStringName(L"UnitName_SliceOfCake"), - GetLocalizedStringName(L"UnitAbbreviation_SliceOfCake"), 10, false, false, true }); + energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_ElectronVolt, + GetLocalizedStringName(L"UnitName_Electron-Volt"), + GetLocalizedStringName(L"UnitAbbreviation_Electron-Volt"), + 1 }); + energyUnits.push_back(OrderedUnit{ + UnitConverterUnits::Energy_FootPound, GetLocalizedStringName(L"UnitName_Foot-Pound"), GetLocalizedStringName(L"UnitAbbreviation_Foot-Pound"), 6 }); + energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Joule, + GetLocalizedStringName(L"UnitName_Joule"), + GetLocalizedStringName(L"UnitAbbreviation_Joule"), + 2, + true, + false, + false }); + energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Kilocalorie, + GetLocalizedStringName(L"UnitName_Kilocalorie"), + GetLocalizedStringName(L"UnitAbbreviation_Kilocalorie"), + 5, + false, + true, + false }); + energyUnits.push_back(OrderedUnit{ + UnitConverterUnits::Energy_Kilojoule, GetLocalizedStringName(L"UnitName_Kilojoule"), GetLocalizedStringName(L"UnitAbbreviation_Kilojoule"), 3 }); + energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Battery, + GetLocalizedStringName(L"UnitName_Battery"), + GetLocalizedStringName(L"UnitAbbreviation_Battery"), + 8, + false, + false, + true }); + energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Banana, + GetLocalizedStringName(L"UnitName_Banana"), + GetLocalizedStringName(L"UnitAbbreviation_Banana"), + 9, + false, + false, + true }); + energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_SliceOfCake, + GetLocalizedStringName(L"UnitName_SliceOfCake"), + GetLocalizedStringName(L"UnitAbbreviation_SliceOfCake"), + 10, + false, + false, + true }); unitMap.emplace(ViewMode::Energy, energyUnits); vector lengthUnits; - lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Centimeter, GetLocalizedStringName(L"UnitName_Centimeter"), - GetLocalizedStringName(L"UnitAbbreviation_Centimeter"), 4, useUSCustomary, useSI, false }); + lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Centimeter, + GetLocalizedStringName(L"UnitName_Centimeter"), + GetLocalizedStringName(L"UnitAbbreviation_Centimeter"), + 4, + useUSCustomary, + useSI, + false }); lengthUnits.push_back( OrderedUnit{ UnitConverterUnits::Length_Foot, GetLocalizedStringName(L"UnitName_Foot"), GetLocalizedStringName(L"UnitAbbreviation_Foot"), 8 }); - lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Inch, GetLocalizedStringName(L"UnitName_Inch"), - GetLocalizedStringName(L"UnitAbbreviation_Inch"), 7, useSI, useUSCustomary, false }); - lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Kilometer, GetLocalizedStringName(L"UnitName_Kilometer"), - GetLocalizedStringName(L"UnitAbbreviation_Kilometer"), 6 }); + lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Inch, + GetLocalizedStringName(L"UnitName_Inch"), + GetLocalizedStringName(L"UnitAbbreviation_Inch"), + 7, + useSI, + useUSCustomary, + false }); + lengthUnits.push_back(OrderedUnit{ + UnitConverterUnits::Length_Kilometer, GetLocalizedStringName(L"UnitName_Kilometer"), GetLocalizedStringName(L"UnitAbbreviation_Kilometer"), 6 }); lengthUnits.push_back( OrderedUnit{ UnitConverterUnits::Length_Meter, GetLocalizedStringName(L"UnitName_Meter"), GetLocalizedStringName(L"UnitAbbreviation_Meter"), 5 }); lengthUnits.push_back( OrderedUnit{ UnitConverterUnits::Length_Micron, GetLocalizedStringName(L"UnitName_Micron"), GetLocalizedStringName(L"UnitAbbreviation_Micron"), 2 }); lengthUnits.push_back( OrderedUnit{ UnitConverterUnits::Length_Mile, GetLocalizedStringName(L"UnitName_Mile"), GetLocalizedStringName(L"UnitAbbreviation_Mile"), 10 }); - lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Millimeter, GetLocalizedStringName(L"UnitName_Millimeter"), - GetLocalizedStringName(L"UnitAbbreviation_Millimeter"), 3 }); - lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Nanometer, GetLocalizedStringName(L"UnitName_Nanometer"), - GetLocalizedStringName(L"UnitAbbreviation_Nanometer"), 1 }); - lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_NauticalMile, GetLocalizedStringName(L"UnitName_NauticalMile"), - GetLocalizedStringName(L"UnitAbbreviation_NauticalMile"), 11 }); + lengthUnits.push_back(OrderedUnit{ + UnitConverterUnits::Length_Millimeter, GetLocalizedStringName(L"UnitName_Millimeter"), GetLocalizedStringName(L"UnitAbbreviation_Millimeter"), 3 }); + lengthUnits.push_back(OrderedUnit{ + UnitConverterUnits::Length_Nanometer, GetLocalizedStringName(L"UnitName_Nanometer"), GetLocalizedStringName(L"UnitAbbreviation_Nanometer"), 1 }); + lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_NauticalMile, + GetLocalizedStringName(L"UnitName_NauticalMile"), + GetLocalizedStringName(L"UnitAbbreviation_NauticalMile"), + 11 }); lengthUnits.push_back( OrderedUnit{ UnitConverterUnits::Length_Yard, GetLocalizedStringName(L"UnitName_Yard"), GetLocalizedStringName(L"UnitAbbreviation_Yard"), 9 }); - lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Paperclip, GetLocalizedStringName(L"UnitName_Paperclip"), - GetLocalizedStringName(L"UnitAbbreviation_Paperclip"), 12, false, false, true }); - lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Hand, GetLocalizedStringName(L"UnitName_Hand"), - GetLocalizedStringName(L"UnitAbbreviation_Hand"), 13, false, false, true }); - lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_JumboJet, GetLocalizedStringName(L"UnitName_JumboJet"), - GetLocalizedStringName(L"UnitAbbreviation_JumboJet"), 14, false, false, true }); + lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Paperclip, + GetLocalizedStringName(L"UnitName_Paperclip"), + GetLocalizedStringName(L"UnitAbbreviation_Paperclip"), + 12, + false, + false, + true }); + lengthUnits.push_back(OrderedUnit{ + UnitConverterUnits::Length_Hand, GetLocalizedStringName(L"UnitName_Hand"), GetLocalizedStringName(L"UnitAbbreviation_Hand"), 13, false, false, true }); + lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_JumboJet, + GetLocalizedStringName(L"UnitName_JumboJet"), + GetLocalizedStringName(L"UnitAbbreviation_JumboJet"), + 14, + false, + false, + true }); unitMap.emplace(ViewMode::Length, lengthUnits); vector powerUnits; - powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_BritishThermalUnitPerMinute, GetLocalizedStringName(L"UnitName_BTUPerMinute"), - GetLocalizedStringName(L"UnitAbbreviation_BTUPerMinute"), 5 }); - powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_FootPoundPerMinute, GetLocalizedStringName(L"UnitName_Foot-PoundPerMinute"), - GetLocalizedStringName(L"UnitAbbreviation_Foot-PoundPerMinute"), 4 }); - powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Horsepower, GetLocalizedStringName(L"UnitName_Horsepower"), - GetLocalizedStringName(L"UnitAbbreviation_Horsepower"), 3, false, true, false }); - powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Kilowatt, GetLocalizedStringName(L"UnitName_Kilowatt"), - GetLocalizedStringName(L"UnitAbbreviation_Kilowatt"), 2, !useWattInsteadOfKilowatt }); - powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Watt, GetLocalizedStringName(L"UnitName_Watt"), - GetLocalizedStringName(L"UnitAbbreviation_Watt"), 1, useWattInsteadOfKilowatt }); - powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_LightBulb, GetLocalizedStringName(L"UnitName_LightBulb"), - GetLocalizedStringName(L"UnitAbbreviation_LightBulb"), 6, false, false, true }); - powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Horse, GetLocalizedStringName(L"UnitName_Horse"), - GetLocalizedStringName(L"UnitAbbreviation_Horse"), 7, false, false, true }); - powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_TrainEngine, GetLocalizedStringName(L"UnitName_TrainEngine"), - GetLocalizedStringName(L"UnitAbbreviation_TrainEngine"), 8, false, false, true }); + powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_BritishThermalUnitPerMinute, + GetLocalizedStringName(L"UnitName_BTUPerMinute"), + GetLocalizedStringName(L"UnitAbbreviation_BTUPerMinute"), + 5 }); + powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_FootPoundPerMinute, + GetLocalizedStringName(L"UnitName_Foot-PoundPerMinute"), + GetLocalizedStringName(L"UnitAbbreviation_Foot-PoundPerMinute"), + 4 }); + powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Horsepower, + GetLocalizedStringName(L"UnitName_Horsepower"), + GetLocalizedStringName(L"UnitAbbreviation_Horsepower"), + 3, + false, + true, + false }); + powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Kilowatt, + GetLocalizedStringName(L"UnitName_Kilowatt"), + GetLocalizedStringName(L"UnitAbbreviation_Kilowatt"), + 2, + !useWattInsteadOfKilowatt }); + powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Watt, + GetLocalizedStringName(L"UnitName_Watt"), + GetLocalizedStringName(L"UnitAbbreviation_Watt"), + 1, + useWattInsteadOfKilowatt }); + powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_LightBulb, + GetLocalizedStringName(L"UnitName_LightBulb"), + GetLocalizedStringName(L"UnitAbbreviation_LightBulb"), + 6, + false, + false, + true }); + powerUnits.push_back(OrderedUnit{ + UnitConverterUnits::Power_Horse, GetLocalizedStringName(L"UnitName_Horse"), GetLocalizedStringName(L"UnitAbbreviation_Horse"), 7, false, false, true }); + powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_TrainEngine, + GetLocalizedStringName(L"UnitName_TrainEngine"), + GetLocalizedStringName(L"UnitAbbreviation_TrainEngine"), + 8, + false, + false, + true }); unitMap.emplace(ViewMode::Power, powerUnits); vector tempUnits; - tempUnits.push_back(OrderedUnit{ UnitConverterUnits::Temperature_DegreesCelsius, GetLocalizedStringName(L"UnitName_DegreesCelsius"), - GetLocalizedStringName(L"UnitAbbreviation_DegreesCelsius"), 1, useFahrenheit, !useFahrenheit, false }); - tempUnits.push_back(OrderedUnit{ UnitConverterUnits::Temperature_DegreesFahrenheit, GetLocalizedStringName(L"UnitName_DegreesFahrenheit"), - GetLocalizedStringName(L"UnitAbbreviation_DegreesFahrenheit"), 2, !useFahrenheit, useFahrenheit, false }); - tempUnits.push_back(OrderedUnit{ UnitConverterUnits::Temperature_Kelvin, GetLocalizedStringName(L"UnitName_Kelvin"), - GetLocalizedStringName(L"UnitAbbreviation_Kelvin"), 3 }); + tempUnits.push_back(OrderedUnit{ UnitConverterUnits::Temperature_DegreesCelsius, + GetLocalizedStringName(L"UnitName_DegreesCelsius"), + GetLocalizedStringName(L"UnitAbbreviation_DegreesCelsius"), + 1, + useFahrenheit, + !useFahrenheit, + false }); + tempUnits.push_back(OrderedUnit{ UnitConverterUnits::Temperature_DegreesFahrenheit, + GetLocalizedStringName(L"UnitName_DegreesFahrenheit"), + GetLocalizedStringName(L"UnitAbbreviation_DegreesFahrenheit"), + 2, + !useFahrenheit, + useFahrenheit, + false }); + tempUnits.push_back(OrderedUnit{ + UnitConverterUnits::Temperature_Kelvin, GetLocalizedStringName(L"UnitName_Kelvin"), GetLocalizedStringName(L"UnitAbbreviation_Kelvin"), 3 }); unitMap.emplace(ViewMode::Temperature, tempUnits); vector timeUnits; timeUnits.push_back( OrderedUnit{ UnitConverterUnits::Time_Day, GetLocalizedStringName(L"UnitName_Day"), GetLocalizedStringName(L"UnitAbbreviation_Day"), 6 }); - timeUnits.push_back(OrderedUnit{ UnitConverterUnits::Time_Hour, GetLocalizedStringName(L"UnitName_Hour"), GetLocalizedStringName(L"UnitAbbreviation_Hour"), - 5, true, false, false }); - timeUnits.push_back(OrderedUnit{ UnitConverterUnits::Time_Microsecond, GetLocalizedStringName(L"UnitName_Microsecond"), - GetLocalizedStringName(L"UnitAbbreviation_Microsecond"), 1 }); - timeUnits.push_back(OrderedUnit{ UnitConverterUnits::Time_Millisecond, GetLocalizedStringName(L"UnitName_Millisecond"), - GetLocalizedStringName(L"UnitAbbreviation_Millisecond"), 2 }); - timeUnits.push_back(OrderedUnit{ UnitConverterUnits::Time_Minute, GetLocalizedStringName(L"UnitName_Minute"), - GetLocalizedStringName(L"UnitAbbreviation_Minute"), 4, false, true, false }); + timeUnits.push_back(OrderedUnit{ + UnitConverterUnits::Time_Hour, GetLocalizedStringName(L"UnitName_Hour"), GetLocalizedStringName(L"UnitAbbreviation_Hour"), 5, true, false, false }); + timeUnits.push_back(OrderedUnit{ + UnitConverterUnits::Time_Microsecond, GetLocalizedStringName(L"UnitName_Microsecond"), GetLocalizedStringName(L"UnitAbbreviation_Microsecond"), 1 }); + timeUnits.push_back(OrderedUnit{ + UnitConverterUnits::Time_Millisecond, GetLocalizedStringName(L"UnitName_Millisecond"), GetLocalizedStringName(L"UnitAbbreviation_Millisecond"), 2 }); + timeUnits.push_back(OrderedUnit{ UnitConverterUnits::Time_Minute, + GetLocalizedStringName(L"UnitName_Minute"), + GetLocalizedStringName(L"UnitAbbreviation_Minute"), + 4, + false, + true, + false }); timeUnits.push_back( OrderedUnit{ UnitConverterUnits::Time_Second, GetLocalizedStringName(L"UnitName_Second"), GetLocalizedStringName(L"UnitAbbreviation_Second"), 3 }); timeUnits.push_back( @@ -393,136 +530,239 @@ void UnitConverterDataLoader::GetUnits(_In_ unordered_map speedUnits; - speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_CentimetersPerSecond, GetLocalizedStringName(L"UnitName_CentimetersPerSecond"), - GetLocalizedStringName(L"UnitAbbreviation_CentimetersPerSecond"), 1 }); - speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_FeetPerSecond, GetLocalizedStringName(L"UnitName_FeetPerSecond"), - GetLocalizedStringName(L"UnitAbbreviation_FeetPerSecond"), 4 }); - speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_KilometersPerHour, GetLocalizedStringName(L"UnitName_KilometersPerHour"), - GetLocalizedStringName(L"UnitAbbreviation_KilometersPerHour"), 3, useUSCustomary, useSI, false }); + speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_CentimetersPerSecond, + GetLocalizedStringName(L"UnitName_CentimetersPerSecond"), + GetLocalizedStringName(L"UnitAbbreviation_CentimetersPerSecond"), + 1 }); + speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_FeetPerSecond, + GetLocalizedStringName(L"UnitName_FeetPerSecond"), + GetLocalizedStringName(L"UnitAbbreviation_FeetPerSecond"), + 4 }); + speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_KilometersPerHour, + GetLocalizedStringName(L"UnitName_KilometersPerHour"), + GetLocalizedStringName(L"UnitAbbreviation_KilometersPerHour"), + 3, + useUSCustomary, + useSI, + false }); speedUnits.push_back( OrderedUnit{ UnitConverterUnits::Speed_Knot, GetLocalizedStringName(L"UnitName_Knot"), GetLocalizedStringName(L"UnitAbbreviation_Knot"), 6 }); speedUnits.push_back( OrderedUnit{ UnitConverterUnits::Speed_Mach, GetLocalizedStringName(L"UnitName_Mach"), GetLocalizedStringName(L"UnitAbbreviation_Mach"), 7 }); - speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_MetersPerSecond, GetLocalizedStringName(L"UnitName_MetersPerSecond"), - GetLocalizedStringName(L"UnitAbbreviation_MetersPerSecond"), 2 }); - speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_MilesPerHour, GetLocalizedStringName(L"UnitName_MilesPerHour"), - GetLocalizedStringName(L"UnitAbbreviation_MilesPerHour"), 5, useSI, useUSCustomary, false }); - speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_Turtle, GetLocalizedStringName(L"UnitName_Turtle"), - GetLocalizedStringName(L"UnitAbbreviation_Turtle"), 8, false, false, true }); - speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_Horse, GetLocalizedStringName(L"UnitName_Horse"), - GetLocalizedStringName(L"UnitAbbreviation_Horse"), 9, false, false, true }); - speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_Jet, GetLocalizedStringName(L"UnitName_Jet"), GetLocalizedStringName(L"UnitAbbreviation_Jet"), - 10, false, false, true }); + speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_MetersPerSecond, + GetLocalizedStringName(L"UnitName_MetersPerSecond"), + GetLocalizedStringName(L"UnitAbbreviation_MetersPerSecond"), + 2 }); + speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_MilesPerHour, + GetLocalizedStringName(L"UnitName_MilesPerHour"), + GetLocalizedStringName(L"UnitAbbreviation_MilesPerHour"), + 5, + useSI, + useUSCustomary, + false }); + speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_Turtle, + GetLocalizedStringName(L"UnitName_Turtle"), + GetLocalizedStringName(L"UnitAbbreviation_Turtle"), + 8, + false, + false, + true }); + speedUnits.push_back(OrderedUnit{ + UnitConverterUnits::Speed_Horse, GetLocalizedStringName(L"UnitName_Horse"), GetLocalizedStringName(L"UnitAbbreviation_Horse"), 9, false, false, true }); + speedUnits.push_back(OrderedUnit{ + UnitConverterUnits::Speed_Jet, GetLocalizedStringName(L"UnitName_Jet"), GetLocalizedStringName(L"UnitAbbreviation_Jet"), 10, false, false, true }); unitMap.emplace(ViewMode::Speed, speedUnits); vector volumeUnits; - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicCentimeter, GetLocalizedStringName(L"UnitName_CubicCentimeter"), - GetLocalizedStringName(L"UnitAbbreviation_CubicCentimeter"), 2 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicFoot, GetLocalizedStringName(L"UnitName_CubicFoot"), - GetLocalizedStringName(L"UnitAbbreviation_CubicFoot"), 13 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicInch, GetLocalizedStringName(L"UnitName_CubicInch"), - GetLocalizedStringName(L"UnitAbbreviation_CubicInch"), 12 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicMeter, GetLocalizedStringName(L"UnitName_CubicMeter"), - GetLocalizedStringName(L"UnitAbbreviation_CubicMeter"), 4 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicYard, GetLocalizedStringName(L"UnitName_CubicYard"), - GetLocalizedStringName(L"UnitAbbreviation_CubicYard"), 14 }); + volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicCentimeter, + GetLocalizedStringName(L"UnitName_CubicCentimeter"), + GetLocalizedStringName(L"UnitAbbreviation_CubicCentimeter"), + 2 }); + volumeUnits.push_back(OrderedUnit{ + UnitConverterUnits::Volume_CubicFoot, GetLocalizedStringName(L"UnitName_CubicFoot"), GetLocalizedStringName(L"UnitAbbreviation_CubicFoot"), 13 }); + volumeUnits.push_back(OrderedUnit{ + UnitConverterUnits::Volume_CubicInch, GetLocalizedStringName(L"UnitName_CubicInch"), GetLocalizedStringName(L"UnitAbbreviation_CubicInch"), 12 }); + volumeUnits.push_back(OrderedUnit{ + UnitConverterUnits::Volume_CubicMeter, GetLocalizedStringName(L"UnitName_CubicMeter"), GetLocalizedStringName(L"UnitAbbreviation_CubicMeter"), 4 }); + volumeUnits.push_back(OrderedUnit{ + UnitConverterUnits::Volume_CubicYard, GetLocalizedStringName(L"UnitName_CubicYard"), GetLocalizedStringName(L"UnitAbbreviation_CubicYard"), 14 }); volumeUnits.push_back( OrderedUnit{ UnitConverterUnits::Volume_CupUS, GetLocalizedStringName(L"UnitName_CupUS"), GetLocalizedStringName(L"UnitAbbreviation_CupUS"), 8 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_FluidOunceUK, GetLocalizedStringName(L"UnitName_FluidOunceUK"), - GetLocalizedStringName(L"UnitAbbreviation_FluidOunceUK"), 17 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_FluidOunceUS, GetLocalizedStringName(L"UnitName_FluidOunceUS"), - GetLocalizedStringName(L"UnitAbbreviation_FluidOunceUS"), 7 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_GallonUK, GetLocalizedStringName(L"UnitName_GallonUK"), - GetLocalizedStringName(L"UnitAbbreviation_GallonUK"), 20 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_GallonUS, GetLocalizedStringName(L"UnitName_GallonUS"), - GetLocalizedStringName(L"UnitAbbreviation_GallonUS"), 11 }); + volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_FluidOunceUK, + GetLocalizedStringName(L"UnitName_FluidOunceUK"), + GetLocalizedStringName(L"UnitAbbreviation_FluidOunceUK"), + 17 }); + volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_FluidOunceUS, + GetLocalizedStringName(L"UnitName_FluidOunceUS"), + GetLocalizedStringName(L"UnitAbbreviation_FluidOunceUS"), + 7 }); + volumeUnits.push_back(OrderedUnit{ + UnitConverterUnits::Volume_GallonUK, GetLocalizedStringName(L"UnitName_GallonUK"), GetLocalizedStringName(L"UnitAbbreviation_GallonUK"), 20 }); + volumeUnits.push_back(OrderedUnit{ + UnitConverterUnits::Volume_GallonUS, GetLocalizedStringName(L"UnitName_GallonUS"), GetLocalizedStringName(L"UnitAbbreviation_GallonUS"), 11 }); volumeUnits.push_back( OrderedUnit{ UnitConverterUnits::Volume_Liter, GetLocalizedStringName(L"UnitName_Liter"), GetLocalizedStringName(L"UnitAbbreviation_Liter"), 3 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_Milliliter, GetLocalizedStringName(L"UnitName_Milliliter"), - GetLocalizedStringName(L"UnitAbbreviation_Milliliter"), 1, useUSCustomary, useSI }); + volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_Milliliter, + GetLocalizedStringName(L"UnitName_Milliliter"), + GetLocalizedStringName(L"UnitAbbreviation_Milliliter"), + 1, + useUSCustomary, + useSI }); volumeUnits.push_back( OrderedUnit{ UnitConverterUnits::Volume_PintUK, GetLocalizedStringName(L"UnitName_PintUK"), GetLocalizedStringName(L"UnitAbbreviation_PintUK"), 18 }); volumeUnits.push_back( OrderedUnit{ UnitConverterUnits::Volume_PintUS, GetLocalizedStringName(L"UnitName_PintUS"), GetLocalizedStringName(L"UnitAbbreviation_PintUS"), 9 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TablespoonUS, GetLocalizedStringName(L"UnitName_TablespoonUS"), - GetLocalizedStringName(L"UnitAbbreviation_TablespoonUS"), 6 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TeaspoonUS, GetLocalizedStringName(L"UnitName_TeaspoonUS"), - GetLocalizedStringName(L"UnitAbbreviation_TeaspoonUS"), 5, useSI, useUSCustomary && m_currentRegionCode != "GB" }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_QuartUK, GetLocalizedStringName(L"UnitName_QuartUK"), - GetLocalizedStringName(L"UnitAbbreviation_QuartUK"), 19 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_QuartUS, GetLocalizedStringName(L"UnitName_QuartUS"), - GetLocalizedStringName(L"UnitAbbreviation_QuartUS"), 10 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TeaspoonUK, GetLocalizedStringName(L"UnitName_TeaspoonUK"), - GetLocalizedStringName(L"UnitAbbreviation_TeaspoonUK"), 15, false, useUSCustomary && m_currentRegionCode == "GB" }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TablespoonUK, GetLocalizedStringName(L"UnitName_TablespoonUK"), - GetLocalizedStringName(L"UnitAbbreviation_TablespoonUK"), 16 }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CoffeeCup, GetLocalizedStringName(L"UnitName_CoffeeCup"), - GetLocalizedStringName(L"UnitAbbreviation_CoffeeCup"), 22, false, false, true }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_Bathtub, GetLocalizedStringName(L"UnitName_Bathtub"), - GetLocalizedStringName(L"UnitAbbreviation_Bathtub"), 23, false, false, true }); - volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_SwimmingPool, GetLocalizedStringName(L"UnitName_SwimmingPool"), - GetLocalizedStringName(L"UnitAbbreviation_SwimmingPool"), 24, false, false, true }); + volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TablespoonUS, + GetLocalizedStringName(L"UnitName_TablespoonUS"), + GetLocalizedStringName(L"UnitAbbreviation_TablespoonUS"), + 6 }); + volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TeaspoonUS, + GetLocalizedStringName(L"UnitName_TeaspoonUS"), + GetLocalizedStringName(L"UnitAbbreviation_TeaspoonUS"), + 5, + useSI, + useUSCustomary && m_currentRegionCode != "GB" }); + volumeUnits.push_back(OrderedUnit{ + UnitConverterUnits::Volume_QuartUK, GetLocalizedStringName(L"UnitName_QuartUK"), GetLocalizedStringName(L"UnitAbbreviation_QuartUK"), 19 }); + volumeUnits.push_back(OrderedUnit{ + UnitConverterUnits::Volume_QuartUS, GetLocalizedStringName(L"UnitName_QuartUS"), GetLocalizedStringName(L"UnitAbbreviation_QuartUS"), 10 }); + volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TeaspoonUK, + GetLocalizedStringName(L"UnitName_TeaspoonUK"), + GetLocalizedStringName(L"UnitAbbreviation_TeaspoonUK"), + 15, + false, + useUSCustomary && m_currentRegionCode == "GB" }); + volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TablespoonUK, + GetLocalizedStringName(L"UnitName_TablespoonUK"), + GetLocalizedStringName(L"UnitAbbreviation_TablespoonUK"), + 16 }); + volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CoffeeCup, + GetLocalizedStringName(L"UnitName_CoffeeCup"), + GetLocalizedStringName(L"UnitAbbreviation_CoffeeCup"), + 22, + false, + false, + true }); + volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_Bathtub, + GetLocalizedStringName(L"UnitName_Bathtub"), + GetLocalizedStringName(L"UnitAbbreviation_Bathtub"), + 23, + false, + false, + true }); + volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_SwimmingPool, + GetLocalizedStringName(L"UnitName_SwimmingPool"), + GetLocalizedStringName(L"UnitAbbreviation_SwimmingPool"), + 24, + false, + false, + true }); unitMap.emplace(ViewMode::Volume, volumeUnits); vector weightUnits; weightUnits.push_back( OrderedUnit{ UnitConverterUnits::Weight_Carat, GetLocalizedStringName(L"UnitName_Carat"), GetLocalizedStringName(L"UnitAbbreviation_Carat"), 1 }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Centigram, GetLocalizedStringName(L"UnitName_Centigram"), - GetLocalizedStringName(L"UnitAbbreviation_Centigram"), 3 }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Decigram, GetLocalizedStringName(L"UnitName_Decigram"), - GetLocalizedStringName(L"UnitAbbreviation_Decigram"), 4 }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Decagram, GetLocalizedStringName(L"UnitName_Decagram"), - GetLocalizedStringName(L"UnitAbbreviation_Decagram"), 6 }); + weightUnits.push_back(OrderedUnit{ + UnitConverterUnits::Weight_Centigram, GetLocalizedStringName(L"UnitName_Centigram"), GetLocalizedStringName(L"UnitAbbreviation_Centigram"), 3 }); + weightUnits.push_back(OrderedUnit{ + UnitConverterUnits::Weight_Decigram, GetLocalizedStringName(L"UnitName_Decigram"), GetLocalizedStringName(L"UnitAbbreviation_Decigram"), 4 }); + weightUnits.push_back(OrderedUnit{ + UnitConverterUnits::Weight_Decagram, GetLocalizedStringName(L"UnitName_Decagram"), GetLocalizedStringName(L"UnitAbbreviation_Decagram"), 6 }); weightUnits.push_back( OrderedUnit{ UnitConverterUnits::Weight_Gram, GetLocalizedStringName(L"UnitName_Gram"), GetLocalizedStringName(L"UnitAbbreviation_Gram"), 5 }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Hectogram, GetLocalizedStringName(L"UnitName_Hectogram"), - GetLocalizedStringName(L"UnitAbbreviation_Hectogram"), 7 }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Kilogram, GetLocalizedStringName(L"UnitName_Kilogram"), - GetLocalizedStringName(L"UnitAbbreviation_Kilogram"), 8, useUSCustomary, useSI }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_LongTon, GetLocalizedStringName(L"UnitName_LongTon"), - GetLocalizedStringName(L"UnitAbbreviation_LongTon"), 14 }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Milligram, GetLocalizedStringName(L"UnitName_Milligram"), - GetLocalizedStringName(L"UnitAbbreviation_Milligram"), 2 }); + weightUnits.push_back(OrderedUnit{ + UnitConverterUnits::Weight_Hectogram, GetLocalizedStringName(L"UnitName_Hectogram"), GetLocalizedStringName(L"UnitAbbreviation_Hectogram"), 7 }); + weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Kilogram, + GetLocalizedStringName(L"UnitName_Kilogram"), + GetLocalizedStringName(L"UnitAbbreviation_Kilogram"), + 8, + useUSCustomary, + useSI }); + weightUnits.push_back(OrderedUnit{ + UnitConverterUnits::Weight_LongTon, GetLocalizedStringName(L"UnitName_LongTon"), GetLocalizedStringName(L"UnitAbbreviation_LongTon"), 14 }); + weightUnits.push_back(OrderedUnit{ + UnitConverterUnits::Weight_Milligram, GetLocalizedStringName(L"UnitName_Milligram"), GetLocalizedStringName(L"UnitAbbreviation_Milligram"), 2 }); weightUnits.push_back( OrderedUnit{ UnitConverterUnits::Weight_Ounce, GetLocalizedStringName(L"UnitName_Ounce"), GetLocalizedStringName(L"UnitAbbreviation_Ounce"), 10 }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Pound, GetLocalizedStringName(L"UnitName_Pound"), - GetLocalizedStringName(L"UnitAbbreviation_Pound"), 11, useSI, useUSCustomary }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_ShortTon, GetLocalizedStringName(L"UnitName_ShortTon"), - GetLocalizedStringName(L"UnitAbbreviation_ShortTon"), 13 }); + weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Pound, + GetLocalizedStringName(L"UnitName_Pound"), + GetLocalizedStringName(L"UnitAbbreviation_Pound"), + 11, + useSI, + useUSCustomary }); + weightUnits.push_back(OrderedUnit{ + UnitConverterUnits::Weight_ShortTon, GetLocalizedStringName(L"UnitName_ShortTon"), GetLocalizedStringName(L"UnitAbbreviation_ShortTon"), 13 }); weightUnits.push_back( OrderedUnit{ UnitConverterUnits::Weight_Stone, GetLocalizedStringName(L"UnitName_Stone"), GetLocalizedStringName(L"UnitAbbreviation_Stone"), 12 }); weightUnits.push_back( OrderedUnit{ UnitConverterUnits::Weight_Tonne, GetLocalizedStringName(L"UnitName_Tonne"), GetLocalizedStringName(L"UnitAbbreviation_Tonne"), 9 }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Snowflake, GetLocalizedStringName(L"UnitName_Snowflake"), - GetLocalizedStringName(L"UnitAbbreviation_Snowflake"), 15, false, false, true }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_SoccerBall, GetLocalizedStringName(L"UnitName_SoccerBall"), - GetLocalizedStringName(L"UnitAbbreviation_SoccerBall"), 16, false, false, true }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Elephant, GetLocalizedStringName(L"UnitName_Elephant"), - GetLocalizedStringName(L"UnitAbbreviation_Elephant"), 17, false, false, true }); - weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Whale, GetLocalizedStringName(L"UnitName_Whale"), - GetLocalizedStringName(L"UnitAbbreviation_Whale"), 18, false, false, true }); + weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Snowflake, + GetLocalizedStringName(L"UnitName_Snowflake"), + GetLocalizedStringName(L"UnitAbbreviation_Snowflake"), + 15, + false, + false, + true }); + weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_SoccerBall, + GetLocalizedStringName(L"UnitName_SoccerBall"), + GetLocalizedStringName(L"UnitAbbreviation_SoccerBall"), + 16, + false, + false, + true }); + weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Elephant, + GetLocalizedStringName(L"UnitName_Elephant"), + GetLocalizedStringName(L"UnitAbbreviation_Elephant"), + 17, + false, + false, + true }); + weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Whale, + GetLocalizedStringName(L"UnitName_Whale"), + GetLocalizedStringName(L"UnitAbbreviation_Whale"), + 18, + false, + false, + true }); unitMap.emplace(ViewMode::Weight, weightUnits); vector pressureUnits; - pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_Atmosphere, GetLocalizedStringName(L"UnitName_Atmosphere"), - GetLocalizedStringName(L"UnitAbbreviation_Atmosphere"), 1, true, false, false }); - pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_Bar, GetLocalizedStringName(L"UnitName_Bar"), - GetLocalizedStringName(L"UnitAbbreviation_Bar"), 2, false, true, false }); - pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_KiloPascal, GetLocalizedStringName(L"UnitName_KiloPascal"), - GetLocalizedStringName(L"UnitAbbreviation_KiloPascal"), 3 }); - pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_MillimeterOfMercury, GetLocalizedStringName(L"UnitName_MillimeterOfMercury "), - GetLocalizedStringName(L"UnitAbbreviation_MillimeterOfMercury "), 4 }); + pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_Atmosphere, + GetLocalizedStringName(L"UnitName_Atmosphere"), + GetLocalizedStringName(L"UnitAbbreviation_Atmosphere"), + 1, + true, + false, + false }); + pressureUnits.push_back(OrderedUnit{ + UnitConverterUnits::Pressure_Bar, GetLocalizedStringName(L"UnitName_Bar"), GetLocalizedStringName(L"UnitAbbreviation_Bar"), 2, false, true, false }); + pressureUnits.push_back(OrderedUnit{ + UnitConverterUnits::Pressure_KiloPascal, GetLocalizedStringName(L"UnitName_KiloPascal"), GetLocalizedStringName(L"UnitAbbreviation_KiloPascal"), 3 }); + pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_MillimeterOfMercury, + GetLocalizedStringName(L"UnitName_MillimeterOfMercury "), + GetLocalizedStringName(L"UnitAbbreviation_MillimeterOfMercury "), + 4 }); pressureUnits.push_back( OrderedUnit{ UnitConverterUnits::Pressure_Pascal, GetLocalizedStringName(L"UnitName_Pascal"), GetLocalizedStringName(L"UnitAbbreviation_Pascal"), 5 }); - pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_PSI, GetLocalizedStringName(L"UnitName_PSI"), - GetLocalizedStringName(L"UnitAbbreviation_PSI"), 6, false, false, false }); + pressureUnits.push_back(OrderedUnit{ + UnitConverterUnits::Pressure_PSI, GetLocalizedStringName(L"UnitName_PSI"), GetLocalizedStringName(L"UnitAbbreviation_PSI"), 6, false, false, false }); unitMap.emplace(ViewMode::Pressure, pressureUnits); vector angleUnits; - angleUnits.push_back(OrderedUnit{ UnitConverterUnits::Angle_Degree, GetLocalizedStringName(L"UnitName_Degree"), - GetLocalizedStringName(L"UnitAbbreviation_Degree"), 1, true, false, false }); - angleUnits.push_back(OrderedUnit{ UnitConverterUnits::Angle_Radian, GetLocalizedStringName(L"UnitName_Radian"), - GetLocalizedStringName(L"UnitAbbreviation_Radian"), 2, false, true, false }); + angleUnits.push_back(OrderedUnit{ UnitConverterUnits::Angle_Degree, + GetLocalizedStringName(L"UnitName_Degree"), + GetLocalizedStringName(L"UnitAbbreviation_Degree"), + 1, + true, + false, + false }); + angleUnits.push_back(OrderedUnit{ UnitConverterUnits::Angle_Radian, + GetLocalizedStringName(L"UnitName_Radian"), + GetLocalizedStringName(L"UnitAbbreviation_Radian"), + 2, + false, + true, + false }); angleUnits.push_back( OrderedUnit{ UnitConverterUnits::Angle_Gradian, GetLocalizedStringName(L"UnitName_Gradian"), GetLocalizedStringName(L"UnitAbbreviation_Gradian"), 3 }); unitMap.emplace(ViewMode::Angle, angleUnits); @@ -722,12 +962,24 @@ void UnitConverterDataLoader::GetExplicitConversionData(_In_ unordered_map>>& spTokens, + String ^ expression, + String ^ result, + _In_ const shared_ptr>>& spTokens, _In_ const shared_ptr>>& spCommands) : m_expression(expression), m_result(result), m_spTokens(spTokens), m_spCommands(spCommands) { @@ -22,7 +24,8 @@ HistoryItemViewModel::HistoryItemViewModel( String ^ HistoryItemViewModel::GetAccessibleExpressionFromTokens( - _In_ shared_ptr>> const& spTokens, _In_ String ^ fallbackExpression) + _In_ shared_ptr>> const& spTokens, + _In_ String ^ fallbackExpression) { // updating accessibility names for expression and result wstringstream accExpression{}; diff --git a/src/CalcViewModel/HistoryItemViewModel.h b/src/CalcViewModel/HistoryItemViewModel.h index 2de2073b..fae51e69 100644 --- a/src/CalcViewModel/HistoryItemViewModel.h +++ b/src/CalcViewModel/HistoryItemViewModel.h @@ -15,7 +15,8 @@ namespace CalculatorApp internal : HistoryItemViewModel( - Platform::String ^ expression, Platform::String ^ result, + Platform::String ^ expression, + Platform::String ^ result, _In_ std::shared_ptr>> const& spTokens, _In_ std::shared_ptr>> const& spCommands); @@ -61,7 +62,8 @@ namespace CalculatorApp private : static Platform::String ^ GetAccessibleExpressionFromTokens( - _In_ std::shared_ptr>> const& spTokens, _In_ Platform::String ^ fallbackExpression); + _In_ std::shared_ptr>> const& spTokens, + _In_ Platform::String ^ fallbackExpression); private: Platform::String ^ m_expression; diff --git a/src/CalcViewModel/HistoryViewModel.cpp b/src/CalcViewModel/HistoryViewModel.cpp index 074d7325..c477deeb 100644 --- a/src/CalcViewModel/HistoryViewModel.cpp +++ b/src/CalcViewModel/HistoryViewModel.cpp @@ -70,7 +70,9 @@ void HistoryViewModel::ReloadHistory(_In_ ViewMode currentMode) localizer.LocalizeDisplayValue(&result); auto item = ref new HistoryItemViewModel( - ref new Platform::String(expression.c_str()), ref new Platform::String(result.c_str()), (*ritr)->historyItemVector.spTokens, + ref new Platform::String(expression.c_str()), + ref new Platform::String(result.c_str()), + (*ritr)->historyItemVector.spTokens, (*ritr)->historyItemVector.spCommands); historyListVM->Append(item); } @@ -89,7 +91,9 @@ void HistoryViewModel::OnHistoryItemAdded(_In_ unsigned int addedItemIndex) localizer.LocalizeDisplayValue(&expression); localizer.LocalizeDisplayValue(&result); auto item = ref new HistoryItemViewModel( - ref new Platform::String(expression.c_str()), ref new Platform::String(result.c_str()), newItem->historyItemVector.spTokens, + ref new Platform::String(expression.c_str()), + ref new Platform::String(result.c_str()), + newItem->historyItemVector.spTokens, newItem->historyItemVector.spCommands); // check if we have not hit the max items diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp index 4a6e8ff5..6acda106 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -236,7 +236,8 @@ void StandardCalculatorViewModel::SetOpenParenthesisCountNarratorAnnouncement() LocalizationSettings::GetInstance().LocalizeDisplayValue(&localizedParenthesisCount); String ^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement( - CalculatorResourceKeys::OpenParenthesisCountAutomationFormat, m_localizedOpenParenthesisCountChangedAutomationFormat, + CalculatorResourceKeys::OpenParenthesisCountAutomationFormat, + m_localizedOpenParenthesisCountChangedAutomationFormat, localizedParenthesisCount.c_str()); Announcement = CalculatorAnnouncement::GetOpenParenthesisCountChangedAnnouncement(announcement); @@ -1960,7 +1961,9 @@ NarratorAnnouncement ^ StandardCalculatorViewModel::GetDisplayUpdatedNarratorAnn else { announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement( - CalculatorResourceKeys::ButtonPressFeedbackFormat, m_localizedButtonPressFeedbackAutomationFormat, m_CalculationResultAutomationName->Data(), + CalculatorResourceKeys::ButtonPressFeedbackFormat, + m_localizedButtonPressFeedbackAutomationFormat, + m_CalculationResultAutomationName->Data(), m_feedbackForButtonPress->Data()); } diff --git a/src/CalcViewModel/UnitConverterViewModel.cpp b/src/CalcViewModel/UnitConverterViewModel.cpp index 65a68f14..7c48e7c4 100644 --- a/src/CalcViewModel/UnitConverterViewModel.cpp +++ b/src/CalcViewModel/UnitConverterViewModel.cpp @@ -463,7 +463,8 @@ void UnitConverterViewModel::UpdateSupplementaryResults(const std::vectorCurrentlyShownApplicationViewId != 0)) { create_task(ApplicationViewSwitcher::TryShowAsStandaloneAsync( - frameService->GetViewId(), ViewSizePreference::Default, activatedEventArgs->CurrentlyShownApplicationViewId, + frameService->GetViewId(), + ViewSizePreference::Default, + activatedEventArgs->CurrentlyShownApplicationViewId, ViewSizePreference::Default)) .then( [safeFrameServiceCreation](bool viewShown) { diff --git a/src/Calculator/Common/AlwaysSelectedCollectionView.h b/src/Calculator/Common/AlwaysSelectedCollectionView.h index f993909f..1b48d43a 100644 --- a/src/Calculator/Common/AlwaysSelectedCollectionView.h +++ b/src/Calculator/Common/AlwaysSelectedCollectionView.h @@ -265,7 +265,9 @@ namespace CalculatorApp private: virtual Platform::Object ^ Convert( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName /*targetType*/, + Platform::Object ^ /*parameter*/, Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert { auto result = dynamic_cast(value); @@ -278,7 +280,9 @@ namespace CalculatorApp virtual Platform::Object ^ ConvertBack( - Platform::Object ^ /*value*/, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, + Platform::Object ^ /*value*/, + Windows::UI::Xaml::Interop::TypeName /*targetType*/, + Platform::Object ^ /*parameter*/, Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack { return Windows::UI::Xaml::DependencyProperty::UnsetValue; diff --git a/src/Calculator/Converters/BitFlipAutomationNameConverter.h b/src/Calculator/Converters/BitFlipAutomationNameConverter.h index 1d94c6f6..101779ee 100644 --- a/src/Calculator/Converters/BitFlipAutomationNameConverter.h +++ b/src/Calculator/Converters/BitFlipAutomationNameConverter.h @@ -15,11 +15,15 @@ namespace CalculatorApp public: virtual Platform::Object ^ Convert( - _In_ Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, _In_ Platform::Object ^ parameter, + _In_ Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName targetType, + _In_ Platform::Object ^ parameter, _In_ Platform::String ^ language); virtual Platform::Object ^ ConvertBack( - _In_ Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, _In_ Platform::Object ^ parameter, + _In_ Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName targetType, + _In_ Platform::Object ^ parameter, _In_ Platform::String ^ language); }; } diff --git a/src/Calculator/Converters/BooleanNegationConverter.h b/src/Calculator/Converters/BooleanNegationConverter.h index 32852631..a0db5c33 100644 --- a/src/Calculator/Converters/BooleanNegationConverter.h +++ b/src/Calculator/Converters/BooleanNegationConverter.h @@ -17,7 +17,10 @@ namespace CalculatorApp ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); virtual Platform::Object ^ ConvertBack( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName targetType, + Platform::Object ^ parameter, + Platform::String ^ language); }; } } diff --git a/src/Calculator/Converters/BooleanToVisibilityConverter.h b/src/Calculator/Converters/BooleanToVisibilityConverter.h index 7375ceb1..b03fb3eb 100644 --- a/src/Calculator/Converters/BooleanToVisibilityConverter.h +++ b/src/Calculator/Converters/BooleanToVisibilityConverter.h @@ -24,7 +24,10 @@ namespace CalculatorApp ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); virtual Platform::Object ^ ConvertBack( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName targetType, + Platform::Object ^ parameter, + Platform::String ^ language); }; /// @@ -39,7 +42,10 @@ namespace CalculatorApp ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); virtual Platform::Object ^ ConvertBack( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName targetType, + Platform::Object ^ parameter, + Platform::String ^ language); }; } diff --git a/src/Calculator/Converters/ItemSizeToVisibilityConverter.h b/src/Calculator/Converters/ItemSizeToVisibilityConverter.h index 6c644eeb..90b8cd4c 100644 --- a/src/Calculator/Converters/ItemSizeToVisibilityConverter.h +++ b/src/Calculator/Converters/ItemSizeToVisibilityConverter.h @@ -14,7 +14,10 @@ namespace CalculatorApp ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); virtual Platform::Object ^ ConvertBack( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName targetType, + Platform::Object ^ parameter, + Platform::String ^ language); }; public @@ -25,7 +28,10 @@ namespace CalculatorApp ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); virtual Platform::Object ^ ConvertBack( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName targetType, + Platform::Object ^ parameter, + Platform::String ^ language); }; } } diff --git a/src/Calculator/Converters/RadixToStringConverter.h b/src/Calculator/Converters/RadixToStringConverter.h index 412c4f7d..b33c8798 100644 --- a/src/Calculator/Converters/RadixToStringConverter.h +++ b/src/Calculator/Converters/RadixToStringConverter.h @@ -17,7 +17,10 @@ namespace CalculatorApp ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); virtual Platform::Object ^ ConvertBack( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName targetType, + Platform::Object ^ parameter, + Platform::String ^ language); }; } } diff --git a/src/Calculator/Converters/VisibilityNegationConverter.h b/src/Calculator/Converters/VisibilityNegationConverter.h index a98aff46..4f06162c 100644 --- a/src/Calculator/Converters/VisibilityNegationConverter.h +++ b/src/Calculator/Converters/VisibilityNegationConverter.h @@ -17,7 +17,10 @@ namespace CalculatorApp ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); virtual Platform::Object ^ ConvertBack( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName targetType, + Platform::Object ^ parameter, + Platform::String ^ language); }; } } diff --git a/src/Calculator/Views/Calculator.xaml.h b/src/Calculator/Views/Calculator.xaml.h index 819459ee..3814e4ac 100644 --- a/src/Calculator/Views/Calculator.xaml.h +++ b/src/Calculator/Views/Calculator.xaml.h @@ -110,7 +110,8 @@ public Memory ^ m_memory; void HistoryFlyout_Opened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args); void HistoryFlyout_Closing( - _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender, _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args); + _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender, + _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args); void HistoryFlyout_Closed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args); void OnHideHistoryClicked(); void OnHideMemoryClicked(); @@ -122,7 +123,8 @@ public bool m_fIsMemoryFlyoutOpen; void OnMemoryFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args); void OnMemoryFlyoutClosing( - _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender, _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args); + _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender, + _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args); void OnMemoryFlyoutClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args); void SetChildAsMemory(); void SetChildAsHistory(); diff --git a/src/Calculator/Views/CalculatorProgrammerBitFlipPanel.xaml.h b/src/Calculator/Views/CalculatorProgrammerBitFlipPanel.xaml.h index fac8a039..3ec6355d 100644 --- a/src/Calculator/Views/CalculatorProgrammerBitFlipPanel.xaml.h +++ b/src/Calculator/Views/CalculatorProgrammerBitFlipPanel.xaml.h @@ -35,7 +35,9 @@ namespace CalculatorApp void AssignFlipButtons(); void SetVisibilityBinding( - _In_ Windows::UI::Xaml::FrameworkElement ^ element, _In_ Platform::String ^ path, _In_ Windows::UI::Xaml::Data::IValueConverter ^ converter); + _In_ Windows::UI::Xaml::FrameworkElement ^ element, + _In_ Platform::String ^ path, + _In_ Windows::UI::Xaml::Data::IValueConverter ^ converter); void OnBitToggled(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e); void UpdateCheckedStates(); diff --git a/src/Calculator/Views/CalculatorScientificOperators.xaml.cpp b/src/Calculator/Views/CalculatorScientificOperators.xaml.cpp index edb06cbe..5ac9dab9 100644 --- a/src/Calculator/Views/CalculatorScientificOperators.xaml.cpp +++ b/src/Calculator/Views/CalculatorScientificOperators.xaml.cpp @@ -69,7 +69,8 @@ void CalculatorScientificOperators::shiftButton_Check(_In_ Platform::Object ^ /* } void CalculatorScientificOperators::shiftButton_IsEnabledChanged( - _In_ Platform::Object ^ /*sender*/, _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ /*e*/) + _In_ Platform::Object ^ /*sender*/, + _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ /*e*/) { SetOperatorRowVisibility(); Common::KeyboardShortcutManager::ShiftButtonChecked(ShiftButton->IsEnabled && ShiftButton->IsChecked->Value); diff --git a/src/Calculator/Views/DateCalculator.xaml.cpp b/src/Calculator/Views/DateCalculator.xaml.cpp index 1a4befc9..b3a9dcdd 100644 --- a/src/Calculator/Views/DateCalculator.xaml.cpp +++ b/src/Calculator/Views/DateCalculator.xaml.cpp @@ -80,7 +80,8 @@ DateCalculator::DateCalculator() // Set the PlaceHolderText for CalendarDatePicker DateTimeFormatter ^ dateTimeFormatter = LocalizationService::GetRegionalSettingsAwareDateTimeFormatter( - L"day month year", localizationSettings.GetCalendarIdentifier(), + L"day month year", + localizationSettings.GetCalendarIdentifier(), ClockIdentifiers::TwentyFourHour); // Clock Identifier is not used DateDiff_FromDate->DateFormat = L"day month year"; diff --git a/src/Calculator/Views/DateCalculator.xaml.h b/src/Calculator/Views/DateCalculator.xaml.h index 982bf308..e158b937 100644 --- a/src/Calculator/Views/DateCalculator.xaml.h +++ b/src/Calculator/Views/DateCalculator.xaml.h @@ -30,11 +30,14 @@ namespace CalculatorApp private: void FromDate_DateChanged( - _In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender, _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e); + _In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender, + _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e); void ToDate_DateChanged( - _In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender, _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e); + _In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender, + _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e); void AddSubtract_DateChanged( - _In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender, _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e); + _In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender, + _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e); void OffsetValue_Changed(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e); void OnCopyMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e); void OnLoaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e); diff --git a/src/Calculator/Views/MainPage.xaml.h b/src/Calculator/Views/MainPage.xaml.h index 0882736f..0d77e324 100644 --- a/src/Calculator/Views/MainPage.xaml.h +++ b/src/Calculator/Views/MainPage.xaml.h @@ -50,7 +50,8 @@ public void OnNavPaneClosed(_In_ Microsoft::UI::Xaml::Controls::NavigationView ^ sender, _In_ Platform::Object ^ args); void OnNavSelectionChanged(_In_ Platform::Object ^ sender, _In_ Microsoft::UI::Xaml::Controls::NavigationViewSelectionChangedEventArgs ^ e); void OnNavItemInvoked( - Microsoft::UI::Xaml::Controls::NavigationView ^ /*sender*/, _In_ Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs ^ e); + Microsoft::UI::Xaml::Controls::NavigationView ^ /*sender*/, + _In_ Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs ^ e); void OnAboutButtonClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ e); void OnAboutFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e); diff --git a/src/Calculator/Views/SupplementaryResults.xaml.h b/src/Calculator/Views/SupplementaryResults.xaml.h index aeca6047..c95721f1 100644 --- a/src/Calculator/Views/SupplementaryResults.xaml.h +++ b/src/Calculator/Views/SupplementaryResults.xaml.h @@ -27,11 +27,15 @@ public internal : virtual Platform::Object ^ Convert( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName targetType, + Platform::Object ^ parameter, Platform::String ^ language) = Windows::UI::Xaml::Data::IValueConverter::Convert; virtual Platform::Object ^ ConvertBack( - Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, + Platform::Object ^ value, + Windows::UI::Xaml::Interop::TypeName targetType, + Platform::Object ^ parameter, Platform::String ^ language) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack; private: diff --git a/src/CalculatorUnitTests/CalcEngineTests.cpp b/src/CalculatorUnitTests/CalcEngineTests.cpp index c8d9a7b1..9d8ad32a 100644 --- a/src/CalculatorUnitTests/CalcEngineTests.cpp +++ b/src/CalculatorUnitTests/CalcEngineTests.cpp @@ -118,18 +118,29 @@ namespace CalculatorEngineTests // Regex matching (descriptions taken from CalcUtils.cpp) // Use 100 for exp/mantissa length as they are tested above vector validDecStrs{ // Start with an optional + or - - L"+1", L"-1", L"1", + L"+1", + L"-1", + L"1", // Followed by zero or more digits - L"-", L"", L"1234567890", + L"-", + L"", + L"1234567890", // Followed by an optional decimal point - L"1.0", L"-.", L"1.", + L"1.0", + L"-.", + L"1.", // Followed by zero or more digits - L"0.0", L"0.123456", + L"0.0", + L"0.123456", // Followed by an optional exponent ('e') - L"1e", L"1.e", L"-e", + L"1e", + L"1.e", + L"-e", // If there's an exponent, its optionally followed by + or - // and followed by zero or more digits - L"1e+12345", L"1e-12345", L"1e123", + L"1e+12345", + L"1e-12345", + L"1e123", // All together L"-123.456e+789" }; @@ -213,7 +224,8 @@ namespace CalculatorEngineTests result = L"123456,78,901,23456"; VERIFY_ARE_EQUAL(result, m_calcEngine->GroupDigits(L",", { 5, 3, 2 }, L"1234567890123456", false), L"Verify multigroup non-repeating grouping."); VERIFY_ARE_EQUAL( - result, m_calcEngine->GroupDigits(L",", { 5, 3, 2, 0, 0 }, L"1234567890123456", false), + result, + m_calcEngine->GroupDigits(L",", { 5, 3, 2, 0, 0 }, L"1234567890123456", false), L"Verify expanded form multigroup non-repeating grouping."); } diff --git a/src/CalculatorUnitTests/CopyPasteManagerTest.cpp b/src/CalculatorUnitTests/CopyPasteManagerTest.cpp index 1cb13c67..b079f3cc 100644 --- a/src/CalculatorUnitTests/CopyPasteManagerTest.cpp +++ b/src/CalculatorUnitTests/CopyPasteManagerTest.cpp @@ -60,22 +60,27 @@ namespace CalculatorUnitTests } VERIFY_ARE_EQUAL( m_CopyPasteManager.ValidatePasteExpression(StringReference(exp_TooLong.c_str()), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1), - StringReference(exp_TooLong.c_str()), L"Verify ValidatePasteExpression handles expressions up to max length"); + StringReference(exp_TooLong.c_str()), + L"Verify ValidatePasteExpression handles expressions up to max length"); exp_TooLong += L"1"; VERIFY_ARE_EQUAL( m_CopyPasteManager.ValidatePasteExpression(StringReference(exp_TooLong.c_str()), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1), - StringReference(L"NoOp"), L"Verify ValidatePasteExpression returns NoOp for strings over max length"); + StringReference(L"NoOp"), + L"Verify ValidatePasteExpression returns NoOp for strings over max length"); VERIFY_ARE_EQUAL( m_CopyPasteManager.ValidatePasteExpression(StringReference(L""), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1), - StringReference(L"NoOp"), L"Verify empty string is invalid"); + StringReference(L"NoOp"), + L"Verify empty string is invalid"); VERIFY_ARE_EQUAL( m_CopyPasteManager.ValidatePasteExpression(StringReference(L"123e456"), ViewMode::Standard, CategoryGroupType::Calculator, -1, -1), - StringReference(L"NoOp"), L"Verify pasting unsupported strings for the current mode is invalid"); + StringReference(L"NoOp"), + L"Verify pasting unsupported strings for the current mode is invalid"); VERIFY_ARE_EQUAL( - m_CopyPasteManager.ValidatePasteExpression(StringReference(L"123"), ViewMode::None, CategoryGroupType::None, -1, -1), StringReference(L"NoOp"), + m_CopyPasteManager.ValidatePasteExpression(StringReference(L"123"), ViewMode::None, CategoryGroupType::None, -1, -1), + StringReference(L"NoOp"), L"Verify pasting without a ViewMode or Category is invalid"); }; @@ -111,18 +116,21 @@ namespace CalculatorUnitTests exp_OperandLimit += L"+1"; } VERIFY_ARE_EQUAL( - m_CopyPasteManager.ExtractOperands(exp_OperandLimit, ViewMode::Standard).size(), 100, + m_CopyPasteManager.ExtractOperands(exp_OperandLimit, ViewMode::Standard).size(), + 100, L"Verify ExtractOperands handles up to MaxOperandCount operands"); exp_OperandLimit += L"+1"; VERIFY_ARE_EQUAL( - m_CopyPasteManager.ExtractOperands(exp_OperandLimit, ViewMode::Standard).size(), 0, + m_CopyPasteManager.ExtractOperands(exp_OperandLimit, ViewMode::Standard).size(), + 0, L"Verify ExtractOperands returns empty vector on too many operands"); VERIFY_ARE_EQUAL( m_CopyPasteManager.ExtractOperands(L"12e9999", ViewMode::Standard).size(), 1, L"Verify ExtractOperands handles up to 4 digit exponents"); VERIFY_ARE_EQUAL( - m_CopyPasteManager.ExtractOperands(L"12e10000", ViewMode::Standard).size(), 0, + m_CopyPasteManager.ExtractOperands(L"12e10000", ViewMode::Standard).size(), + 0, L"Verify ExtractOperands returns empty vector when the exponent is too long"); }; @@ -152,8 +160,11 @@ namespace CalculatorUnitTests VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch( vector{ L"11111111111111111111111" }, ViewMode::Programmer, CategoryGroupType::Calculator, OctBase, QwordType)); VERIFY_IS_FALSE(m_CopyPasteManager.ExpressionRegExMatch( - vector{ L"10000000000000000000000000000000000000000000000000000000000000000" }, ViewMode::Programmer, CategoryGroupType::Calculator, - BinBase, QwordType)); + vector{ L"10000000000000000000000000000000000000000000000000000000000000000" }, + ViewMode::Programmer, + CategoryGroupType::Calculator, + BinBase, + QwordType)); VERIFY_IS_FALSE( m_CopyPasteManager.ExpressionRegExMatch( @@ -195,13 +206,16 @@ namespace CalculatorUnitTests pair scientificModeMaximums = make_pair(m_CopyPasteManager.MaxScientificOperandLength, 0); pair converterModeMaximums = make_pair(m_CopyPasteManager.MaxConverterInputLength, 0); VERIFY_ARE_EQUAL( - m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Standard, CategoryGroupType::None, -1, -1), standardModeMaximums, + m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Standard, CategoryGroupType::None, -1, -1), + standardModeMaximums, L"Verify Standard mode maximum values"); VERIFY_ARE_EQUAL( - m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Scientific, CategoryGroupType::None, -1, -1), scientificModeMaximums, + m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::Scientific, CategoryGroupType::None, -1, -1), + scientificModeMaximums, L"Verify Scientific mode maximum values"); VERIFY_ARE_EQUAL( - m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::None, CategoryGroupType::Converter, -1, -1), converterModeMaximums, + m_CopyPasteManager.GetMaxOperandLengthAndValue(ViewMode::None, CategoryGroupType::Converter, -1, -1), + converterModeMaximums, L"Verify Converter mode maximum values"); unsigned long long int ullQwordMax = UINT64_MAX; diff --git a/src/CalculatorUnitTests/DateUtils.h b/src/CalculatorUnitTests/DateUtils.h index fcb0807c..b21bb331 100644 --- a/src/CalculatorUnitTests/DateUtils.h +++ b/src/CalculatorUnitTests/DateUtils.h @@ -40,8 +40,10 @@ namespace DateCalculationUnitTests // Returns long date format for a date static Platform::String ^ GetLongDate(SYSTEMTIME systemTime) { auto formatter = ref new Windows::Globalization::DateTimeFormatting::DateTimeFormatter( - L"longdate", Windows::Globalization::ApplicationLanguages::Languages, - Windows::System::UserProfile::GlobalizationPreferences::HomeGeographicRegion, Windows::Globalization::CalendarIdentifiers::Gregorian, + L"longdate", + Windows::Globalization::ApplicationLanguages::Languages, + Windows::System::UserProfile::GlobalizationPreferences::HomeGeographicRegion, + Windows::Globalization::CalendarIdentifiers::Gregorian, Windows::Globalization::ClockIdentifiers::TwentyFourHour); Windows::Foundation::DateTime dateTime = SystemTimeToDateTime(systemTime); diff --git a/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp b/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp index 6383b0b7..4c6135d0 100644 --- a/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp +++ b/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp @@ -270,7 +270,8 @@ namespace CalculatorUnitTests { NumbersAndOperatorsEnum::Five, L"7" + std::wstring(m_decimalSeparator->Data()) + L"5", L"" }, { NumbersAndOperatorsEnum::Five, L"7" + std::wstring(m_decimalSeparator->Data()) + L"55", L"" }, { NumbersAndOperatorsEnum::Five, L"7" + std::wstring(m_decimalSeparator->Data()) + L"555", L"" }, - { NumbersAndOperatorsEnum::Multiply, L"7" + std::wstring(m_decimalSeparator->Data()) + L"555", + { NumbersAndOperatorsEnum::Multiply, + L"7" + std::wstring(m_decimalSeparator->Data()) + L"555", L"7" + std::wstring(m_decimalSeparator->Data()) + L"555 * " }, { NumbersAndOperatorsEnum::Three, L"3", L"7" + std::wstring(m_decimalSeparator->Data()) + L"555 * " }, { NumbersAndOperatorsEnum::Equals, L"22" + std::wstring(m_decimalSeparator->Data()) + L"665", L"" }, diff --git a/src/CalculatorUnitTests/UnitConverterTest.cpp b/src/CalculatorUnitTests/UnitConverterTest.cpp index dbf6c380..5d77ea89 100644 --- a/src/CalculatorUnitTests/UnitConverterTest.cpp +++ b/src/CalculatorUnitTests/UnitConverterTest.cpp @@ -492,8 +492,21 @@ namespace UnitConverterUnitTests void UnitConverterTest::UnitConverterTestMaxDigitsReached() { - ExecuteCommands({ Command::One, Command::Two, Command::Three, Command::Four, Command::Five, Command::Six, Command::Seven, Command::Eight, Command::Nine, - Command::One, Command::Zero, Command::One, Command::One, Command::One, Command::Two }); + ExecuteCommands({ Command::One, + Command::Two, + Command::Three, + Command::Four, + Command::Five, + Command::Six, + Command::Seven, + Command::Eight, + Command::Nine, + Command::One, + Command::Zero, + Command::One, + Command::One, + Command::One, + Command::Two }); VERIFY_ARE_EQUAL(0, s_testVMCallback->GetMaxDigitsReachedCallCount()); @@ -504,8 +517,22 @@ namespace UnitConverterUnitTests void UnitConverterTest::UnitConverterTestMaxDigitsReached_LeadingDecimal() { - ExecuteCommands({ Command::Zero, Command::Decimal, Command::One, Command::Two, Command::Three, Command::Four, Command::Five, Command::Six, - Command::Seven, Command::Eight, Command::Nine, Command::One, Command::Zero, Command::One, Command::One, Command::One }); + ExecuteCommands({ Command::Zero, + Command::Decimal, + Command::One, + Command::Two, + Command::Three, + Command::Four, + Command::Five, + Command::Six, + Command::Seven, + Command::Eight, + Command::Nine, + Command::One, + Command::Zero, + Command::One, + Command::One, + Command::One }); VERIFY_ARE_EQUAL(0, s_testVMCallback->GetMaxDigitsReachedCallCount()); @@ -516,8 +543,22 @@ namespace UnitConverterUnitTests void UnitConverterTest::UnitConverterTestMaxDigitsReached_TrailingDecimal() { - ExecuteCommands({ Command::One, Command::Two, Command::Three, Command::Four, Command::Five, Command::Six, Command::Seven, Command::Eight, Command::Nine, - Command::One, Command::Zero, Command::One, Command::One, Command::One, Command::Two, Command::Decimal }); + ExecuteCommands({ Command::One, + Command::Two, + Command::Three, + Command::Four, + Command::Five, + Command::Six, + Command::Seven, + Command::Eight, + Command::Nine, + Command::One, + Command::Zero, + Command::One, + Command::One, + Command::One, + Command::Two, + Command::Decimal }); VERIFY_ARE_EQUAL(0, s_testVMCallback->GetMaxDigitsReachedCallCount()); @@ -528,8 +569,21 @@ namespace UnitConverterUnitTests void UnitConverterTest::UnitConverterTestMaxDigitsReached_MultipleTimes() { - ExecuteCommands({ Command::One, Command::Two, Command::Three, Command::Four, Command::Five, Command::Six, Command::Seven, Command::Eight, Command::Nine, - Command::One, Command::Zero, Command::One, Command::One, Command::One, Command::Two }); + ExecuteCommands({ Command::One, + Command::Two, + Command::Three, + Command::Four, + Command::Five, + Command::Six, + Command::Seven, + Command::Eight, + Command::Nine, + Command::One, + Command::Zero, + Command::One, + Command::One, + Command::One, + Command::Two }); VERIFY_ARE_EQUAL(0, s_testVMCallback->GetMaxDigitsReachedCallCount());