diff --git a/src/CalcViewModel/Common/Automation/NarratorAnnouncement.cpp b/src/CalcViewModel/Common/Automation/NarratorAnnouncement.cpp
index 5b6d99b..33825b0 100644
--- a/src/CalcViewModel/Common/Automation/NarratorAnnouncement.cpp
+++ b/src/CalcViewModel/Common/Automation/NarratorAnnouncement.cpp
@@ -22,6 +22,7 @@ namespace CalculatorApp::Common::Automation
StringReference DisplayCopied(L"DisplayCopied");
StringReference OpenParenthesisCountChanged(L"OpenParenthesisCountChanged");
StringReference NoParenthesisAdded(L"NoParenthesisAdded");
+ StringReference GraphModeChanged(L"GraphModeChanged");
}
}
@@ -139,3 +140,12 @@ NarratorAnnouncement ^ CalculatorAnnouncement::GetNoRightParenthesisAddedAnnounc
AutomationNotificationKind::ActionCompleted,
AutomationNotificationProcessing::ImportantMostRecent);
}
+
+NarratorAnnouncement ^ CalculatorAnnouncement::GetGraphModeChangedAnnouncement(Platform::String ^ announcement)
+{
+ return ref new NarratorAnnouncement(
+ announcement,
+ CalculatorActivityIds::GraphModeChanged,
+ AutomationNotificationKind::ActionCompleted,
+ AutomationNotificationProcessing::ImportantMostRecent);
+}
diff --git a/src/CalcViewModel/Common/Automation/NarratorAnnouncement.h b/src/CalcViewModel/Common/Automation/NarratorAnnouncement.h
index c4c0c52..e508675 100644
--- a/src/CalcViewModel/Common/Automation/NarratorAnnouncement.h
+++ b/src/CalcViewModel/Common/Automation/NarratorAnnouncement.h
@@ -92,5 +92,8 @@ public
static NarratorAnnouncement ^ GetOpenParenthesisCountChangedAnnouncement(Platform::String ^ announcement);
static NarratorAnnouncement ^ GetNoRightParenthesisAddedAnnouncement(Platform::String ^ announcement);
+
+ static NarratorAnnouncement ^ GetGraphModeChangedAnnouncement(Platform::String ^ announcement);
+
};
}
diff --git a/src/Calculator/Calculator.vcxproj.filters b/src/Calculator/Calculator.vcxproj.filters
index 1a9988b..6f8b28c 100644
--- a/src/Calculator/Calculator.vcxproj.filters
+++ b/src/Calculator/Calculator.vcxproj.filters
@@ -1489,11 +1489,5 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw
index f014efb..6a1b8c0 100644
--- a/src/Calculator/Resources/en-US/Resources.resw
+++ b/src/Calculator/Resources/en-US/Resources.resw
@@ -3698,4 +3698,24 @@
Unable to calculate the range for this function.
Error displayed when Range is not returned from the analyzer.
-
+
+ Switch to equation mode
+ Used in Graphing Calculator to switch the view to the equation mode
+
+
+ Switch to graph mode
+ Used in Graphing Calculator to switch the view to the graph mode
+
+
+ Switch to equation mode
+ Used in Graphing Calculator to switch the view to the equation mode
+
+
+ Current mode is equation mode
+ Announcement used in Graphing Calculator when switching to the equation mode
+
+
+ Current mode is graph mode
+ Announcement used in Graphing Calculator when switching to the graph mode
+
+
\ No newline at end of file
diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml
index 3a83f90..8947a61 100644
--- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml
+++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml
@@ -1,6 +1,7 @@
-
+
+
-
-
-
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -175,11 +340,49 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Visibility="{x:Bind ShouldDisplayPanel(IsSmallState, SwitchModeToggleButton.IsChecked.Value, x:True), Mode=OneWay}">
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
@@ -481,7 +685,7 @@
Grid.Row="1"
Grid.RowSpan="2"
Grid.Column="1"
- Margin="0,0,0,0">
+ Visibility="{x:Bind ShouldDisplayPanel(IsSmallState, SwitchModeToggleButton.IsChecked.Value, x:False), Mode=OneWay}">
@@ -498,9 +702,9 @@
+ KeyGraphFeaturesRequested="OnEquationKeyGraphFeaturesRequested"
+ Visibility="{x:Bind IsKeyGraphFeaturesVisible, Converter={StaticResource BooleanToVisibilityNegationConverter}, Mode=OneWay}"/>
IsOpen != newValue)
+ if ((TraceValuePopup->Visibility == ::Visibility::Visible) != newValue)
{
- TraceValuePopup->IsOpen = newValue;
- if (TraceValuePopup->IsOpen)
- {
- // Set the keyboard focus to the graph control so we can use the arrow keys safely.
- GraphingControl->Focus(::FocusState::Programmatic);
- }
+ TraceValuePopup->Visibility = newValue ? ::Visibility::Visible : ::Visibility::Collapsed;
}
}
@@ -118,10 +119,8 @@ void GraphingCalculator::OnEquationsVectorChanged(IObservableVectorX = (int)GraphingControl->TraceLocation.X + 15;
- TraceValuePopupTransform->Y = (int)GraphingControl->TraceLocation.Y - 30;
-
TraceValue->Text = "(" + newPoint.X.ToString() + ", " + newPoint.Y.ToString() + ")";
+ PositionGraphPopup();
}
GraphingCalculatorViewModel ^ GraphingCalculator::ViewModel::get()
@@ -377,3 +376,63 @@ void GraphingCalculator::OnKeyGraphFeaturesClosed(Object ^ sender, RoutedEventAr
{
IsKeyGraphFeaturesVisible = false;
}
+
+Visibility GraphingCalculator::ShouldDisplayPanel(bool isSmallState, bool isEquationModeActivated, bool isGraphPanel)
+{
+ return (!isSmallState || isEquationModeActivated ^ isGraphPanel) ? ::Visibility::Visible : ::Visibility::Collapsed;
+}
+
+Platform::String ^ GraphingCalculator::GetInfoForSwitchModeToggleButton(bool isChecked)
+{
+ if (isChecked)
+ {
+ return AppResourceProvider::GetInstance().GetResourceString(L"GraphSwitchToGraphMode");
+ }
+ else
+ {
+ return AppResourceProvider::GetInstance().GetResourceString(L"GraphSwitchToEquationMode");
+ }
+}
+
+void GraphingCalculator::SwitchModeToggleButton_Checked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
+{
+ auto narratorNotifier = ref new NarratorNotifier();
+ String ^ announcementText;
+ if (SwitchModeToggleButton->IsChecked->Value)
+ {
+ announcementText = AppResourceProvider::GetInstance().GetResourceString(L"GraphSwitchedToEquationModeAnnouncement");
+ }
+ else
+ {
+ announcementText = AppResourceProvider::GetInstance().GetResourceString(L"GraphSwitchedToGraphModeAnnouncement");
+ }
+
+ auto announcement = CalculatorAnnouncement::GetGraphModeChangedAnnouncement(announcementText);
+ narratorNotifier->Announce(announcement);
+}
+
+void GraphingCalculator::PositionGraphPopup()
+{
+ if (GraphingControl->TraceLocation.X + 15 + TraceValuePopup->ActualWidth >= GraphingControl->ActualWidth)
+ {
+ TraceValuePopupTransform->X = (int)GraphingControl->TraceLocation.X - 15 - TraceValuePopup->ActualWidth;
+ }
+ else
+ {
+ TraceValuePopupTransform->X = (int)GraphingControl->TraceLocation.X + 15;
+ }
+
+ if (GraphingControl->TraceLocation.Y >= 30)
+ {
+ TraceValuePopupTransform->Y = (int)GraphingControl->TraceLocation.Y - 30;
+ }
+ else
+ {
+ TraceValuePopupTransform->Y = (int)GraphingControl->TraceLocation.Y;
+ }
+}
+
+void GraphingCalculator::TraceValuePopup_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e)
+{
+ PositionGraphPopup();
+}
diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h
index 004f36f..f2de531 100644
--- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h
+++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h
@@ -13,16 +13,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 ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
{
public:
GraphingCalculator();
OBSERVABLE_OBJECT();
+ DEPENDENCY_PROPERTY_OWNER(GraphingCalculator);
COMMAND_FOR_METHOD(ZoomOutButtonPressed, GraphingCalculator::OnZoomOutCommand);
COMMAND_FOR_METHOD(ZoomInButtonPressed, GraphingCalculator::OnZoomInCommand);
COMMAND_FOR_METHOD(ZoomResetButtonPressed, GraphingCalculator::OnZoomResetCommand);
OBSERVABLE_PROPERTY_RW(bool, IsKeyGraphFeaturesVisible);
+ DEPENDENCY_PROPERTY(bool, IsSmallState);
property CalculatorApp::ViewModel::GraphingCalculatorViewModel^ ViewModel
{
@@ -30,39 +32,43 @@ namespace CalculatorApp
void set(CalculatorApp::ViewModel::GraphingCalculatorViewModel^ vm);
}
+ Windows::UI::Xaml::Visibility ShouldDisplayPanel(bool isSmallState, bool isEquationModeActivated, bool isGraphPanel);
+ Platform::String ^ GetInfoForSwitchModeToggleButton(bool isChecked);
private:
- void GraphingCalculator_DataContextChanged(Windows::UI::Xaml::FrameworkElement^ sender, Windows::UI::Xaml::DataContextChangedEventArgs^ args);
+ void GraphingCalculator_DataContextChanged(Windows::UI::Xaml::FrameworkElement ^ sender, Windows::UI::Xaml::DataContextChangedEventArgs ^ args);
- void OnVariableChanged(Platform::Object^ sender, CalculatorApp::ViewModel::VariableChangedEventArgs args);
+ void GraphVariablesUpdated(Platform::Object ^ sender, Object ^ args);
+ void OnVariableChanged(Platform::Object ^ sender, CalculatorApp::ViewModel::VariableChangedEventArgs args);
void OnEquationsVectorChanged(
Windows::Foundation::Collections::IObservableVector ^ sender,
Windows::Foundation::Collections::IVectorChangedEventArgs ^ event);
- void TextBoxLosingFocus(Windows::UI::Xaml::Controls::TextBox^ textbox, Windows::UI::Xaml::Input::LosingFocusEventArgs^ args);
- void TextBoxKeyDown(Windows::UI::Xaml::Controls::TextBox^ textbox, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
- void SubmitTextbox(Windows::UI::Xaml::Controls::TextBox^ textbox);
+ void TextBoxLosingFocus(Windows::UI::Xaml::Controls::TextBox ^ textbox, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args);
+ 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);
+ double validateDouble(Platform::String ^ value, double defaultValue);
- CalculatorApp::ViewModel::GraphingCalculatorViewModel^ m_viewModel;
+ CalculatorApp::ViewModel::GraphingCalculatorViewModel ^ m_viewModel;
- void OnShareClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void OnShareClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnShowTracePopupChanged(bool newValue);
void OnTracePointChanged(Windows::Foundation::Point newPoint);
-
private:
Windows::Foundation::EventRegistrationToken m_dataRequestedToken;
Windows::Foundation::EventRegistrationToken m_vectorChangedToken;
Windows::Foundation::EventRegistrationToken m_variableUpdatedToken;
- void OnDataRequested(Windows::ApplicationModel::DataTransfer::DataTransferManager^ sender, Windows::ApplicationModel::DataTransfer::DataRequestedEventArgs^ e);
+ void OnDataRequested(
+ Windows::ApplicationModel::DataTransfer::DataTransferManager ^ sender,
+ Windows::ApplicationModel::DataTransfer::DataRequestedEventArgs ^ e);
- void TextBoxGotFocus(Windows::UI::Xaml::Controls::TextBox^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void TextBoxGotFocus(Windows::UI::Xaml::Controls::TextBox ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnActiveTracingClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
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);
@@ -70,6 +76,9 @@ namespace CalculatorApp
void OnEquationKeyGraphFeaturesRequested(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnKeyGraphFeaturesClosed(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
bool ActiveTracingOn;
+ void SwitchModeToggleButton_Checked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
+ void TraceValuePopup_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
+ void PositionGraphPopup();
};
}
diff --git a/src/Calculator/Views/MainPage.xaml b/src/Calculator/Views/MainPage.xaml
index d7f8bf5..cb0c8d1 100644
--- a/src/Calculator/Views/MainPage.xaml
+++ b/src/Calculator/Views/MainPage.xaml
@@ -96,7 +96,7 @@
-
+