mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-10 07:22:31 -07:00
Use different formatter for different currency (#1432)
* Use different formatter for different currency
* Add functional tests for currency fraction digit format
* Revert "Add functional tests for currency fraction digit format"
This reverts commit bd8aab3384
.
* Add TestCurrencyFormattingLogic in UnitConverterViewModelUnitTests
* Fix InitializeMultipleConverterTest
* Add comment for a line of code
* Add default case for switch in ConvertToLocalizedString
* Remove trailing decimal
Disable decimal input if maxFractionDigits is 0
Fix input may be blocked after switched active
* Fix: UpdateIsDecimalEnabled should do nothing for non-currency converter
* Remove unnecessary SetValue method
* Add a comment
* Add functional UI Tests for currency converter
Reset currency before tests
Fix: input is blocked after switching to currency with less fractional digits
* Set Priority=0 for currency format related tests
* Truncate digits in display value after switcing
To fix incorrect result after switching currency with less fractional digits
This commit is contained in:
parent
6359a14a9b
commit
61d06b2d2f
13 changed files with 432 additions and 43 deletions
|
@ -227,8 +227,19 @@ namespace CalculatorApp
|
|||
void OnCopyCommand(Platform::Object ^ parameter);
|
||||
void OnPasteCommand(Platform::Object ^ parameter);
|
||||
|
||||
enum class CurrencyFormatterParameter
|
||||
{
|
||||
Default,
|
||||
ForValue1,
|
||||
ForValue2,
|
||||
};
|
||||
|
||||
Platform::String
|
||||
^ GetLocalizedAutomationName(_In_ Platform::String ^ displayvalue, _In_ Platform::String ^ unitname, _In_ Platform::String ^ format);
|
||||
^ GetLocalizedAutomationName(
|
||||
_In_ Platform::String ^ displayvalue,
|
||||
_In_ Platform::String ^ unitname,
|
||||
_In_ Platform::String ^ format,
|
||||
_In_ CurrencyFormatterParameter cfp);
|
||||
Platform::String
|
||||
^ GetLocalizedConversionResultStringFormat(
|
||||
_In_ Platform::String ^ fromValue,
|
||||
|
@ -276,11 +287,13 @@ namespace CalculatorApp
|
|||
void SupplementaryResultsTimerCancel(Windows::System::Threading::ThreadPoolTimer ^ timer);
|
||||
void RefreshSupplementaryResults();
|
||||
void UpdateInputBlocked(_In_ const std::wstring& currencyInput);
|
||||
void UpdateCurrencyFormatter();
|
||||
void UpdateIsDecimalEnabled();
|
||||
bool UnitsAreValid();
|
||||
void ResetCategory();
|
||||
|
||||
void OnButtonPressed(Platform::Object ^ parameter);
|
||||
Platform::String ^ ConvertToLocalizedString(const std::wstring& stringToLocalize, bool allowPartialStrings);
|
||||
Platform::String ^ ConvertToLocalizedString(const std::wstring& stringToLocalize, bool allowPartialStrings, CurrencyFormatterParameter cfp);
|
||||
|
||||
std::shared_ptr<UnitConversionManager::IUnitConverter> m_model;
|
||||
wchar_t m_decimalSeparator;
|
||||
|
@ -290,6 +303,34 @@ namespace CalculatorApp
|
|||
Source,
|
||||
Target
|
||||
} m_value1cp;
|
||||
property CurrencyFormatterParameter CurrencyFormatterParameterFrom
|
||||
{
|
||||
CurrencyFormatterParameter get()
|
||||
{
|
||||
return m_value1cp == ConversionParameter::Source ? CurrencyFormatterParameter::ForValue1 : CurrencyFormatterParameter::ForValue2;
|
||||
}
|
||||
}
|
||||
property CurrencyFormatterParameter CurrencyFormatterParameterTo
|
||||
{
|
||||
CurrencyFormatterParameter get()
|
||||
{
|
||||
return m_value1cp == ConversionParameter::Target ? CurrencyFormatterParameter::ForValue1 : CurrencyFormatterParameter::ForValue2;
|
||||
}
|
||||
}
|
||||
property Windows::Globalization::NumberFormatting::CurrencyFormatter^ CurrencyFormatterFrom
|
||||
{
|
||||
Windows::Globalization::NumberFormatting::CurrencyFormatter^ get()
|
||||
{
|
||||
return m_value1cp == ConversionParameter::Source ? m_currencyFormatter1 : m_currencyFormatter2;
|
||||
}
|
||||
}
|
||||
property Windows::Globalization::NumberFormatting::CurrencyFormatter^ CurrencyFormatterTo
|
||||
{
|
||||
Windows::Globalization::NumberFormatting::CurrencyFormatter^ get()
|
||||
{
|
||||
return m_value1cp == ConversionParameter::Target ? m_currencyFormatter1 : m_currencyFormatter2;
|
||||
}
|
||||
}
|
||||
property Platform::String^ ValueFrom
|
||||
{
|
||||
Platform::String^ get() { return m_value1cp == ConversionParameter::Source ? Value1 : Value2; }
|
||||
|
@ -323,7 +364,8 @@ namespace CalculatorApp
|
|||
std::mutex m_cacheMutex;
|
||||
Windows::Globalization::NumberFormatting::DecimalFormatter ^ m_decimalFormatter;
|
||||
Windows::Globalization::NumberFormatting::CurrencyFormatter ^ m_currencyFormatter;
|
||||
int m_currencyMaxFractionDigits;
|
||||
Windows::Globalization::NumberFormatting::CurrencyFormatter ^ m_currencyFormatter1;
|
||||
Windows::Globalization::NumberFormatting::CurrencyFormatter ^ m_currencyFormatter2;
|
||||
std::wstring m_valueFromUnlocalized;
|
||||
std::wstring m_valueToUnlocalized;
|
||||
bool m_relocalizeStringOnSwitch;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue