From ca0b3d83e877a56d96e8f21410bfd44054fb20a8 Mon Sep 17 00:00:00 2001 From: Pepe Rivera Date: Tue, 14 Jan 2020 13:52:57 -0800 Subject: [PATCH] fix bugs (#934) --- src/Calculator/Controls/EquationTextBox.cpp | 9 +++++++-- .../Views/GraphingCalculator/EquationInputArea.xaml | 10 ++++++++++ src/GraphControl/Control/Grapher.cpp | 9 ++++++++- src/GraphControl/Models/Equation.cpp | 10 +++++++++- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/Calculator/Controls/EquationTextBox.cpp b/src/Calculator/Controls/EquationTextBox.cpp index 98b3cf1..718c910 100644 --- a/src/Calculator/Controls/EquationTextBox.cpp +++ b/src/Calculator/Controls/EquationTextBox.cpp @@ -273,19 +273,24 @@ void EquationTextBox::UpdateButtonsVisualState() void EquationTextBox::UpdateCommonVisualState() { String ^ state = nullptr; + bool richEditHasContent = RichEditHasContent(); if (m_HasFocus && HasError) { state = "FocusedError"; } - else if (IsAddEquationMode && ((m_HasFocus || m_isPointerOver) && !RichEditHasContent())) + else if (IsAddEquationMode && m_HasFocus && !richEditHasContent) { - state = "AddEquation"; + state = "AddEquationFocused"; } else if (m_HasFocus) { state = "Focused"; } + else if (IsAddEquationMode && m_isPointerOver && !richEditHasContent) + { + state = "AddEquation"; + } else if (HasError && (m_isPointerOver || m_isColorChooserFlyoutOpen)) { state = "PointerOverError"; diff --git a/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml b/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml index 8756f1f..981b776 100644 --- a/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml +++ b/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml @@ -305,6 +305,16 @@ + + + + + + + + + + diff --git a/src/GraphControl/Control/Grapher.cpp b/src/GraphControl/Control/Grapher.cpp index af19d68..4da2123 100644 --- a/src/GraphControl/Control/Grapher.cpp +++ b/src/GraphControl/Control/Grapher.cpp @@ -277,8 +277,15 @@ namespace GraphControl { request += L","; } + auto equationRequest = eq->GetRequest()->Data(); - request += eq->GetRequest()->Data(); + // If the equation request failed, then fail graphing. + if (equationRequest == nullptr) + { + return false; + } + + request += equationRequest; } request += s_getGraphClosingTags; diff --git a/src/GraphControl/Models/Equation.cpp b/src/GraphControl/Models/Equation.cpp index 52cdb7c..02be2cb 100644 --- a/src/GraphControl/Models/Equation.cpp +++ b/src/GraphControl/Models/Equation.cpp @@ -29,7 +29,9 @@ namespace GraphControl // Check for unicode characters of less than, less than or equal to, greater than and greater than or equal to. if (expr.find(L">><") != wstring_view::npos || expr.find(L"><<") != wstring_view::npos || expr.find(L">≥<") != wstring_view::npos - || expr.find(L">≤<") != wstring_view::npos) + || expr.find(L">≤<") != wstring_view::npos || expr.find(8805) != wstring_view::npos || expr.find(8804) != wstring_view::npos + || expr.find(L"><<") != wstring_view::npos + || expr.find(L">><") != wstring_view::npos) { request = L"plotIneq2D"; } @@ -37,6 +39,12 @@ namespace GraphControl { request = L"plotEq2d"; } + // If the expression contains both x and y but no equal or inequality sign, then that cannot be graphed. + else if (expr.find(L">x<") != wstring_view::npos && (expr.find(L">y<") != wstring_view::npos)) + { + return nullptr; + } + // Else default to plot2d else { request = L"plot2d";