diff --git a/src/CalcViewModel/GraphingCalculator/GraphingSettingsViewModel.cpp b/src/CalcViewModel/GraphingCalculator/GraphingSettingsViewModel.cpp index 8bb0d7f8..4353777c 100644 --- a/src/CalcViewModel/GraphingCalculator/GraphingSettingsViewModel.cpp +++ b/src/CalcViewModel/GraphingCalculator/GraphingSettingsViewModel.cpp @@ -3,11 +3,9 @@ #include "pch.h" #include "GraphingSettingsViewModel.h" -#include using namespace CalculatorApp::ViewModel; using namespace CalculatorApp::ViewModel::Common; -using namespace CalcManager::NumberFormattingUtils; using namespace GraphControl; using namespace std; using namespace Platform; @@ -55,21 +53,22 @@ void GraphingSettingsViewModel::InitRanges() m_XMaxValue = xMax; m_YMinValue = yMin; m_YMaxValue = yMax; - auto valueStr = to_wstring(m_XMinValue); - TrimTrailingZeros(valueStr); - XMin = ref new String(valueStr.c_str()); - valueStr = to_wstring(m_XMaxValue); - TrimTrailingZeros(valueStr); - XMax = ref new String(valueStr.c_str()); + std::wostringstream xMinStr; + xMinStr << m_XMinValue; + XMin = ref new String(xMinStr.str().c_str()); - valueStr = to_wstring(m_YMinValue); - TrimTrailingZeros(valueStr); - YMin = ref new String(valueStr.c_str()); + std::wostringstream xMaxStr; + xMaxStr << m_XMaxValue; + XMax = ref new String(xMaxStr.str().c_str()); - valueStr = to_wstring(m_YMaxValue); - TrimTrailingZeros(valueStr); - YMax = ref new String(valueStr.c_str()); + std::wostringstream yMinStr; + yMinStr << m_YMinValue; + YMin = ref new String(yMinStr.str().c_str()); + + std::wostringstream yMaxStr; + yMaxStr << m_YMaxValue; + YMax = ref new String(yMaxStr.str().c_str()); m_dontUpdateDisplayRange = false; } diff --git a/src/CalcViewModel/GraphingCalculator/GraphingSettingsViewModel.h b/src/CalcViewModel/GraphingCalculator/GraphingSettingsViewModel.h index 77f1dda1..185c79e0 100644 --- a/src/CalcViewModel/GraphingCalculator/GraphingSettingsViewModel.h +++ b/src/CalcViewModel/GraphingCalculator/GraphingSettingsViewModel.h @@ -51,21 +51,14 @@ namespace CalculatorApp::ViewModel m_XIsMinLastChanged = true; if (m_Graph != nullptr) { - try + std::wistringstream input(value->Data()); + double number; + if (input >> number) { - size_t sz; - auto number = std::stod(value->Data(), &sz); - if (value->Length() == sz) - { - m_Graph->XAxisMin = m_XMinValue = number; - XMinError = false; - } - else - { - XMinError = true; - } + m_Graph->XAxisMin = m_XMinValue = number; + XMinError = false; } - catch (...) + else { XMinError = true; } @@ -92,21 +85,14 @@ namespace CalculatorApp::ViewModel m_XIsMinLastChanged = false; if (m_Graph != nullptr) { - try + std::wistringstream input(value->Data()); + double number; + if (input >> number) { - size_t sz; - auto number = std::stod(value->Data(), &sz); - if (value->Length() == sz) - { - m_Graph->XAxisMax = m_XMaxValue = number; - XMaxError = false; - } - else - { - XMaxError = true; - } + m_Graph->XAxisMax = m_XMaxValue = number; + XMaxError = false; } - catch (...) + else { XMaxError = true; } @@ -133,21 +119,14 @@ namespace CalculatorApp::ViewModel m_YIsMinLastChanged = true; if (m_Graph != nullptr) { - try + std::wistringstream input(value->Data()); + double number; + if (input >> number) { - size_t sz; - auto number = std::stod(value->Data(), &sz); - if (value->Length() == sz) - { - m_Graph->YAxisMin = m_YMinValue = number; - YMinError = false; - } - else - { - YMinError = true; - } + m_Graph->YAxisMin = m_YMinValue = number; + YMinError = false; } - catch (...) + else { YMinError = true; } @@ -174,21 +153,14 @@ namespace CalculatorApp::ViewModel m_YIsMinLastChanged = false; if (m_Graph != nullptr) { - try + std::wistringstream input(value->Data()); + double number; + if (input >> number) { - size_t sz; - auto number = std::stod(value->Data(), &sz); - if (value->Length() == sz) - { - m_Graph->YAxisMax = m_YMaxValue = number; - YMaxError = false; - } - else - { - YMaxError = true; - } + m_Graph->YAxisMax = m_YMaxValue = number; + YMaxError = false; } - catch (...) + else { YMaxError = true; }