Fix the result in wrong number base while leaving and switching back … (#1654)

* Fix the result in wrong number base while leaving and switching back to Programmer

* Rename ResetDisplay() to ResetRadix()

* Update related unit test

* Fixed the decimal number with point in programmer memory
This commit is contained in:
hanzhang54 2021-08-19 15:44:48 +08:00 committed by GitHub
parent 28a143c07d
commit ce014908e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 11 deletions

View file

@ -1188,20 +1188,20 @@ void StandardCalculatorViewModel::SetCalculatorType(ViewMode targetState)
{
case ViewMode::Standard:
IsStandard = true;
ResetDisplay();
ResetRadixAndUpdateMemory(true);
SetPrecision(StandardModePrecision);
UpdateMaxIntDigits();
break;
case ViewMode::Scientific:
IsScientific = true;
ResetDisplay();
ResetRadixAndUpdateMemory(true);
SetPrecision(ScientificModePrecision);
break;
case ViewMode::Programmer:
IsProgrammer = true;
ResetDisplay();
ResetRadixAndUpdateMemory(false);
SetPrecision(ProgrammerModePrecision);
break;
}
@ -1227,11 +1227,18 @@ String ^ StandardCalculatorViewModel::GetLocalizedStringFormat(String ^ format,
return LocalizationStringUtil::GetLocalizedString(format, displayValue);
}
void StandardCalculatorViewModel::ResetDisplay()
void StandardCalculatorViewModel::ResetRadixAndUpdateMemory(bool resetRadix)
{
AreHEXButtonsEnabled = false;
CurrentRadixType = NumberBase::DecBase;
m_standardCalculatorManager.SetRadix(RadixType::Decimal);
if (resetRadix)
{
AreHEXButtonsEnabled = false;
CurrentRadixType = NumberBase::DecBase;
m_standardCalculatorManager.SetRadix(RadixType::Decimal);
}
else
{
m_standardCalculatorManager.SetMemorizedNumbersString();
}
}
void StandardCalculatorViewModel::SetPrecision(int32_t precision)