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
This commit is contained in:
Rudy Huyn
2019-04-15 09:31:02 -07:00
committed by Pepe Rivera
parent afdda581a4
commit 109326508f
78 changed files with 133 additions and 345 deletions

View File

@@ -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}"/>
<controls:CalculatorButton x:Name="closeParenthesisButton"
x:Uid="closeParenthesisButton"
Grid.Row="5"

View File

@@ -12,8 +12,8 @@
#include "Converters/BooleanToVisibilityConverter.h"
#include "Views/NumberPad.xaml.h"
using namespace std;
using namespace CalculatorApp;
using namespace CalculatorApp::ViewModel;
using namespace Platform;
using namespace Windows::UI::Xaml;
@@ -35,12 +35,10 @@ CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators() :
void CalculatorProgrammerRadixOperators::OnLoaded(Object^, RoutedEventArgs^)
{
m_progModeRadixChangeToken = Model->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();
}

View File

@@ -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);
};
}

View File

@@ -11,8 +11,6 @@
x:Name="ControlRoot"
d:DesignHeight="400"
d:DesignWidth="315"
Loaded="OnLoaded"
Unloaded="OnUnloaded"
mc:Ignorable="d">
<UserControl.Resources>
<converters:BooleanNegationConverter x:Key="BooleanNegationConverter"/>
@@ -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}"/>
<controls:CalculatorButton x:Name="closeParenthesisButton"
x:Uid="closeParenthesisButton"
Grid.Row="8"

View File

@@ -16,6 +16,7 @@ using namespace CalculatorApp;
using namespace CalculatorApp::Common;
using namespace CalculatorApp::ViewModel;
using namespace std;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
@@ -38,15 +39,6 @@ CalculatorScientificOperators::CalculatorScientificOperators()
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*/)
{
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());
}

View File

@@ -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;
};
}