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:
Stephanie Anderl 2019-03-14 16:20:05 -07:00 committed by GitHub
parent ac5292cf88
commit d37c75fec2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 165 additions and 31 deletions

View file

@ -41,6 +41,7 @@ namespace CalculatorApp::ViewModel
StringReference DisplayValue(L"DisplayValue");
StringReference IsInError(L"IsInError");
StringReference BinaryDisplayValue(L"BinaryDisplayValue");
StringReference OpenParenthesisCount(L"OpenParenthesisCount");
}
namespace CalculatorResourceKeys
@ -53,6 +54,8 @@ namespace CalculatorApp::ViewModel
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");
StringReference ButtonPressFeedbackFormat(L"Format_ButtonPressAuditoryFeedback");
StringReference MemorySave(L"Format_MemorySave");
@ -92,7 +95,9 @@ StandardCalculatorViewModel::StandardCalculatorViewModel() :
m_localizedMemorySavedAutomationFormat(nullptr),
m_localizedMemoryItemChangedAutomationFormat(nullptr),
m_localizedMemoryItemClearedAutomationFormat(nullptr),
m_localizedMemoryCleared(nullptr)
m_localizedMemoryCleared(nullptr),
m_localizedOpenParenthesisCountChangedAutomationFormat(nullptr),
m_localizedNoRightParenthesisAddedFormat(nullptr)
{
WeakReference calculatorViewModel(this);
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)
{
if (selectedExpressionCommandType == CommandType::OperandCommand)