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:
parent
de3a1cdff7
commit
1b1eb4c7e7
@ -24,6 +24,7 @@ namespace CalculatorApp::Common::Automation
|
||||
StringReference OpenParenthesisCountChanged(L"OpenParenthesisCountChanged");
|
||||
StringReference NoParenthesisAdded(L"NoParenthesisAdded");
|
||||
StringReference GraphModeChanged(L"GraphModeChanged");
|
||||
StringReference GraphViewChanged(L"GraphViewChanged");
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,3 +151,12 @@ NarratorAnnouncement ^ CalculatorAnnouncement::GetGraphModeChangedAnnouncement(P
|
||||
AutomationNotificationKind::ActionCompleted,
|
||||
AutomationNotificationProcessing::ImportantMostRecent);
|
||||
}
|
||||
|
||||
NarratorAnnouncement ^ CalculatorAnnouncement::GetGraphViewChangedAnnouncement(Platform::String ^ announcement)
|
||||
{
|
||||
return ref new NarratorAnnouncement(
|
||||
announcement,
|
||||
CalculatorActivityIds::GraphViewChanged,
|
||||
AutomationNotificationKind::ActionCompleted,
|
||||
AutomationNotificationProcessing::MostRecent);
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ public
|
||||
static NarratorAnnouncement ^ GetNoRightParenthesisAddedAnnouncement(Platform::String ^ announcement);
|
||||
|
||||
static NarratorAnnouncement ^ GetGraphModeChangedAnnouncement(Platform::String ^ announcement);
|
||||
static NarratorAnnouncement ^ GetGraphViewChangedAnnouncement(Platform::String ^ announcement);
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -81,6 +81,18 @@ namespace CalculatorApp
|
||||
{
|
||||
return LocalizationStringUtilInternal::GetLocalizedString(pMessage, param1->Data(), param2->Data(), param3->Data(), param4->Data());
|
||||
}
|
||||
|
||||
static Platform::String
|
||||
^ GetLocalizedString(
|
||||
Platform::String ^ pMessage,
|
||||
Platform::String ^ param1,
|
||||
Platform::String ^ param2,
|
||||
Platform::String ^ param3,
|
||||
Platform::String ^ param4,
|
||||
Platform::String ^ param5)
|
||||
{
|
||||
return LocalizationStringUtilInternal::GetLocalizedString(pMessage, param1->Data(), param2->Data(), param3->Data(), param4->Data(), param5->Data());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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"
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -84,6 +84,7 @@ namespace GraphControl
|
||||
void Grapher::ZoomFromCenter(double scale)
|
||||
{
|
||||
ScaleRange(0, 0, scale);
|
||||
GraphViewChangedEvent(this, ref new RoutedEventArgs());
|
||||
}
|
||||
|
||||
void Grapher::ScaleRange(double centerX, double centerY, double scale)
|
||||
@ -95,6 +96,7 @@ namespace GraphControl
|
||||
if (SUCCEEDED(renderer->ScaleRange(centerX, centerY, scale)))
|
||||
{
|
||||
m_renderMain->RunRenderPass();
|
||||
GraphViewChangedEvent(this, ref new RoutedEventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,6 +111,7 @@ namespace GraphControl
|
||||
if (SUCCEEDED(renderer->ResetRange()))
|
||||
{
|
||||
m_renderMain->RunRenderPass();
|
||||
GraphViewChangedEvent(this, ref new RoutedEventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -249,6 +252,8 @@ namespace GraphControl
|
||||
co_await TryUpdateGraph(keepCurrentView);
|
||||
}
|
||||
}
|
||||
|
||||
GraphPlottedEvent(this, ref new RoutedEventArgs());
|
||||
}
|
||||
|
||||
task<bool> Grapher::TryUpdateGraph(bool keepCurrentView)
|
||||
@ -603,6 +608,7 @@ namespace GraphControl
|
||||
const auto [centerX, centerY] = PointerPositionToGraphPosition(pos.X, pos.Y, ActualWidth, ActualHeight);
|
||||
|
||||
ScaleRange(centerX, centerY, scale);
|
||||
GraphViewChangedEvent(this, ref new RoutedEventArgs());
|
||||
|
||||
e->Handled = true;
|
||||
}
|
||||
@ -676,6 +682,7 @@ namespace GraphControl
|
||||
if (needsRenderPass)
|
||||
{
|
||||
m_renderMain->RunRenderPass();
|
||||
GraphViewChangedEvent(this, ref new RoutedEventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ public
|
||||
event TracingValueChangedEventHandler ^ TracingValueChangedEvent;
|
||||
event PointerValueChangedEventHandler ^ PointerValueChangedEvent;
|
||||
event TracingChangedEventHandler ^ TracingChangedEvent;
|
||||
event Windows::UI::Xaml::RoutedEventHandler ^ GraphViewChangedEvent;
|
||||
event Windows::UI::Xaml::RoutedEventHandler ^ GraphPlottedEvent;
|
||||
virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler ^ PropertyChanged;
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user