diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.cpp b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.cpp index 5b93cfb..efc047f 100644 --- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.cpp +++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.cpp @@ -74,6 +74,8 @@ GraphingCalculator::GraphingCalculator() // Update where the pointer value is (ie: where the user cursor from keyboard inputs moves the point to) GraphingControl->PointerValueChangedEvent += ref new PointerValueChangedEventHandler(this, &GraphingCalculator::OnPointerPointChanged); + GraphingControl->UseCommaDecimalSeperator = LocalizationSettings::GetInstance().GetDecimalSeparator() == ','; + // OemMinus and OemAdd aren't declared in the VirtualKey enum, we can't add this accelerator XAML-side auto virtualKey = ref new KeyboardAccelerator(); virtualKey->Key = (VirtualKey)189; // OemPlus key diff --git a/src/Calculator/Views/GraphingCalculator/GraphingNumPad.xaml.cpp b/src/Calculator/Views/GraphingCalculator/GraphingNumPad.xaml.cpp index 751e8a5..d3235af 100644 --- a/src/Calculator/Views/GraphingCalculator/GraphingNumPad.xaml.cpp +++ b/src/Calculator/Views/GraphingCalculator/GraphingNumPad.xaml.cpp @@ -9,6 +9,7 @@ #include "Controls/MathRichEditBox.h" using namespace CalculatorApp; +using namespace CalculatorApp::Common; using namespace Platform; using namespace Windows::Foundation; @@ -60,9 +61,9 @@ static const std::unordered_mapContent = localizationSettings.GetDecimalSeparator(); Num0Button->Content = localizationSettings.GetDigitSymbolFromEnUsDigit('0'); Num1Button->Content = localizationSettings.GetDigitSymbolFromEnUsDigit('1'); diff --git a/src/GraphControl/Control/Grapher.cpp b/src/GraphControl/Control/Grapher.cpp index 6cdccf9..4ed9ed3 100644 --- a/src/GraphControl/Control/Grapher.cpp +++ b/src/GraphControl/Control/Grapher.cpp @@ -29,6 +29,7 @@ using namespace Windows::UI::Xaml::Media; using namespace GraphControl; DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, ForceProportionalAxes); +DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, UseCommaDecimalSeperator); DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, Variables); DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, Equations); DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, AxesColor); @@ -279,7 +280,14 @@ namespace GraphControl if (numValidEquations++ > 0) { - request += L","; + if (!UseCommaDecimalSeperator) + { + request += L","; + } + else + { + request += L";"; + } } auto equationRequest = eq->GetRequest()->Data(); @@ -511,6 +519,20 @@ namespace GraphControl TryUpdateGraph(false); } + void Grapher::OnUseCommaDecimalSeperatorPropertyChanged(bool oldValue, bool newValue) + { + if (newValue) + { + m_solver->ParsingOptions().SetLocalizationType(::LocalizationType::DecimalCommaAndListSemicolon); + m_solver->FormatOptions().SetLocalizationType(::LocalizationType::DecimalCommaAndListSemicolon); + } + else + { + m_solver->ParsingOptions().SetLocalizationType(::LocalizationType::DecimalPointAndListComma); + m_solver->FormatOptions().SetLocalizationType(::LocalizationType::DecimalPointAndListComma); + } + } + void Grapher::OnPointerEntered(PointerRoutedEventArgs ^ e) { if (m_renderMain) diff --git a/src/GraphControl/Control/Grapher.h b/src/GraphControl/Control/Grapher.h index facfe88..cddec89 100644 --- a/src/GraphControl/Control/Grapher.h +++ b/src/GraphControl/Control/Grapher.h @@ -38,6 +38,7 @@ public DEPENDENCY_PROPERTY_OWNER(Grapher); DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(bool, ForceProportionalAxes, true); + DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(bool, UseCommaDecimalSeperator, false); DEPENDENCY_PROPERTY_WITH_DEFAULT( SINGLE_ARG(Windows::Foundation::Collections::IObservableMap ^), Variables, @@ -266,6 +267,7 @@ public private: void OnForceProportionalAxesPropertyChanged(bool oldValue, bool newValue); + void OnUseCommaDecimalSeperatorPropertyChanged(bool oldValue, bool newValue); void OnEquationsPropertyChanged(EquationCollection ^ oldValue, EquationCollection ^ newValue); void OnAxesColorPropertyChanged(Windows::UI::Color oldValue, Windows::UI::Color newValue); void OnGraphBackgroundPropertyChanged(Windows::UI::Color oldValue, Windows::UI::Color newValue); diff --git a/src/GraphingImpl/Mocks/MathSolver.h b/src/GraphingImpl/Mocks/MathSolver.h index 7f9a0fc..5706555 100644 --- a/src/GraphingImpl/Mocks/MathSolver.h +++ b/src/GraphingImpl/Mocks/MathSolver.h @@ -13,6 +13,10 @@ namespace MockGraphingImpl void SetFormatType(Graphing::FormatType type) override { } + + void SetLocalizationType(Graphing::LocalizationType value) override + { + } }; class EvalOptions : public Graphing::IEvalOptions @@ -46,6 +50,10 @@ namespace MockGraphingImpl void SetMathMLPrefix(const std::wstring& value) override { } + + void SetLocalizationType(Graphing::LocalizationType value) override + { + } }; class MockExpression : public Graphing::IExpression diff --git a/src/GraphingInterfaces/IMathSolver.h b/src/GraphingInterfaces/IMathSolver.h index c1df98a..8f1ddaa 100644 --- a/src/GraphingInterfaces/IMathSolver.h +++ b/src/GraphingInterfaces/IMathSolver.h @@ -34,6 +34,7 @@ namespace Graphing virtual ~IParsingOptions() = default; virtual void SetFormatType(FormatType type) = 0; + virtual void SetLocalizationType(LocalizationType value) = 0; }; struct IEvalOptions : public NonCopyable, public NonMoveable @@ -49,7 +50,8 @@ namespace Graphing virtual ~IFormatOptions() = default; virtual void SetFormatType(FormatType type) = 0; - virtual void SetMathMLPrefix(const std::wstring& value) = 0; + virtual void SetMathMLPrefix(const std::wstring& value) = 0; + virtual void SetLocalizationType(LocalizationType value) = 0; }; struct IMathSolver : public NonCopyable, public NonMoveable