Add automation name to graph control (#1032)

* fix bugs

* Update src/Calculator/Resources/en-US/Resources.resw

Co-Authored-By: Rudy Huyn <rudyhuyn@gmail.com>

Co-authored-by: Rudy Huyn <rudyhuyn@gmail.com>
This commit is contained in:
Pepe Rivera
2020-03-06 16:25:50 -08:00
committed by GitHub
parent de3a1cdff7
commit 1b1eb4c7e7
9 changed files with 89 additions and 0 deletions

View File

@@ -4174,6 +4174,10 @@
<value>Start tracing</value>
<comment>This is the tooltip/automation name for the graphing calculator start tracing button</comment>
</data>
<data name="graphAutomationName" xml:space="preserve">
<value>Graph viewing window, x-axis bounded by %1 and %2, y-axis bounded by %3 and %4, displaying %5 equations</value>
<comment>{Locked="%1","%2", "%3", "%4", "%5"}. </comment>
</data>
<data name="sliderOptionsButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Configure slider</value>
<comment>This is the tooltip text for the slider options button in Graphing Calculator</comment>

View File

@@ -471,7 +471,10 @@
</Grid.Resources>
<graphControl:Grapher Name="GraphingControl"
Style="{ThemeResource ThemedGrapherStyle}"
AutomationProperties.Name="{x:Bind GraphControlAutomationName, Mode=OneWay}"
ForceProportionalAxes="False"
GraphPlottedEvent="GraphingControl_GraphPlottedEvent"
GraphViewChangedEvent="GraphingControl_GraphViewChangedEvent"
LosingFocus="GraphingControl_LosingFocus"
LostFocus="GraphingControl_LostFocus"
RequestedTheme="Light"

View File

@@ -53,6 +53,7 @@ using namespace Windows::UI::ViewManagement;
constexpr auto sc_ViewModelPropertyName = L"ViewModel";
DEPENDENCY_PROPERTY_INITIALIZATION(GraphingCalculator, IsSmallState);
DEPENDENCY_PROPERTY_INITIALIZATION(GraphingCalculator, GraphControlAutomationName);
GraphingCalculator::GraphingCalculator()
: m_accessibilitySettings{ ref new AccessibilitySettings() }
@@ -120,6 +121,8 @@ void GraphingCalculator::GraphingCalculator_DataContextChanged(FrameworkElement
m_variableUpdatedToken = ViewModel->VariableUpdated +=
ref new EventHandler<VariableChangedEventArgs>(this, &CalculatorApp::GraphingCalculator::OnVariableChanged);
UpdateGraphAutomationName();
}
void GraphingCalculator::OnEquationsVectorChanged(IObservableVector<EquationViewModel ^> ^ sender, IVectorChangedEventArgs ^ event)
@@ -620,6 +623,48 @@ void GraphingCalculator::SetDefaultFocus()
}
}
void GraphingCalculator::GraphingControl_GraphViewChangedEvent(Object ^ sender, RoutedEventArgs ^ e)
{
UpdateGraphAutomationName();
auto announcement = CalculatorAnnouncement::GetGraphViewChangedAnnouncement(GraphControlAutomationName);
auto peer = FrameworkElementAutomationPeer::FromElement(GraphingControl);
if (peer != nullptr)
{
peer->RaiseNotificationEvent(announcement->Kind, announcement->Processing, announcement->Announcement, announcement->ActivityId);
}
}
void GraphingCalculator::GraphingControl_GraphPlottedEvent(Object ^ sender, RoutedEventArgs ^ e)
{
UpdateGraphAutomationName();
}
void GraphingCalculator::UpdateGraphAutomationName()
{
int numEquations = 0;
double xAxisMin, xAxisMax, yAxisMin, yAxisMax;
// Only count equations that are graphed
for (auto equation : ViewModel->Equations)
{
if (equation->GraphEquation->IsValidated)
{
numEquations++;
}
}
GraphingControl->GetDisplayRanges(&xAxisMin, &xAxisMax, &yAxisMin, &yAxisMax);
GraphControlAutomationName = LocalizationStringUtil::GetLocalizedString(
AppResourceProvider::GetInstance()->GetResourceString(L"graphAutomationName"),
xAxisMin.ToString(),
xAxisMax.ToString(),
yAxisMin.ToString(),
yAxisMax.ToString(),
numEquations.ToString());
}
void GraphingCalculator::GraphMenuFlyoutItem_Click(Object ^ sender, RoutedEventArgs ^ e)
{
auto dataPackage = ref new DataPackage();

View File

@@ -27,6 +27,7 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
COMMAND_FOR_METHOD(ZoomResetButtonPressed, GraphingCalculator::OnZoomResetCommand);
OBSERVABLE_PROPERTY_R(bool, IsKeyGraphFeaturesVisible);
DEPENDENCY_PROPERTY(bool, IsSmallState);
DEPENDENCY_PROPERTY(Platform::String ^, GraphControlAutomationName);
property CalculatorApp::ViewModel::GraphingCalculatorViewModel^ ViewModel
{
@@ -65,6 +66,8 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
void GraphingControl_LostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void GraphingControl_LosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args);
void GraphingControl_VariablesUpdated(Platform::Object ^ sender, Object ^ args);
void GraphingControl_GraphViewChangedEvent(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void GraphingControl_GraphPlottedEvent(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnEquationKeyGraphFeaturesRequested(Platform::Object ^ sender, CalculatorApp::ViewModel::EquationViewModel ^ e);
void OnKeyGraphFeaturesClosed(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void TraceValuePopup_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
@@ -78,6 +81,8 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
void DisplayGraphSettings();
void AddTracePointerShadow();
void UpdateGraphAutomationName();
private:
Windows::Foundation::EventRegistrationToken m_dataRequestedToken;
Windows::Foundation::EventRegistrationToken m_vectorChangedToken;