Fixes #282 Narrator does not convey error information when no more Right Parenthesis can be added in expression. (#284)
* Added narrator announcements when right parenthesis is clicked
This commit is contained in:
parent
ac5292cf88
commit
d37c75fec2
@ -546,6 +546,11 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
|
|||||||
if ((m_openParenCount >= MAXPRECDEPTH && nx) || (!m_openParenCount && !nx)
|
if ((m_openParenCount >= MAXPRECDEPTH && nx) || (!m_openParenCount && !nx)
|
||||||
|| ((m_precedenceOpCount >= MAXPRECDEPTH && m_nPrecOp[m_precedenceOpCount - 1] != 0)))
|
|| ((m_precedenceOpCount >= MAXPRECDEPTH && m_nPrecOp[m_precedenceOpCount - 1] != 0)))
|
||||||
{
|
{
|
||||||
|
if (!m_openParenCount && !nx)
|
||||||
|
{
|
||||||
|
m_pCalcDisplay->OnNoRightParenAdded();
|
||||||
|
}
|
||||||
|
|
||||||
HandleErrorCommand(wParam);
|
HandleErrorCommand(wParam);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,6 @@ namespace CalculationManager
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Callback from the engine
|
/// Callback from the engine
|
||||||
/// Used to set the current unmatched open parenthesis count
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parenthesisCount">string containing the parenthesis count</param>
|
/// <param name="parenthesisCount">string containing the parenthesis count</param>
|
||||||
void CalculatorManager::SetParenDisplayText(const wstring& parenthesisCount)
|
void CalculatorManager::SetParenDisplayText(const wstring& parenthesisCount)
|
||||||
@ -117,6 +116,14 @@ namespace CalculationManager
|
|||||||
m_displayCallback->SetParenDisplayText(parenthesisCount);
|
m_displayCallback->SetParenDisplayText(parenthesisCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Callback from the engine
|
||||||
|
/// </summary>
|
||||||
|
void CalculatorManager::OnNoRightParenAdded()
|
||||||
|
{
|
||||||
|
m_displayCallback->OnNoRightParenAdded();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset CalculatorManager.
|
/// Reset CalculatorManager.
|
||||||
/// Set the mode to the standard calculator
|
/// Set the mode to the standard calculator
|
||||||
|
@ -42,7 +42,7 @@ namespace CalculationManager
|
|||||||
MemorizedNumberClear = 335
|
MemorizedNumberClear = 335
|
||||||
};
|
};
|
||||||
|
|
||||||
class CalculatorManager sealed : public virtual ICalcDisplay
|
class CalculatorManager sealed : public ICalcDisplay
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ICalcDisplay* const m_displayCallback;
|
ICalcDisplay* const m_displayCallback;
|
||||||
@ -94,7 +94,8 @@ namespace CalculationManager
|
|||||||
void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const &tokens, _Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const &commands) override;
|
void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const &tokens, _Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const &commands) override;
|
||||||
void SetMemorizedNumbers(_In_ const std::vector<std::wstring>& memorizedNumbers) override;
|
void SetMemorizedNumbers(_In_ const std::vector<std::wstring>& memorizedNumbers) override;
|
||||||
void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) override;
|
void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) override;
|
||||||
void SetParenDisplayText(const std::wstring& parenthesisCount);
|
void SetParenDisplayText(const std::wstring& parenthesisCount) override;
|
||||||
|
void OnNoRightParenAdded() override;
|
||||||
void DisplayPasteError();
|
void DisplayPasteError();
|
||||||
void MaxDigitsReached() override;
|
void MaxDigitsReached() override;
|
||||||
void BinaryOperatorReceived() override;
|
void BinaryOperatorReceived() override;
|
||||||
|
@ -13,6 +13,7 @@ public:
|
|||||||
virtual void SetIsInError(bool isInError) = 0;
|
virtual void SetIsInError(bool isInError) = 0;
|
||||||
virtual void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const &tokens, _Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const &commands) = 0;
|
virtual void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const &tokens, _Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const &commands) = 0;
|
||||||
virtual void SetParenDisplayText(const std::wstring& pszText) = 0;
|
virtual void SetParenDisplayText(const std::wstring& pszText) = 0;
|
||||||
|
virtual void OnNoRightParenAdded() = 0;
|
||||||
virtual void MaxDigitsReached() = 0; // not an error but still need to inform UI layer.
|
virtual void MaxDigitsReached() = 0; // not an error but still need to inform UI layer.
|
||||||
virtual void BinaryOperatorReceived() = 0;
|
virtual void BinaryOperatorReceived() = 0;
|
||||||
virtual void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) = 0;
|
virtual void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) = 0;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
@ -20,6 +20,8 @@ namespace CalculatorApp::Common::Automation
|
|||||||
StringReference CategoryNameChanged(L"CategoryNameChanged");
|
StringReference CategoryNameChanged(L"CategoryNameChanged");
|
||||||
StringReference UpdateCurrencyRates(L"UpdateCurrencyRates");
|
StringReference UpdateCurrencyRates(L"UpdateCurrencyRates");
|
||||||
StringReference DisplayCopied(L"DisplayCopied");
|
StringReference DisplayCopied(L"DisplayCopied");
|
||||||
|
StringReference OpenParenthesisCountChanged(L"OpenParenthesisCountChanged");
|
||||||
|
StringReference NoParenthesisAdded(L"NoParenthesisAdded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,3 +144,21 @@ NarratorAnnouncement^ CalculatorAnnouncement::GetDisplayCopiedAnnouncement(Strin
|
|||||||
AutomationNotificationKind::ActionCompleted,
|
AutomationNotificationKind::ActionCompleted,
|
||||||
AutomationNotificationProcessing::ImportantMostRecent);
|
AutomationNotificationProcessing::ImportantMostRecent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NarratorAnnouncement^ CalculatorAnnouncement::GetOpenParenthesisCountChangedAnnouncement(String^ announcement)
|
||||||
|
{
|
||||||
|
return ref new NarratorAnnouncement(
|
||||||
|
announcement,
|
||||||
|
CalculatorActivityIds::OpenParenthesisCountChanged,
|
||||||
|
AutomationNotificationKind::ActionCompleted,
|
||||||
|
AutomationNotificationProcessing::ImportantMostRecent);
|
||||||
|
}
|
||||||
|
|
||||||
|
NarratorAnnouncement^ CalculatorAnnouncement::GetNoRightParenthesisAddedAnnouncement(String^ announcement)
|
||||||
|
{
|
||||||
|
return ref new NarratorAnnouncement(
|
||||||
|
announcement,
|
||||||
|
CalculatorActivityIds::NoParenthesisAdded,
|
||||||
|
AutomationNotificationKind::ActionCompleted,
|
||||||
|
AutomationNotificationProcessing::ImportantMostRecent);
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -90,5 +90,8 @@ namespace CalculatorApp::Common::Automation
|
|||||||
static NarratorAnnouncement^ GetUpdateCurrencyRatesAnnouncement(Platform::String^ announcement);
|
static NarratorAnnouncement^ GetUpdateCurrencyRatesAnnouncement(Platform::String^ announcement);
|
||||||
|
|
||||||
static NarratorAnnouncement^ GetDisplayCopiedAnnouncement(Platform::String^ announcement);
|
static NarratorAnnouncement^ GetDisplayCopiedAnnouncement(Platform::String^ announcement);
|
||||||
|
|
||||||
|
static NarratorAnnouncement^ GetOpenParenthesisCountChangedAnnouncement(Platform::String^ announcement);
|
||||||
|
static NarratorAnnouncement^ GetNoRightParenthesisAddedAnnouncement(Platform::String ^ announcement);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,7 @@ void CalculatorDisplay::SetPrimaryDisplay(_In_ const wstring& displayStringValue
|
|||||||
{
|
{
|
||||||
if (m_callbackReference)
|
if (m_callbackReference)
|
||||||
{
|
{
|
||||||
auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>();
|
if (auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>())
|
||||||
if (calcVM)
|
|
||||||
{
|
{
|
||||||
calcVM->SetPrimaryDisplay(displayStringValue, isError);
|
calcVM->SetPrimaryDisplay(displayStringValue, isError);
|
||||||
}
|
}
|
||||||
@ -41,20 +40,29 @@ void CalculatorDisplay::SetParenDisplayText(_In_ const std::wstring& parenthesis
|
|||||||
{
|
{
|
||||||
if (m_callbackReference != nullptr)
|
if (m_callbackReference != nullptr)
|
||||||
{
|
{
|
||||||
auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>();
|
if (auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>())
|
||||||
if (calcVM)
|
|
||||||
{
|
{
|
||||||
calcVM->SetParenthesisCount(parenthesisCount);
|
calcVM->SetParenthesisCount(parenthesisCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalculatorDisplay::OnNoRightParenAdded()
|
||||||
|
{
|
||||||
|
if (m_callbackReference != nullptr)
|
||||||
|
{
|
||||||
|
if (auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>())
|
||||||
|
{
|
||||||
|
calcVM->OnNoRightParenAdded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CalculatorDisplay::SetIsInError(bool isError)
|
void CalculatorDisplay::SetIsInError(bool isError)
|
||||||
{
|
{
|
||||||
if (m_callbackReference != nullptr)
|
if (m_callbackReference != nullptr)
|
||||||
{
|
{
|
||||||
auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>();
|
if (auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>())
|
||||||
if (calcVM)
|
|
||||||
{
|
{
|
||||||
calcVM->IsInError = isError;
|
calcVM->IsInError = isError;
|
||||||
}
|
}
|
||||||
@ -65,8 +73,7 @@ void CalculatorDisplay::SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorV
|
|||||||
{
|
{
|
||||||
if (m_callbackReference != nullptr)
|
if (m_callbackReference != nullptr)
|
||||||
{
|
{
|
||||||
auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>();
|
if(auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>())
|
||||||
if (calcVM)
|
|
||||||
{
|
{
|
||||||
calcVM->SetExpressionDisplay(tokens, commands);
|
calcVM->SetExpressionDisplay(tokens, commands);
|
||||||
}
|
}
|
||||||
@ -77,8 +84,7 @@ void CalculatorDisplay::SetMemorizedNumbers(_In_ const vector<std::wstring>& new
|
|||||||
{
|
{
|
||||||
if (m_callbackReference != nullptr)
|
if (m_callbackReference != nullptr)
|
||||||
{
|
{
|
||||||
auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>();
|
if (auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>())
|
||||||
if (calcVM)
|
|
||||||
{
|
{
|
||||||
calcVM->SetMemorizedNumbers(newMemorizedNumbers);
|
calcVM->SetMemorizedNumbers(newMemorizedNumbers);
|
||||||
}
|
}
|
||||||
@ -89,8 +95,7 @@ void CalculatorDisplay::OnHistoryItemAdded(_In_ unsigned int addedItemIndex)
|
|||||||
{
|
{
|
||||||
if (m_historyCallbackReference != nullptr)
|
if (m_historyCallbackReference != nullptr)
|
||||||
{
|
{
|
||||||
auto historyVM = m_historyCallbackReference.Resolve<ViewModel::HistoryViewModel>();
|
if (auto historyVM = m_historyCallbackReference.Resolve<ViewModel::HistoryViewModel>())
|
||||||
if (historyVM)
|
|
||||||
{
|
{
|
||||||
historyVM->OnHistoryItemAdded(addedItemIndex);
|
historyVM->OnHistoryItemAdded(addedItemIndex);
|
||||||
}
|
}
|
||||||
@ -101,8 +106,7 @@ void CalculatorDisplay::MaxDigitsReached()
|
|||||||
{
|
{
|
||||||
if (m_callbackReference != nullptr)
|
if (m_callbackReference != nullptr)
|
||||||
{
|
{
|
||||||
auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>();
|
if (auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>())
|
||||||
if (calcVM)
|
|
||||||
{
|
{
|
||||||
calcVM->OnMaxDigitsReached();
|
calcVM->OnMaxDigitsReached();
|
||||||
}
|
}
|
||||||
@ -113,8 +117,7 @@ void CalculatorDisplay::BinaryOperatorReceived()
|
|||||||
{
|
{
|
||||||
if (m_callbackReference != nullptr)
|
if (m_callbackReference != nullptr)
|
||||||
{
|
{
|
||||||
auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>();
|
if (auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>())
|
||||||
if (calcVM)
|
|
||||||
{
|
{
|
||||||
calcVM->OnBinaryOperatorReceived();
|
calcVM->OnBinaryOperatorReceived();
|
||||||
}
|
}
|
||||||
@ -125,8 +128,7 @@ void CalculatorDisplay::MemoryItemChanged(unsigned int indexOfMemory)
|
|||||||
{
|
{
|
||||||
if (m_callbackReference != nullptr)
|
if (m_callbackReference != nullptr)
|
||||||
{
|
{
|
||||||
auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>();
|
if (auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>())
|
||||||
if (calcVM)
|
|
||||||
{
|
{
|
||||||
calcVM->OnMemoryItemChanged(indexOfMemory);
|
calcVM->OnMemoryItemChanged(indexOfMemory);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ namespace CalculatorApp
|
|||||||
void SetMemorizedNumbers(_In_ const std::vector<std::wstring>& memorizedNumbers) override;
|
void SetMemorizedNumbers(_In_ const std::vector<std::wstring>& memorizedNumbers) override;
|
||||||
void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) override;
|
void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) override;
|
||||||
void SetParenDisplayText(_In_ const std::wstring& parenthesisCount) override;
|
void SetParenDisplayText(_In_ const std::wstring& parenthesisCount) override;
|
||||||
|
void OnNoRightParenAdded() override;
|
||||||
void MaxDigitsReached() override;
|
void MaxDigitsReached() override;
|
||||||
void BinaryOperatorReceived() override;
|
void BinaryOperatorReceived() override;
|
||||||
void MemoryItemChanged(unsigned int indexOfMemory) override;
|
void MemoryItemChanged(unsigned int indexOfMemory) override;
|
||||||
|
@ -41,6 +41,7 @@ namespace CalculatorApp::ViewModel
|
|||||||
StringReference DisplayValue(L"DisplayValue");
|
StringReference DisplayValue(L"DisplayValue");
|
||||||
StringReference IsInError(L"IsInError");
|
StringReference IsInError(L"IsInError");
|
||||||
StringReference BinaryDisplayValue(L"BinaryDisplayValue");
|
StringReference BinaryDisplayValue(L"BinaryDisplayValue");
|
||||||
|
StringReference OpenParenthesisCount(L"OpenParenthesisCount");
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CalculatorResourceKeys
|
namespace CalculatorResourceKeys
|
||||||
@ -53,6 +54,8 @@ namespace CalculatorApp::ViewModel
|
|||||||
StringReference OctButton(L"Format_OctButtonValue");
|
StringReference OctButton(L"Format_OctButtonValue");
|
||||||
StringReference BinButton(L"Format_BinButtonValue");
|
StringReference BinButton(L"Format_BinButtonValue");
|
||||||
StringReference LeftParenthesisAutomationFormat(L"Format_OpenParenthesisAutomationNamePrefix");
|
StringReference LeftParenthesisAutomationFormat(L"Format_OpenParenthesisAutomationNamePrefix");
|
||||||
|
StringReference OpenParenthesisCountAutomationFormat(L"Format_OpenParenthesisCountAutomationNamePrefix");
|
||||||
|
StringReference NoParenthesisAdded(L"NoRightParenthesisAdded_Announcement");
|
||||||
StringReference MaxDigitsReachedFormat(L"Format_MaxDigitsReached");
|
StringReference MaxDigitsReachedFormat(L"Format_MaxDigitsReached");
|
||||||
StringReference ButtonPressFeedbackFormat(L"Format_ButtonPressAuditoryFeedback");
|
StringReference ButtonPressFeedbackFormat(L"Format_ButtonPressAuditoryFeedback");
|
||||||
StringReference MemorySave(L"Format_MemorySave");
|
StringReference MemorySave(L"Format_MemorySave");
|
||||||
@ -92,7 +95,9 @@ StandardCalculatorViewModel::StandardCalculatorViewModel() :
|
|||||||
m_localizedMemorySavedAutomationFormat(nullptr),
|
m_localizedMemorySavedAutomationFormat(nullptr),
|
||||||
m_localizedMemoryItemChangedAutomationFormat(nullptr),
|
m_localizedMemoryItemChangedAutomationFormat(nullptr),
|
||||||
m_localizedMemoryItemClearedAutomationFormat(nullptr),
|
m_localizedMemoryItemClearedAutomationFormat(nullptr),
|
||||||
m_localizedMemoryCleared(nullptr)
|
m_localizedMemoryCleared(nullptr),
|
||||||
|
m_localizedOpenParenthesisCountChangedAutomationFormat(nullptr),
|
||||||
|
m_localizedNoRightParenthesisAddedFormat(nullptr)
|
||||||
{
|
{
|
||||||
WeakReference calculatorViewModel(this);
|
WeakReference calculatorViewModel(this);
|
||||||
m_calculatorDisplay.SetCallback(calculatorViewModel);
|
m_calculatorDisplay.SetCallback(calculatorViewModel);
|
||||||
@ -226,6 +231,34 @@ void StandardCalculatorViewModel::SetParenthesisCount(_In_ const wstring& parent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StandardCalculatorViewModel::SetOpenParenthesisCountNarratorAnnouncement()
|
||||||
|
{
|
||||||
|
String^ parenthesisCount = ((m_OpenParenthesisCount == nullptr) ? "0" : m_OpenParenthesisCount);
|
||||||
|
wstring localizedParenthesisCount = parenthesisCount->Data();
|
||||||
|
LocalizationSettings::GetInstance().LocalizeDisplayValue(&localizedParenthesisCount);
|
||||||
|
|
||||||
|
String^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(
|
||||||
|
CalculatorResourceKeys::OpenParenthesisCountAutomationFormat,
|
||||||
|
m_localizedOpenParenthesisCountChangedAutomationFormat,
|
||||||
|
localizedParenthesisCount.c_str());
|
||||||
|
|
||||||
|
Announcement = CalculatorAnnouncement::GetOpenParenthesisCountChangedAnnouncement(announcement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StandardCalculatorViewModel::OnNoRightParenAdded()
|
||||||
|
{
|
||||||
|
SetNoParenAddedNarratorAnnouncement();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StandardCalculatorViewModel::SetNoParenAddedNarratorAnnouncement()
|
||||||
|
{
|
||||||
|
String^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(
|
||||||
|
CalculatorResourceKeys::NoParenthesisAdded,
|
||||||
|
m_localizedNoRightParenthesisAddedFormat);
|
||||||
|
|
||||||
|
Announcement = CalculatorAnnouncement::GetNoRightParenthesisAddedAnnouncement(announcement);
|
||||||
|
}
|
||||||
|
|
||||||
void StandardCalculatorViewModel::DisableButtons(CommandType selectedExpressionCommandType)
|
void StandardCalculatorViewModel::DisableButtons(CommandType selectedExpressionCommandType)
|
||||||
{
|
{
|
||||||
if (selectedExpressionCommandType == CommandType::OperandCommand)
|
if (selectedExpressionCommandType == CommandType::OperandCommand)
|
||||||
|
@ -36,6 +36,7 @@ namespace CalculatorApp
|
|||||||
extern Platform::StringReference IsMemoryEmpty;
|
extern Platform::StringReference IsMemoryEmpty;
|
||||||
extern Platform::StringReference IsInError;
|
extern Platform::StringReference IsInError;
|
||||||
extern Platform::StringReference BinaryDisplayValue;
|
extern Platform::StringReference BinaryDisplayValue;
|
||||||
|
extern Platform::StringReference OpenParenthesisCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Windows::UI::Xaml::Data::Bindable]
|
[Windows::UI::Xaml::Data::Bindable]
|
||||||
@ -263,7 +264,7 @@ namespace CalculatorApp
|
|||||||
|
|
||||||
property Platform::String^ LeftParenthesisAutomationName
|
property Platform::String^ LeftParenthesisAutomationName
|
||||||
{
|
{
|
||||||
Platform::String^ get()
|
Platform::String^ get()
|
||||||
{
|
{
|
||||||
return GetLeftParenthesisAutomationName();
|
return GetLeftParenthesisAutomationName();
|
||||||
}
|
}
|
||||||
@ -290,6 +291,9 @@ namespace CalculatorApp
|
|||||||
void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const &tokens, _Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const &commands);
|
void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const &tokens, _Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const &commands);
|
||||||
void SetHistoryExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const &tokens, _Inout_ std::shared_ptr<CalculatorVector <std::shared_ptr<IExpressionCommand>>> const &commands);
|
void SetHistoryExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const &tokens, _Inout_ std::shared_ptr<CalculatorVector <std::shared_ptr<IExpressionCommand>>> const &commands);
|
||||||
void SetParenthesisCount(_In_ const std::wstring& parenthesisCount);
|
void SetParenthesisCount(_In_ const std::wstring& parenthesisCount);
|
||||||
|
void SetOpenParenthesisCountNarratorAnnouncement();
|
||||||
|
void OnNoRightParenAdded();
|
||||||
|
void SetNoParenAddedNarratorAnnouncement();
|
||||||
void OnMaxDigitsReached();
|
void OnMaxDigitsReached();
|
||||||
void OnBinaryOperatorReceived();
|
void OnBinaryOperatorReceived();
|
||||||
void OnMemoryItemChanged(unsigned int indexOfMemory);
|
void OnMemoryItemChanged(unsigned int indexOfMemory);
|
||||||
@ -337,6 +341,8 @@ namespace CalculatorApp
|
|||||||
Platform::String^ m_localizedMemoryItemChangedAutomationFormat;
|
Platform::String^ m_localizedMemoryItemChangedAutomationFormat;
|
||||||
Platform::String^ m_localizedMemoryItemClearedAutomationFormat;
|
Platform::String^ m_localizedMemoryItemClearedAutomationFormat;
|
||||||
Platform::String^ m_localizedMemoryCleared;
|
Platform::String^ m_localizedMemoryCleared;
|
||||||
|
Platform::String^ m_localizedOpenParenthesisCountChangedAutomationFormat;
|
||||||
|
Platform::String^ m_localizedNoRightParenthesisAddedFormat;
|
||||||
|
|
||||||
bool m_pinned;
|
bool m_pinned;
|
||||||
bool m_isOperandEnabled;
|
bool m_isOperandEnabled;
|
||||||
|
@ -1321,6 +1321,14 @@
|
|||||||
<value>Right parenthesis</value>
|
<value>Right parenthesis</value>
|
||||||
<comment>Screen reader prompt for the Calculator ")" button on the scientific operator keypad</comment>
|
<comment>Screen reader prompt for the Calculator ")" button on the scientific operator keypad</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Format_OpenParenthesisCountAutomationNamePrefix" xml:space="preserve">
|
||||||
|
<value>Open parenthesis count %1</value>
|
||||||
|
<comment>{Locked="%1"} Screen reader prompt for the Calculator "(" button on the scientific and programmer operator keypad. %1 is the localized count of open parenthesis, e.g. "2".</comment>
|
||||||
|
</data>
|
||||||
|
<data name="NoRightParenthesisAdded_Announcement" xml:space="preserve">
|
||||||
|
<value>There are no open parentheses to close.</value>
|
||||||
|
<comment>{Locked="%1"} Screen reader prompt for the Calculator when the ")" button on the scientific and programmer operator keypad cannot be added to the equation. e.g. "1+)".</comment>
|
||||||
|
</data>
|
||||||
<data name="ftoeButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
<data name="ftoeButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||||
<value>Scientific notation</value>
|
<value>Scientific notation</value>
|
||||||
<comment>Screen reader prompt for the Calculator F-E the scientific operator keypad</comment>
|
<comment>Screen reader prompt for the Calculator F-E the scientific operator keypad</comment>
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
d:DesignHeight="395"
|
d:DesignHeight="395"
|
||||||
d:DesignWidth="315"
|
d:DesignWidth="315"
|
||||||
Loaded="OnLoaded"
|
Loaded="OnLoaded"
|
||||||
|
Unloaded="OnUnloaded"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<Grid x:Name="ProgRadixOps">
|
<Grid x:Name="ProgRadixOps">
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -34,8 +34,13 @@ CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators() :
|
|||||||
|
|
||||||
void CalculatorProgrammerRadixOperators::OnLoaded(Object^, RoutedEventArgs^)
|
void CalculatorProgrammerRadixOperators::OnLoaded(Object^, RoutedEventArgs^)
|
||||||
{
|
{
|
||||||
auto viewmodel = safe_cast<StandardCalculatorViewModel^>(this->DataContext);
|
m_progModeRadixChangeToken = Model->ProgModeRadixChange += ref new ProgModeRadixChangeHandler(this, &CalculatorProgrammerRadixOperators::ProgModeRadixChange);
|
||||||
viewmodel->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)
|
void CalculatorProgrammerRadixOperators::Shift_Clicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||||
@ -94,3 +99,11 @@ void CalculatorProgrammerRadixOperators::IsErrorVisualState::set(bool value)
|
|||||||
NumberPad->IsErrorVisualState = m_isErrorVisualState;
|
NumberPad->IsErrorVisualState = m_isErrorVisualState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalculatorProgrammerRadixOperators::OnViewModelPropertyChanged(Object^ sender, PropertyChangedEventArgs^ e)
|
||||||
|
{
|
||||||
|
if (e->PropertyName == CalculatorViewModelProperties::OpenParenthesisCount && closeParenthesisButton->FocusState != ::FocusState::Unfocused)
|
||||||
|
{
|
||||||
|
Model->SetOpenParenthesisCountNarratorAnnouncement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -33,8 +33,12 @@ namespace CalculatorApp
|
|||||||
void Shift_Clicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void Shift_Clicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
void SetVisibilityBinding(Windows::UI::Xaml::FrameworkElement^ element, Platform::String^ path, Windows::UI::Xaml::Data::IValueConverter^ converter);
|
void SetVisibilityBinding(Windows::UI::Xaml::FrameworkElement^ element, Platform::String^ path, Windows::UI::Xaml::Data::IValueConverter^ converter);
|
||||||
void OnLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void OnLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
|
void OnUnloaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
void ProgModeRadixChange();
|
void ProgModeRadixChange();
|
||||||
|
void OnViewModelPropertyChanged(Platform::Object^ sender, Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e);
|
||||||
|
|
||||||
bool m_isErrorVisualState;
|
bool m_isErrorVisualState;
|
||||||
|
Windows::Foundation::EventRegistrationToken m_progModeRadixChangeToken;
|
||||||
|
Windows::Foundation::EventRegistrationToken m_propertyChangedToken;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
x:Name="ControlRoot"
|
x:Name="ControlRoot"
|
||||||
d:DesignHeight="400"
|
d:DesignHeight="400"
|
||||||
d:DesignWidth="315"
|
d:DesignWidth="315"
|
||||||
|
Loaded="OnLoaded"
|
||||||
|
Unloaded="OnUnloaded"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<converters:BooleanNegationConverter x:Key="BooleanNegationConverter"/>
|
<converters:BooleanNegationConverter x:Key="BooleanNegationConverter"/>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -38,6 +38,15 @@ CalculatorScientificOperators::CalculatorScientificOperators()
|
|||||||
Common::KeyboardShortcutManager::ShiftButtonChecked(false);
|
Common::KeyboardShortcutManager::ShiftButtonChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalculatorScientificOperators::OnLoaded(Object^, RoutedEventArgs^)
|
||||||
|
{
|
||||||
|
m_propertyChangedToken = Model->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*/)
|
void CalculatorScientificOperators::ShortLayout_Completed(_In_ Platform::Object^ /*sender*/, _In_ Platform::Object^ /*e*/)
|
||||||
{
|
{
|
||||||
IsWideLayout = false;
|
IsWideLayout = false;
|
||||||
@ -97,3 +106,11 @@ void CalculatorScientificOperators::SetOperatorRowVisibility()
|
|||||||
InvRow1->Visibility = invRowVis;
|
InvRow1->Visibility = invRowVis;
|
||||||
InvRow2->Visibility = invRowVis;
|
InvRow2->Visibility = invRowVis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalculatorScientificOperators::OnViewModelPropertyChanged(Object^ sender, PropertyChangedEventArgs^ e)
|
||||||
|
{
|
||||||
|
if (e->PropertyName == CalculatorViewModelProperties::OpenParenthesisCount && closeParenthesisButton->FocusState != ::FocusState::Unfocused)
|
||||||
|
{
|
||||||
|
Model->SetOpenParenthesisCountNarratorAnnouncement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -41,5 +41,10 @@ namespace CalculatorApp
|
|||||||
void shiftButton_Check(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
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 shiftButton_IsEnabledChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ e);
|
||||||
void SetOperatorRowVisibility();
|
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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,11 @@ namespace CalculatorManagerTest
|
|||||||
m_parenDisplay = parenthesisCount;
|
m_parenDisplay = parenthesisCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnNoRightParenAdded() override
|
||||||
|
{
|
||||||
|
// This method is used to create a narrator announcement when a close parenthesis cannot be added because there are no open parentheses
|
||||||
|
}
|
||||||
|
|
||||||
const wstring& GetPrimaryDisplay() const
|
const wstring& GetPrimaryDisplay() const
|
||||||
{
|
{
|
||||||
return m_primaryDisplay;
|
return m_primaryDisplay;
|
||||||
|
Loading…
Reference in New Issue
Block a user