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:
parent
28a143c07d
commit
ce014908e2
@ -1188,20 +1188,20 @@ void StandardCalculatorViewModel::SetCalculatorType(ViewMode targetState)
|
|||||||
{
|
{
|
||||||
case ViewMode::Standard:
|
case ViewMode::Standard:
|
||||||
IsStandard = true;
|
IsStandard = true;
|
||||||
ResetDisplay();
|
ResetRadixAndUpdateMemory(true);
|
||||||
SetPrecision(StandardModePrecision);
|
SetPrecision(StandardModePrecision);
|
||||||
UpdateMaxIntDigits();
|
UpdateMaxIntDigits();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ViewMode::Scientific:
|
case ViewMode::Scientific:
|
||||||
IsScientific = true;
|
IsScientific = true;
|
||||||
ResetDisplay();
|
ResetRadixAndUpdateMemory(true);
|
||||||
SetPrecision(ScientificModePrecision);
|
SetPrecision(ScientificModePrecision);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ViewMode::Programmer:
|
case ViewMode::Programmer:
|
||||||
IsProgrammer = true;
|
IsProgrammer = true;
|
||||||
ResetDisplay();
|
ResetRadixAndUpdateMemory(false);
|
||||||
SetPrecision(ProgrammerModePrecision);
|
SetPrecision(ProgrammerModePrecision);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1227,11 +1227,18 @@ String ^ StandardCalculatorViewModel::GetLocalizedStringFormat(String ^ format,
|
|||||||
return LocalizationStringUtil::GetLocalizedString(format, displayValue);
|
return LocalizationStringUtil::GetLocalizedString(format, displayValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StandardCalculatorViewModel::ResetDisplay()
|
void StandardCalculatorViewModel::ResetRadixAndUpdateMemory(bool resetRadix)
|
||||||
{
|
{
|
||||||
|
if (resetRadix)
|
||||||
|
{
|
||||||
AreHEXButtonsEnabled = false;
|
AreHEXButtonsEnabled = false;
|
||||||
CurrentRadixType = NumberBase::DecBase;
|
CurrentRadixType = NumberBase::DecBase;
|
||||||
m_standardCalculatorManager.SetRadix(RadixType::Decimal);
|
m_standardCalculatorManager.SetRadix(RadixType::Decimal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_standardCalculatorManager.SetMemorizedNumbersString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StandardCalculatorViewModel::SetPrecision(int32_t precision)
|
void StandardCalculatorViewModel::SetPrecision(int32_t precision)
|
||||||
|
@ -283,7 +283,7 @@ namespace CalculatorApp
|
|||||||
void Recalculate(bool fromHistory = false);
|
void Recalculate(bool fromHistory = false);
|
||||||
bool IsOperator(CalculationManager::Command cmdenum);
|
bool IsOperator(CalculationManager::Command cmdenum);
|
||||||
void SetMemorizedNumbersString();
|
void SetMemorizedNumbersString();
|
||||||
void ResetDisplay();
|
void ResetRadixAndUpdateMemory(bool resetRadix);
|
||||||
|
|
||||||
void SetPrecision(int32_t precision);
|
void SetPrecision(int32_t precision);
|
||||||
void UpdateMaxIntDigits()
|
void UpdateMaxIntDigits()
|
||||||
|
@ -42,7 +42,7 @@ namespace CalculatorUnitTests
|
|||||||
viewModel->IsStandard = true;
|
viewModel->IsStandard = true;
|
||||||
viewModel->IsScientific = false;
|
viewModel->IsScientific = false;
|
||||||
viewModel->IsProgrammer = false;
|
viewModel->IsProgrammer = false;
|
||||||
viewModel->ResetDisplay();
|
viewModel->ResetRadixAndUpdateMemory(true);
|
||||||
viewModel->SetPrecision(StandardModePrecision);
|
viewModel->SetPrecision(StandardModePrecision);
|
||||||
}
|
}
|
||||||
else if (mode == 1)
|
else if (mode == 1)
|
||||||
@ -50,7 +50,7 @@ namespace CalculatorUnitTests
|
|||||||
viewModel->IsScientific = true;
|
viewModel->IsScientific = true;
|
||||||
viewModel->IsProgrammer = false;
|
viewModel->IsProgrammer = false;
|
||||||
viewModel->IsStandard = false;
|
viewModel->IsStandard = false;
|
||||||
viewModel->ResetDisplay();
|
viewModel->ResetRadixAndUpdateMemory(true);
|
||||||
viewModel->SetPrecision(ScientificModePrecision);
|
viewModel->SetPrecision(ScientificModePrecision);
|
||||||
}
|
}
|
||||||
else if (mode == 2)
|
else if (mode == 2)
|
||||||
@ -58,7 +58,7 @@ namespace CalculatorUnitTests
|
|||||||
viewModel->IsProgrammer = true;
|
viewModel->IsProgrammer = true;
|
||||||
viewModel->IsScientific = false;
|
viewModel->IsScientific = false;
|
||||||
viewModel->IsStandard = false;
|
viewModel->IsStandard = false;
|
||||||
viewModel->ResetDisplay();
|
viewModel->ResetRadixAndUpdateMemory(false);
|
||||||
viewModel->SetPrecision(ProgrammerModePrecision);
|
viewModel->SetPrecision(ProgrammerModePrecision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user