diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw
index 2502d4a..13476ed 100644
--- a/src/Calculator/Resources/en-US/Resources.resw
+++ b/src/Calculator/Resources/en-US/Resources.resw
@@ -3435,6 +3435,42 @@
^
{Locked}This is the character that should trigger this button. Note that it is a character and not a key, so it does not come from the Windows::System::VirtualKey enum.
+
+ Home
+ {Locked}This is the shortcut for the zoom reset button.
+
+
+ Reset View
+ This is the tool tip automation name for the Calculator zoom reset button.
+
+
+ Reset View
+ Screen reader prompt for the reset zoom button.
+
+
+ Add
+ {Locked}This is the shortcut for the zoom in button.
+
+
+ Zoom In
+ This is the tool tip automation name for the Calculator zoom in button.
+
+
+ Zoom In
+ Screen reader prompt for the zoom in button.
+
+
+ Subtract
+ {Locked}This is the shortcut for the zoom out button.
+
+
+ Zoom Out
+ This is the tool tip automation name for the Calculator zoom out button.
+
+
+ Zoom Out
+ Screen reader prompt for the zoom out button.
+
Add Equation
Placeholder text for the equation input button
diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml
index 1c7e9aa..67ce13b 100644
--- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml
+++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml
@@ -12,6 +12,22 @@
mc:Ignorable="d">
+
+
@@ -30,8 +46,7 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.cpp b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.cpp
index fc87801..ccfb1fe 100644
--- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.cpp
+++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.cpp
@@ -242,3 +242,18 @@ void GraphingCalculator::TextBoxGotFocus(TextBox^ sender, RoutedEventArgs^ e)
{
sender->SelectAll();
}
+
+void GraphingCalculator::OnZoomInCommand(Object ^ /* parameter */)
+{
+ GraphingControl->ZoomFromCenter(zoomInScale);
+}
+
+void GraphingCalculator::OnZoomOutCommand(Object ^ /* parameter */)
+{
+ GraphingControl->ZoomFromCenter(zoomOutScale);
+}
+
+void GraphingCalculator::OnZoomResetCommand(Object ^ /* parameter */)
+{
+ GraphingControl->ResetGrid();
+}
diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h
index 4212ea3..b5d3dfa 100644
--- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h
+++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h
@@ -6,12 +6,18 @@
namespace CalculatorApp
{
+ constexpr double zoomInScale = 1 / 1.0625;
+ constexpr double zoomOutScale = 1.0625;
+
public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
{
public:
GraphingCalculator();
OBSERVABLE_OBJECT();
+ COMMAND_FOR_METHOD(ZoomOutButtonPressed, GraphingCalculator::OnZoomOutCommand);
+ COMMAND_FOR_METHOD(ZoomInButtonPressed, GraphingCalculator::OnZoomInCommand);
+ COMMAND_FOR_METHOD(ZoomResetButtonPressed, GraphingCalculator::OnZoomResetCommand);
property CalculatorApp::ViewModel::GraphingCalculatorViewModel^ ViewModel
{
@@ -29,6 +35,10 @@ namespace CalculatorApp
void TextBoxKeyDown(Windows::UI::Xaml::Controls::TextBox^ textbox, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
void SubmitTextbox(Windows::UI::Xaml::Controls::TextBox^ textbox);
+ void OnZoomInCommand(Object ^ parameter);
+ void OnZoomOutCommand(Object ^ parameter);
+ void OnZoomResetCommand(Object ^ parameter);
+
double validateDouble(Platform::String^ value, double defaultValue);
CalculatorApp::ViewModel::GraphingCalculatorViewModel^ m_viewModel;
diff --git a/src/GraphControl/Control/Grapher.cpp b/src/GraphControl/Control/Grapher.cpp
index 66f2375..3fb3890 100644
--- a/src/GraphControl/Control/Grapher.cpp
+++ b/src/GraphControl/Control/Grapher.cpp
@@ -92,6 +92,11 @@ namespace GraphControl
}
}
+ void Grapher::ZoomFromCenter(double scale)
+ {
+ ScaleRange(0, 0, scale);
+ }
+
void Grapher::ScaleRange(double centerX, double centerY, double scale)
{
if (m_graph != nullptr && m_renderMain != nullptr)
@@ -106,6 +111,20 @@ namespace GraphControl
}
}
+ void Grapher::ResetGrid()
+ {
+ if (m_graph != nullptr && m_renderMain != nullptr)
+ {
+ if (auto renderer = m_graph->GetRenderer())
+ {
+ if (SUCCEEDED(renderer->ResetRange()))
+ {
+ m_renderMain->RunRenderPass();
+ }
+ }
+ }
+ }
+
void Grapher::OnApplyTemplate()
{
auto swapChainPanel = dynamic_cast(GetTemplateChild(StringReference(s_templateKey_SwapChainPanel)));
diff --git a/src/GraphControl/Control/Grapher.h b/src/GraphControl/Control/Grapher.h
index 2353e7d..9178ac9 100644
--- a/src/GraphControl/Control/Grapher.h
+++ b/src/GraphControl/Control/Grapher.h
@@ -127,6 +127,8 @@ namespace GraphControl
event Windows::Foundation::EventHandler^>^ VariablesUpdated;
void SetVariable(Platform::String^ variableName, double newValue);
+ void ZoomFromCenter(double scale);
+ void ResetGrid();
protected:
#pragma region Control Overrides