diff --git a/src/CalcManager/CEngine/CalcUtils.cpp b/src/CalcManager/CEngine/CalcUtils.cpp index 4aa8311d..d9687530 100644 --- a/src/CalcManager/CEngine/CalcUtils.cpp +++ b/src/CalcManager/CEngine/CalcUtils.cpp @@ -44,6 +44,7 @@ bool IsGuiSettingOpCode(WPARAM opCode) { case IDC_INV: case IDC_FE: + case IDC_AE: case IDC_MCLEAR: case IDC_BACK: case IDC_EXP: diff --git a/src/CalcManager/CEngine/Rational.cpp b/src/CalcManager/CEngine/Rational.cpp index 22a972a3..fe8408dd 100644 --- a/src/CalcManager/CEngine/Rational.cpp +++ b/src/CalcManager/CEngine/Rational.cpp @@ -444,14 +444,14 @@ namespace CalcEngine return !(lhs < rhs); } - wstring Rational::ToString(uint32_t radix, NUMOBJ_FMT fmt, int32_t precision) const + wstring Rational::ToString(uint32_t radix, NUMOBJ_FMT fmt, NUMOBJ_AUTOFMT afmt, int32_t precision) const { PRAT rat = this->ToPRAT(); wstring result{}; try { - result = RatToString(rat, fmt, radix, precision); + result = RatToString(rat, fmt, afmt, radix, precision); } catch (DWORD error) { diff --git a/src/CalcManager/CEngine/calc.cpp b/src/CalcManager/CEngine/calc.cpp index 7be2ff13..7142dffc 100644 --- a/src/CalcManager/CEngine/calc.cpp +++ b/src/CalcManager/CEngine/calc.cpp @@ -75,6 +75,7 @@ CCalcEngine::CCalcEngine(bool fPrecedence, bool fIntegerMode, CalculationManager m_bError(false), m_bInv(false), m_nFE(FMT_FLOAT), + m_nAE(AUTOFMT_DISABLED), m_bNoPrevEqu(true), m_numwidth(QWORD_WIDTH), m_angletype(ANGLE_DEG), @@ -120,7 +121,7 @@ void CCalcEngine::InitChopNumbers() auto maxVal = m_chopNumbers[i] / 2; maxVal = RationalMath::Integer(maxVal); - m_maxDecimalValueStrings[i] = maxVal.ToString(10, FMT_FLOAT, m_precision); + m_maxDecimalValueStrings[i] = maxVal.ToString(10, FMT_FLOAT, AUTOFMT_ENABLED, m_precision); } } diff --git a/src/CalcManager/CEngine/scicomm.cpp b/src/CalcManager/CEngine/scicomm.cpp index 71bec081..06e9c88f 100644 --- a/src/CalcManager/CEngine/scicomm.cpp +++ b/src/CalcManager/CEngine/scicomm.cpp @@ -757,6 +757,12 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam) DisplayNum(); break; + case IDC_AE: + // Toggle automatic exponential notation display. + m_nAE = NUMOBJ_AUTOFMT(!(int)m_nAE); + DisplayNum(); + break; + case IDC_EXP: if (m_bRecord && !m_fIntegerMode && m_input.TryBeginExponent()) { @@ -1033,7 +1039,7 @@ wstring CCalcEngine::GetStringForDisplay(Rational const& rat, uint32_t radix) // Check for standard\scientific mode if (!m_fIntegerMode) { - result = rat.ToString(radix, m_nFE, m_precision); + result = rat.ToString(radix, m_nFE, m_nAE, m_precision); } else { @@ -1051,7 +1057,7 @@ wstring CCalcEngine::GetStringForDisplay(Rational const& rat, uint32_t radix) tempRat = -((tempRat ^ m_chopNumbers[m_numwidth]) + 1); } - result = tempRat.ToString(radix, m_nFE, m_precision); + result = tempRat.ToString(radix, m_nFE, m_nAE, m_precision); } catch (DWORD) { diff --git a/src/CalcManager/CEngine/scidisp.cpp b/src/CalcManager/CEngine/scidisp.cpp index 431a3990..f3d02453 100644 --- a/src/CalcManager/CEngine/scidisp.cpp +++ b/src/CalcManager/CEngine/scidisp.cpp @@ -40,13 +40,14 @@ typedef struct { int32_t precision; uint32_t radix; INT nFE; + INT nAE; NUM_WIDTH numwidth; bool fIntMath; bool bRecord; bool bUseSep; } LASTDISP; -LASTDISP gldPrevious = { 0, -1, 0, -1, (NUM_WIDTH)-1, false, false, false }; +LASTDISP gldPrevious = { 0, -1, 0, -1, -1, (NUM_WIDTH)-1, false, false, false }; // Truncates if too big, makes it a non negative - the number in rat. Doesn't do anything if not in INT mode CalcEngine::Rational CCalcEngine::TruncateNumForIntMath(CalcEngine::Rational const& rat) @@ -87,6 +88,7 @@ void CCalcEngine::DisplayNum(void) gldPrevious.precision != m_precision || gldPrevious.radix != m_radix || gldPrevious.nFE != (int)m_nFE || + gldPrevious.nAE != (int)m_nAE || gldPrevious.bUseSep != true || gldPrevious.numwidth != m_numwidth || gldPrevious.fIntMath != m_fIntegerMode || @@ -95,6 +97,7 @@ void CCalcEngine::DisplayNum(void) gldPrevious.precision = m_precision; gldPrevious.radix = m_radix; gldPrevious.nFE = (int)m_nFE; + gldPrevious.nAE = (int)m_nAE; gldPrevious.numwidth = m_numwidth; gldPrevious.fIntMath = m_fIntegerMode; diff --git a/src/CalcManager/CalculatorManager.cpp b/src/CalcManager/CalculatorManager.cpp index 1d62e010..5130a38a 100644 --- a/src/CalcManager/CalculatorManager.cpp +++ b/src/CalcManager/CalculatorManager.cpp @@ -28,6 +28,7 @@ namespace CalculationManager m_currentDegreeMode(Command::CommandNULL), m_savedDegreeMode(Command::CommandDEG), m_isExponentialFormat(false), + m_isAutoExponentialFormat(true), m_persistedPrimaryValue(), m_currentCalculatorEngine(nullptr), m_pStdHistory(new CalculatorHistory(CM_STD, MAX_HISTORY_ITEMS)), @@ -139,6 +140,11 @@ namespace CalculationManager m_isExponentialFormat = false; m_scientificCalculatorEngine->ProcessCommand(IDC_FE); } + if (!m_isAutoExponentialFormat) + { + m_isAutoExponentialFormat = true; + m_scientificCalculatorEngine->ProcessCommand(IDC_AE); + } } if (m_programmerCalculatorEngine) { @@ -248,7 +254,7 @@ namespace CalculationManager m_currentDegreeMode = command; } - if (command != Command::CommandFE) + if (command != Command::CommandFE && command != Command::CommandAE) { m_savedCommands.push_back(MapCommandForSerialize(command)); // Save the commands in the m_savedCommands } @@ -285,6 +291,8 @@ namespace CalculationManager break; case Command::CommandFE: m_isExponentialFormat = !m_isExponentialFormat; + case Command::CommandAE: + m_isAutoExponentialFormat = !m_isAutoExponentialFormat; // fall through default: m_currentCalculatorEngine->ProcessCommand(static_cast(command)); diff --git a/src/CalcManager/CalculatorManager.h b/src/CalcManager/CalculatorManager.h index 9f60c534..3d2fbe59 100644 --- a/src/CalcManager/CalculatorManager.h +++ b/src/CalcManager/CalculatorManager.h @@ -57,6 +57,7 @@ namespace CalculationManager CalcEngine::Rational m_persistedPrimaryValue; bool m_isExponentialFormat; + bool m_isAutoExponentialFormat; static const unsigned int m_maximumMemorySize = 100; diff --git a/src/CalcManager/Command.h b/src/CalcManager/Command.h index 25ad7cf0..390cc5b3 100644 --- a/src/CalcManager/Command.h +++ b/src/CalcManager/Command.h @@ -99,6 +99,7 @@ namespace CalculationManager CommandPERCENT = 118, CommandFE = 119, + CommandAE = 148, CommandPI = 120, CommandEQU = 121, diff --git a/src/CalcManager/ExpressionCommand.cpp b/src/CalcManager/ExpressionCommand.cpp index 393a4716..f13028e0 100644 --- a/src/CalcManager/ExpressionCommand.cpp +++ b/src/CalcManager/ExpressionCommand.cpp @@ -293,7 +293,7 @@ wstring COpndCommand::GetString(uint32_t radix, int32_t precision, wchar_t decim if (m_fInitialized) { - result = m_value.ToString(radix, eNUMOBJ_FMT::FMT_FLOAT, precision); + result = m_value.ToString(radix, eNUMOBJ_FMT::FMT_FLOAT, eNUMOBJ_AUTOFMT::AUTOFMT_ENABLED, precision); } return result; diff --git a/src/CalcManager/Header Files/CCommand.h b/src/CalcManager/Header Files/CCommand.h index 1944061b..33ba6501 100644 --- a/src/CalcManager/Header Files/CCommand.h +++ b/src/CalcManager/Header Files/CCommand.h @@ -103,6 +103,7 @@ #define IDC_UNARYLAST IDC_PERCENT #define IDC_FE 119 +#define IDC_AE 148 #define IDC_PI 120 #define IDC_EQU 121 diff --git a/src/CalcManager/Header Files/CalcEngine.h b/src/CalcManager/Header Files/CalcEngine.h index a0a44ffd..611036a1 100644 --- a/src/CalcManager/Header Files/CalcEngine.h +++ b/src/CalcManager/Header Files/CalcEngine.h @@ -88,6 +88,7 @@ private: bool m_bSetCalcState; //Flag for setting the engine result state CalcEngine::CalcInput m_input; // Global calc input object for decimal strings eNUMOBJ_FMT m_nFE; /* Scientific notation conversion flag. */ + eNUMOBJ_AUTOFMT m_nAE; /* Automatic scientific notation conversion flag. */ CalcEngine::Rational m_maxTrigonometricNum; std::unique_ptr m_memoryValue; // Current memory value. diff --git a/src/CalcManager/Header Files/Rational.h b/src/CalcManager/Header Files/Rational.h index 8ded3c27..d667177e 100644 --- a/src/CalcManager/Header Files/Rational.h +++ b/src/CalcManager/Header Files/Rational.h @@ -64,7 +64,7 @@ namespace CalcEngine friend bool operator<=(Rational const& lhs, Rational const& rhs); friend bool operator>=(Rational const& lhs, Rational const& rhs); - std::wstring ToString(uint32_t radix, NUMOBJ_FMT format, int32_t precision) const; + std::wstring ToString(uint32_t radix, NUMOBJ_FMT format, NUMOBJ_AUTOFMT autoformat, int32_t precision) const; uint64_t ToUInt64_t() const; private: diff --git a/src/CalcManager/Ratpack/conv.cpp b/src/CalcManager/Ratpack/conv.cpp index f7112bb4..805bc03d 100644 --- a/src/CalcManager/Ratpack/conv.cpp +++ b/src/CalcManager/Ratpack/conv.cpp @@ -1038,14 +1038,14 @@ bool stripzeroesnum(_Inout_ PNUMBER pnum, long starting) // representation. // //----------------------------------------------------------------------------- -wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_t precision) +wstring NumberToString(_Inout_ PNUMBER& pnum, int format, int autoformat, uint32_t radix, int32_t precision) { stripzeroesnum(pnum, precision + 2); long length = pnum->cdigit; long exponent = pnum->exp + length; // Actual number of digits to the left of decimal long oldFormat = format; - if (exponent > precision && format == FMT_FLOAT) + if (exponent > precision && format == FMT_FLOAT && autoformat == AUTOFMT_ENABLED) { // Force scientific mode to prevent user from assuming 33rd digit is exact. format = FMT_SCIENTIFIC; @@ -1065,7 +1065,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_ // - if number is zero no rounding // - if number of digits is less than the maximum output no rounding PNUMBER round = nullptr; - if (!zernum(pnum) && (pnum->cdigit >= precision || (length - exponent > precision && exponent >= -MAX_ZEROS_AFTER_DECIMAL))) + if (!zernum(pnum) && (pnum->cdigit >= precision && autoformat == AUTOFMT_ENABLED || (length - exponent > precision && (exponent >= -MAX_ZEROS_AFTER_DECIMAL || autoformat == AUTOFMT_DISABLED)))) { // Otherwise round. round = longtonum(radix, radix); @@ -1088,9 +1088,9 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_ if (format == FMT_FLOAT) { // Figure out if the exponent will fill more space than the non-exponent field. - if ((length - exponent > precision) || (exponent > precision + 3)) + if ((length - exponent > precision) || (exponent > precision + 3 && autoformat == AUTOFMT_ENABLED)) { - if (exponent >= -MAX_ZEROS_AFTER_DECIMAL) + if (exponent >= -MAX_ZEROS_AFTER_DECIMAL || autoformat == AUTOFMT_DISABLED) { round->exp -= exponent; length = precision + exponent; @@ -1119,7 +1119,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_ { // WARNING: nesting/recursion, too much has been changed, need to // re-figure format. - return NumberToString(pnum, oldFormat, radix, precision); + return NumberToString(pnum, oldFormat, autoformat, radix, precision); } } else @@ -1257,11 +1257,11 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_ // why a pointer to the rational is passed in. // //----------------------------------------------------------------------------- -wstring RatToString(_Inout_ PRAT& prat, int format, uint32_t radix, int32_t precision) +wstring RatToString(_Inout_ PRAT& prat, int format, int autoformat, uint32_t radix, int32_t precision) { PNUMBER p = RatToNumber(prat, radix, precision); - wstring result = NumberToString(p, format, radix, precision); + wstring result = NumberToString(p, format, autoformat, radix, precision); destroynum(p); return result; diff --git a/src/CalcManager/Ratpack/ratpak.h b/src/CalcManager/Ratpack/ratpak.h index f5a508ee..3ff16e84 100644 --- a/src/CalcManager/Ratpack/ratpak.h +++ b/src/CalcManager/Ratpack/ratpak.h @@ -34,6 +34,11 @@ enum eNUMOBJ_FMT { }; +enum eNUMOBJ_AUTOFMT { + AUTOFMT_DISABLED, // never use scientific notation for FMT_FLOAT + AUTOFMT_ENABLED // use scientific notation if number is out of FMT_FLOAT range +}; + enum eANGLE_TYPE { ANGLE_DEG, // Calculate trig using 360 degrees per revolution ANGLE_RAD, // Calculate trig using 2 pi radians per revolution @@ -42,6 +47,7 @@ enum eANGLE_TYPE { }; typedef enum eNUMOBJ_FMT NUMOBJ_FMT; +typedef enum eNUMOBJ_AUTOFMT NUMOBJ_AUTOFMT; typedef enum eANGLE_TYPE ANGLE_TYPE; //----------------------------------------------------------------------------- @@ -312,10 +318,10 @@ extern bool equnum(_In_ PNUMBER a, _In_ PNUMBER b ); // returns true of a == extern bool lessnum(_In_ PNUMBER a, _In_ PNUMBER b ); // returns true of a < b extern bool zernum(_In_ PNUMBER a ); // returns true of a == 0 extern bool zerrat(_In_ PRAT a ); // returns true if a == 0/q -extern std::wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_t precision); +extern std::wstring NumberToString(_Inout_ PNUMBER& pnum, int format, int autoformat, uint32_t radix, int32_t precision); // returns a text representation of a PRAT -extern std::wstring RatToString(_Inout_ PRAT& prat, int format, uint32_t radix, int32_t precision); +extern std::wstring RatToString(_Inout_ PRAT& prat, int format, int autoformat, uint32_t radix, int32_t precision); // converts a PRAT into a PNUMBER extern PNUMBER RatToNumber(_In_ PRAT prat, uint32_t radix, int32_t precision); // flattens a PRAT by converting it to a PNUMBER and back to a PRAT diff --git a/src/CalcViewModel/Common/CalculatorButtonUser.h b/src/CalcViewModel/Common/CalculatorButtonUser.h index cd602c69..0ddab530 100644 --- a/src/CalcViewModel/Common/CalculatorButtonUser.h +++ b/src/CalcViewModel/Common/CalculatorButtonUser.h @@ -48,6 +48,7 @@ namespace CalculatorApp XPower2 = (int) CM::Command::CommandSQR, Mod = (int) CM::Command::CommandMOD, FToE = (int) CM::Command::CommandFE, + AutoE = (int) CM::Command::CommandAE, LogBaseE = (int) CM::Command::CommandLN, InvSin = (int) CM::Command::CommandASIN, InvCos = (int) CM::Command::CommandACOS, @@ -179,6 +180,7 @@ namespace CalculatorApp XPower2 = (int) CM::Command::CommandSQR, Mod = (int) CM::Command::CommandMOD, FToE = (int) CM::Command::CommandFE, + AutoE = (int) CM::Command::CommandAE, LogBaseE = (int) CM::Command::CommandLN, InvSin = (int) CM::Command::CommandASIN, InvCos = (int) CM::Command::CommandACOS, diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp index c8b87071..3fa4d752 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -73,6 +73,7 @@ StandardCalculatorViewModel::StandardCalculatorViewModel() : m_MemorizedNumbers(ref new Vector()), m_IsMemoryEmpty(true), m_IsFToEChecked(false), + m_IsAutoEChecked(true), m_isShiftChecked(false), m_IsShiftProgrammerChecked(false), m_IsQwordEnabled(true), @@ -414,6 +415,11 @@ void StandardCalculatorViewModel::FtoEButtonToggled() OnButtonPressed(NumbersAndOperatorsEnum::FToE); } +void StandardCalculatorViewModel::AutoEButtonToggled() +{ + OnButtonPressed(NumbersAndOperatorsEnum::AutoE); +} + void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum) { DisplayExpressionToken^ displayExpressionToken = ExpressionTokens->GetAt(m_tokenPosition); @@ -553,7 +559,7 @@ bool StandardCalculatorViewModel::IsOperator(Command cmdenum) { if ((cmdenum == Command::Command0) || (cmdenum == Command::Command1) || (cmdenum == Command::Command2) || (cmdenum == Command::Command3) || (cmdenum == Command::Command4) || (cmdenum == Command::Command5) || (cmdenum == Command::Command6) || (cmdenum == Command::Command7) || (cmdenum == Command::Command8) || (cmdenum == Command::Command9) || (cmdenum == Command::CommandPNT) || (cmdenum == Command::CommandBACK) - || (cmdenum == Command::CommandEXP) || (cmdenum == Command::CommandFE) || (cmdenum == Command::ModeBasic) || (cmdenum == Command::ModeBasic) || (cmdenum == Command::ModeProgrammer) || (cmdenum == Command::ModeScientific) + || (cmdenum == Command::CommandEXP) || (cmdenum == Command::CommandFE) || (cmdenum == Command::CommandAE) || (cmdenum == Command::ModeBasic) || (cmdenum == Command::ModeBasic) || (cmdenum == Command::ModeProgrammer) || (cmdenum == Command::ModeScientific) || (cmdenum == Command::CommandINV) || (cmdenum == Command::CommandCENTR) || (cmdenum == Command::CommandDEG) || (cmdenum == Command::CommandRAD) || (cmdenum == Command::CommandGRAD) || ((cmdenum >= Command::CommandBINEDITSTART) && (cmdenum <= Command::CommandBINEDITEND))) { @@ -586,6 +592,7 @@ void StandardCalculatorViewModel::OnButtonPressed(Object^ parameter) numOpEnum != NumbersAndOperatorsEnum::IsStandardMode && numOpEnum != NumbersAndOperatorsEnum::IsProgrammerMode && numOpEnum != NumbersAndOperatorsEnum::FToE && + numOpEnum != NumbersAndOperatorsEnum::AutoE && (numOpEnum != NumbersAndOperatorsEnum::Degree) && (numOpEnum != NumbersAndOperatorsEnum::Radians) && (numOpEnum != NumbersAndOperatorsEnum::Grads)) { if (!m_keyPressed) @@ -621,6 +628,10 @@ void StandardCalculatorViewModel::OnButtonPressed(Object^ parameter) { IsFToEChecked = false; } + if (!IsAutoEChecked) + { + IsAutoEChecked = true; + } } if (numOpEnum == NumbersAndOperatorsEnum::Degree || numOpEnum == NumbersAndOperatorsEnum::Radians || numOpEnum == NumbersAndOperatorsEnum::Grads) { @@ -640,6 +651,7 @@ void StandardCalculatorViewModel::OnButtonPressed(Object^ parameter) ((numOpEnum != NumbersAndOperatorsEnum::Degree) && (numOpEnum != NumbersAndOperatorsEnum::Radians) && (numOpEnum != NumbersAndOperatorsEnum::Grads))) { IsFToEEnabled = true; + IsAutoEEnabled = true; m_isLastOperationHistoryLoad = false; } @@ -1144,6 +1156,7 @@ Array^ StandardCalculatorViewModel::Serialize() DataWriter^ writer = ref new DataWriter(); writer->WriteUInt32(static_cast(m_CurrentAngleType)); writer->WriteBoolean(IsFToEChecked); + writer->WriteBoolean(IsAutoEChecked); writer->WriteBoolean(IsCurrentViewPinned); writer->WriteUInt32(static_cast(m_standardCalculatorManager.SerializeSavedDegreeMode())); @@ -1202,6 +1215,7 @@ void StandardCalculatorViewModel::Deserialize(Array^ state) m_CurrentAngleType = ConvertIntegerToNumbersAndOperatorsEnum(reader->ReadUInt32()); IsFToEChecked = reader->ReadBoolean(); + IsAutoEChecked = reader->ReadBoolean(); IsCurrentViewPinned = reader->ReadBoolean(); Command serializedDegreeMode = static_cast(reader->ReadUInt32()); @@ -1566,6 +1580,10 @@ void StandardCalculatorViewModel::Recalculate(bool fromHistory) { m_standardCalculatorManager.SendCommand(Command::CommandFE); } + if (!IsAutoEChecked) + { + m_standardCalculatorManager.SendCommand(Command::CommandAE); + } m_standardCalculatorManager.SendCommand(currentDegreeMode); size_t currentCommandsSize = currentCommands.size(); diff --git a/src/CalcViewModel/StandardCalculatorViewModel.h b/src/CalcViewModel/StandardCalculatorViewModel.h index 7fb311c5..238ab8ed 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.h +++ b/src/CalcViewModel/StandardCalculatorViewModel.h @@ -72,6 +72,8 @@ namespace CalculatorApp OBSERVABLE_PROPERTY_RW(bool, IsMemoryEmpty); OBSERVABLE_PROPERTY_RW(bool, IsFToEChecked); OBSERVABLE_PROPERTY_RW(bool, IsFToEEnabled); + OBSERVABLE_PROPERTY_RW(bool, IsAutoEChecked); + OBSERVABLE_PROPERTY_RW(bool, IsAutoEEnabled); OBSERVABLE_PROPERTY_RW(bool, IsHyperbolicChecked); OBSERVABLE_PROPERTY_RW(bool, AreHEXButtonsEnabled); NAMED_OBSERVABLE_PROPERTY_RW(Platform::String^, CalculationResultAutomationName); @@ -226,6 +228,7 @@ namespace CalculatorApp IsDecimalEnabled = value; AreHEXButtonsEnabled = IsProgrammer; IsFToEEnabled = value; + IsAutoEEnabled = value; RaisePropertyChanged(L"IsOperandEnabled"); } } @@ -305,6 +308,7 @@ namespace CalculatorApp void Recalculate(bool fromHistory = false); bool IsOperator(CalculationManager::Command cmdenum); void FtoEButtonToggled(); + void AutoEButtonToggled(); void SwitchProgrammerModeBase(RADIX_TYPE calculatorBase); void SetMemorizedNumbersString(); void SwitchAngleType(NumbersAndOperatorsEnum num); diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw index e7383a35..424510f1 100644 --- a/src/Calculator/Resources/en-US/Resources.resw +++ b/src/Calculator/Resources/en-US/Resources.resw @@ -3371,4 +3371,8 @@ Microsoft Services Agreement Displayed on a link to the Microsoft Services Agreement in the about this app information - + + B + {Locked}This is the value that comes from the VirtualKey enum that represents the button. This value is not localized and must be one value that comes from the Windows::System::VirtualKey enum. + + \ No newline at end of file diff --git a/src/Calculator/Views/Calculator.xaml.cpp b/src/Calculator/Views/Calculator.xaml.cpp index d8ae99c9..e2964514 100644 --- a/src/Calculator/Views/Calculator.xaml.cpp +++ b/src/Calculator/Views/Calculator.xaml.cpp @@ -492,6 +492,7 @@ void Calculator::OnHistoryItemClicked(_In_ HistoryItemViewModel^ e) Model->SetExpressionDisplay(e->GetTokens(), e->GetCommands()); Model->SetPrimaryDisplay(e->Result->Data(), false); Model->IsFToEEnabled = false; + Model->IsAutoEEnabled = false; TraceLogger::GetInstance().LogHistoryItemLoadEnd(tokenSize); CloseHistoryFlyout(); diff --git a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml index 86d9f2a6..6fa8f6d8 100644 --- a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml +++ b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml @@ -50,6 +50,7 @@ + @@ -62,6 +63,7 @@ + @@ -116,5 +118,21 @@ FToE + + + AutoE + + diff --git a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.cpp b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.cpp index 981b2168..182591fd 100644 --- a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.cpp +++ b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.cpp @@ -44,6 +44,19 @@ void CalculatorScientificAngleButtons::FToEButton_Toggled(_In_ Object^ sender,_I { auto viewModel = safe_cast(this->DataContext); viewModel->FtoEButtonToggled(); + if (Model->IsFToEChecked) + { + autoeButton->Visibility = ::Visibility::Collapsed; + } + else { + autoeButton->Visibility = ::Visibility::Visible; + } +} + +void CalculatorScientificAngleButtons::AutoEButton_Toggled(_In_ Object^ sender, _In_ RoutedEventArgs^ e) +{ + auto viewModel = safe_cast(this->DataContext); + viewModel->AutoEButtonToggled(); } void CalculatorApp::CalculatorScientificAngleButtons::OnAngleButtonPressed(_In_ Object^ commandParameter) diff --git a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.h b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.h index eeac9d5d..9b67d636 100644 --- a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.h +++ b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.h @@ -35,6 +35,7 @@ namespace CalculatorApp private: void OnAngleButtonPressed(_In_ Platform::Object^ commandParameter); void FToEButton_Toggled(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e); + void AutoEButton_Toggled(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e); void HypButton_Toggled(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e); bool m_isErrorVisualState; diff --git a/src/CalculatorUnitTests/HistoryTests.cpp b/src/CalculatorUnitTests/HistoryTests.cpp index c85ad82c..41649010 100644 --- a/src/CalculatorUnitTests/HistoryTests.cpp +++ b/src/CalculatorUnitTests/HistoryTests.cpp @@ -77,6 +77,7 @@ namespace CalculatorFunctionalTests m_standardViewModel->SetExpressionDisplay(e->GetTokens(), e->GetCommands()); m_standardViewModel->SetPrimaryDisplay(e->Result->Data(), false/*IsError*/); m_standardViewModel->IsFToEEnabled = false; + m_standardViewModel->IsAutoEEnabled = false; } void AddSingleHistoryItem(unsigned int windowId = 0)