From afdda581a42dc869d9487bf4aa9d7e941f71aa27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 12 Apr 2019 22:40:02 +0200 Subject: [PATCH 01/23] Drop unneeded const-qualifier on return type (#396) --- src/CalcManager/CalculatorHistory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CalcManager/CalculatorHistory.h b/src/CalcManager/CalculatorHistory.h index 8116e9e4..ea87f857 100644 --- a/src/CalcManager/CalculatorHistory.h +++ b/src/CalcManager/CalculatorHistory.h @@ -38,7 +38,7 @@ namespace CalculationManager void ClearHistory(); unsigned int AddItem(_In_ std::shared_ptr const &spHistoryItem); bool RemoveItem(unsigned int uIdx); - const size_t MaxHistorySize() const { return m_maxHistorySize; } + size_t MaxHistorySize() const { return m_maxHistorySize; } ~CalculatorHistory(void); private: From 109326508f6b13410fc2baf953ea5e1ce26ece0b Mon Sep 17 00:00:00 2001 From: Rudy Huyn Date: Mon, 15 Apr 2019 09:31:02 -0700 Subject: [PATCH 02/23] Improve the support of Narrator with parenthesis (#368) * Modify how we manage Narrator with parenthesis and refactor right parenthesis * Optimization * remove extra spaces * take feedback into account --- src/CalcManager/CEngine/scicomm.cpp | 4 +- src/CalcManager/CalculatorManager.cpp | 6 +- src/CalcManager/CalculatorManager.h | 2 +- src/CalcManager/Header Files/ICalcDisplay.h | 2 +- .../Common/Automation/NarratorNotifier.cpp | 2 +- .../Common/CalculatorDisplay.cpp | 2 +- src/CalcViewModel/Common/CalculatorDisplay.h | 2 +- .../StandardCalculatorViewModel.cpp | 73 +++++++++---------- .../StandardCalculatorViewModel.h | 14 +--- src/Calculator/Resources/am-ET/Resources.resw | 5 +- src/Calculator/Resources/ar-SA/Resources.resw | 5 +- .../Resources/az-Latn-AZ/Resources.resw | 5 +- src/Calculator/Resources/be-BY/Resources.resw | 5 +- src/Calculator/Resources/bg-BG/Resources.resw | 5 +- src/Calculator/Resources/ca-ES/Resources.resw | 5 +- src/Calculator/Resources/cs-CZ/Resources.resw | 5 +- src/Calculator/Resources/da-DK/Resources.resw | 5 +- src/Calculator/Resources/de-DE/Resources.resw | 5 +- src/Calculator/Resources/el-GR/Resources.resw | 5 +- src/Calculator/Resources/en-GB/Resources.resw | 5 +- src/Calculator/Resources/es-ES/Resources.resw | 5 +- src/Calculator/Resources/es-MX/Resources.resw | 5 +- src/Calculator/Resources/et-EE/Resources.resw | 5 +- src/Calculator/Resources/eu-ES/Resources.resw | 5 +- src/Calculator/Resources/fa-IR/Resources.resw | 5 +- src/Calculator/Resources/fi-FI/Resources.resw | 5 +- .../Resources/fil-PH/Resources.resw | 5 +- src/Calculator/Resources/fr-CA/Resources.resw | 5 +- src/Calculator/Resources/fr-FR/Resources.resw | 5 +- src/Calculator/Resources/gl-ES/Resources.resw | 5 +- src/Calculator/Resources/he-IL/Resources.resw | 5 +- src/Calculator/Resources/hi-IN/Resources.resw | 5 +- src/Calculator/Resources/hr-HR/Resources.resw | 5 +- src/Calculator/Resources/hu-HU/Resources.resw | 5 +- src/Calculator/Resources/id-ID/Resources.resw | 5 +- src/Calculator/Resources/is-IS/Resources.resw | 5 +- src/Calculator/Resources/it-IT/Resources.resw | 5 +- src/Calculator/Resources/ja-JP/Resources.resw | 5 +- src/Calculator/Resources/kk-KZ/Resources.resw | 5 +- src/Calculator/Resources/km-KH/Resources.resw | 5 +- src/Calculator/Resources/kn-IN/Resources.resw | 5 +- src/Calculator/Resources/ko-KR/Resources.resw | 5 +- src/Calculator/Resources/lo-LA/Resources.resw | 5 +- src/Calculator/Resources/lt-LT/Resources.resw | 5 +- src/Calculator/Resources/lv-LV/Resources.resw | 5 +- src/Calculator/Resources/mk-MK/Resources.resw | 5 +- src/Calculator/Resources/ml-IN/Resources.resw | 5 +- src/Calculator/Resources/ms-MY/Resources.resw | 5 +- src/Calculator/Resources/nb-NO/Resources.resw | 5 +- src/Calculator/Resources/nl-NL/Resources.resw | 5 +- src/Calculator/Resources/pl-PL/Resources.resw | 5 +- src/Calculator/Resources/pt-BR/Resources.resw | 5 +- src/Calculator/Resources/pt-PT/Resources.resw | 5 +- src/Calculator/Resources/ro-RO/Resources.resw | 5 +- src/Calculator/Resources/ru-RU/Resources.resw | 5 +- src/Calculator/Resources/sk-SK/Resources.resw | 5 +- src/Calculator/Resources/sl-SI/Resources.resw | 5 +- src/Calculator/Resources/sq-AL/Resources.resw | 5 +- .../Resources/sr-Latn-RS/Resources.resw | 5 +- src/Calculator/Resources/sv-SE/Resources.resw | 5 +- src/Calculator/Resources/sw-KE/Resources.resw | 5 +- src/Calculator/Resources/ta-IN/Resources.resw | 5 +- src/Calculator/Resources/te-IN/Resources.resw | 5 +- src/Calculator/Resources/th-TH/Resources.resw | 5 +- src/Calculator/Resources/tr-TR/Resources.resw | 5 +- src/Calculator/Resources/uk-UA/Resources.resw | 5 +- .../Resources/uz-Latn-UZ/Resources.resw | 5 +- src/Calculator/Resources/vi-VN/Resources.resw | 5 +- src/Calculator/Resources/zh-CN/Resources.resw | 5 +- src/Calculator/Resources/zh-TW/Resources.resw | 5 +- .../CalculatorProgrammerRadixOperators.xaml | 4 +- ...alculatorProgrammerRadixOperators.xaml.cpp | 18 ++--- .../CalculatorProgrammerRadixOperators.xaml.h | 4 +- .../Views/CalculatorScientificOperators.xaml | 6 +- .../CalculatorScientificOperators.xaml.cpp | 21 ++---- .../CalculatorScientificOperators.xaml.h | 8 +- src/Calculator/pch.h | 1 + .../CalculatorManagerTest.cpp | 4 +- 78 files changed, 133 insertions(+), 345 deletions(-) diff --git a/src/CalcManager/CEngine/scicomm.cpp b/src/CalcManager/CEngine/scicomm.cpp index d450a70d..4e0322d0 100644 --- a/src/CalcManager/CEngine/scicomm.cpp +++ b/src/CalcManager/CEngine/scicomm.cpp @@ -390,7 +390,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam) cleared for CENTR */ if (nullptr != m_pCalcDisplay) { - m_pCalcDisplay->SetParenDisplayText(L""); + m_pCalcDisplay->SetParenthesisNumber(0); m_pCalcDisplay->SetExpressionDisplay(make_shared>>(), make_shared>>()); } @@ -594,7 +594,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam) // Set the "(=xx" indicator. if (nullptr != m_pCalcDisplay) { - m_pCalcDisplay->SetParenDisplayText(m_openParenCount ? to_wstring(m_openParenCount) : L""); + m_pCalcDisplay->SetParenthesisNumber(m_openParenCount >= 0 ? static_cast(m_openParenCount) : 0); } if (!m_bError) diff --git a/src/CalcManager/CalculatorManager.cpp b/src/CalcManager/CalculatorManager.cpp index b4b4dfaf..d5bbd029 100644 --- a/src/CalcManager/CalculatorManager.cpp +++ b/src/CalcManager/CalculatorManager.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "pch.h" @@ -111,9 +111,9 @@ namespace CalculationManager /// Callback from the engine /// /// string containing the parenthesis count - void CalculatorManager::SetParenDisplayText(const wstring& parenthesisCount) + void CalculatorManager::SetParenthesisNumber(_In_ unsigned int parenthesisCount) { - m_displayCallback->SetParenDisplayText(parenthesisCount); + m_displayCallback->SetParenthesisNumber(parenthesisCount); } /// diff --git a/src/CalcManager/CalculatorManager.h b/src/CalcManager/CalculatorManager.h index 0b9986b0..e00dc243 100644 --- a/src/CalcManager/CalculatorManager.h +++ b/src/CalcManager/CalculatorManager.h @@ -94,7 +94,7 @@ namespace CalculationManager void SetExpressionDisplay(_Inout_ std::shared_ptr>> const &tokens, _Inout_ std::shared_ptr>> const &commands) override; void SetMemorizedNumbers(_In_ const std::vector& memorizedNumbers) override; void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) override; - void SetParenDisplayText(const std::wstring& parenthesisCount) override; + void SetParenthesisNumber(_In_ unsigned int parenthesisCount) override; void OnNoRightParenAdded() override; void DisplayPasteError(); void MaxDigitsReached() override; diff --git a/src/CalcManager/Header Files/ICalcDisplay.h b/src/CalcManager/Header Files/ICalcDisplay.h index 2ba57e65..73fce932 100644 --- a/src/CalcManager/Header Files/ICalcDisplay.h +++ b/src/CalcManager/Header Files/ICalcDisplay.h @@ -12,7 +12,7 @@ public: virtual void SetPrimaryDisplay(const std::wstring& pszText, bool isError) = 0; virtual void SetIsInError(bool isInError) = 0; virtual void SetExpressionDisplay(_Inout_ std::shared_ptr>> const &tokens, _Inout_ std::shared_ptr>> const &commands) = 0; - virtual void SetParenDisplayText(const std::wstring& pszText) = 0; + virtual void SetParenthesisNumber(_In_ unsigned int count) = 0; virtual void OnNoRightParenAdded() = 0; virtual void MaxDigitsReached() = 0; // not an error but still need to inform UI layer. virtual void BinaryOperatorReceived() = 0; diff --git a/src/CalcViewModel/Common/Automation/NarratorNotifier.cpp b/src/CalcViewModel/Common/Automation/NarratorNotifier.cpp index 4dc48074..b17aaba4 100644 --- a/src/CalcViewModel/Common/Automation/NarratorNotifier.cpp +++ b/src/CalcViewModel/Common/Automation/NarratorNotifier.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Implementation of the NarratorNotifier class. diff --git a/src/CalcViewModel/Common/CalculatorDisplay.cpp b/src/CalcViewModel/Common/CalculatorDisplay.cpp index cd531e01..4da98129 100644 --- a/src/CalcViewModel/Common/CalculatorDisplay.cpp +++ b/src/CalcViewModel/Common/CalculatorDisplay.cpp @@ -36,7 +36,7 @@ void CalculatorDisplay::SetPrimaryDisplay(_In_ const wstring& displayStringValue } } -void CalculatorDisplay::SetParenDisplayText(_In_ const std::wstring& parenthesisCount) +void CalculatorDisplay::SetParenthesisNumber(_In_ unsigned int parenthesisCount) { if (m_callbackReference != nullptr) { diff --git a/src/CalcViewModel/Common/CalculatorDisplay.h b/src/CalcViewModel/Common/CalculatorDisplay.h index 9ff06a6e..877bdf06 100644 --- a/src/CalcViewModel/Common/CalculatorDisplay.h +++ b/src/CalcViewModel/Common/CalculatorDisplay.h @@ -21,7 +21,7 @@ namespace CalculatorApp void SetExpressionDisplay(_Inout_ std::shared_ptr>> const &tokens, _Inout_ std::shared_ptr>> const &commands) override; void SetMemorizedNumbers(_In_ const std::vector& memorizedNumbers) override; void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) override; - void SetParenDisplayText(_In_ const std::wstring& parenthesisCount) override; + void SetParenthesisNumber(_In_ unsigned int parenthesisCount) override; void OnNoRightParenAdded() override; void MaxDigitsReached() override; void BinaryOperatorReceived() override; diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp index c01c4789..944b8d1a 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -48,7 +48,6 @@ namespace CalculatorResourceKeys StringReference DecButton(L"Format_DecButtonValue"); StringReference OctButton(L"Format_OctButtonValue"); StringReference BinButton(L"Format_BinButtonValue"); - StringReference LeftParenthesisAutomationFormat(L"Format_OpenParenthesisAutomationNamePrefix"); StringReference OpenParenthesisCountAutomationFormat(L"Format_OpenParenthesisCountAutomationNamePrefix"); StringReference NoParenthesisAdded(L"NoRightParenthesisAdded_Announcement"); StringReference MaxDigitsReachedFormat(L"Format_MaxDigitsReached"); @@ -80,8 +79,8 @@ StandardCalculatorViewModel::StandardCalculatorViewModel() : m_isBinaryBitFlippingEnabled(false), m_CurrentRadixType(RADIX_TYPE::DEC_RADIX), m_CurrentAngleType(NumbersAndOperatorsEnum::Degree), - m_OpenParenthesisCount(L""), m_Announcement(nullptr), + m_OpenParenthesisCount(0), m_feedbackForButtonPress(nullptr), m_isRtlLanguage(false), m_localizedMaxDigitsReachedAutomationFormat(nullptr), @@ -102,7 +101,6 @@ StandardCalculatorViewModel::StandardCalculatorViewModel() : m_localizedDecimalAutomationFormat = AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::DecButton); m_localizedOctalAutomationFormat = AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::OctButton); m_localizedBinaryAutomationFormat = AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::BinButton); - m_leftParenthesisAutomationFormat = AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::LeftParenthesisAutomationFormat); // Initialize the Automation Name CalculationResultAutomationName = GetLocalizedStringFormat(m_localizedCalculationResultAutomationFormat, m_DisplayValue); @@ -216,19 +214,23 @@ void StandardCalculatorViewModel::DisplayPasteError() m_standardCalculatorManager.DisplayPasteError(); } -void StandardCalculatorViewModel::SetParenthesisCount(_In_ const wstring& parenthesisCount) +void StandardCalculatorViewModel::SetParenthesisCount(_In_ unsigned int parenthesisCount) { + if (m_OpenParenthesisCount == parenthesisCount) + { + return; + } + + OpenParenthesisCount = parenthesisCount; if (IsProgrammer || IsScientific) { - OpenParenthesisCount = ref new String(parenthesisCount.c_str()); - RaisePropertyChanged("LeftParenthesisAutomationName"); + SetOpenParenthesisCountNarratorAnnouncement(); } } void StandardCalculatorViewModel::SetOpenParenthesisCountNarratorAnnouncement() { - String^ parenthesisCount = ((m_OpenParenthesisCount == nullptr) ? "0" : m_OpenParenthesisCount); - wstring localizedParenthesisCount = parenthesisCount->Data(); + wstring localizedParenthesisCount = to_wstring(m_OpenParenthesisCount).c_str(); LocalizationSettings::GetInstance().LocalizeDisplayValue(&localizedParenthesisCount); String^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement( @@ -281,15 +283,6 @@ void StandardCalculatorViewModel::DisableButtons(CommandType selectedExpressionC } } -String ^ StandardCalculatorViewModel::GetLeftParenthesisAutomationName() -{ - String^ parenthesisCount = ((m_OpenParenthesisCount == nullptr) ? "0" : m_OpenParenthesisCount); - wstring localizedParenthesisCount = std::wstring(parenthesisCount->Data()); - LocalizationSettings::GetInstance().LocalizeDisplayValue(&localizedParenthesisCount); - - return GetLocalizedStringFormat(m_leftParenthesisAutomationFormat, ref new String(localizedParenthesisCount.c_str())); -} - void StandardCalculatorViewModel::SetExpressionDisplay(_Inout_ shared_ptr>> const &tokens, _Inout_ shared_ptr>> const &commands) { m_tokens = tokens; @@ -1422,29 +1415,29 @@ void StandardCalculatorViewModel::SaveEditedCommand(_In_ unsigned int tokenPosit switch (nOpCode) { - case static_cast(Command::CommandASIN) : - updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandSIN), true, angleType); - break; - case static_cast(Command::CommandACOS) : - updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandCOS), true, angleType); - break; - case static_cast(Command::CommandATAN) : - updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandTAN), true, angleType); - break; - case static_cast(Command::CommandASINH) : - updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandSINH), true, angleType); - break; - case static_cast(Command::CommandACOSH) : - updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandCOSH), true, angleType); - break; - case static_cast(Command::CommandATANH) : - updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandTANH), true, angleType); - break; - case static_cast(Command::CommandPOWE) : - updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandLN), true, angleType); - break; - default: - updatedToken = CCalcEngine::OpCodeToUnaryString(nOpCode, false, angleType); + case static_cast(Command::CommandASIN) : + updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandSIN), true, angleType); + break; + case static_cast(Command::CommandACOS) : + updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandCOS), true, angleType); + break; + case static_cast(Command::CommandATAN) : + updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandTAN), true, angleType); + break; + case static_cast(Command::CommandASINH) : + updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandSINH), true, angleType); + break; + case static_cast(Command::CommandACOSH) : + updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandCOSH), true, angleType); + break; + case static_cast(Command::CommandATANH) : + updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandTANH), true, angleType); + break; + case static_cast(Command::CommandPOWE) : + updatedToken = CCalcEngine::OpCodeToUnaryString(static_cast(Command::CommandLN), true, angleType); + break; + default: + updatedToken = CCalcEngine::OpCodeToUnaryString(nOpCode, false, angleType); } if ((token.first.length() > 0) && (token.first[token.first.length() - 1] == L'(')) { diff --git a/src/CalcViewModel/StandardCalculatorViewModel.h b/src/CalcViewModel/StandardCalculatorViewModel.h index ba6dc82b..91ba2557 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.h +++ b/src/CalcViewModel/StandardCalculatorViewModel.h @@ -75,12 +75,12 @@ namespace CalculatorApp OBSERVABLE_PROPERTY_RW(bool, IsDwordEnabled); OBSERVABLE_PROPERTY_RW(bool, IsWordEnabled); OBSERVABLE_PROPERTY_RW(bool, IsByteEnabled); - OBSERVABLE_NAMED_PROPERTY_RW(Platform::String^, OpenParenthesisCount); OBSERVABLE_PROPERTY_RW(int, CurrentRadixType); OBSERVABLE_PROPERTY_RW(bool, AreTokensUpdated); OBSERVABLE_PROPERTY_RW(bool, AreHistoryShortcutsEnabled); OBSERVABLE_PROPERTY_RW(bool, AreProgrammerRadixOperatorsEnabled); OBSERVABLE_PROPERTY_RW(CalculatorApp::Common::Automation::NarratorAnnouncement^, Announcement); + OBSERVABLE_PROPERTY_R(unsigned int, OpenParenthesisCount); COMMAND_FOR_METHOD(CopyCommand, StandardCalculatorViewModel::OnCopyCommand); COMMAND_FOR_METHOD(PasteCommand, StandardCalculatorViewModel::OnPasteCommand); @@ -255,14 +255,6 @@ namespace CalculatorApp void set(bool value) { m_completeTextSelection = value; } } - property Platform::String^ LeftParenthesisAutomationName - { - Platform::String^ get() - { - return GetLeftParenthesisAutomationName(); - } - } - internal: void OnPaste(Platform::String^ pastedString, CalculatorApp::Common::ViewMode mode); void OnCopyCommand(Platform::Object^ parameter); @@ -283,7 +275,7 @@ namespace CalculatorApp void SetTokens(_Inout_ std::shared_ptr>> const &tokens); void SetExpressionDisplay(_Inout_ std::shared_ptr>> const &tokens, _Inout_ std::shared_ptr>> const &commands); void SetHistoryExpressionDisplay(_Inout_ std::shared_ptr>> const &tokens, _Inout_ std::shared_ptr>> const &commands); - void SetParenthesisCount(_In_ const std::wstring& parenthesisCount); + void SetParenthesisCount(_In_ unsigned int parenthesisCount); void SetOpenParenthesisCountNarratorAnnouncement(); void OnNoRightParenAdded(); void SetNoParenAddedNarratorAnnouncement(); @@ -354,7 +346,6 @@ namespace CalculatorApp bool m_isLastOperationHistoryLoad; Platform::String^ m_selectedExpressionLastData; Common::DisplayExpressionToken^ m_selectedExpressionToken; - Platform::String^ m_leftParenthesisAutomationFormat; Platform::String^ LocalizeDisplayValue(_In_ std::wstring const &displayValue, _In_ bool isError); Platform::String^ CalculateNarratorDisplayValue(_In_ std::wstring const &displayValue, _In_ Platform::String^ localizedDisplayValue, _In_ bool isError); @@ -364,7 +355,6 @@ namespace CalculatorApp CalculationManager::Command ConvertToOperatorsEnum(NumbersAndOperatorsEnum operation); void DisableButtons(CalculationManager::CommandType selectedExpressionCommandType); - Platform::String^ GetLeftParenthesisAutomationName(); Platform::String^ m_feedbackForButtonPress; void OnButtonPressed(Platform::Object^ parameter); diff --git a/src/Calculator/Resources/am-ET/Resources.resw b/src/Calculator/Resources/am-ET/Resources.resw index 24edcb5f..5ccff34a 100644 --- a/src/Calculator/Resources/am-ET/Resources.resw +++ b/src/Calculator/Resources/am-ET/Resources.resw @@ -901,10 +901,7 @@ የግራ ቅንፍ Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - የግራ ቅንፍ፣ የክፍት ቅንፍ ቁጥር %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + የቀኝ ቅንፍ Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/ar-SA/Resources.resw b/src/Calculator/Resources/ar-SA/Resources.resw index 051c055c..90780d3c 100644 --- a/src/Calculator/Resources/ar-SA/Resources.resw +++ b/src/Calculator/Resources/ar-SA/Resources.resw @@ -901,10 +901,7 @@ أقواس يسرى Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - القوس الأيسر، عدد الأقواس المفتوحة %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + أقواس يمنى Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/az-Latn-AZ/Resources.resw b/src/Calculator/Resources/az-Latn-AZ/Resources.resw index 60fa2da8..e5941d65 100644 --- a/src/Calculator/Resources/az-Latn-AZ/Resources.resw +++ b/src/Calculator/Resources/az-Latn-AZ/Resources.resw @@ -901,10 +901,7 @@ Sol mötərizə Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Sol mötərizə, açıq mötərizənin sayı %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Sağ mötərizə Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/be-BY/Resources.resw b/src/Calculator/Resources/be-BY/Resources.resw index f5498b31..85457396 100644 --- a/src/Calculator/Resources/be-BY/Resources.resw +++ b/src/Calculator/Resources/be-BY/Resources.resw @@ -901,10 +901,7 @@ Левая дужка Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Левая дужка, пачатак адліку дужак (%1) - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Правая дужка Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/bg-BG/Resources.resw b/src/Calculator/Resources/bg-BG/Resources.resw index 069f995a..9737c537 100644 --- a/src/Calculator/Resources/bg-BG/Resources.resw +++ b/src/Calculator/Resources/bg-BG/Resources.resw @@ -901,10 +901,7 @@ Лява скоба Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Лява скоба, брой на отваряща скоба %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Дясна скоба Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/ca-ES/Resources.resw b/src/Calculator/Resources/ca-ES/Resources.resw index b2672e8f..28177726 100644 --- a/src/Calculator/Resources/ca-ES/Resources.resw +++ b/src/Calculator/Resources/ca-ES/Resources.resw @@ -901,10 +901,7 @@ Parèntesi d'obertura Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Parèntesi d'obertura, recompte de parèntesis d'obertura %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Parèntesi de tancament Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/cs-CZ/Resources.resw b/src/Calculator/Resources/cs-CZ/Resources.resw index 85db6271..db9a320e 100644 --- a/src/Calculator/Resources/cs-CZ/Resources.resw +++ b/src/Calculator/Resources/cs-CZ/Resources.resw @@ -901,10 +901,7 @@ Levá závorka Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Levá závorka, počet otevřených závorek %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Pravá závorka Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/da-DK/Resources.resw b/src/Calculator/Resources/da-DK/Resources.resw index 5f69bd5d..96c16947 100644 --- a/src/Calculator/Resources/da-DK/Resources.resw +++ b/src/Calculator/Resources/da-DK/Resources.resw @@ -901,10 +901,7 @@ Venstreparentes Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Venstre parentes, åben parentes antal %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Højreparentes Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/de-DE/Resources.resw b/src/Calculator/Resources/de-DE/Resources.resw index 8d0a6adb..2c76b451 100644 --- a/src/Calculator/Resources/de-DE/Resources.resw +++ b/src/Calculator/Resources/de-DE/Resources.resw @@ -901,10 +901,7 @@ Öffnende Klammer Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Runde Klammer links, Anzahl der öffnenden Klammern: %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Schließende Klammer Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/el-GR/Resources.resw b/src/Calculator/Resources/el-GR/Resources.resw index 5a394bf3..cc791405 100644 --- a/src/Calculator/Resources/el-GR/Resources.resw +++ b/src/Calculator/Resources/el-GR/Resources.resw @@ -901,10 +901,7 @@ Αριστερή παρένθεση Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Αριστερή παρένθεση, πλήθος ανοιχτών παρενθέσεων %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Δεξιά παρένθεση Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/en-GB/Resources.resw b/src/Calculator/Resources/en-GB/Resources.resw index 84310eb0..b8077985 100644 --- a/src/Calculator/Resources/en-GB/Resources.resw +++ b/src/Calculator/Resources/en-GB/Resources.resw @@ -901,10 +901,7 @@ Left parenthesis Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Left parenthesis, open parenthesis count %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Right parenthesis Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/es-ES/Resources.resw b/src/Calculator/Resources/es-ES/Resources.resw index e2e44b8e..34cc2c94 100644 --- a/src/Calculator/Resources/es-ES/Resources.resw +++ b/src/Calculator/Resources/es-ES/Resources.resw @@ -901,10 +901,7 @@ Paréntesis de apertura Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Paréntesis de apertura, número de paréntesis abiertos %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Paréntesis de cierre Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/es-MX/Resources.resw b/src/Calculator/Resources/es-MX/Resources.resw index a0d04589..44151b87 100644 --- a/src/Calculator/Resources/es-MX/Resources.resw +++ b/src/Calculator/Resources/es-MX/Resources.resw @@ -901,10 +901,7 @@ Paréntesis de apertura Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Abrir paréntesis, recuento de paréntesis abiertos %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Paréntesis de cierre Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/et-EE/Resources.resw b/src/Calculator/Resources/et-EE/Resources.resw index 2709cabd..41060649 100644 --- a/src/Calculator/Resources/et-EE/Resources.resw +++ b/src/Calculator/Resources/et-EE/Resources.resw @@ -901,10 +901,7 @@ Vasaksulg Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Vasaksulg, avavate sulgude arv %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Paremsulg Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/eu-ES/Resources.resw b/src/Calculator/Resources/eu-ES/Resources.resw index dcea8382..98264063 100644 --- a/src/Calculator/Resources/eu-ES/Resources.resw +++ b/src/Calculator/Resources/eu-ES/Resources.resw @@ -901,10 +901,7 @@ Ezkerreko parentesia Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Ezkerreko parentesia, ireki %1. parentesia - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Eskuineko parentesia Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/fa-IR/Resources.resw b/src/Calculator/Resources/fa-IR/Resources.resw index 713f24fa..edd9e34b 100644 --- a/src/Calculator/Resources/fa-IR/Resources.resw +++ b/src/Calculator/Resources/fa-IR/Resources.resw @@ -901,10 +901,7 @@ پرانتز سمت چپ Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - پرانتز چپ، تعداد پرانتزهای باز %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + پرانتز سمت راست Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/fi-FI/Resources.resw b/src/Calculator/Resources/fi-FI/Resources.resw index 71dcaa25..b2a92d88 100644 --- a/src/Calculator/Resources/fi-FI/Resources.resw +++ b/src/Calculator/Resources/fi-FI/Resources.resw @@ -901,10 +901,7 @@ Vasen sulje Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Vasen sulje, avaavien sulkeiden määrä %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Oikea sulje Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/fil-PH/Resources.resw b/src/Calculator/Resources/fil-PH/Resources.resw index 24805b92..1409ce52 100644 --- a/src/Calculator/Resources/fil-PH/Resources.resw +++ b/src/Calculator/Resources/fil-PH/Resources.resw @@ -901,10 +901,7 @@ Kaliwang parenthesis Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Bilang ng kaliwang panaklong, pambukas na panaklong %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Kanang parenthesis Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/fr-CA/Resources.resw b/src/Calculator/Resources/fr-CA/Resources.resw index b4ad2696..895689d9 100644 --- a/src/Calculator/Resources/fr-CA/Resources.resw +++ b/src/Calculator/Resources/fr-CA/Resources.resw @@ -901,10 +901,7 @@ Parenthèse gauche Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - %1 parenthèses gauches ouvrantes - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Parenthèse droite Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/fr-FR/Resources.resw b/src/Calculator/Resources/fr-FR/Resources.resw index ef24ec55..c5f0a6c4 100644 --- a/src/Calculator/Resources/fr-FR/Resources.resw +++ b/src/Calculator/Resources/fr-FR/Resources.resw @@ -901,10 +901,7 @@ Parenthèse gauche Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Parenthèse gauche, nombre de parenthèses ouvertes %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Parenthèse droite Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/gl-ES/Resources.resw b/src/Calculator/Resources/gl-ES/Resources.resw index dbc0137a..21aac3cd 100644 --- a/src/Calculator/Resources/gl-ES/Resources.resw +++ b/src/Calculator/Resources/gl-ES/Resources.resw @@ -901,10 +901,7 @@ Paréntese esquerda Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Paréntese de apertura, total de parénteses abertos %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Paréntese dereita Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/he-IL/Resources.resw b/src/Calculator/Resources/he-IL/Resources.resw index c72e7a71..2a86f3ff 100644 --- a/src/Calculator/Resources/he-IL/Resources.resw +++ b/src/Calculator/Resources/he-IL/Resources.resw @@ -901,10 +901,7 @@ סוגר שמאלי Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - סוגריים ימניים, פתח ספירת סוגריים %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + סוגר ימני Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/hi-IN/Resources.resw b/src/Calculator/Resources/hi-IN/Resources.resw index aeb6b18f..9a4ce3f5 100644 --- a/src/Calculator/Resources/hi-IN/Resources.resw +++ b/src/Calculator/Resources/hi-IN/Resources.resw @@ -901,10 +901,7 @@ बायाँ कोष्ठक Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - बायाँ कोष्ठक, खुले कोष्ठक की संख्या %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + दायाँ कोष्ठक Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/hr-HR/Resources.resw b/src/Calculator/Resources/hr-HR/Resources.resw index 4a3ecbdb..4039f357 100644 --- a/src/Calculator/Resources/hr-HR/Resources.resw +++ b/src/Calculator/Resources/hr-HR/Resources.resw @@ -901,10 +901,7 @@ Lijeva zagrada Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Lijeva zagrada, broj otvorenih zagrada %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Desna zagrada Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/hu-HU/Resources.resw b/src/Calculator/Resources/hu-HU/Resources.resw index bef5d1fa..3afa8a62 100644 --- a/src/Calculator/Resources/hu-HU/Resources.resw +++ b/src/Calculator/Resources/hu-HU/Resources.resw @@ -901,10 +901,7 @@ Nyitó zárójel Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Bal oldali vagy nyitó zárójelek száma: %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Berekesztő zárójel Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/id-ID/Resources.resw b/src/Calculator/Resources/id-ID/Resources.resw index 9fb7e6b4..dc8fc070 100644 --- a/src/Calculator/Resources/id-ID/Resources.resw +++ b/src/Calculator/Resources/id-ID/Resources.resw @@ -901,10 +901,7 @@ Tanda kurung tutup Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Tanda kurung kiri, tanda kurung terbuka berjumlah %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Tanda kurung buka Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/is-IS/Resources.resw b/src/Calculator/Resources/is-IS/Resources.resw index a5f382ef..32c1df20 100644 --- a/src/Calculator/Resources/is-IS/Resources.resw +++ b/src/Calculator/Resources/is-IS/Resources.resw @@ -901,10 +901,7 @@ Vinstri svigi Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Vinstri svigi, opnir svigar telja %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Hægri svigi Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/it-IT/Resources.resw b/src/Calculator/Resources/it-IT/Resources.resw index 039fdc97..21abf33e 100644 --- a/src/Calculator/Resources/it-IT/Resources.resw +++ b/src/Calculator/Resources/it-IT/Resources.resw @@ -901,10 +901,7 @@ Parentesi sinistra Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Conteggio parentesi sinistra, parentesi aperta %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Parentesi destra Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/ja-JP/Resources.resw b/src/Calculator/Resources/ja-JP/Resources.resw index f0015cb1..805294a3 100644 --- a/src/Calculator/Resources/ja-JP/Resources.resw +++ b/src/Calculator/Resources/ja-JP/Resources.resw @@ -901,10 +901,7 @@ 始め丸かっこ Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - 左かっこ、開きかっこの数 %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + 終わり丸かっこ Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/kk-KZ/Resources.resw b/src/Calculator/Resources/kk-KZ/Resources.resw index aac098dd..9cae015a 100644 --- a/src/Calculator/Resources/kk-KZ/Resources.resw +++ b/src/Calculator/Resources/kk-KZ/Resources.resw @@ -901,10 +901,7 @@ Сол жақ жақша Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Сол жақ жақша, ашық жақша саны: %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Оң жақ жақша Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/km-KH/Resources.resw b/src/Calculator/Resources/km-KH/Resources.resw index 2ccfb850..001536c3 100644 --- a/src/Calculator/Resources/km-KH/Resources.resw +++ b/src/Calculator/Resources/km-KH/Resources.resw @@ -901,10 +901,7 @@ វង់ក្រចកឆ្វេង Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - វង់​ក្រចក​ឆ្វេង បើក​ការ​រាប់​វង់​ក្រចក %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + វង់ក្រចកស្តាំ Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/kn-IN/Resources.resw b/src/Calculator/Resources/kn-IN/Resources.resw index c6a2cb3c..f7205b98 100644 --- a/src/Calculator/Resources/kn-IN/Resources.resw +++ b/src/Calculator/Resources/kn-IN/Resources.resw @@ -901,10 +901,7 @@ ಎಡ ಆವರಣ ಚಿಹ್ನೆ Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - ಎಡ ಆವರಣ, ಬಲ ಆವರಣ ಎಣಿಕೆ %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + ಬಲ ಆವರಣ ಚಿಹ್ನೆ Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/ko-KR/Resources.resw b/src/Calculator/Resources/ko-KR/Resources.resw index 6a9c6903..636cd7fa 100644 --- a/src/Calculator/Resources/ko-KR/Resources.resw +++ b/src/Calculator/Resources/ko-KR/Resources.resw @@ -901,10 +901,7 @@ 여는 괄호 Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - 왼쪽 괄호 또는 여는 괄호 수 %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + 닫는 괄호 Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/lo-LA/Resources.resw b/src/Calculator/Resources/lo-LA/Resources.resw index 4ca195ee..668cbcfd 100644 --- a/src/Calculator/Resources/lo-LA/Resources.resw +++ b/src/Calculator/Resources/lo-LA/Resources.resw @@ -901,10 +901,7 @@ ວົງເລັບຊ້າຍ Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - <mrk mtype="seg" mid="55">ວົງເລັບຊ້າຍ, ເປີດຍອດລວມວົງເລັບ %1</mrk> - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + ວົງເລັບຂວາ Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/lt-LT/Resources.resw b/src/Calculator/Resources/lt-LT/Resources.resw index 65350a0a..6fe0cdb0 100644 --- a/src/Calculator/Resources/lt-LT/Resources.resw +++ b/src/Calculator/Resources/lt-LT/Resources.resw @@ -901,10 +901,7 @@ Kairysis lenktinis skliaustas Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Kairysis skliaustas, atidarančio skliausto skaičius %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Dešinysis lenktinis skliaustas Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/lv-LV/Resources.resw b/src/Calculator/Resources/lv-LV/Resources.resw index 3925267a..fd0aa0d3 100644 --- a/src/Calculator/Resources/lv-LV/Resources.resw +++ b/src/Calculator/Resources/lv-LV/Resources.resw @@ -901,10 +901,7 @@ Kreisās puses apaļā iekava Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Kreisā iekava, atvērto iekavu skaits: %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Labās puses apaļā iekava Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/mk-MK/Resources.resw b/src/Calculator/Resources/mk-MK/Resources.resw index e655626d..ae662665 100644 --- a/src/Calculator/Resources/mk-MK/Resources.resw +++ b/src/Calculator/Resources/mk-MK/Resources.resw @@ -901,10 +901,7 @@ Лева заграда Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Лева заграда, отворена заграда пресметува %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Десна заграда Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/ml-IN/Resources.resw b/src/Calculator/Resources/ml-IN/Resources.resw index 4c49b6db..dfd4f85c 100644 --- a/src/Calculator/Resources/ml-IN/Resources.resw +++ b/src/Calculator/Resources/ml-IN/Resources.resw @@ -901,10 +901,7 @@ ഇടത് ആവരണചിഹ്നം Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - ഇടത് പാരന്തെസിസ്, പാരന്തെസിസ് കൗണ്ട് %1 തുറക്കുക - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + വലത് ബ്രാക്കറ്റ് Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/ms-MY/Resources.resw b/src/Calculator/Resources/ms-MY/Resources.resw index 11478d55..f92fb352 100644 --- a/src/Calculator/Resources/ms-MY/Resources.resw +++ b/src/Calculator/Resources/ms-MY/Resources.resw @@ -901,10 +901,7 @@ Tanda kurungan kiri Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Tanda kurung kiri, buka kiraan tanda kurung %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Tanda kurungan kanan Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/nb-NO/Resources.resw b/src/Calculator/Resources/nb-NO/Resources.resw index 54d286c6..7bdbe851 100644 --- a/src/Calculator/Resources/nb-NO/Resources.resw +++ b/src/Calculator/Resources/nb-NO/Resources.resw @@ -901,10 +901,7 @@ Venstreparentes Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Venstreparentes, åpen parentes teller %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Høyreparentes Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/nl-NL/Resources.resw b/src/Calculator/Resources/nl-NL/Resources.resw index cd523a0f..da027ca9 100644 --- a/src/Calculator/Resources/nl-NL/Resources.resw +++ b/src/Calculator/Resources/nl-NL/Resources.resw @@ -901,10 +901,7 @@ Haakje openen Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Haakje openen, aantal haakjes openen %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Haakje sluiten Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/pl-PL/Resources.resw b/src/Calculator/Resources/pl-PL/Resources.resw index 0aa9f567..6f168924 100644 --- a/src/Calculator/Resources/pl-PL/Resources.resw +++ b/src/Calculator/Resources/pl-PL/Resources.resw @@ -901,10 +901,7 @@ Lewy nawias Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Lewy nawias, liczba otwartych nawiasów: %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Prawy nawias Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/pt-BR/Resources.resw b/src/Calculator/Resources/pt-BR/Resources.resw index 8a9fb639..9caeb8d7 100644 --- a/src/Calculator/Resources/pt-BR/Resources.resw +++ b/src/Calculator/Resources/pt-BR/Resources.resw @@ -901,10 +901,7 @@ Parêntese esquerdo Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Parêntese esquerdo, contagem de parêntese de abertura %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Parêntese direito Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/pt-PT/Resources.resw b/src/Calculator/Resources/pt-PT/Resources.resw index d8f59c86..3a120893 100644 --- a/src/Calculator/Resources/pt-PT/Resources.resw +++ b/src/Calculator/Resources/pt-PT/Resources.resw @@ -901,10 +901,7 @@ Parêntese à esquerda Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Parêntese à esquerda, abrir contagem de parênteses %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Parêntese à direita Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/ro-RO/Resources.resw b/src/Calculator/Resources/ro-RO/Resources.resw index 71f717ed..02a518d5 100644 --- a/src/Calculator/Resources/ro-RO/Resources.resw +++ b/src/Calculator/Resources/ro-RO/Resources.resw @@ -901,10 +901,7 @@ Paranteză stânga Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Contor paranteze stânga, paranteze deschise %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Paranteză dreapta Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/ru-RU/Resources.resw b/src/Calculator/Resources/ru-RU/Resources.resw index b1397c57..9c46030e 100644 --- a/src/Calculator/Resources/ru-RU/Resources.resw +++ b/src/Calculator/Resources/ru-RU/Resources.resw @@ -901,10 +901,7 @@ Открывающая круглая скобка Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Левая круглая скобка, количество открывающих круглых скобок — %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Закрывающая круглая скобка Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/sk-SK/Resources.resw b/src/Calculator/Resources/sk-SK/Resources.resw index 220ab2e7..48c4aeb6 100644 --- a/src/Calculator/Resources/sk-SK/Resources.resw +++ b/src/Calculator/Resources/sk-SK/Resources.resw @@ -901,10 +901,7 @@ Ľavá zátvorka Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Ľavá zátvorka, počet ľavých zátvoriek je %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Pravá zátvorka Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/sl-SI/Resources.resw b/src/Calculator/Resources/sl-SI/Resources.resw index 861bfdfd..e2ef8cdc 100644 --- a/src/Calculator/Resources/sl-SI/Resources.resw +++ b/src/Calculator/Resources/sl-SI/Resources.resw @@ -901,10 +901,7 @@ Levi oklepaj Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Levi oklepaj, število oklepajev %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Desni oklepaj Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/sq-AL/Resources.resw b/src/Calculator/Resources/sq-AL/Resources.resw index 577d6e9f..10165d09 100644 --- a/src/Calculator/Resources/sq-AL/Resources.resw +++ b/src/Calculator/Resources/sq-AL/Resources.resw @@ -901,10 +901,7 @@ Kllapa e majtë Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Kllapa e majtë, numri i kllapave hapëse %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Kllapa e djathtë Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/sr-Latn-RS/Resources.resw b/src/Calculator/Resources/sr-Latn-RS/Resources.resw index 5939e576..d4545c5b 100644 --- a/src/Calculator/Resources/sr-Latn-RS/Resources.resw +++ b/src/Calculator/Resources/sr-Latn-RS/Resources.resw @@ -901,10 +901,7 @@ Leva zagrada Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Otvorena zagrada, broj otvorenih zagrada %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Desna zagrada Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/sv-SE/Resources.resw b/src/Calculator/Resources/sv-SE/Resources.resw index 4bdb8fa9..4e5afb85 100644 --- a/src/Calculator/Resources/sv-SE/Resources.resw +++ b/src/Calculator/Resources/sv-SE/Resources.resw @@ -901,10 +901,7 @@ Vänster parentes Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Vänster parentes, antal inledande parenteser är %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Höger parentes Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/sw-KE/Resources.resw b/src/Calculator/Resources/sw-KE/Resources.resw index 0faa58ca..15a1cfc8 100644 --- a/src/Calculator/Resources/sw-KE/Resources.resw +++ b/src/Calculator/Resources/sw-KE/Resources.resw @@ -901,10 +901,7 @@ Mabano ya kushoto Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Mabano ya kushoto, fungua idadi ya mabano %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Mabano ya kulia Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/ta-IN/Resources.resw b/src/Calculator/Resources/ta-IN/Resources.resw index 17c7e276..7bbfc867 100644 --- a/src/Calculator/Resources/ta-IN/Resources.resw +++ b/src/Calculator/Resources/ta-IN/Resources.resw @@ -901,10 +901,7 @@ இடது அடைப்புக்குறி Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - இடது அடைப்புக்குறி, திறப்பு அடைப்புக்குறி கணக்கு %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + வலது அடைப்புக்குறி Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/te-IN/Resources.resw b/src/Calculator/Resources/te-IN/Resources.resw index 455a5670..40f55346 100644 --- a/src/Calculator/Resources/te-IN/Resources.resw +++ b/src/Calculator/Resources/te-IN/Resources.resw @@ -901,10 +901,7 @@ ఎడమ కుండలీకరణం Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - ఎడమ కుండలీకరణం, కుండలీకరణ గణనను %1 తెరవు - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + కుడి కుండలీకరణం Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/th-TH/Resources.resw b/src/Calculator/Resources/th-TH/Resources.resw index df9449b9..a3cbf576 100644 --- a/src/Calculator/Resources/th-TH/Resources.resw +++ b/src/Calculator/Resources/th-TH/Resources.resw @@ -901,10 +901,7 @@ วงเล็บเปิด Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - วงเล็บเปิด จำนวนวงเล็บเปิด %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + วงเล็บปิด Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/tr-TR/Resources.resw b/src/Calculator/Resources/tr-TR/Resources.resw index 0e2fa16f..08403c8c 100644 --- a/src/Calculator/Resources/tr-TR/Resources.resw +++ b/src/Calculator/Resources/tr-TR/Resources.resw @@ -901,10 +901,7 @@ Sol parantez Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Sol parantez, parantez sayımını aç %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Sağ parantez Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/uk-UA/Resources.resw b/src/Calculator/Resources/uk-UA/Resources.resw index 332499ac..66d44cb7 100644 --- a/src/Calculator/Resources/uk-UA/Resources.resw +++ b/src/Calculator/Resources/uk-UA/Resources.resw @@ -901,10 +901,7 @@ Ліва кругла дужка Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Ліва кругла дужка, кількість відкривних круглих дужок – %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Права кругла дужка Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/uz-Latn-UZ/Resources.resw b/src/Calculator/Resources/uz-Latn-UZ/Resources.resw index 40d72599..257528d1 100644 --- a/src/Calculator/Resources/uz-Latn-UZ/Resources.resw +++ b/src/Calculator/Resources/uz-Latn-UZ/Resources.resw @@ -901,10 +901,7 @@ Chap qavs Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Chap qavs, ochiq qavslar soni - %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + O‘ng qavs Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/vi-VN/Resources.resw b/src/Calculator/Resources/vi-VN/Resources.resw index c1febc7f..606eba80 100644 --- a/src/Calculator/Resources/vi-VN/Resources.resw +++ b/src/Calculator/Resources/vi-VN/Resources.resw @@ -901,10 +901,7 @@ Dấu ngoặc đơn trái Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - Ngoặc trái, tính ngoặc mở %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + Dấu ngoặc đơn phải Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/zh-CN/Resources.resw b/src/Calculator/Resources/zh-CN/Resources.resw index c64d8e8d..786d6f7d 100644 --- a/src/Calculator/Resources/zh-CN/Resources.resw +++ b/src/Calculator/Resources/zh-CN/Resources.resw @@ -901,10 +901,7 @@ 左括号 Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - 左括号,左开式括号计数 %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + 右括号 Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Resources/zh-TW/Resources.resw b/src/Calculator/Resources/zh-TW/Resources.resw index 2e9708fa..ac0798ad 100644 --- a/src/Calculator/Resources/zh-TW/Resources.resw +++ b/src/Calculator/Resources/zh-TW/Resources.resw @@ -901,10 +901,7 @@ 左括弧 Screen reader prompt for the Calculator "(" button on the scientific operator keypad - - 左括弧,左括弧計數 %1 - {Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific operator keypad. %1 is the localized count of open parenthesis, e.g. "2". - + 右括弧 Screen reader prompt for the Calculator ")" button on the scientific operator keypad diff --git a/src/Calculator/Views/CalculatorProgrammerRadixOperators.xaml b/src/Calculator/Views/CalculatorProgrammerRadixOperators.xaml index 5c84f4f7..06cf0123 100644 --- a/src/Calculator/Views/CalculatorProgrammerRadixOperators.xaml +++ b/src/Calculator/Views/CalculatorProgrammerRadixOperators.xaml @@ -409,10 +409,10 @@ Style="{StaticResource ParenthesisCalcButtonStyle}" FontSize="18" AutomationProperties.AutomationId="openParenthesisButton" - AutomationProperties.Name="{Binding LeftParenthesisAutomationName}" ButtonId="OpenParenthesis" Content="(" - Tag="{x:Bind Model.OpenParenthesisCount, Mode=OneWay}"/> + GotFocus="OpenParenthesisButton_GotFocus" + Tag="{x:Bind ParenthesisCountToString(Model.OpenParenthesisCount), Mode=OneWay}"/> ProgModeRadixChange += ref new ProgModeRadixChangeHandler(this, &CalculatorProgrammerRadixOperators::ProgModeRadixChange); - m_propertyChangedToken = Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &CalculatorProgrammerRadixOperators::OnViewModelPropertyChanged); } void CalculatorProgrammerRadixOperators::OnUnloaded(Object^, RoutedEventArgs^) { Model->ProgModeRadixChange -= m_progModeRadixChangeToken; - Model->PropertyChanged -= m_propertyChangedToken; } void CalculatorProgrammerRadixOperators::Shift_Clicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) @@ -100,10 +98,12 @@ void CalculatorProgrammerRadixOperators::IsErrorVisualState::set(bool value) } } -void CalculatorProgrammerRadixOperators::OnViewModelPropertyChanged(Object^ sender, PropertyChangedEventArgs^ e) -{ - if (e->PropertyName == StandardCalculatorViewModel::OpenParenthesisCountPropertyName && closeParenthesisButton->FocusState != ::FocusState::Unfocused) - { - Model->SetOpenParenthesisCountNarratorAnnouncement(); - } +String^ CalculatorProgrammerRadixOperators::ParenthesisCountToString(unsigned int count) { + return (count == 0) ? ref new String() : ref new String(to_wstring(count).data()); +} + + +void CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators::OpenParenthesisButton_GotFocus(Object^ sender, RoutedEventArgs^ e) +{ + Model->SetOpenParenthesisCountNarratorAnnouncement(); } diff --git a/src/Calculator/Views/CalculatorProgrammerRadixOperators.xaml.h b/src/Calculator/Views/CalculatorProgrammerRadixOperators.xaml.h index 7dd819d0..407fb1a6 100644 --- a/src/Calculator/Views/CalculatorProgrammerRadixOperators.xaml.h +++ b/src/Calculator/Views/CalculatorProgrammerRadixOperators.xaml.h @@ -26,6 +26,7 @@ namespace CalculatorApp bool get(); void set(bool value); } + Platform::String^ ParenthesisCountToString(unsigned int count); DEPENDENCY_PROPERTY_OWNER(CalculatorProgrammerRadixOperators); @@ -35,10 +36,9 @@ namespace CalculatorApp void OnLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void OnUnloaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void ProgModeRadixChange(); - void OnViewModelPropertyChanged(Platform::Object^ sender, Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e); bool m_isErrorVisualState; Windows::Foundation::EventRegistrationToken m_progModeRadixChangeToken; - Windows::Foundation::EventRegistrationToken m_propertyChangedToken; + void OpenParenthesisButton_GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); }; } diff --git a/src/Calculator/Views/CalculatorScientificOperators.xaml b/src/Calculator/Views/CalculatorScientificOperators.xaml index 3db97aa9..1ef614c3 100644 --- a/src/Calculator/Views/CalculatorScientificOperators.xaml +++ b/src/Calculator/Views/CalculatorScientificOperators.xaml @@ -11,8 +11,6 @@ x:Name="ControlRoot" d:DesignHeight="400" d:DesignWidth="315" - Loaded="OnLoaded" - Unloaded="OnUnloaded" mc:Ignorable="d"> @@ -729,10 +727,10 @@ Style="{StaticResource ParenthesisCalcButtonStyle}" FontSize="19" AutomationProperties.AutomationId="openParenthesisButton" - AutomationProperties.Name="{Binding LeftParenthesisAutomationName}" ButtonId="OpenParenthesis" Content="(" - Tag="{x:Bind Model.OpenParenthesisCount, Mode=OneWay}"/> + GotFocus="OpenParenthesisButton_GotFocus" + Tag="{x:Bind ParenthesisCountToString(Model.OpenParenthesisCount), Mode=OneWay}"/> PropertyChanged += ref new PropertyChangedEventHandler(this, &CalculatorScientificOperators::OnViewModelPropertyChanged); -} -void CalculatorScientificOperators::OnUnloaded(Object^, RoutedEventArgs^) -{ - Model->PropertyChanged -= m_propertyChangedToken; -} - void CalculatorScientificOperators::ShortLayout_Completed(_In_ Platform::Object^ /*sender*/, _In_ Platform::Object^ /*e*/) { IsWideLayout = false; @@ -107,10 +99,11 @@ void CalculatorScientificOperators::SetOperatorRowVisibility() InvRow2->Visibility = invRowVis; } -void CalculatorScientificOperators::OnViewModelPropertyChanged(Object^ sender, PropertyChangedEventArgs^ e) +void CalculatorScientificOperators::OpenParenthesisButton_GotFocus(Object^ sender, RoutedEventArgs^ e) { - if (e->PropertyName == StandardCalculatorViewModel::OpenParenthesisCountPropertyName && closeParenthesisButton->FocusState != ::FocusState::Unfocused) - { - Model->SetOpenParenthesisCountNarratorAnnouncement(); - } + Model->SetOpenParenthesisCountNarratorAnnouncement(); +} + +String^ CalculatorScientificOperators::ParenthesisCountToString(unsigned int count) { + return (count == 0) ? ref new String() : ref new String(to_wstring(count).data()); } diff --git a/src/Calculator/Views/CalculatorScientificOperators.xaml.h b/src/Calculator/Views/CalculatorScientificOperators.xaml.h index ec10191c..ebe185ca 100644 --- a/src/Calculator/Views/CalculatorScientificOperators.xaml.h +++ b/src/Calculator/Views/CalculatorScientificOperators.xaml.h @@ -33,7 +33,8 @@ namespace CalculatorApp DEPENDENCY_PROPERTY_WITH_DEFAULT(bool, IsWideLayout, false); bool IsShiftEnabled(bool isWideLayout, bool isErrorState) { return !(isWideLayout || isErrorState); } - + void OpenParenthesisButton_GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + Platform::String^ ParenthesisCountToString(unsigned int count); private: void ShortLayout_Completed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e); void WideLayout_Completed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e); @@ -41,10 +42,5 @@ namespace CalculatorApp void shiftButton_Check(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e); void shiftButton_IsEnabledChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ e); void SetOperatorRowVisibility(); - void OnViewModelPropertyChanged(Platform::Object^ sender, Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e); - void OnLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); - void OnUnloaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); - - Windows::Foundation::EventRegistrationToken m_propertyChangedToken; }; } diff --git a/src/Calculator/pch.h b/src/Calculator/pch.h index b29e1e45..f37ca4bf 100644 --- a/src/Calculator/pch.h +++ b/src/Calculator/pch.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/src/CalculatorUnitTests/CalculatorManagerTest.cpp b/src/CalculatorUnitTests/CalculatorManagerTest.cpp index 14939d34..79e0637e 100644 --- a/src/CalculatorUnitTests/CalculatorManagerTest.cpp +++ b/src/CalculatorUnitTests/CalculatorManagerTest.cpp @@ -57,7 +57,7 @@ namespace CalculatorManagerTest m_memorizedNumberStrings = numbers; } - void SetParenDisplayText(const std::wstring& parenthesisCount) override + void SetParenthesisNumber(unsigned int parenthesisCount) override { m_parenDisplay = parenthesisCount; } @@ -115,7 +115,7 @@ namespace CalculatorManagerTest private: wstring m_primaryDisplay; wstring m_expression; - wstring m_parenDisplay; + unsigned int m_parenDisplay; bool m_isError; vector m_memorizedNumberStrings; int m_maxDigitsCalledCount; From 5a6c6f427464fb6a53d7caa0a9879fb3ba61aa39 Mon Sep 17 00:00:00 2001 From: Rudy Huyn Date: Mon, 15 Apr 2019 09:51:06 -0700 Subject: [PATCH 03/23] Prevent the application to crash when the current page is Date Calculation and users paste a text (#391) Fix the else condition in ApplicationViewModel::OnPaste How changes were validated: Manually Fixes #389 --- src/CalcViewModel/ApplicationViewModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CalcViewModel/ApplicationViewModel.cpp b/src/CalcViewModel/ApplicationViewModel.cpp index f99ce036..358589b5 100644 --- a/src/CalcViewModel/ApplicationViewModel.cpp +++ b/src/CalcViewModel/ApplicationViewModel.cpp @@ -189,7 +189,7 @@ void ApplicationViewModel::OnPasteCommand(Object^ parameter) { ConverterViewModel->OnPasteCommand(parameter); } - else + else if (NavCategory::IsCalculatorViewMode(m_mode)) { CalculatorViewModel->OnPasteCommand(parameter); } From 775771d62a664230edc16d964bc71ea462190f92 Mon Sep 17 00:00:00 2001 From: Matt Cooley Date: Mon, 15 Apr 2019 14:12:10 -0700 Subject: [PATCH 04/23] Internal builds now require the OAuth access token (#457) --- .../prepare-release-internalonly.yaml | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/build/pipelines/templates/prepare-release-internalonly.yaml b/build/pipelines/templates/prepare-release-internalonly.yaml index 363ca049..a6a4973b 100644 --- a/build/pipelines/templates/prepare-release-internalonly.yaml +++ b/build/pipelines/templates/prepare-release-internalonly.yaml @@ -28,8 +28,8 @@ jobs: - task: PkgESSetupBuild@10 displayName: Initialize Package ES inputs: - productName: Calculator - disableWorkspace: true + productName: Calculator + disableWorkspace: true env: XES_DISABLEPROV: true @@ -46,6 +46,8 @@ jobs: - task: PkgESCodeSign@10 displayName: Send bundle to Package ES code signing service + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) inputs: signConfigXml: build\config\SignConfig.xml inPathRoot: $(Build.ArtifactStagingDirectory)\appxBundle @@ -60,25 +62,25 @@ jobs: - task: CopyFiles@2 displayName: Copy signed AppxBundle to vpack staging folder inputs: - sourceFolder: $(Build.ArtifactStagingDirectory)\appxBundleSigned - targetFolder: $(Build.ArtifactStagingDirectory)\vpack\appxBundle + sourceFolder: $(Build.ArtifactStagingDirectory)\appxBundleSigned + targetFolder: $(Build.ArtifactStagingDirectory)\vpack\appxBundle - task: PkgESVPack@10 displayName: Create and push vpack for app env: - SYSTEM_ACCESSTOKEN: $(System.AccessToken) + SYSTEM_ACCESSTOKEN: $(System.AccessToken) inputs: - sourceDirectory: $(Build.ArtifactStagingDirectory)\vpack\appxBundle - description: VPack for the Calculator Application - pushPkgName: calculator.app - version: $(versionMajor).$(versionMinor).$(versionBuild) - owner: paxeeapps + sourceDirectory: $(Build.ArtifactStagingDirectory)\vpack\appxBundle + description: VPack for the Calculator Application + pushPkgName: calculator.app + version: $(versionMajor).$(versionMinor).$(versionBuild) + owner: paxeeapps - task: PublishBuildArtifacts@1 displayName: Publish vpack\app artifact with vpack manifest inputs: - pathtoPublish: $(XES_VPACKMANIFESTDIRECTORY)\$(XES_VPACKMANIFESTNAME) - artifactName: vpack\app + pathtoPublish: $(XES_VPACKMANIFESTDIRECTORY)\$(XES_VPACKMANIFESTNAME) + artifactName: vpack\app # TODO (macool): create and push internal test packages and test config From ad25feda6bfac4b4779b92500b01d341931dcbb0 Mon Sep 17 00:00:00 2001 From: Rudy Huyn Date: Tue, 16 Apr 2019 11:29:43 -0700 Subject: [PATCH 05/23] Keep input when users refresh currency rates (#369) Fixes #260 Description of the changes: prevent UnitConverterViewModel to reset values when users click on update rates. recompute UnitConverter's caches (m_ratioMap and m_categoryToUnits) once rates are updated (but check first if the user did/didn't change the category) How changes were validated: Manually tested with fake currency rates (HTTP responses modified on the fly via FiddlerCore) Verified that it works no matter the selected field (From or To) Verified that the currencies selected are kept after a refresh --- src/CalcManager/UnitConverter.cpp | 41 +++++++++++-------- src/CalcManager/UnitConverter.h | 8 ++-- src/CalcViewModel/UnitConverterViewModel.cpp | 12 ++++-- src/CalcViewModel/UnitConverterViewModel.h | 2 + .../UnitConverterViewModelUnitTests.h | 5 ++- 5 files changed, 43 insertions(+), 25 deletions(-) diff --git a/src/CalcManager/UnitConverter.cpp b/src/CalcManager/UnitConverter.cpp index 0548719a..718e47f4 100644 --- a/src/CalcManager/UnitConverter.cpp +++ b/src/CalcManager/UnitConverter.cpp @@ -63,7 +63,8 @@ UnitConverter::UnitConverter(_In_ const shared_ptr& dataLo unquoteConversions[L"{sc}"] = L';'; unquoteConversions[L"{lb}"] = LEFTESCAPECHAR; unquoteConversions[L"{rb}"] = RIGHTESCAPECHAR; - Reset(); + ClearValues(); + ResetCategoriesAndRatios(); } void UnitConverter::Initialize() @@ -75,7 +76,7 @@ bool UnitConverter::CheckLoad() { if (m_categories.empty()) { - Reset(); + ResetCategoriesAndRatios(); } return !m_categories.empty(); } @@ -152,7 +153,6 @@ void UnitConverter::SetCurrentUnitTypes(const Unit& fromType, const Unit& toType Calculate(); UpdateCurrencySymbols(); - UpdateViewModel(); } /// @@ -336,7 +336,8 @@ wstring UnitConverter::Serialize() /// wstring holding the serialized data. If it does not have expected number of parameters, we will ignore it void UnitConverter::DeSerialize(const wstring& serializedData) { - Reset(); + ClearValues(); + ResetCategoriesAndRatios(); if (serializedData.empty()) { @@ -615,7 +616,7 @@ void UnitConverter::SendCommand(Command command) clearFront = false; clearBack = false; ClearValues(); - Reset(); + ResetCategoriesAndRatios(); break; default: @@ -634,8 +635,6 @@ void UnitConverter::SendCommand(Command command) } Calculate(); - - UpdateViewModel(); } /// @@ -824,19 +823,16 @@ vector> UnitConverter::CalculateSuggested() returnVector.push_back(whimsicalReturnVector.at(0)); } - // - return returnVector; } /// -/// Resets the converter to its initial state +/// Resets categories and ratios /// -void UnitConverter::Reset() +void UnitConverter::ResetCategoriesAndRatios() { m_categories = m_dataLoader->LoadOrderedCategories(); - ClearValues(); m_switchedActive = false; if (m_categories.empty()) @@ -881,7 +877,6 @@ void UnitConverter::Reset() } InitializeSelectedUnits(); - Calculate(); } /// @@ -972,11 +967,21 @@ bool UnitConverter::AnyUnitIsEmpty() /// void UnitConverter::Calculate() { - unordered_map conversionTable = m_ratioMap[m_fromType]; - double returnValue = stod(m_currentDisplay); - if (AnyUnitIsEmpty() || (conversionTable[m_toType].ratio == 1.0 && conversionTable[m_toType].offset == 0.0)) + if (AnyUnitIsEmpty()) { m_returnDisplay = m_currentDisplay; + m_returnHasDecimal = m_currentHasDecimal; + TrimString(m_returnDisplay); + UpdateViewModel(); + return; + } + + unordered_map conversionTable = m_ratioMap[m_fromType]; + double returnValue = stod(m_currentDisplay); + if (conversionTable[m_toType].ratio == 1.0 && conversionTable[m_toType].offset == 0.0) + { + m_returnDisplay = m_currentDisplay; + m_returnHasDecimal = m_currentHasDecimal; TrimString(m_returnDisplay); } else @@ -1015,9 +1020,9 @@ void UnitConverter::Calculate() m_returnDisplay = returnString; TrimString(m_returnDisplay); } + m_returnHasDecimal = (m_returnDisplay.find(L'.') != m_returnDisplay.npos); } - - m_returnHasDecimal = (m_returnDisplay.find(L'.') != m_returnDisplay.npos); + UpdateViewModel(); } /// diff --git a/src/CalcManager/UnitConverter.h b/src/CalcManager/UnitConverter.h index 4e130d12..010216f0 100644 --- a/src/CalcManager/UnitConverter.h +++ b/src/CalcManager/UnitConverter.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once @@ -195,6 +195,8 @@ namespace UnitConversionManager virtual void SetViewModelCallback(_In_ const std::shared_ptr& newCallback) = 0; virtual void SetViewModelCurrencyCallback(_In_ const std::shared_ptr& newCallback) = 0; virtual concurrency::task> RefreshCurrencyRatios() = 0; + virtual void Calculate() = 0; + virtual void ResetCategoriesAndRatios() = 0; }; class UnitConverter : public IUnitConverter, public std::enable_shared_from_this @@ -218,6 +220,8 @@ namespace UnitConversionManager void SetViewModelCallback(_In_ const std::shared_ptr& newCallback) override; void SetViewModelCurrencyCallback(_In_ const std::shared_ptr& newCallback) override; concurrency::task> RefreshCurrencyRatios() override; + void Calculate() override; + void ResetCategoriesAndRatios() override; // IUnitConverter static std::vector StringToVector(const std::wstring& w, const wchar_t * delimiter, bool addRemainder = false); @@ -228,9 +232,7 @@ namespace UnitConversionManager bool CheckLoad(); double Convert(double value, ConversionData conversionData); std::vector> CalculateSuggested(); - void Reset(); void ClearValues(); - void Calculate(); void TrimString(std::wstring& input); void InitializeSelectedUnits(); std::wstring RoundSignificant(double num, int numSignificant); diff --git a/src/CalcViewModel/UnitConverterViewModel.cpp b/src/CalcViewModel/UnitConverterViewModel.cpp index 76d9aa3a..446ae582 100644 --- a/src/CalcViewModel/UnitConverterViewModel.cpp +++ b/src/CalcViewModel/UnitConverterViewModel.cpp @@ -165,12 +165,16 @@ void UnitConverterViewModel::PopulateData() } void UnitConverterViewModel::OnCategoryChanged(Object^ parameter) +{ + m_model->SendCommand(UCM::Command::Clear); + ResetCategory(); +} + +void UnitConverterViewModel::ResetCategory() { UCM::Category currentCategory = CurrentCategory->GetModelCategory(); IsCurrencyCurrentCategory = currentCategory.id == NavCategory::Serialize(ViewMode::Currency); - m_model->SendCommand(UCM::Command::Clear); - m_isInputBlocked = false; SetSelectedUnits(); @@ -706,7 +710,9 @@ void UnitConverterViewModel::OnCurrencyDataLoadFinished(bool didLoad) { m_isCurrencyDataLoaded = true; CurrencyDataLoadFailed = !didLoad; - ResetView(); + m_model->ResetCategoriesAndRatios(); + m_model->Calculate(); + ResetCategory(); StringReference key = didLoad ? UnitConverterResourceKeys::CurrencyRatesUpdated : UnitConverterResourceKeys::CurrencyRatesUpdateFailed; String^ announcement = AppResourceProvider::GetInstance().GetResourceString(key); diff --git a/src/CalcViewModel/UnitConverterViewModel.h b/src/CalcViewModel/UnitConverterViewModel.h index 5a982384..2c6c8af3 100644 --- a/src/CalcViewModel/UnitConverterViewModel.h +++ b/src/CalcViewModel/UnitConverterViewModel.h @@ -223,6 +223,7 @@ namespace CalculatorApp void UpdateValue2AutomationName(); Platform::String^ Serialize(); void Deserialize(Platform::String^ state); + void ResetCategoriesAndRatio(); // Saving And Restoring User Preferences of Category and Associated-Units across Sessions. void SaveUserPreferences(); @@ -263,6 +264,7 @@ namespace CalculatorApp void RefreshSupplementaryResults(); void UpdateInputBlocked(_In_ const std::wstring& currencyInput); bool UnitsAreValid(); + void ResetCategory(); void OnButtonPressed(Platform::Object^ parameter); Platform::String^ ConvertToLocalizedString(const std::wstring& stringToLocalize, bool allowPartialStrings); diff --git a/src/CalculatorUnitTests/UnitConverterViewModelUnitTests.h b/src/CalculatorUnitTests/UnitConverterViewModelUnitTests.h index 1e1b57c8..903fd074 100644 --- a/src/CalculatorUnitTests/UnitConverterViewModelUnitTests.h +++ b/src/CalculatorUnitTests/UnitConverterViewModelUnitTests.h @@ -42,11 +42,14 @@ namespace CalculatorUnitTests void SendCommand(UCM::Command command) override; void SetViewModelCallback(const std::shared_ptr& newCallback) override; void SetViewModelCurrencyCallback(_In_ const std::shared_ptr& /*newCallback*/) override {} + void Calculate() override {} + void ResetCategoriesAndRatios() override{} concurrency::task> RefreshCurrencyRatios() override { - co_return std::make_pair(L"", L""); + co_return std::make_pair(true, L""); } + UINT m_initCallCount; UINT m_getCategoriesCallCount; UINT m_setCurrentCategoryCallCount; From 7a7ceb58882828096cac87494f5a1ffb5359e212 Mon Sep 17 00:00:00 2001 From: Rudy Huyn Date: Tue, 16 Apr 2019 17:17:24 -0700 Subject: [PATCH 06/23] Modify how modulo is calculated in Normal and Scientific mode. (#412) ## Fixes #111 > The modulo operator on this calculator gives the result that is different to the most used calculators. The current `modrate` function is the equivalent of rem(...)/remainder(...), not mod(...)/modulo(...) available in some popular Math apps. ### Description of the changes: - rename `modrate` in `remrate` to be more accurate. - add `modrate`, calculating modulo similarly to Matlab, Bing, Google calculator, Maxima, Wolfram Alpha and Microsoft Excel - Add `RationalMath::Mod` using `modrate` as an alternative to `Rational::operator%` using `remrate` - Add a helper `SIGN` to retrieve the sign of a `Rational`. - modify `CalcEngine` to use `modrate` in Normal and Scientific mode and `remrate` in Programmer mode. ### How changes were validated: - manually and unit tests added --- src/CalcManager/CEngine/Rational.cpp | 15 +- src/CalcManager/CEngine/RationalMath.cpp | 30 +++ src/CalcManager/CEngine/scioper.cpp | 28 ++- src/CalcManager/Header Files/CalcEngine.h | 4 +- src/CalcManager/Header Files/RationalMath.h | 1 + src/CalcManager/Ratpack/exp.cpp | 2 +- src/CalcManager/Ratpack/fact.cpp | 4 +- src/CalcManager/Ratpack/itrans.cpp | 14 +- src/CalcManager/Ratpack/logic.cpp | 186 +++++++++------ src/CalcManager/Ratpack/ratpak.h | 6 +- src/CalcManager/Ratpack/support.cpp | 16 +- src/CalculatorUnitTests/CalcEngineTests.cpp | 2 +- src/CalculatorUnitTests/CalcInputTest.cpp | 2 +- .../CalculatorUnitTests.vcxproj | 1 + .../CalculatorUnitTests.vcxproj.filters | 1 + src/CalculatorUnitTests/RationalTest.cpp | 225 ++++++++++++++++++ 16 files changed, 429 insertions(+), 108 deletions(-) create mode 100644 src/CalculatorUnitTests/RationalTest.cpp diff --git a/src/CalcManager/CEngine/Rational.cpp b/src/CalcManager/CEngine/Rational.cpp index fd86b72a..c93c79a6 100644 --- a/src/CalcManager/CEngine/Rational.cpp +++ b/src/CalcManager/CEngine/Rational.cpp @@ -182,6 +182,13 @@ namespace CalcEngine return *this; } + /// + /// Calculate the remainder after division, the sign of a result will match the sign of the current object. + /// + /// + /// This function has the same behavior as the standard C/C++ operator '%' + /// to calculate the modulus after division instead, use instead. + /// Rational& Rational::operator%=(Rational const& rhs) { PRAT lhsRat = this->ToPRAT(); @@ -189,7 +196,7 @@ namespace CalcEngine try { - modrat(&lhsRat, rhsRat); + remrat(&lhsRat, rhsRat); destroyrat(rhsRat); } catch (uint32_t error) @@ -342,6 +349,12 @@ namespace CalcEngine return lhs; } + /// + /// Calculate the remainder after division, the sign of a result will match the sign of lhs. + /// + /// + /// This function has the same behavior as the standard C/C++ operator '%', to calculate the modulus after division instead, use instead. + /// Rational operator%(Rational lhs, Rational const& rhs) { lhs %= rhs; diff --git a/src/CalcManager/CEngine/RationalMath.cpp b/src/CalcManager/CEngine/RationalMath.cpp index 37dc7926..f5de74fc 100644 --- a/src/CalcManager/CEngine/RationalMath.cpp +++ b/src/CalcManager/CEngine/RationalMath.cpp @@ -387,3 +387,33 @@ Rational RationalMath::ATanh(Rational const& rat) return result; } + +/// +/// Calculate the modulus after division, the sign of the result will match the sign of b. +/// +/// +/// When one of the operand is negative +/// the result will differ from the C/C++ operator '%' +/// use instead to calculate the remainder after division. +/// +Rational RationalMath::Mod(Rational const& a, Rational const& b) +{ + PRAT prat = a.ToPRAT(); + PRAT pn = b.ToPRAT(); + + try + { + modrat(&prat, pn); + destroyrat(pn); + } + catch (uint32_t error) + { + destroyrat(prat); + destroyrat(pn); + throw(error); + } + + auto res = Rational{ prat }; + destroyrat(prat); + return res; +} diff --git a/src/CalcManager/CEngine/scioper.cpp b/src/CalcManager/CEngine/scioper.cpp index b09083c4..9ced7021 100644 --- a/src/CalcManager/CEngine/scioper.cpp +++ b/src/CalcManager/CEngine/scioper.cpp @@ -78,7 +78,7 @@ CalcEngine::Rational CCalcEngine::DoOperation(int operation, CalcEngine::Rationa case IDC_DIV: case IDC_MOD: { - int iNumeratorSign = 1, iDenominatorSign = 1, iFinalSign = 1; + int iNumeratorSign = 1, iDenominatorSign = 1; auto temp = result; result = rhs; @@ -107,20 +107,30 @@ CalcEngine::Rational CCalcEngine::DoOperation(int operation, CalcEngine::Rationa if (operation == IDC_DIV) { - iFinalSign = iNumeratorSign * iDenominatorSign; result /= temp; + if (m_fIntegerMode && (iNumeratorSign * iDenominatorSign) == -1) + { + result = -(Integer(result)); + } } else { - iFinalSign = iNumeratorSign; - result %= temp; - } + if (m_fIntegerMode) + { + // Programmer mode, use remrat (remainder after division) + result %= temp; - if (m_fIntegerMode && iFinalSign == -1) - { - result = -(Integer(result)); + if (iNumeratorSign == -1) + { + result = -(Integer(result)); + } + } + else + { + //other modes, use modrat (modulus after division) + result = Mod(result, temp); + } } - break; } diff --git a/src/CalcManager/Header Files/CalcEngine.h b/src/CalcManager/Header Files/CalcEngine.h index db906e51..c84f2d55 100644 --- a/src/CalcManager/Header Files/CalcEngine.h +++ b/src/CalcManager/Header Files/CalcEngine.h @@ -45,7 +45,7 @@ namespace CalculationManager class IResourceProvider; } -namespace CalculatorUnitTests +namespace CalculatorEngineTests { class CalcEngineTests; } @@ -160,5 +160,5 @@ private: static void ChangeBaseConstants(uint32_t radix, int maxIntDigits, int32_t precision); void BaseOrPrecisionChanged(); - friend class CalculatorUnitTests::CalcEngineTests; + friend class CalculatorEngineTests::CalcEngineTests; }; diff --git a/src/CalcManager/Header Files/RationalMath.h b/src/CalcManager/Header Files/RationalMath.h index b52c1c5f..59500573 100644 --- a/src/CalcManager/Header Files/RationalMath.h +++ b/src/CalcManager/Header Files/RationalMath.h @@ -13,6 +13,7 @@ namespace CalcEngine::RationalMath Rational Pow(Rational const& base, Rational const& pow); Rational Root(Rational const& base, Rational const& root); Rational Fact(Rational const& rat); + Rational Mod(Rational const& a, Rational const& b); Rational Exp(Rational const& rat); Rational Log(Rational const& rat); diff --git a/src/CalcManager/Ratpack/exp.cpp b/src/CalcManager/Ratpack/exp.cpp index c8691cfa..95637404 100644 --- a/src/CalcManager/Ratpack/exp.cpp +++ b/src/CalcManager/Ratpack/exp.cpp @@ -408,7 +408,7 @@ void powratNumeratorDenominator(PRAT *px, PRAT y, uint32_t radix, int32_t precis //--------------------------------------------------------------------------- void powratcomp(PRAT *px, PRAT y, uint32_t radix, int32_t precision) { - int32_t sign = ((*px)->pp->sign * (*px)->pq->sign); + int32_t sign = SIGN(*px); // Take the absolute value (*px)->pp->sign = 1; diff --git a/src/CalcManager/Ratpack/fact.cpp b/src/CalcManager/Ratpack/fact.cpp index c974b005..276151ae 100644 --- a/src/CalcManager/Ratpack/fact.cpp +++ b/src/CalcManager/Ratpack/fact.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. //----------------------------------------------------------------------------- @@ -216,7 +216,7 @@ void factrat( PRAT *px, uint32_t radix, int32_t precision) // Check for negative integers and throw an error. if ( ( zerrat(frac) || ( LOGRATRADIX(frac) <= -precision) ) && - ( (*px)->pp->sign * (*px)->pq->sign == -1 ) ) + ( SIGN(*px) == -1 ) ) { throw CALC_E_DOMAIN; } diff --git a/src/CalcManager/Ratpack/itrans.cpp b/src/CalcManager/Ratpack/itrans.cpp index 1ecbf4a1..0d2a297e 100644 --- a/src/CalcManager/Ratpack/itrans.cpp +++ b/src/CalcManager/Ratpack/itrans.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. //----------------------------------------------------------------------------- @@ -92,11 +92,9 @@ void asinanglerat( _Inout_ PRAT *pa, ANGLE_TYPE angletype, uint32_t radix, int32 void asinrat( PRAT *px, uint32_t radix, int32_t precision) { - int32_t sgn; PRAT pret= nullptr; PRAT phack= nullptr; - - sgn = (*px)->pp->sign* (*px)->pq->sign; + int32_t sgn = SIGN(*px); (*px)->pp->sign = 1; (*px)->pq->sign = 1; @@ -204,9 +202,7 @@ void _acosrat( PRAT *px, int32_t precision) void acosrat( PRAT *px, uint32_t radix, int32_t precision) { - int32_t sgn; - - sgn = (*px)->pp->sign*(*px)->pq->sign; + int32_t sgn = SIGN(*px); (*px)->pp->sign = 1; (*px)->pq->sign = 1; @@ -291,10 +287,8 @@ void _atanrat( PRAT *px, int32_t precision) void atanrat( PRAT *px, uint32_t radix, int32_t precision) { - int32_t sgn; PRAT tmpx= nullptr; - - sgn = (*px)->pp->sign * (*px)->pq->sign; + int32_t sgn = SIGN(*px); (*px)->pp->sign = 1; (*px)->pq->sign = 1; diff --git a/src/CalcManager/Ratpack/logic.cpp b/src/CalcManager/Ratpack/logic.cpp index c7f8a3a3..6444898e 100644 --- a/src/CalcManager/Ratpack/logic.cpp +++ b/src/CalcManager/Ratpack/logic.cpp @@ -18,54 +18,54 @@ using namespace std; -void lshrat( PRAT *pa, PRAT b, uint32_t radix, int32_t precision) +void lshrat(PRAT *pa, PRAT b, uint32_t radix, int32_t precision) { - PRAT pwr= nullptr; + PRAT pwr = nullptr; int32_t intb; intrat(pa, radix, precision); - if ( !zernum( (*pa)->pp ) ) - { + if (!zernum((*pa)->pp)) + { // If input is zero we're done. - if ( rat_gt( b, rat_max_exp, precision) ) - { + if (rat_gt(b, rat_max_exp, precision)) + { // Don't attempt lsh of anything big - throw( CALC_E_DOMAIN ); - } + throw(CALC_E_DOMAIN); + } intb = rattoi32(b, radix, precision); - DUPRAT(pwr,rat_two); + DUPRAT(pwr, rat_two); ratpowi32(&pwr, intb, precision); mulrat(pa, pwr, precision); destroyrat(pwr); - } + } } -void rshrat( PRAT *pa, PRAT b, uint32_t radix, int32_t precision) +void rshrat(PRAT *pa, PRAT b, uint32_t radix, int32_t precision) { - PRAT pwr= nullptr; + PRAT pwr = nullptr; int32_t intb; intrat(pa, radix, precision); - if ( !zernum( (*pa)->pp ) ) - { + if (!zernum((*pa)->pp)) + { // If input is zero we're done. - if ( rat_lt( b, rat_min_exp, precision) ) - { + if (rat_lt(b, rat_min_exp, precision)) + { // Don't attempt rsh of anything big and negative. - throw( CALC_E_DOMAIN ); - } + throw(CALC_E_DOMAIN); + } intb = rattoi32(b, radix, precision); - DUPRAT(pwr,rat_two); + DUPRAT(pwr, rat_two); ratpowi32(&pwr, intb, precision); divrat(pa, pwr, precision); destroyrat(pwr); - } + } } -void boolrat( PRAT *pa, PRAT b, int func, uint32_t radix, int32_t precision); -void boolnum( PNUMBER *pa, PNUMBER b, int func ); +void boolrat(PRAT *pa, PRAT b, int func, uint32_t radix, int32_t precision); +void boolnum(PNUMBER *pa, PNUMBER b, int func); enum { @@ -74,22 +74,22 @@ enum { FUNC_XOR } BOOL_FUNCS; -void andrat( PRAT *pa, PRAT b, uint32_t radix, int32_t precision) +void andrat(PRAT *pa, PRAT b, uint32_t radix, int32_t precision) { - boolrat( pa, b, FUNC_AND, radix, precision); + boolrat(pa, b, FUNC_AND, radix, precision); } -void orrat( PRAT *pa, PRAT b, uint32_t radix, int32_t precision) +void orrat(PRAT *pa, PRAT b, uint32_t radix, int32_t precision) { - boolrat( pa, b, FUNC_OR, radix, precision); + boolrat(pa, b, FUNC_OR, radix, precision); } -void xorrat( PRAT *pa, PRAT b, uint32_t radix, int32_t precision) +void xorrat(PRAT *pa, PRAT b, uint32_t radix, int32_t precision) { - boolrat( pa, b, FUNC_XOR, radix, precision); + boolrat(pa, b, FUNC_XOR, radix, precision); } //--------------------------------------------------------------------------- @@ -104,15 +104,15 @@ void xorrat( PRAT *pa, PRAT b, uint32_t radix, int32_t precision) // //--------------------------------------------------------------------------- -void boolrat( PRAT *pa, PRAT b, int func, uint32_t radix, int32_t precision) +void boolrat(PRAT *pa, PRAT b, int func, uint32_t radix, int32_t precision) { - PRAT tmp= nullptr; - intrat( pa, radix, precision); - DUPRAT(tmp,b); - intrat( &tmp, radix, precision); + PRAT tmp = nullptr; + intrat(pa, radix, precision); + DUPRAT(tmp, b); + intrat(&tmp, radix, precision); - boolnum( &((*pa)->pp), tmp->pp, func ); + boolnum(&((*pa)->pp), tmp->pp, func); destroyrat(tmp); } @@ -130,11 +130,11 @@ void boolrat( PRAT *pa, PRAT b, int func, uint32_t radix, int32_t precision) // //--------------------------------------------------------------------------- -void boolnum( PNUMBER *pa, PNUMBER b, int func ) +void boolnum(PNUMBER *pa, PNUMBER b, int func) { - PNUMBER c= nullptr; - PNUMBER a= nullptr; + PNUMBER c = nullptr; + PNUMBER a = nullptr; MANTTYPE *pcha; MANTTYPE *pchb; MANTTYPE *pchc; @@ -143,26 +143,26 @@ void boolnum( PNUMBER *pa, PNUMBER b, int func ) MANTTYPE da; MANTTYPE db; - a=*pa; - cdigits = max( a->cdigit+a->exp, b->cdigit+b->exp ) - - min( a->exp, b->exp ); - createnum( c, cdigits ); - c->exp = min( a->exp, b->exp ); + a = *pa; + cdigits = max(a->cdigit + a->exp, b->cdigit + b->exp) - + min(a->exp, b->exp); + createnum(c, cdigits); + c->exp = min(a->exp, b->exp); mexp = c->exp; c->cdigit = cdigits; pcha = a->mant; pchb = b->mant; pchc = c->mant; - for ( ;cdigits > 0; cdigits--, mexp++ ) + for (; cdigits > 0; cdigits--, mexp++) + { + da = (((mexp >= a->exp) && (cdigits + a->exp - c->exp > + (c->cdigit - a->cdigit))) ? + *pcha++ : 0); + db = (((mexp >= b->exp) && (cdigits + b->exp - c->exp > + (c->cdigit - b->cdigit))) ? + *pchb++ : 0); + switch (func) { - da = ( ( ( mexp >= a->exp ) && ( cdigits + a->exp - c->exp > - (c->cdigit - a->cdigit) ) ) ? - *pcha++ : 0 ); - db = ( ( ( mexp >= b->exp ) && ( cdigits + b->exp - c->exp > - (c->cdigit - b->cdigit) ) ) ? - *pchb++ : 0 ); - switch ( func ) - { case FUNC_AND: *pchc++ = da & db; break; @@ -172,15 +172,51 @@ void boolnum( PNUMBER *pa, PNUMBER b, int func ) case FUNC_XOR: *pchc++ = da ^ db; break; - } } + } c->sign = a->sign; - while ( c->cdigit > 1 && *(--pchc) == 0 ) - { + while (c->cdigit > 1 && *(--pchc) == 0) + { c->cdigit--; - } - destroynum( *pa ); - *pa=c; + } + destroynum(*pa); + *pa = c; +} + +//----------------------------------------------------------------------------- +// +// FUNCTION: remrat +// +// ARGUMENTS: pointer to a rational a second rational. +// +// RETURN: None, changes pointer. +// +// DESCRIPTION: Calculate the remainder of *pa / b, +// equivalent of 'pa % b' in C/C++ and produces a result +// that is either zero or has the same sign as the dividend. +// +//----------------------------------------------------------------------------- + +void remrat(PRAT *pa, PRAT b) + +{ + if (zerrat(b)) + { + throw CALC_E_INDEFINITE; + } + + PRAT tmp = nullptr; + DUPRAT(tmp, b); + + mulnumx(&((*pa)->pp), tmp->pq); + mulnumx(&(tmp->pp), (*pa)->pq); + remnum(&((*pa)->pp), tmp->pp, BASEX); + mulnumx(&((*pa)->pq), tmp->pq); + + // Get *pa back in the integer over integer form. + RENORMALIZE(*pa); + + destroyrat(tmp); } //----------------------------------------------------------------------------- @@ -191,28 +227,38 @@ void boolnum( PNUMBER *pa, PNUMBER b, int func ) // // RETURN: None, changes pointer. // -// DESCRIPTION: Does the rational equivalent of frac(*pa); +// DESCRIPTION: Calculate the remainder of *pa / b, with the sign of the result +// either zero or has the same sign as the divisor. +// NOTE: When *pa or b are negative, the result won't be the same as +// the C/C++ operator %, use remrat if it's the behavior you expect. // //----------------------------------------------------------------------------- -void modrat( PRAT *pa, PRAT b ) - +void modrat(PRAT *pa, PRAT b) { + //contrary to remrat(X, 0) returning 0, modrat(X, 0) must return X + if (zerrat(b)) + { + return; + } + PRAT tmp = nullptr; + DUPRAT(tmp, b); - if ( zerrat( b ) ) - { - throw CALC_E_INDEFINITE; - } - DUPRAT(tmp,b); + auto needAdjust = (SIGN(*pa) == -1 ? (SIGN(b) == 1) : (SIGN(b) == -1)); - mulnumx( &((*pa)->pp), tmp->pq ); - mulnumx( &(tmp->pp), (*pa)->pq ); - remnum( &((*pa)->pp), tmp->pp, BASEX ); - mulnumx( &((*pa)->pq), tmp->pq ); + mulnumx(&((*pa)->pp), tmp->pq); + mulnumx(&(tmp->pp), (*pa)->pq); + remnum(&((*pa)->pp), tmp->pp, BASEX); + mulnumx(&((*pa)->pq), tmp->pq); + + if (needAdjust && !zerrat(*pa)) + { + addrat(pa, b, BASEX); + } // Get *pa back in the integer over integer form. RENORMALIZE(*pa); - destroyrat( tmp ); + destroyrat(tmp); } diff --git a/src/CalcManager/Ratpack/ratpak.h b/src/CalcManager/Ratpack/ratpak.h index 75ac28de..d9bc11ce 100644 --- a/src/CalcManager/Ratpack/ratpak.h +++ b/src/CalcManager/Ratpack/ratpak.h @@ -148,6 +148,9 @@ extern PRAT rat_min_i32; #define LOGNUM2(pnum) ((pnum)->cdigit+(pnum)->exp) #define LOGRAT2(prat) (LOGNUM2((prat)->pp)-LOGNUM2((prat)->pq)) +// SIGN returns the sign of the rational +#define SIGN(prat) ((prat)->pp->sign*(prat)->pq->sign) + #if defined( DEBUG_RATPAK ) //----------------------------------------------------------------------------- // @@ -423,7 +426,8 @@ extern void divnumx( _Inout_ PNUMBER *pa, _In_ PNUMBER b, int32_t precision); extern void divrat( _Inout_ PRAT *pa, _In_ PRAT b, int32_t precision); extern void fracrat( _Inout_ PRAT *pa , uint32_t radix, int32_t precision); extern void factrat( _Inout_ PRAT *pa, uint32_t radix, int32_t precision); -extern void modrat( _Inout_ PRAT *pa, _In_ PRAT b ); +extern void remrat(_Inout_ PRAT *pa, _In_ PRAT b); +extern void modrat(_Inout_ PRAT *pa, _In_ PRAT b); extern void gcdrat( _Inout_ PRAT *pa, int32_t precision); extern void intrat( _Inout_ PRAT *px, uint32_t radix, int32_t precision); extern void mulnum( _Inout_ PNUMBER *pa, _In_ PNUMBER b, uint32_t radix); diff --git a/src/CalcManager/Ratpack/support.cpp b/src/CalcManager/Ratpack/support.cpp index ebee00c6..22683b4c 100644 --- a/src/CalcManager/Ratpack/support.cpp +++ b/src/CalcManager/Ratpack/support.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. //---------------------------------------------------------------------------- @@ -296,7 +296,7 @@ void intrat( PRAT *px, uint32_t radix, int32_t precision) // Subtract the fractional part of the rational PRAT pret = nullptr; DUPRAT(pret,*px); - modrat( &pret, rat_one ); + remrat( &pret, rat_one ); subrat( px, pret, precision); destroyrat( pret ); @@ -348,8 +348,7 @@ bool rat_ge( PRAT a, PRAT b, int32_t precision) b->pp->sign *= -1; addrat( &rattmp, b, precision); b->pp->sign *= -1; - bool bret = ( zernum( rattmp->pp ) || - rattmp->pp->sign * rattmp->pq->sign == 1 ); + bool bret = ( zernum( rattmp->pp ) || SIGN(rattmp) == 1 ); destroyrat( rattmp ); return( bret ); } @@ -374,8 +373,7 @@ bool rat_gt( PRAT a, PRAT b, int32_t precision) b->pp->sign *= -1; addrat( &rattmp, b, precision); b->pp->sign *= -1; - bool bret = ( !zernum( rattmp->pp ) && - rattmp->pp->sign * rattmp->pq->sign == 1 ); + bool bret = ( !zernum( rattmp->pp ) && SIGN(rattmp) == 1 ); destroyrat( rattmp ); return( bret ); } @@ -400,8 +398,7 @@ bool rat_le( PRAT a, PRAT b, int32_t precision) b->pp->sign *= -1; addrat( &rattmp, b, precision); b->pp->sign *= -1; - bool bret = ( zernum( rattmp->pp ) || - rattmp->pp->sign * rattmp->pq->sign == -1 ); + bool bret = ( zernum( rattmp->pp ) || SIGN(rattmp) == -1 ); destroyrat( rattmp ); return( bret ); } @@ -426,8 +423,7 @@ bool rat_lt( PRAT a, PRAT b, int32_t precision) b->pp->sign *= -1; addrat( &rattmp, b, precision); b->pp->sign *= -1; - bool bret = ( !zernum( rattmp->pp ) && - rattmp->pp->sign * rattmp->pq->sign == -1 ); + bool bret = ( !zernum( rattmp->pp ) && SIGN(rattmp) == -1 ); destroyrat( rattmp ); return( bret ); } diff --git a/src/CalculatorUnitTests/CalcEngineTests.cpp b/src/CalculatorUnitTests/CalcEngineTests.cpp index d572a442..9109c8d6 100644 --- a/src/CalculatorUnitTests/CalcEngineTests.cpp +++ b/src/CalculatorUnitTests/CalcEngineTests.cpp @@ -13,7 +13,7 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework; static constexpr size_t MAX_HISTORY_SIZE = 20; -namespace CalculatorUnitTests +namespace CalculatorEngineTests { TEST_CLASS(CalcEngineTests) { diff --git a/src/CalculatorUnitTests/CalcInputTest.cpp b/src/CalculatorUnitTests/CalcInputTest.cpp index 551fbd71..4d224a3e 100644 --- a/src/CalculatorUnitTests/CalcInputTest.cpp +++ b/src/CalculatorUnitTests/CalcInputTest.cpp @@ -8,7 +8,7 @@ using namespace std; using namespace CalculationManager; using namespace Microsoft::VisualStudio::CppUnitTestFramework; -namespace CalculatorUnitTests +namespace CalculatorEngineTests { TEST_CLASS(CalcInputTest) { diff --git a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj index d199044c..0afdfd14 100644 --- a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj +++ b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj @@ -248,6 +248,7 @@ + diff --git a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters index 57ac4fe2..20400d4a 100644 --- a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters +++ b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters @@ -29,6 +29,7 @@ Mocks + diff --git a/src/CalculatorUnitTests/RationalTest.cpp b/src/CalculatorUnitTests/RationalTest.cpp new file mode 100644 index 00000000..c19692fd --- /dev/null +++ b/src/CalculatorUnitTests/RationalTest.cpp @@ -0,0 +1,225 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#include "pch.h" +#include +#include "Header Files/Rational.h" +#include "Header Files/RationalMath.h" + +using namespace CalcEngine; +using namespace CalcEngine::RationalMath; +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + +namespace CalculatorEngineTests +{ + TEST_CLASS(RationalTest) + { + public: + TEST_CLASS_INITIALIZE(CommonSetup) + { + ChangeConstants(10, 128); + } + + TEST_METHOD(TestModuloOperandsNotModified) + { + // Verify results but also check that operands are not modified + Rational rat25(25); + Rational ratminus25(-25); + Rational rat4(4); + Rational ratminus4(-4); + Rational res = Mod(rat25, rat4); + VERIFY_ARE_EQUAL(res, 1); + VERIFY_ARE_EQUAL(rat25, 25); + VERIFY_ARE_EQUAL(rat4, 4); + res = Mod(rat25, ratminus4); + VERIFY_ARE_EQUAL(res, -3); + VERIFY_ARE_EQUAL(rat25, 25); + VERIFY_ARE_EQUAL(ratminus4, -4); + res = Mod(ratminus25, ratminus4); + VERIFY_ARE_EQUAL(res, -1); + VERIFY_ARE_EQUAL(ratminus25, -25); + VERIFY_ARE_EQUAL(ratminus4, -4); + res = Mod(ratminus25, rat4); + VERIFY_ARE_EQUAL(res, 3); + VERIFY_ARE_EQUAL(ratminus25, -25); + VERIFY_ARE_EQUAL(rat4, 4); + } + + TEST_METHOD(TestModuloInteger) + { + // Check with integers + auto res = Mod(Rational(426), Rational(56478)); + VERIFY_ARE_EQUAL(res, 426); + res = Mod(Rational(56478), Rational(426)); + VERIFY_ARE_EQUAL(res, 246); + res = Mod(Rational(-643), Rational(8756)); + VERIFY_ARE_EQUAL(res, 8113); + res = Mod(Rational(643), Rational(-8756)); + VERIFY_ARE_EQUAL(res, -8113); + res = Mod(Rational(-643), Rational(-8756)); + VERIFY_ARE_EQUAL(res, -643); + res = Mod(Rational(1000), Rational(250)); + VERIFY_ARE_EQUAL(res, 0); + res = Mod(Rational(1000), Rational(-250)); + VERIFY_ARE_EQUAL(res, 0); + } + + TEST_METHOD(TestModuloZero) + { + // Test with Zero + auto res = Mod(Rational(343654332), Rational(0)); + VERIFY_ARE_EQUAL(res, 343654332); + res = Mod(Rational(0), Rational(8756)); + VERIFY_ARE_EQUAL(res, 0); + res = Mod(Rational(0), Rational(-242)); + VERIFY_ARE_EQUAL(res, 0); + res = Mod(Rational(0), Rational(0)); + VERIFY_ARE_EQUAL(res, 0); + res = Mod(Rational(Number(1, 0, { 23242 }), Number(1, 0, { 2 })), Rational(Number(1, 0, { 0 }), Number(1, 0, { 23 }))); + VERIFY_ARE_EQUAL(res, 11621); + } + + TEST_METHOD(TestModuloRational) + { + // Test with rational numbers + auto res = Mod(Rational(Number(1, 0, { 250 }), Number(1, 0, { 100 })), Rational(89)); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"2.5"); + res = Mod(Rational(Number(1, 0, { 3330 }), Number(1, 0, { 1332 })), Rational(1)); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"0.5"); + res = Mod(Rational(Number(1, 0, { 12250 }), Number(1, 0, { 100 })), Rational(10)); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"2.5"); + res = Mod(Rational(Number(-1, 0, { 12250 }), Number(1, 0, { 100 })), Rational(10)); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"7.5"); + res = Mod(Rational(Number(-1, 0, { 12250 }), Number(1, 0, { 100 })), Rational(-10)); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"-2.5"); + res = Mod(Rational(Number(1, 0, { 12250 }), Number(1, 0, { 100 })), Rational(-10)); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"-7.5"); + res = Mod(Rational(Number(1, 0, { 1000 }), Number(1, 0, { 3 })), Rational(1)); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"0.33333333"); + res = Mod(Rational(Number(1, 0, { 1000 }), Number(1, 0, { 3 })), Rational(-10)); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"-6.6666667"); + res = Mod(Rational(834345), Rational(Number(1, 0, { 103 }), Number(1, 0, { 100 }))); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"0.71"); + res = Mod(Rational(834345), Rational(Number(-1, 0, { 103 }), Number(1, 0, { 100 }))); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"-0.32"); + } + + TEST_METHOD(TestRemainderOperandsNotModified) + { + //Verify results but also check that operands are not modified + Rational rat25(25); + Rational ratminus25(-25); + Rational rat4(4); + Rational ratminus4(-4); + Rational res = rat25 % rat4; + VERIFY_ARE_EQUAL(res, 1); + VERIFY_ARE_EQUAL(rat25, 25); + VERIFY_ARE_EQUAL(rat4, 4); + res = rat25 % ratminus4; + VERIFY_ARE_EQUAL(res, 1); + VERIFY_ARE_EQUAL(rat25, 25); + VERIFY_ARE_EQUAL(ratminus4, -4); + res = ratminus25 % ratminus4; + VERIFY_ARE_EQUAL(res, -1); + VERIFY_ARE_EQUAL(ratminus25, -25); + VERIFY_ARE_EQUAL(ratminus4, -4); + res = ratminus25 % rat4; + VERIFY_ARE_EQUAL(res, -1); + VERIFY_ARE_EQUAL(ratminus25, -25); + VERIFY_ARE_EQUAL(rat4, 4); + } + + TEST_METHOD(TestRemainderInteger) + { + // Check with integers + auto res = Rational(426) % Rational(56478); + VERIFY_ARE_EQUAL(res, 426); + res = Rational(56478) % Rational(426); + VERIFY_ARE_EQUAL(res, 246); + res = Rational(-643) % Rational(8756); + VERIFY_ARE_EQUAL(res, -643); + res = Rational(643) % Rational(-8756); + VERIFY_ARE_EQUAL(res, 643); + res = Rational(-643) % Rational(-8756); + VERIFY_ARE_EQUAL(res, -643); + res = Rational(-124) % Rational(-124); + VERIFY_ARE_EQUAL(res, 0); + res = Rational(24) % Rational(24); + VERIFY_ARE_EQUAL(res, 0); + } + + TEST_METHOD(TestRemainderZero) + { + // Test with Zero + auto res = Rational(0) % Rational(3654); + VERIFY_ARE_EQUAL(res, 0); + res = Rational(0) % Rational(-242); + VERIFY_ARE_EQUAL(res, 0); + for (auto number : { 343654332, 0, -23423 }) + { + try + { + res = Rational(number) % Rational(0); + Assert::Fail(); + } + catch (uint32_t t) + { + if (t != CALC_E_INDEFINITE) + { + Assert::Fail(); + } + } + catch (...) + { + Assert::Fail(); + } + + try + { + res = Rational(Number(1, number, { 0 }), Number(1, 0, { 2 })) % Rational(Number(1, 0, { 0 }), Number(1, 0, { 23 })); + Assert::Fail(); + } + catch (uint32_t t) + { + if (t != CALC_E_INDEFINITE) + { + Assert::Fail(); + } + } + catch (...) + { + Assert::Fail(); + } + } + } + + TEST_METHOD(TestRemainderRational) + { + //Test with rational numbers + auto res = Rational(Number(1, 0, { 250 }), Number(1, 0, { 100 })) % Rational(89); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"2.5"); + res = Rational(Number(1, 0, { 3330 }), Number(1, 0, { 1332 })) % Rational(1); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"0.5"); + res = Rational(Number(1, 0, { 12250 }), Number(1, 0, { 100 })) % Rational(10); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"2.5"); + res = Rational(Number(-1, 0, { 12250 }), Number(1, 0, { 100 })) % Rational(10); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"-2.5"); + res = Rational(Number(-1, 0, { 12250 }), Number(1, 0, { 100 })) % Rational(-10); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"-2.5"); + res = Rational(Number(1, 0, { 12250 }), Number(1, 0, { 100 })) % Rational(-10); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"2.5"); + res = Rational(Number(1, 0, { 1000 }), Number(1, 0, { 3 })) % Rational(1); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"0.33333333"); + res = Rational(Number(1, 0, { 1000 }), Number(1, 0, { 3 })) % Rational(-10); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"3.3333333"); + res = Rational(Number(-1, 0, { 1000 }), Number(1, 0, { 3 })) % Rational(-10); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"-3.3333333"); + res = Rational(834345) % Rational(Number(1, 0, { 103 }), Number(1, 0, { 100 })); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"0.71"); + res = Rational(834345) % Rational(Number(-1, 0, { 103 }), Number(1, 0, { 100 })); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"0.71"); + res = Rational(-834345) % Rational(Number(1, 0, { 103 }), Number(1, 0, { 100 })); + VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 8), L"-0.71"); + } + }; +} From c150cd4ece9945aee39a6b174c2ea97b5cade0c7 Mon Sep 17 00:00:00 2001 From: jatinkumar Date: Tue, 16 Apr 2019 20:46:07 -0400 Subject: [PATCH 07/23] Removed AppBar, OperatorTextBox and OperandTextBox controls (#440) Fixes #407 Removed AppBar, OperatorTextBox and OperandTextBox controls --- src/CalcViewModel/ApplicationViewModel.cpp | 2 - src/CalcViewModel/ApplicationViewModel.h | 10 -- .../StandardCalculatorViewModel.h | 1 - src/Calculator/Calculator.vcxproj | 5 - src/Calculator/Calculator.vcxproj.filters | 15 --- src/Calculator/Controls/AppBar.h | 29 ----- src/Calculator/Controls/OperandTextBox.cpp | 58 ---------- src/Calculator/Controls/OperandTextBox.h | 19 ---- src/Calculator/Controls/OperatorTextBox.cpp | 59 ---------- src/Calculator/Controls/OperatorTextBox.h | 19 ---- src/Calculator/Views/Calculator.xaml | 101 +----------------- src/Calculator/Views/MainPage.xaml.cpp | 7 -- src/Calculator/Views/MainPage.xaml.h | 2 - .../Views/SupplementaryResults.xaml.h | 2 - 14 files changed, 1 insertion(+), 328 deletions(-) delete mode 100644 src/Calculator/Controls/AppBar.h delete mode 100644 src/Calculator/Controls/OperandTextBox.cpp delete mode 100644 src/Calculator/Controls/OperandTextBox.h delete mode 100644 src/Calculator/Controls/OperatorTextBox.cpp delete mode 100644 src/Calculator/Controls/OperatorTextBox.h diff --git a/src/CalcViewModel/ApplicationViewModel.cpp b/src/CalcViewModel/ApplicationViewModel.cpp index 358589b5..5033080b 100644 --- a/src/CalcViewModel/ApplicationViewModel.cpp +++ b/src/CalcViewModel/ApplicationViewModel.cpp @@ -36,7 +36,6 @@ namespace { StringReference CategoriesPropertyName(L"Categories"); StringReference ClearMemoryVisibilityPropertyName(L"ClearMemoryVisibility"); - StringReference AppBarVisibilityPropertyName(L"AppBarVisibility"); } ApplicationViewModel::ApplicationViewModel() : @@ -164,7 +163,6 @@ void ApplicationViewModel::OnModeChanged() TraceLogger::GetInstance().LogModeChangeEnd(m_mode, ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())); RaisePropertyChanged(ClearMemoryVisibilityPropertyName); - RaisePropertyChanged(AppBarVisibilityPropertyName); } void ApplicationViewModel::OnCopyCommand(Object^ parameter) diff --git a/src/CalcViewModel/ApplicationViewModel.h b/src/CalcViewModel/ApplicationViewModel.h index f13e00ad..74567ca1 100644 --- a/src/CalcViewModel/ApplicationViewModel.h +++ b/src/CalcViewModel/ApplicationViewModel.h @@ -66,16 +66,6 @@ namespace CalculatorApp } } - property Windows::UI::Xaml::Visibility AppBarVisibility - { - Windows::UI::Xaml::Visibility get() - { - return CalculatorApp::Common::NavCategory::IsCalculatorViewMode(Mode) - ? Windows::UI::Xaml::Visibility::Visible - : Windows::UI::Xaml::Visibility::Collapsed; - } - } - private: bool TryRecoverFromNavigationModeFailure(); diff --git a/src/CalcViewModel/StandardCalculatorViewModel.h b/src/CalcViewModel/StandardCalculatorViewModel.h index 91ba2557..42d025c4 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.h +++ b/src/CalcViewModel/StandardCalculatorViewModel.h @@ -86,7 +86,6 @@ namespace CalculatorApp COMMAND_FOR_METHOD(PasteCommand, StandardCalculatorViewModel::OnPasteCommand); COMMAND_FOR_METHOD(ButtonPressed, StandardCalculatorViewModel::OnButtonPressed); COMMAND_FOR_METHOD(ClearMemoryCommand, StandardCalculatorViewModel::OnClearMemoryCommand); - COMMAND_FOR_METHOD(PinUnpinAppBarButtonOnClicked, StandardCalculatorViewModel::OnPinUnpinCommand); COMMAND_FOR_METHOD(MemoryItemPressed, StandardCalculatorViewModel::OnMemoryItemPressed); COMMAND_FOR_METHOD(MemoryAdd, StandardCalculatorViewModel::OnMemoryAdd); COMMAND_FOR_METHOD(MemorySubtract, StandardCalculatorViewModel::OnMemorySubtract); diff --git a/src/Calculator/Calculator.vcxproj b/src/Calculator/Calculator.vcxproj index 4e19aab2..64e4ad06 100644 --- a/src/Calculator/Calculator.vcxproj +++ b/src/Calculator/Calculator.vcxproj @@ -234,12 +234,9 @@ - - - @@ -372,8 +369,6 @@ - - diff --git a/src/Calculator/Calculator.vcxproj.filters b/src/Calculator/Calculator.vcxproj.filters index cc25a224..a888b192 100644 --- a/src/Calculator/Calculator.vcxproj.filters +++ b/src/Calculator/Calculator.vcxproj.filters @@ -271,12 +271,6 @@ - - Controls - - - Controls - Controls @@ -321,9 +315,6 @@ Common - - Controls - Controls @@ -370,12 +361,6 @@ - - Controls - - - Controls - Controls diff --git a/src/Calculator/Controls/AppBar.h b/src/Calculator/Controls/AppBar.h deleted file mode 100644 index b6ac3740..00000000 --- a/src/Calculator/Controls/AppBar.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#pragma once - -#include "Common/KeyboardShortcutManager.h" - -namespace CalculatorApp -{ - namespace Controls - { - public ref class AppBar sealed : public Windows::UI::Xaml::Controls::AppBar - { - public: - AppBar() - {} - - protected: - virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override - { - Windows::UI::Xaml::Controls::AppBar::OnKeyDown(e); - if (e->Key == Windows::System::VirtualKey::Escape) - { - Common::KeyboardShortcutManager::IgnoreEscape(true); - } - } - }; - } -} diff --git a/src/Calculator/Controls/OperandTextBox.cpp b/src/Calculator/Controls/OperandTextBox.cpp deleted file mode 100644 index 31e814c2..00000000 --- a/src/Calculator/Controls/OperandTextBox.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include "pch.h" -#include "OperandTextBox.h" -#include "regex" - -using namespace CalculatorApp; -using namespace CalculatorApp::Controls; - -using namespace Platform; -using namespace std; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::Devices::Input; -using namespace Windows::System; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Navigation; - -void OperandTextBox::OnApplyTemplate() -{ - this->IsEnabled = false; - this->IsHitTestVisible = false; - this->IsTapEnabled = false; - this->MaxLength = 50; - this->IsRightTapEnabled = false; - this->IsTabStop = false; - auto parent = VisualTreeHelper::GetParent(this); - ListViewItem^ listViewItem; - ListView^ listView; - while (parent != nullptr) - { - if (listViewItem == nullptr) - { - listViewItem = dynamic_cast(parent); - } - - listView = dynamic_cast(parent); - if (listView != nullptr) - { - break; - } - parent = VisualTreeHelper::GetParent(parent); - } - - if (listView != nullptr) - { - listViewItem->IsEnabled = false; - listViewItem->IsHitTestVisible = false; - listViewItem->IsTapEnabled = false; - } - TextBox::OnApplyTemplate(); -} diff --git a/src/Calculator/Controls/OperandTextBox.h b/src/Calculator/Controls/OperandTextBox.h deleted file mode 100644 index a8508e12..00000000 --- a/src/Calculator/Controls/OperandTextBox.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#pragma once - -namespace CalculatorApp -{ - namespace Controls - { - public ref class OperandTextBox sealed : public Windows::UI::Xaml::Controls::TextBox - { - public: - OperandTextBox() { } - - protected: - virtual void OnApplyTemplate() override; - }; - } -} diff --git a/src/Calculator/Controls/OperatorTextBox.cpp b/src/Calculator/Controls/OperatorTextBox.cpp deleted file mode 100644 index 53153504..00000000 --- a/src/Calculator/Controls/OperatorTextBox.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include "pch.h" -#include "OperatorTextBox.h" -#include "regex" - -using namespace CalculatorApp; -using namespace CalculatorApp::Controls; - -using namespace Platform; -using namespace std; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::Devices::Input; -using namespace Windows::System; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Navigation; - -void OperatorTextBox::OnApplyTemplate() -{ - this->IsEnabled = false; - this->IsHitTestVisible = false; - this->IsTapEnabled = false; - this->MaxLength = 50; - this->IsReadOnly = true; - this->IsRightTapEnabled = false; - this->IsTabStop = false; - auto parent = VisualTreeHelper::GetParent(this); - ListViewItem^ listViewItem; - ListView^ listView; - while (parent != nullptr) - { - if (listViewItem == nullptr) - { - listViewItem = dynamic_cast(parent); - } - - listView = dynamic_cast(parent); - if (listView != nullptr) - { - break; - } - parent = VisualTreeHelper::GetParent(parent); - } - - if (listView != nullptr) - { - listViewItem->IsEnabled = false; - listViewItem->IsHitTestVisible = false; - listViewItem->IsTapEnabled = false; - } - TextBox::OnApplyTemplate(); -} diff --git a/src/Calculator/Controls/OperatorTextBox.h b/src/Calculator/Controls/OperatorTextBox.h deleted file mode 100644 index db92c46e..00000000 --- a/src/Calculator/Controls/OperatorTextBox.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#pragma once - -namespace CalculatorApp -{ - namespace Controls - { - public ref class OperatorTextBox sealed : public Windows::UI::Xaml::Controls::TextBox - { - public: - OperatorTextBox() { } - - protected: - virtual void OnApplyTemplate() override; - }; - } -} diff --git a/src/Calculator/Views/Calculator.xaml b/src/Calculator/Views/Calculator.xaml index 0ceec73e..c58bcdfb 100644 --- a/src/Calculator/Views/Calculator.xaml +++ b/src/Calculator/Views/Calculator.xaml @@ -36,106 +36,7 @@ - - - - - + - - - - - - - - -