From fd3fb059b47e764a6ff94eefdfd83eab9be3d084 Mon Sep 17 00:00:00 2001 From: David Shoemaker Date: Wed, 4 Dec 2019 13:58:01 -0800 Subject: [PATCH 01/21] PR after merge and reset onto feature\graphingcalculator --- src/Calculator/Calculator.vcxproj | 9 + src/Calculator/GraphingSettings.xaml | 136 +++++++++++ src/Calculator/GraphingSettings.xaml.cpp | 220 ++++++++++++++++++ src/Calculator/GraphingSettings.xaml.h | 55 +++++ src/Calculator/Resources/en-US/Resources.resw | 38 +++ .../GraphingCalculator.xaml | 17 ++ .../GraphingCalculator.xaml.cpp | 4 + src/GraphControl/Control/Grapher.h | 99 ++++++++ src/GraphingImpl/Mocks/MathSolver.h | 7 + src/GraphingInterfaces/GraphingEnums.h | 8 +- src/GraphingInterfaces/IGraphRenderer.h | 2 + src/GraphingInterfaces/IMathSolver.h | 4 + 12 files changed, 595 insertions(+), 4 deletions(-) create mode 100644 src/Calculator/GraphingSettings.xaml create mode 100644 src/Calculator/GraphingSettings.xaml.cpp create mode 100644 src/Calculator/GraphingSettings.xaml.h diff --git a/src/Calculator/Calculator.vcxproj b/src/Calculator/Calculator.vcxproj index 974a818b1..292bc8a20 100644 --- a/src/Calculator/Calculator.vcxproj +++ b/src/Calculator/Calculator.vcxproj @@ -257,6 +257,9 @@ + + GraphingSettings.xaml + App.xaml @@ -341,6 +344,9 @@ Designer + + Designer + Designer @@ -415,6 +421,9 @@ + + GraphingSettings.xaml + Create Create diff --git a/src/Calculator/GraphingSettings.xaml b/src/Calculator/GraphingSettings.xaml new file mode 100644 index 000000000..4ac411529 --- /dev/null +++ b/src/Calculator/GraphingSettings.xaml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Calculator/GraphingSettings.xaml.cpp b/src/Calculator/GraphingSettings.xaml.cpp new file mode 100644 index 000000000..e94e68a13 --- /dev/null +++ b/src/Calculator/GraphingSettings.xaml.cpp @@ -0,0 +1,220 @@ +#include "pch.h" + +#include "GraphingSettings.xaml.h" +#include + +using namespace Graphing; + +using namespace CalculatorApp; +using namespace CalculatorApp::Controls; + +using namespace Platform; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::UI::Xaml::Controls::Primitives; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Input; +using namespace Windows::UI::Xaml::Media; +using namespace Windows::UI::Xaml::Navigation; + +GraphingSettings::GraphingSettings() +{ + InitializeComponent(); + + auto resLoader = AppResourceProvider::GetInstance(); + + x_MinHeading->Text = resLoader.GetResourceString(L"x-min"); + x_MaxHeading->Text = resLoader.GetResourceString(L"x-max"); + y_MinHeading->Text = resLoader.GetResourceString(L"y-min"); + y_MaxHeading->Text = resLoader.GetResourceString(L"y-max"); + + GridHeading->Text = resLoader.GetResourceString(L"GridHeading"); + UnitsHeading->Text = resLoader.GetResourceString(L"UnitsHeading"); + + Radians->Content = resLoader.GetResourceString(L"TrigModeRadians"); + Degrees->Content = resLoader.GetResourceString(L"TrigModeDegrees"); + Gradians->Content = resLoader.GetResourceString(L"TrigModeGradians"); +} + +void GraphingSettings::GraphingCalculator_DataContextChanged(FrameworkElement ^ sender, DataContextChangedEventArgs ^ args) +{ + // The graph control we are working with + m_ParentGrapher = (GraphControl::Grapher ^) args->NewValue; +} + +void GraphingSettings::TrigUnitModeClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) +{ + if (Degrees->IsChecked->Value == true) + { + m_ParentGrapher->TrigUnitMode = (int)Graphing::EvalTrigUnitMode::Degrees; + } + + if (Radians->IsChecked->Value == true) + { + m_ParentGrapher->TrigUnitMode = (int)Graphing::EvalTrigUnitMode::Radians; + } + + if (Gradians->IsChecked->Value == true) + { + m_ParentGrapher->TrigUnitMode = (int)Graphing::EvalTrigUnitMode::Grads; + } +} + +void GraphingSettings::UpdateExtents(Platform::Object ^ sender) +{ + FrameworkElement ^ fe = (FrameworkElement ^) sender; + FrameworkElement ^ currentFocus = (FrameworkElement ^) FocusManager::GetFocusedElement(); + + bool thisControlHasFocus = (fe == currentFocus); + TextBox ^ tb = reinterpret_cast(sender); + bool widthChanged = false; + bool heightChanged = false; + + try + { + double newVal = std::stod(tb->Text->Begin()); + if (tb->Name == "x_min" && newVal != m_xMin) + { + widthChanged = true; + m_xMin = newVal; + m_ParentGrapher->XAxisMin = m_xMin; + } + + if (tb->Name == "x_max" && newVal != m_xMax) + { + widthChanged = true; + m_xMax = newVal; + m_ParentGrapher->XAxisMax = m_xMax; + } + + if (tb->Name == "y_min" && newVal != m_yMin) + { + heightChanged = true; + m_yMin = newVal; + m_ParentGrapher->YAxisMin = m_yMin; + } + + if (tb->Name == "y_max" && newVal != m_yMax) + { + heightChanged = true; + m_yMax = newVal; + m_ParentGrapher->YAxisMax = m_yMax; + } + + // Only the focused element get's to trigger the recompute + + if (thisControlHasFocus) + { + if (m_preserveAspectRatio) + { + if (widthChanged) + { + m_width = m_xMax - m_xMin; + m_height = m_width / m_currentAspectRatio; + double bounds = m_height / 2; + m_yMin = -bounds; + m_yMax = bounds; + m_ParentGrapher->YAxisMin = m_yMin; + m_ParentGrapher->YAxisMax = m_yMax; + } + + if (heightChanged) + { + m_height = m_yMax - m_yMin; + m_width = m_height * m_currentAspectRatio; + double bounds = m_width / 2; + m_xMin = -bounds; + m_xMax = bounds; + m_ParentGrapher->XAxisMin = m_xMin; + m_ParentGrapher->XAxisMax = m_xMax; + } + + if (widthChanged || heightChanged) + { + x_min->Text = m_xMin.ToString(); + x_max->Text = m_xMax.ToString(); + + y_min->Text = m_yMin.ToString(); + y_max->Text = m_yMax.ToString(); + + m_ParentGrapher->SetDisplayRanges(m_xMin, m_xMax, m_yMin, m_yMax); + } + } + } + } + catch (const std::exception&) + { + } +} + +void CalculatorApp::Controls::GraphingSettings::OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) +{ + m_ParentGrapher->GetDisplayRanges(&m_xMin, &m_xMax, &m_yMin, &m_yMax); + + // Now we can load our UX + x_min->Text = m_xMin.ToString(); + x_max->Text = m_xMax.ToString(); + + y_min->Text = m_yMin.ToString(); + y_max->Text = m_yMax.ToString(); + + switch ((Graphing::EvalTrigUnitMode)m_ParentGrapher->TrigUnitMode) + { + case Graphing::EvalTrigUnitMode::Degrees: + { + Degrees->IsChecked = true; + } + break; + case Graphing::EvalTrigUnitMode::Radians: + { + Radians->IsChecked = true; + } + break; + case Graphing::EvalTrigUnitMode::Grads: + { + Gradians->IsChecked = true; + } + break; + + case Graphing::EvalTrigUnitMode::Invalid: + { + OutputDebugString(L"GraphingSettings::GraphingCalculator_DataContextChanged Unsupported TrigUnitMode\r\n"); + m_ParentGrapher->TrigUnitMode = (int)Graphing::EvalTrigUnitMode::Radians; + } + } + + m_width = m_xMax - m_xMin; + m_height = m_yMax - m_yMin; + m_currentAspectRatio = m_height / m_width; +} + +void GraphingSettings::OnLosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args) +{ + UpdateExtents(sender); +} + +void GraphingSettings::OnKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) +{ + if (e->Key == Windows::System::VirtualKey::Enter) + { + UpdateExtents(sender); + } +} + +void CalculatorApp::Controls::GraphingSettings::OnPreserveAspectRatioClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) +{ + if (m_preserveAspectRatio) + { + // On now, turning it off + m_preserveAspectRatio = false; + PreserveAspectRatioSymbol->Opacity = 0.25; + } + else + { + // Off now, turning it on + m_preserveAspectRatio = true; + PreserveAspectRatioSymbol->Opacity = 1.0; + } +} diff --git a/src/Calculator/GraphingSettings.xaml.h b/src/Calculator/GraphingSettings.xaml.h new file mode 100644 index 000000000..70d34fb3f --- /dev/null +++ b/src/Calculator/GraphingSettings.xaml.h @@ -0,0 +1,55 @@ +// +// MyUserControl.xaml.h +// Declaration of the MyUserControl class +// + +#pragma once + +#include "..\..\src\GraphingInterfaces\IMathSolver.h" + +#include "CalcViewModel/Common/Utils.h" + +#include "GraphingSettings.g.h" +#include + +namespace CalculatorApp +{ + namespace Controls + { + [Windows::Foundation::Metadata::WebHostHidden] public ref class GraphingSettings sealed + { + public: + GraphingSettings(); + + private: + void TrigUnitModeClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); + + void GraphingCalculator_DataContextChanged(Windows::UI::Xaml::FrameworkElement ^ sender, Windows::UI::Xaml::DataContextChangedEventArgs ^ args); + + // Helper for updating the extents from the various ways we can trigger it. + void UpdateExtents(Platform::Object ^ sender); + + + GraphControl::Grapher^ m_ParentGrapher; + + std::mutex m_updating; + bool m_loading; + + double + m_currentAspectRatio, + m_width, + m_height, + m_xMin, + m_yMin, + m_xMax, + m_yMax; + + bool m_preserveAspectRatio = true; + + void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); + void OnLosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args); + void OnKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e); + void OnPreserveAspectRatioClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); + }; + } +} diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw index e19f73a9e..f97264fc7 100644 --- a/src/Calculator/Resources/en-US/Resources.resw +++ b/src/Calculator/Resources/en-US/Resources.resw @@ -4202,6 +4202,44 @@ Current mode is graph mode Announcement used in Graphing Calculator when switching to the graph mode + + Grid + Heading for grid extents on the settings + + + Degrees + Degrees mode on settings page + + + Gradians + Gradian mode on settings page + + + Radians + Radians mode on settings page + + + Unit + Heading for Unit's on the settings + + + x-max + X maximum value header + + + x-min + X minimum value header + + + y-max + Y Maximum value header + + + y-min + Y minimum value header + + + Enter an equation Used in the Graphing Calculator to indicate to users that they can enter an equation in the textbox diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml index fe5c112ef..95e04e7b2 100644 --- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml +++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml @@ -414,6 +414,23 @@ FontSize="18" Glyph=""/> + + VariableUpdated += ref new EventHandler(this, &CalculatorApp::GraphingCalculator::OnVariableChanged); + + // Let the graph settings know who it's parent is. + GraphSettings->DataContext = GraphingControl; } void GraphingCalculator::OnEquationsVectorChanged(IObservableVector ^ sender, IVectorChangedEventArgs ^ event) diff --git a/src/GraphControl/Control/Grapher.h b/src/GraphControl/Control/Grapher.h index f09f3e79c..b3c8e2f01 100644 --- a/src/GraphControl/Control/Grapher.h +++ b/src/GraphControl/Control/Grapher.h @@ -98,6 +98,105 @@ public void SetVariable(Platform::String ^ variableName, double newValue); Platform::String ^ ConvertToLinear(Platform::String ^ mmlString); void PlotGraph(); + void AnalyzeEquation(GraphControl::Equation ^ equation); + // We can't use the EValTrigUnitMode enum directly in as the property type because it comes from another module which doesn't expose + // it as a public enum class. So the compiler doesn't recognize it as a valid type for the ABI boundary. + property int TrigUnitMode + { + void set(int value) + { + if (value != (int)m_solver->EvalOptions().GetTrigUnitMode()) + { + m_solver->EvalOptions().SetTrigUnitMode((Graphing::EvalTrigUnitMode)value); + UpdateGraph(); + } + } + + int get() + { + return (int)m_solver->EvalOptions().GetTrigUnitMode(); + } + } + + property double XAxisMin + { + double get() + { + return m_graph->GetOptions().GetDefaultXRange().first; + } + void set(double value) + { + std::pair newValue(value, XAxisMax); + m_graph->GetOptions().SetDefaultXRange(newValue); + m_renderMain->RunRenderPass(); + } + } + + property double XAxisMax + { + double get() + { + return m_graph->GetOptions().GetDefaultXRange().second; + } + void set(double value) + { + std::pair newValue(XAxisMax, value); + m_graph->GetOptions().SetDefaultXRange(newValue); + m_renderMain->RunRenderPass(); + } + } + + property double YAxisMin + { + double get() + { + return m_graph->GetOptions().GetDefaultXRange().first; + } + void set(double value) + { + std::pair newValue(value, YAxisMax); + m_graph->GetOptions().SetDefaultYRange(newValue); + m_renderMain->RunRenderPass(); + } + } + + property double YAxisMax + { + double get() + { + return m_graph->GetOptions().GetDefaultXRange().second; + } + void set(double value) + { + std::pair newValue(YAxisMax, value); + m_graph->GetOptions().SetDefaultYRange(newValue); + m_renderMain->RunRenderPass(); + } + } + + void GetDisplayRanges(double* xMin, double* xMax, double* yMin, double* yMax) + { + try + { + m_graph->GetRenderer()->GetDisplayRanges(*xMin, *xMax, *yMin, *yMax); + } + catch (const std::exception&) + { + OutputDebugString(L"GetDisplayRanges failed\r\n"); + } + } + + void SetDisplayRanges(double xMin, double xMax, double yMin, double yMax) + { + try + { + m_graph->GetRenderer()->SetDisplayRanges(xMin, xMax, yMin, yMax); + } + catch (const std::exception&) + { + OutputDebugString(L"SetDisplayRanges failed\r\n"); + } + } GraphControl::KeyGraphFeaturesInfo ^ AnalyzeEquation(GraphControl::Equation ^ equation); protected: diff --git a/src/GraphingImpl/Mocks/MathSolver.h b/src/GraphingImpl/Mocks/MathSolver.h index 7394c341e..a520cd808 100644 --- a/src/GraphingImpl/Mocks/MathSolver.h +++ b/src/GraphingImpl/Mocks/MathSolver.h @@ -17,6 +17,13 @@ namespace MockGraphingImpl class EvalOptions : public Graphing::IEvalOptions { + Graphing::EvalTrigUnitMode GetTrigUnitMode() override + { + return Graphing::EvalTrigUnitMode::Invalid; + } + void SetTrigUnitMode(Graphing::EvalTrigUnitMode value) override + { + } }; class FormatOptions : public Graphing::IFormatOptions diff --git a/src/GraphingInterfaces/GraphingEnums.h b/src/GraphingInterfaces/GraphingEnums.h index 81bfbebe8..2e78531c7 100644 --- a/src/GraphingInterfaces/GraphingEnums.h +++ b/src/GraphingInterfaces/GraphingEnums.h @@ -130,16 +130,16 @@ namespace Graphing enum class EvalTrigUnitMode { // Invalid value. - Invalid, + Invalid = 3, // Default trig unit. Period of sin is 2pi - Radians, + Radians = 0, // Degrees as trig unit. Period of sin is 360 degrees - Degrees, + Degrees = 1, // Grads as trig unit. Period of sin is 400 grads - Grads + Grads = 2 }; // Specifies the type of contextual action diff --git a/src/GraphingInterfaces/IGraphRenderer.h b/src/GraphingInterfaces/IGraphRenderer.h index a7af01a84..9f7b643f9 100644 --- a/src/GraphingInterfaces/IGraphRenderer.h +++ b/src/GraphingInterfaces/IGraphRenderer.h @@ -29,5 +29,7 @@ namespace Graphing::Renderer virtual HRESULT GetBitmap(std::shared_ptr& bitmapOut, bool& hasSomeMissingDataOut) = 0; + virtual HRESULT GetDisplayRanges(double& xMin, double& xMax, double& yMin, double& yMax) = 0; + virtual HRESULT SetDisplayRanges(double xMin, double xMax, double yMin, double yMax) = 0; }; } diff --git a/src/GraphingInterfaces/IMathSolver.h b/src/GraphingInterfaces/IMathSolver.h index 25c7cbadf..8c801badb 100644 --- a/src/GraphingInterfaces/IMathSolver.h +++ b/src/GraphingInterfaces/IMathSolver.h @@ -36,6 +36,10 @@ namespace Graphing struct IEvalOptions : public NonCopyable, public NonMoveable { virtual ~IEvalOptions() = default; + + virtual Graphing::EvalTrigUnitMode GetTrigUnitMode() = 0; + virtual void SetTrigUnitMode(Graphing::EvalTrigUnitMode value) = 0; + }; struct IFormatOptions : public NonCopyable, public NonMoveable From 3054b996c8aab934f388f7a6b669f020d4106849 Mon Sep 17 00:00:00 2001 From: David Shoemaker Date: Fri, 6 Dec 2019 10:21:37 -0800 Subject: [PATCH 02/21] PR comment updates. --- src/Calculator/Calculator.vcxproj | 18 +- src/Calculator/Calculator.vcxproj.filters | 4 + src/Calculator/GraphingSettings.xaml | 136 ------------ src/Calculator/GraphingSettings.xaml.h | 55 ----- src/Calculator/Resources/en-US/Resources.resw | 18 +- .../GraphingCalculator.xaml | 4 +- .../GraphingCalculator/GraphingSettings.xaml | 207 ++++++++++++++++++ .../GraphingSettings.xaml.cpp | 55 ++--- .../GraphingSettings.xaml.h | 42 ++++ src/GraphControl/Control/Grapher.h | 7 +- 10 files changed, 296 insertions(+), 250 deletions(-) delete mode 100644 src/Calculator/GraphingSettings.xaml delete mode 100644 src/Calculator/GraphingSettings.xaml.h create mode 100644 src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml rename src/Calculator/{ => Views/GraphingCalculator}/GraphingSettings.xaml.cpp (71%) create mode 100644 src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.h diff --git a/src/Calculator/Calculator.vcxproj b/src/Calculator/Calculator.vcxproj index 292bc8a20..cf36ed299 100644 --- a/src/Calculator/Calculator.vcxproj +++ b/src/Calculator/Calculator.vcxproj @@ -257,9 +257,6 @@ - - GraphingSettings.xaml - App.xaml @@ -299,6 +296,9 @@ Views\GraphingCalculator\GraphingCalculator.xaml + + Views\GraphingCalculator\GraphingSettings.xaml + Views\GraphingCalculator\KeyGraphFeaturesPanel.xaml @@ -344,9 +344,6 @@ Designer - - Designer - Designer @@ -369,6 +366,7 @@ + @@ -421,9 +419,6 @@ - - GraphingSettings.xaml - Create Create @@ -469,6 +464,9 @@ Views\GraphingCalculator\GraphingCalculator.xaml + + Views\GraphingCalculator\GraphingSettings.xaml + Views\GraphingCalculator\KeyGraphFeaturesPanel.xaml @@ -900,4 +898,4 @@ - + \ No newline at end of file diff --git a/src/Calculator/Calculator.vcxproj.filters b/src/Calculator/Calculator.vcxproj.filters index 0233c028e..c2259d259 100644 --- a/src/Calculator/Calculator.vcxproj.filters +++ b/src/Calculator/Calculator.vcxproj.filters @@ -509,6 +509,8 @@ Views\GraphingCalculator + + Views\GraphingCalculator Views\GraphingCalculator @@ -1560,5 +1562,7 @@ + + \ No newline at end of file diff --git a/src/Calculator/GraphingSettings.xaml b/src/Calculator/GraphingSettings.xaml deleted file mode 100644 index 4ac411529..000000000 --- a/src/Calculator/GraphingSettings.xaml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Calculator/GraphingSettings.xaml.h b/src/Calculator/GraphingSettings.xaml.h deleted file mode 100644 index 70d34fb3f..000000000 --- a/src/Calculator/GraphingSettings.xaml.h +++ /dev/null @@ -1,55 +0,0 @@ -// -// MyUserControl.xaml.h -// Declaration of the MyUserControl class -// - -#pragma once - -#include "..\..\src\GraphingInterfaces\IMathSolver.h" - -#include "CalcViewModel/Common/Utils.h" - -#include "GraphingSettings.g.h" -#include - -namespace CalculatorApp -{ - namespace Controls - { - [Windows::Foundation::Metadata::WebHostHidden] public ref class GraphingSettings sealed - { - public: - GraphingSettings(); - - private: - void TrigUnitModeClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); - - void GraphingCalculator_DataContextChanged(Windows::UI::Xaml::FrameworkElement ^ sender, Windows::UI::Xaml::DataContextChangedEventArgs ^ args); - - // Helper for updating the extents from the various ways we can trigger it. - void UpdateExtents(Platform::Object ^ sender); - - - GraphControl::Grapher^ m_ParentGrapher; - - std::mutex m_updating; - bool m_loading; - - double - m_currentAspectRatio, - m_width, - m_height, - m_xMin, - m_yMin, - m_xMax, - m_yMax; - - bool m_preserveAspectRatio = true; - - void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); - void OnLosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args); - void OnKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e); - void OnPreserveAspectRatioClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); - }; - } -} diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw index f97264fc7..fda828023 100644 --- a/src/Calculator/Resources/en-US/Resources.resw +++ b/src/Calculator/Resources/en-US/Resources.resw @@ -4202,39 +4202,39 @@ Current mode is graph mode Announcement used in Graphing Calculator when switching to the graph mode - + Grid Heading for grid extents on the settings - + Degrees Degrees mode on settings page - + Gradians Gradian mode on settings page - + Radians Radians mode on settings page - + Unit Heading for Unit's on the settings - + x-max X maximum value header - + x-min X minimum value header - + y-max Y Maximum value header - + y-min Y minimum value header diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml index 95e04e7b2..68a3444db 100644 --- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml +++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml @@ -426,11 +426,11 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Calculator/GraphingSettings.xaml.cpp b/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.cpp similarity index 71% rename from src/Calculator/GraphingSettings.xaml.cpp rename to src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.cpp index e94e68a13..c9b555e2e 100644 --- a/src/Calculator/GraphingSettings.xaml.cpp +++ b/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.cpp @@ -1,12 +1,11 @@ #include "pch.h" #include "GraphingSettings.xaml.h" -#include +#include "CalcViewModel\Common\AppResourceProvider.cpp" using namespace Graphing; using namespace CalculatorApp; -using namespace CalculatorApp::Controls; using namespace Platform; using namespace Windows::Foundation; @@ -22,26 +21,12 @@ using namespace Windows::UI::Xaml::Navigation; GraphingSettings::GraphingSettings() { InitializeComponent(); - - auto resLoader = AppResourceProvider::GetInstance(); - - x_MinHeading->Text = resLoader.GetResourceString(L"x-min"); - x_MaxHeading->Text = resLoader.GetResourceString(L"x-max"); - y_MinHeading->Text = resLoader.GetResourceString(L"y-min"); - y_MaxHeading->Text = resLoader.GetResourceString(L"y-max"); - - GridHeading->Text = resLoader.GetResourceString(L"GridHeading"); - UnitsHeading->Text = resLoader.GetResourceString(L"UnitsHeading"); - - Radians->Content = resLoader.GetResourceString(L"TrigModeRadians"); - Degrees->Content = resLoader.GetResourceString(L"TrigModeDegrees"); - Gradians->Content = resLoader.GetResourceString(L"TrigModeGradians"); } void GraphingSettings::GraphingCalculator_DataContextChanged(FrameworkElement ^ sender, DataContextChangedEventArgs ^ args) { // The graph control we are working with - m_ParentGrapher = (GraphControl::Grapher ^) args->NewValue; + m_ParentGrapher = dynamic_cast(args->NewValue); } void GraphingSettings::TrigUnitModeClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) @@ -64,39 +49,39 @@ void GraphingSettings::TrigUnitModeClick(Platform::Object ^ sender, Windows::UI: void GraphingSettings::UpdateExtents(Platform::Object ^ sender) { - FrameworkElement ^ fe = (FrameworkElement ^) sender; - FrameworkElement ^ currentFocus = (FrameworkElement ^) FocusManager::GetFocusedElement(); + Control ^ senderControl = static_cast(sender); + bool thisControlHasFocus = senderControl->FocusState != ::FocusState::Unfocused; + + TextBox ^ tb = static_cast(sender); - bool thisControlHasFocus = (fe == currentFocus); - TextBox ^ tb = reinterpret_cast(sender); bool widthChanged = false; bool heightChanged = false; try { double newVal = std::stod(tb->Text->Begin()); - if (tb->Name == "x_min" && newVal != m_xMin) + if (tb->Name == "x_Min" && newVal != m_xMin) { widthChanged = true; m_xMin = newVal; m_ParentGrapher->XAxisMin = m_xMin; } - if (tb->Name == "x_max" && newVal != m_xMax) + if (tb->Name == "x_Max" && newVal != m_xMax) { widthChanged = true; m_xMax = newVal; m_ParentGrapher->XAxisMax = m_xMax; } - if (tb->Name == "y_min" && newVal != m_yMin) + if (tb->Name == "y_Min" && newVal != m_yMin) { heightChanged = true; m_yMin = newVal; m_ParentGrapher->YAxisMin = m_yMin; } - if (tb->Name == "y_max" && newVal != m_yMax) + if (tb->Name == "y_Max" && newVal != m_yMax) { heightChanged = true; m_yMax = newVal; @@ -133,11 +118,11 @@ void GraphingSettings::UpdateExtents(Platform::Object ^ sender) if (widthChanged || heightChanged) { - x_min->Text = m_xMin.ToString(); - x_max->Text = m_xMax.ToString(); + x_Min->Text = m_xMin.ToString(); + x_Max->Text = m_xMax.ToString(); - y_min->Text = m_yMin.ToString(); - y_max->Text = m_yMax.ToString(); + y_Min->Text = m_yMin.ToString(); + y_Max->Text = m_yMax.ToString(); m_ParentGrapher->SetDisplayRanges(m_xMin, m_xMax, m_yMin, m_yMax); } @@ -149,16 +134,16 @@ void GraphingSettings::UpdateExtents(Platform::Object ^ sender) } } -void CalculatorApp::Controls::GraphingSettings::OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) +void GraphingSettings::OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) { m_ParentGrapher->GetDisplayRanges(&m_xMin, &m_xMax, &m_yMin, &m_yMax); // Now we can load our UX - x_min->Text = m_xMin.ToString(); - x_max->Text = m_xMax.ToString(); + x_Min->Text = m_xMin.ToString(); + x_Max->Text = m_xMax.ToString(); - y_min->Text = m_yMin.ToString(); - y_max->Text = m_yMax.ToString(); + y_Min->Text = m_yMin.ToString(); + y_Max->Text = m_yMax.ToString(); switch ((Graphing::EvalTrigUnitMode)m_ParentGrapher->TrigUnitMode) { @@ -203,7 +188,7 @@ void GraphingSettings::OnKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::I } } -void CalculatorApp::Controls::GraphingSettings::OnPreserveAspectRatioClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) +void GraphingSettings::OnPreserveAspectRatioClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) { if (m_preserveAspectRatio) { diff --git a/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.h b/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.h new file mode 100644 index 000000000..58fe5dcf0 --- /dev/null +++ b/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.h @@ -0,0 +1,42 @@ +// +// MyUserControl.xaml.h +// Declaration of the MyUserControl class +// + +#pragma once + +#include "CalcViewModel/Common/Utils.h" + +#include "Views\GraphingCalculator\GraphingSettings.g.h" +#include + +namespace CalculatorApp +{ + [Windows::Foundation::Metadata::WebHostHidden] public ref class GraphingSettings sealed + { + public: + GraphingSettings(); + + private: + void TrigUnitModeClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); + + void GraphingCalculator_DataContextChanged(Windows::UI::Xaml::FrameworkElement ^ sender, Windows::UI::Xaml::DataContextChangedEventArgs ^ args); + + // Helper for updating the extents from the various ways we can trigger it. + void UpdateExtents(Platform::Object ^ sender); + + GraphControl::Grapher ^ m_ParentGrapher; + + std::mutex m_updating; + bool m_loading; + + double m_currentAspectRatio, m_width, m_height, m_xMin, m_yMin, m_xMax, m_yMax; + + bool m_preserveAspectRatio = true; + + void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); + void OnLosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args); + void OnKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e); + void OnPreserveAspectRatioClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); + }; +} diff --git a/src/GraphControl/Control/Grapher.h b/src/GraphControl/Control/Grapher.h index b3c8e2f01..209ba58ac 100644 --- a/src/GraphControl/Control/Grapher.h +++ b/src/GraphControl/Control/Grapher.h @@ -99,7 +99,8 @@ public Platform::String ^ ConvertToLinear(Platform::String ^ mmlString); void PlotGraph(); void AnalyzeEquation(GraphControl::Equation ^ equation); - // We can't use the EValTrigUnitMode enum directly in as the property type because it comes from another module which doesn't expose + + // We can't use the EValTrigUnitMode enum directly in as the property type because it comes from another module which doesn't expose // it as a public enum class. So the compiler doesn't recognize it as a valid type for the ABI boundary. property int TrigUnitMode { @@ -140,7 +141,7 @@ public } void set(double value) { - std::pair newValue(XAxisMax, value); + std::pair newValue(XAxisMin, value); m_graph->GetOptions().SetDefaultXRange(newValue); m_renderMain->RunRenderPass(); } @@ -168,7 +169,7 @@ public } void set(double value) { - std::pair newValue(YAxisMax, value); + std::pair newValue(YAxisMin, value); m_graph->GetOptions().SetDefaultYRange(newValue); m_renderMain->RunRenderPass(); } From f3de60b1f531e9031a379af816c30d43a404ffa7 Mon Sep 17 00:00:00 2001 From: sanderl <46726333+sanderl@users.noreply.github.com> Date: Tue, 10 Dec 2019 16:16:55 -0800 Subject: [PATCH 03/21] Updated GraphingInterfaces and added logic to enable key graph features for equations with variables --- src/GraphControl/Control/Grapher.cpp | 5 +++++ src/GraphControl/Control/Grapher.h | 6 +++--- src/GraphingImpl/Mocks/MathSolver.h | 2 +- src/GraphingInterfaces/Common.h | 4 ++++ src/GraphingInterfaces/GraphingEnums.h | 11 +++++++---- src/GraphingInterfaces/IBitmap.h | 3 +++ src/GraphingInterfaces/IEquation.h | 3 +++ src/GraphingInterfaces/IEquationOptions.h | 3 +++ src/GraphingInterfaces/IGraph.h | 3 +++ src/GraphingInterfaces/IGraphAnalyzer.h | 3 +++ src/GraphingInterfaces/IGraphRenderer.h | 7 +++++-- src/GraphingInterfaces/IGraphingOptions.h | 7 +++++++ src/GraphingInterfaces/IMathSolver.h | 8 +++++--- 13 files changed, 52 insertions(+), 13 deletions(-) diff --git a/src/GraphControl/Control/Grapher.cpp b/src/GraphControl/Control/Grapher.cpp index 786688592..37301d99a 100644 --- a/src/GraphControl/Control/Grapher.cpp +++ b/src/GraphControl/Control/Grapher.cpp @@ -479,6 +479,11 @@ namespace GraphControl { options.SetForceProportional(ForceProportionalAxes); + if (!options.GetAllowKeyGraphFeaturesForFunctionsWithParameters()) + { + options.SetAllowKeyGraphFeaturesForFunctionsWithParameters(true); + } + if (!validEqs.empty()) { vector graphColors; diff --git a/src/GraphControl/Control/Grapher.h b/src/GraphControl/Control/Grapher.h index 209ba58ac..494edd332 100644 --- a/src/GraphControl/Control/Grapher.h +++ b/src/GraphControl/Control/Grapher.h @@ -100,7 +100,7 @@ public void PlotGraph(); void AnalyzeEquation(GraphControl::Equation ^ equation); - // We can't use the EValTrigUnitMode enum directly in as the property type because it comes from another module which doesn't expose + // We can't use the EvalTrigUnitMode enum directly in as the property type because it comes from another module which doesn't expose // it as a public enum class. So the compiler doesn't recognize it as a valid type for the ABI boundary. property int TrigUnitMode { @@ -108,8 +108,8 @@ public { if (value != (int)m_solver->EvalOptions().GetTrigUnitMode()) { - m_solver->EvalOptions().SetTrigUnitMode((Graphing::EvalTrigUnitMode)value); - UpdateGraph(); + m_solver->EvalOptions().SetTrigUnitMode((EvalTrigUnitMode)value); + PlotGraph(); } } diff --git a/src/GraphingImpl/Mocks/MathSolver.h b/src/GraphingImpl/Mocks/MathSolver.h index a520cd808..10dfdfd65 100644 --- a/src/GraphingImpl/Mocks/MathSolver.h +++ b/src/GraphingImpl/Mocks/MathSolver.h @@ -17,7 +17,7 @@ namespace MockGraphingImpl class EvalOptions : public Graphing::IEvalOptions { - Graphing::EvalTrigUnitMode GetTrigUnitMode() override + Graphing::EvalTrigUnitMode GetTrigUnitMode() const override { return Graphing::EvalTrigUnitMode::Invalid; } diff --git a/src/GraphingInterfaces/Common.h b/src/GraphingInterfaces/Common.h index 37514c29b..f31524000 100644 --- a/src/GraphingInterfaces/Common.h +++ b/src/GraphingInterfaces/Common.h @@ -1,7 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once #include #include + #ifndef GRAPHINGAPI #ifdef GRAPHING_ENGINE_IMPL #define GRAPHINGAPI __declspec(dllexport) diff --git a/src/GraphingInterfaces/GraphingEnums.h b/src/GraphingInterfaces/GraphingEnums.h index 2e78531c7..e810731c8 100644 --- a/src/GraphingInterfaces/GraphingEnums.h +++ b/src/GraphingInterfaces/GraphingEnums.h @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once namespace Graphing @@ -130,16 +133,16 @@ namespace Graphing enum class EvalTrigUnitMode { // Invalid value. - Invalid = 3, + Invalid, // Default trig unit. Period of sin is 2pi - Radians = 0, + Radians, // Degrees as trig unit. Period of sin is 360 degrees - Degrees = 1, + Degrees, // Grads as trig unit. Period of sin is 400 grads - Grads = 2 + Grads }; // Specifies the type of contextual action diff --git a/src/GraphingInterfaces/IBitmap.h b/src/GraphingInterfaces/IBitmap.h index 46ba34a2d..ee042d53a 100644 --- a/src/GraphingInterfaces/IBitmap.h +++ b/src/GraphingInterfaces/IBitmap.h @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once #include diff --git a/src/GraphingInterfaces/IEquation.h b/src/GraphingInterfaces/IEquation.h index f49a0f9a0..1925effd2 100644 --- a/src/GraphingInterfaces/IEquation.h +++ b/src/GraphingInterfaces/IEquation.h @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once #include "Common.h" diff --git a/src/GraphingInterfaces/IEquationOptions.h b/src/GraphingInterfaces/IEquationOptions.h index 1bdd07370..d4769feeb 100644 --- a/src/GraphingInterfaces/IEquationOptions.h +++ b/src/GraphingInterfaces/IEquationOptions.h @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once #include "Common.h" diff --git a/src/GraphingInterfaces/IGraph.h b/src/GraphingInterfaces/IGraph.h index e42fd2b40..9eca23624 100644 --- a/src/GraphingInterfaces/IGraph.h +++ b/src/GraphingInterfaces/IGraph.h @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once #include "Common.h" diff --git a/src/GraphingInterfaces/IGraphAnalyzer.h b/src/GraphingInterfaces/IGraphAnalyzer.h index bfbeed066..4bd962c48 100644 --- a/src/GraphingInterfaces/IGraphAnalyzer.h +++ b/src/GraphingInterfaces/IGraphAnalyzer.h @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once #include "Common.h" diff --git a/src/GraphingInterfaces/IGraphRenderer.h b/src/GraphingInterfaces/IGraphRenderer.h index 9f7b643f9..388b80c1d 100644 --- a/src/GraphingInterfaces/IGraphRenderer.h +++ b/src/GraphingInterfaces/IGraphRenderer.h @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once #include "Common.h" @@ -26,10 +29,10 @@ namespace Graphing::Renderer virtual HRESULT ChangeRange(ChangeRangeAction action) = 0; virtual HRESULT MoveRangeByRatio(double ratioX, double ratioY) = 0; virtual HRESULT ResetRange() = 0; + virtual HRESULT GetDisplayRanges(double& xMin, double& xMax, double& yMin, double& yMax) = 0; + virtual HRESULT SetDisplayRanges(double xMin, double xMax, double yMin, double yMax) = 0; virtual HRESULT GetBitmap(std::shared_ptr& bitmapOut, bool& hasSomeMissingDataOut) = 0; - virtual HRESULT GetDisplayRanges(double& xMin, double& xMax, double& yMin, double& yMax) = 0; - virtual HRESULT SetDisplayRanges(double xMin, double xMax, double yMin, double yMax) = 0; }; } diff --git a/src/GraphingInterfaces/IGraphingOptions.h b/src/GraphingInterfaces/IGraphingOptions.h index 728d6b736..3c3101726 100644 --- a/src/GraphingInterfaces/IGraphingOptions.h +++ b/src/GraphingInterfaces/IGraphingOptions.h @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once #include @@ -49,6 +52,10 @@ namespace Graphing virtual void SetBackColor(const Graphing::Color& value) = 0; virtual void ResetBackColor() = 0; + virtual void SetAllowKeyGraphFeaturesForFunctionsWithParameters(bool kgf) = 0; + virtual bool GetAllowKeyGraphFeaturesForFunctionsWithParameters() const = 0; + virtual void ResetAllowKeyGraphFeaturesForFunctionsWithParameters() = 0; + virtual Graphing::Color GetZerosColor() const = 0; virtual void SetZerosColor(const Graphing::Color& value) = 0; virtual void ResetZerosColor() = 0; diff --git a/src/GraphingInterfaces/IMathSolver.h b/src/GraphingInterfaces/IMathSolver.h index 8c801badb..c1df98ac8 100644 --- a/src/GraphingInterfaces/IMathSolver.h +++ b/src/GraphingInterfaces/IMathSolver.h @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once #include "Common.h" @@ -37,9 +40,8 @@ namespace Graphing { virtual ~IEvalOptions() = default; - virtual Graphing::EvalTrigUnitMode GetTrigUnitMode() = 0; - virtual void SetTrigUnitMode(Graphing::EvalTrigUnitMode value) = 0; - + virtual EvalTrigUnitMode GetTrigUnitMode() const = 0; + virtual void SetTrigUnitMode(EvalTrigUnitMode value) = 0; }; struct IFormatOptions : public NonCopyable, public NonMoveable From 1fb8b18f9f16e8e2c18a73df80b396d5853f7fa8 Mon Sep 17 00:00:00 2001 From: sanderl <46726333+sanderl@users.noreply.github.com> Date: Wed, 11 Dec 2019 16:21:18 -0800 Subject: [PATCH 04/21] Removed LockAspectRatio, hooked up the engine for graph options and started fixing the styling on the page. --- src/Calculator/Calculator.vcxproj | 4 +- .../GraphingCalculator.xaml | 2 +- .../GraphingCalculator/GraphingSettings.xaml | 119 ++++++++------ .../GraphingSettings.xaml.cpp | 153 +++++------------- .../GraphingSettings.xaml.h | 4 +- 5 files changed, 117 insertions(+), 165 deletions(-) diff --git a/src/Calculator/Calculator.vcxproj b/src/Calculator/Calculator.vcxproj index cf36ed299..652751562 100644 --- a/src/Calculator/Calculator.vcxproj +++ b/src/Calculator/Calculator.vcxproj @@ -16,7 +16,7 @@ 10.0 black Always - TemporaryKey.pfx + true False @@ -898,4 +898,4 @@ - \ No newline at end of file + diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml index 68a3444db..9f4c7294e 100644 --- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml +++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml @@ -422,7 +422,7 @@ Margin="0,0,10,0" Style="{StaticResource GraphButtonStyle}" RequestedTheme="Light"> - + diff --git a/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml b/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml index 4d10f0b72..bebf23759 100644 --- a/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml +++ b/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml @@ -22,55 +22,101 @@ + + + - + - + + + + + - - - + + + + - - - + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + - - - - - - (sender); - bool thisControlHasFocus = senderControl->FocusState != ::FocusState::Unfocused; TextBox ^ tb = static_cast(sender); bool widthChanged = false; bool heightChanged = false; - try + double newVal = std::stod(tb->Text->Begin()); + if (tb->Name == "x_Min" && newVal != m_xMin) { - double newVal = std::stod(tb->Text->Begin()); - if (tb->Name == "x_Min" && newVal != m_xMin) - { - widthChanged = true; - m_xMin = newVal; - m_ParentGrapher->XAxisMin = m_xMin; - } - - if (tb->Name == "x_Max" && newVal != m_xMax) - { - widthChanged = true; - m_xMax = newVal; - m_ParentGrapher->XAxisMax = m_xMax; - } - - if (tb->Name == "y_Min" && newVal != m_yMin) - { - heightChanged = true; - m_yMin = newVal; - m_ParentGrapher->YAxisMin = m_yMin; - } - - if (tb->Name == "y_Max" && newVal != m_yMax) - { - heightChanged = true; - m_yMax = newVal; - m_ParentGrapher->YAxisMax = m_yMax; - } + widthChanged = true; + m_xMin = newVal; + m_ParentGrapher->XAxisMin = m_xMin; + } - // Only the focused element get's to trigger the recompute + if (tb->Name == "x_Max" && newVal != m_xMax) + { + widthChanged = true; + m_xMax = newVal; + m_ParentGrapher->XAxisMax = m_xMax; + } - if (thisControlHasFocus) - { - if (m_preserveAspectRatio) - { - if (widthChanged) - { - m_width = m_xMax - m_xMin; - m_height = m_width / m_currentAspectRatio; - double bounds = m_height / 2; - m_yMin = -bounds; - m_yMax = bounds; - m_ParentGrapher->YAxisMin = m_yMin; - m_ParentGrapher->YAxisMax = m_yMax; - } - - if (heightChanged) - { - m_height = m_yMax - m_yMin; - m_width = m_height * m_currentAspectRatio; - double bounds = m_width / 2; - m_xMin = -bounds; - m_xMax = bounds; - m_ParentGrapher->XAxisMin = m_xMin; - m_ParentGrapher->XAxisMax = m_xMax; - } - - if (widthChanged || heightChanged) - { - x_Min->Text = m_xMin.ToString(); - x_Max->Text = m_xMax.ToString(); - - y_Min->Text = m_yMin.ToString(); - y_Max->Text = m_yMax.ToString(); - - m_ParentGrapher->SetDisplayRanges(m_xMin, m_xMax, m_yMin, m_yMax); - } - } - } + if (tb->Name == "y_Min" && newVal != m_yMin) + { + heightChanged = true; + m_yMin = newVal; + m_ParentGrapher->YAxisMin = m_yMin; } - catch (const std::exception&) + + if (tb->Name == "y_Max" && newVal != m_yMax) { + heightChanged = true; + m_yMax = newVal; + m_ParentGrapher->YAxisMax = m_yMax; } } @@ -147,32 +99,27 @@ void GraphingSettings::OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::Ro switch ((Graphing::EvalTrigUnitMode)m_ParentGrapher->TrigUnitMode) { - case Graphing::EvalTrigUnitMode::Degrees: - { - Degrees->IsChecked = true; - } - break; - case Graphing::EvalTrigUnitMode::Radians: - { - Radians->IsChecked = true; - } - break; - case Graphing::EvalTrigUnitMode::Grads: - { - Gradians->IsChecked = true; - } - break; - - case Graphing::EvalTrigUnitMode::Invalid: - { - OutputDebugString(L"GraphingSettings::GraphingCalculator_DataContextChanged Unsupported TrigUnitMode\r\n"); - m_ParentGrapher->TrigUnitMode = (int)Graphing::EvalTrigUnitMode::Radians; - } + case Graphing::EvalTrigUnitMode::Degrees: + { + Degrees->IsChecked = true; + break; + } + case Graphing::EvalTrigUnitMode::Radians: + { + Radians->IsChecked = true; + break; + } + case Graphing::EvalTrigUnitMode::Grads: + { + Gradians->IsChecked = true; + break; + } + case Graphing::EvalTrigUnitMode::Invalid: + { + m_ParentGrapher->TrigUnitMode = (int)Graphing::EvalTrigUnitMode::Radians; + break; + } } - - m_width = m_xMax - m_xMin; - m_height = m_yMax - m_yMin; - m_currentAspectRatio = m_height / m_width; } void GraphingSettings::OnLosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args) @@ -187,19 +134,3 @@ void GraphingSettings::OnKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::I UpdateExtents(sender); } } - -void GraphingSettings::OnPreserveAspectRatioClicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) -{ - if (m_preserveAspectRatio) - { - // On now, turning it off - m_preserveAspectRatio = false; - PreserveAspectRatioSymbol->Opacity = 0.25; - } - else - { - // Off now, turning it on - m_preserveAspectRatio = true; - PreserveAspectRatioSymbol->Opacity = 1.0; - } -} diff --git a/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.h b/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.h index 58fe5dcf0..80f822ccc 100644 --- a/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.h +++ b/src/Calculator/Views/GraphingCalculator/GraphingSettings.xaml.h @@ -30,9 +30,7 @@ namespace CalculatorApp std::mutex m_updating; bool m_loading; - double m_currentAspectRatio, m_width, m_height, m_xMin, m_yMin, m_xMax, m_yMax; - - bool m_preserveAspectRatio = true; + double m_xMin, m_yMin, m_xMax, m_yMax; void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); void OnLosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args); From d2d7c28273241df55a645381652a2fc3a637e783 Mon Sep 17 00:00:00 2001 From: sanderl <46726333+sanderl@users.noreply.github.com> Date: Thu, 12 Dec 2019 15:38:51 -0800 Subject: [PATCH 05/21] Updated UI for GraphSettings --- src/Calculator/App.xaml | 25 +++ src/Calculator/Calculator.vcxproj | 2 +- src/Calculator/Resources/en-US/Resources.resw | 20 +- .../GraphingCalculator.xaml | 4 +- .../GraphingCalculator/GraphingSettings.xaml | 199 +++++++----------- .../GraphingSettings.xaml.cpp | 57 ++--- 6 files changed, 149 insertions(+), 158 deletions(-) diff --git a/src/Calculator/App.xaml b/src/Calculator/App.xaml index 4930120ee..b29988ca4 100644 --- a/src/Calculator/App.xaml +++ b/src/Calculator/App.xaml @@ -84,6 +84,14 @@ Opacity="0.6" Color="{StaticResource SystemChromeWhiteColor}"/> + + + + + + + + @@ -177,6 +185,14 @@ Color="#000000"/> + + + + + + + + @@ -234,6 +250,15 @@ + + + + + + + + + diff --git a/src/Calculator/Calculator.vcxproj b/src/Calculator/Calculator.vcxproj index 652751562..ec12440c4 100644 --- a/src/Calculator/Calculator.vcxproj +++ b/src/Calculator/Calculator.vcxproj @@ -16,7 +16,7 @@ 10.0 black Always - + TemporaryKey.pfx true False diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw index fda828023..e205a1c93 100644 --- a/src/Calculator/Resources/en-US/Resources.resw +++ b/src/Calculator/Resources/en-US/Resources.resw @@ -4219,29 +4219,35 @@ Radians mode on settings page - Unit + Units Heading for Unit's on the settings - x-max + X-Max X maximum value header - x-min + X-Min X minimum value header - y-max + Y-Max Y Maximum value header - y-min + Y-Min Y minimum value header - - Enter an equation Used in the Graphing Calculator to indicate to users that they can enter an equation in the textbox + + Grid options + This is the tooltip text for the grid options button in Graphing Calculator + + + Grid options + This is the automation name text for the grid options button in Graphing Calculator + diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml index 9f4c7294e..866a33021 100644 --- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml +++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml @@ -415,8 +415,8 @@ Glyph=""/> -