Fix the project code style, as it is not consistent. (#236)

Fixes #202
This PR fixes code style for the project files.

The Problem
Different files in the project use different code style. That is not consistent and leads to harder maintenance of the project.

Description of the changes:
Have investigated and determined the most used code style across the given codebase
Have configured IDE and applied code style to all project files.
Have crafted clang-formatter config.
see https://clang.llvm.org/docs/ClangFormat.html
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Some cases were fixed manually
How changes were validated:
manual/ad-hoc testing, automated testing

All tests pass as before because these are only code style changes.
Additional
Please review, and let me know if I have any mistake in the code style. In case of any mistake, I will change the configuration and re-apply it to the project.
This commit is contained in:
Oleg Abrazhaev
2019-05-02 20:59:19 +02:00
committed by Daniel Belcher
parent c77f1de84c
commit 2826d37056
237 changed files with 12824 additions and 11843 deletions

View File

@@ -45,7 +45,7 @@ constexpr unsigned int TIMER_INTERVAL_IN_MS = 10000;
const TimeSpan SUPPLEMENTARY_VALUES_INTERVAL = { 10 * TIMER_INTERVAL_IN_MS };
static Unit^ EMPTY_UNIT = ref new Unit(UCM::EMPTY_UNIT);
static Unit ^ EMPTY_UNIT = ref new Unit(UCM::EMPTY_UNIT);
constexpr size_t UNIT_LIST = 0;
constexpr size_t SELECTED_SOURCE_UNIT = 1;
@@ -89,38 +89,38 @@ namespace CalculatorApp::ViewModel::UnitConverterResourceKeys
StringReference CurrencyRatesUpdateFailed(L"CurrencyRatesUpdateFailed");
}
UnitConverterViewModel::UnitConverterViewModel(const shared_ptr<UCM::IUnitConverter>& model) :
m_model(model),
m_resettingTimer(false),
m_value1cp(ConversionParameter::Source),
m_Value1Active(true),
m_Value2Active(false),
m_Value1("0"),
m_Value2("0"),
m_valueToUnlocalized(L"0"),
m_valueFromUnlocalized(L"0"),
m_relocalizeStringOnSwitch(false),
m_Categories(ref new Vector<Category^>()),
m_Units(ref new Vector<Unit^>()),
m_SupplementaryResults(ref new Vector<SupplementaryResult^>),
m_IsDropDownOpen(false),
m_IsDropDownEnabled(true),
m_IsCurrencyLoadingVisible(false),
m_isCurrencyDataLoaded(false),
m_lastAnnouncedFrom(L""),
m_lastAnnouncedTo(L""),
m_lastAnnouncedConversionResult(L""),
m_isValue1Updating(false),
m_isValue2Updating(false),
m_Announcement(nullptr),
m_Mode(ViewMode::None),
m_CurrencySymbol1(L""),
m_CurrencySymbol2(L""),
m_IsCurrencyCurrentCategory(false),
m_CurrencyRatioEquality(L""),
m_CurrencyRatioEqualityAutomationName(L""),
m_isInputBlocked(false),
m_CurrencyDataLoadFailed(false)
UnitConverterViewModel::UnitConverterViewModel(const shared_ptr<UCM::IUnitConverter>& model)
: m_model(model)
, m_resettingTimer(false)
, m_value1cp(ConversionParameter::Source)
, m_Value1Active(true)
, m_Value2Active(false)
, m_Value1("0")
, m_Value2("0")
, m_valueToUnlocalized(L"0")
, m_valueFromUnlocalized(L"0")
, m_relocalizeStringOnSwitch(false)
, m_Categories(ref new Vector<Category ^>())
, m_Units(ref new Vector<Unit ^>())
, m_SupplementaryResults(ref new Vector<SupplementaryResult ^>)
, m_IsDropDownOpen(false)
, m_IsDropDownEnabled(true)
, m_IsCurrencyLoadingVisible(false)
, m_isCurrencyDataLoaded(false)
, m_lastAnnouncedFrom(L"")
, m_lastAnnouncedTo(L"")
, m_lastAnnouncedConversionResult(L"")
, m_isValue1Updating(false)
, m_isValue2Updating(false)
, m_Announcement(nullptr)
, m_Mode(ViewMode::None)
, m_CurrencySymbol1(L"")
, m_CurrencySymbol2(L"")
, m_IsCurrencyCurrentCategory(false)
, m_CurrencyRatioEquality(L"")
, m_CurrencyRatioEqualityAutomationName(L"")
, m_isInputBlocked(false)
, m_CurrencyDataLoadFailed(false)
{
m_model->SetViewModelCallback(make_shared<UnitConverterVMCallback>(this));
m_model->SetViewModelCurrencyCallback(make_shared<ViewModelCurrencyCallback>(this));
@@ -164,7 +164,7 @@ void UnitConverterViewModel::PopulateData()
InitializeView();
}
void UnitConverterViewModel::OnCategoryChanged(Object^ parameter)
void UnitConverterViewModel::OnCategoryChanged(Object ^ parameter)
{
m_model->SendCommand(UCM::Command::Clear);
ResetCategory();
@@ -210,9 +210,9 @@ void UnitConverterViewModel::BuildUnitList(const vector<UCM::Unit>& modelUnitLis
}
}
Unit^ UnitConverterViewModel::FindUnitInList(UCM::Unit target)
Unit ^ UnitConverterViewModel::FindUnitInList(UCM::Unit target)
{
for (Unit^ vmUnit : m_Units)
for (Unit ^ vmUnit : m_Units)
{
UCM::Unit modelUnit = vmUnit->GetModelUnit();
if (modelUnit.id == target.id)
@@ -224,7 +224,7 @@ Unit^ UnitConverterViewModel::FindUnitInList(UCM::Unit target)
return EMPTY_UNIT;
}
void UnitConverterViewModel::OnUnitChanged(Object^ parameter)
void UnitConverterViewModel::OnUnitChanged(Object ^ parameter)
{
if ((m_Unit1 == nullptr) || (m_Unit2 == nullptr))
{
@@ -249,7 +249,7 @@ void UnitConverterViewModel::OnUnitChanged(Object^ parameter)
}
}
void UnitConverterViewModel::OnSwitchActive(Platform::Object^ unused)
void UnitConverterViewModel::OnSwitchActive(Platform::Object ^ unused)
{
// this can be false if this switch occurs without the user having explicitly updated any strings
// (for example, during deserialization). We only want to try this cleanup if there's actually
@@ -282,9 +282,9 @@ void UnitConverterViewModel::OnSwitchActive(Platform::Object^ unused)
m_model->SwitchActive(m_valueFromUnlocalized);
}
String^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& stringToLocalize, bool allowPartialStrings)
String ^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& stringToLocalize, bool allowPartialStrings)
{
Platform::String^ result;
Platform::String ^ result;
if (stringToLocalize.empty())
{
@@ -368,7 +368,7 @@ String^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& str
// Since the output from GetLocaleInfoEx() and DecimalFormatter are differing for decimal string
// we are adding the below work-around of editing the string returned by DecimalFormatter
// and replacing the decimal separator with the one returned by GetLocaleInfoEx()
String^ formattedSampleString = m_decimalFormatter->Format(stod("1.1"));
String ^ formattedSampleString = m_decimalFormatter->Format(stod("1.1"));
wstring formattedSampleWString = wstring(formattedSampleString->Data());
wstring resultWithDecimal = wstring(result->Data());
@@ -398,7 +398,7 @@ String^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& str
void UnitConverterViewModel::DisplayPasteError()
{
String^ errorMsg = AppResourceProvider::GetInstance().GetCEngineString(StringReference(SIDS_DOMAIN)); /*SIDS_DOMAIN is for "invalid input"*/
String ^ errorMsg = AppResourceProvider::GetInstance().GetCEngineString(StringReference(SIDS_DOMAIN)); /*SIDS_DOMAIN is for "invalid input"*/
Value1 = errorMsg;
Value2 = errorMsg;
m_relocalizeStringOnSwitch = false;
@@ -406,9 +406,9 @@ void UnitConverterViewModel::DisplayPasteError()
void UnitConverterViewModel::UpdateDisplay(const wstring& from, const wstring& to)
{
String^ fromStr = this->ConvertToLocalizedString(from, true);
String ^ fromStr = this->ConvertToLocalizedString(from, true);
UpdateInputBlocked(from);
String^ toStr = this->ConvertToLocalizedString(to, true);
String ^ toStr = this->ConvertToLocalizedString(to, true);
bool updatedValueFrom = ValueFrom != fromStr;
bool updatedValueTo = ValueTo != toStr;
@@ -463,17 +463,16 @@ void UnitConverterViewModel::UpdateSupplementaryResults(const std::vector<std::t
// Schedule the timer
m_supplementaryResultsTimer = ThreadPoolTimer::CreateTimer(
ref new TimerElapsedHandler(this, &UnitConverterViewModel::SupplementaryResultsTimerTick, TIMER_CALLBACK_CONTEXT),
SUPPLEMENTARY_VALUES_INTERVAL,
ref new TimerElapsedHandler(this, &UnitConverterViewModel::SupplementaryResultsTimerTick, TIMER_CALLBACK_CONTEXT), SUPPLEMENTARY_VALUES_INTERVAL,
ref new TimerDestroyedHandler(this, &UnitConverterViewModel::SupplementaryResultsTimerCancel, TIMER_CALLBACK_CONTEXT));
}
void UnitConverterViewModel::OnValueActivated(IActivatable^ control)
void UnitConverterViewModel::OnValueActivated(IActivatable ^ control)
{
control->IsActive = true;
}
void UnitConverterViewModel::OnButtonPressed(Platform::Object^ parameter)
void UnitConverterViewModel::OnButtonPressed(Platform::Object ^ parameter)
{
NumbersAndOperatorsEnum numOpEnum = CalculatorButtonPressedEventArgs::GetOperationFromCommandParameter(parameter);
UCM::Command command = CommandFromButtonId(numOpEnum);
@@ -484,18 +483,8 @@ void UnitConverterViewModel::OnButtonPressed(Platform::Object^ parameter)
return;
}
static const vector<UCM::Command> OPERANDS = {
UCM::Command::Zero,
UCM::Command::One,
UCM::Command::Two,
UCM::Command::Three,
UCM::Command::Four,
UCM::Command::Five,
UCM::Command::Six,
UCM::Command::Seven,
UCM::Command::Eight,
UCM::Command::Nine
};
static const vector<UCM::Command> OPERANDS = { UCM::Command::Zero, UCM::Command::One, UCM::Command::Two, UCM::Command::Three, UCM::Command::Four,
UCM::Command::Five, UCM::Command::Six, UCM::Command::Seven, UCM::Command::Eight, UCM::Command::Nine };
if (find(begin(OPERANDS), end(OPERANDS), command) != OPERANDS.end())
{
@@ -513,14 +502,14 @@ void UnitConverterViewModel::OnButtonPressed(Platform::Object^ parameter)
m_model->SendCommand(command);
}
void UnitConverterViewModel::OnCopyCommand(Platform::Object^ parameter)
void UnitConverterViewModel::OnCopyCommand(Platform::Object ^ parameter)
{
//EventWriteClipboardCopy_Start();
// EventWriteClipboardCopy_Start();
CopyPasteManager::CopyToClipboard(ref new Platform::String(m_valueFromUnlocalized.c_str()));
//EventWriteClipboardCopy_Stop();
// EventWriteClipboardCopy_Stop();
}
void UnitConverterViewModel::OnPasteCommand(Platform::Object^ parameter)
void UnitConverterViewModel::OnPasteCommand(Platform::Object ^ parameter)
{
// if there's nothing to copy early out
if (!CopyPasteManager::HasStringToPaste())
@@ -529,13 +518,10 @@ void UnitConverterViewModel::OnPasteCommand(Platform::Object^ parameter)
}
// Ensure that the paste happens on the UI thread
//EventWriteClipboardPaste_Start();
// EventWriteClipboardPaste_Start();
// Any converter ViewMode is fine here.
CopyPasteManager::GetStringToPaste(m_Mode, NavCategory::GetGroupType(m_Mode)).then(
[this](String^ pastedString)
{
OnPaste(pastedString, m_Mode);
}, concurrency::task_continuation_context::use_current());
CopyPasteManager::GetStringToPaste(m_Mode, NavCategory::GetGroupType(m_Mode))
.then([this](String ^ pastedString) { OnPaste(pastedString, m_Mode); }, concurrency::task_continuation_context::use_current());
}
void UnitConverterViewModel::InitializeView()
@@ -543,7 +529,7 @@ void UnitConverterViewModel::InitializeView()
vector<UCM::Category> categories = m_model->GetCategories();
for (UINT i = 0; i < categories.size(); i++)
{
Category^ category = ref new Category(categories[i]);
Category ^ category = ref new Category(categories[i]);
m_Categories->Append(category);
}
@@ -551,7 +537,7 @@ void UnitConverterViewModel::InitializeView()
CurrentCategory = ref new Category(m_model->GetCurrentCategory());
}
void UnitConverterViewModel::OnPropertyChanged(Platform::String^ prop)
void UnitConverterViewModel::OnPropertyChanged(Platform::String ^ prop)
{
static bool isCategoryChanging = false;
@@ -625,10 +611,10 @@ void UnitConverterViewModel::OnPropertyChanged(Platform::String^ prop)
}
}
String^ UnitConverterViewModel::Serialize()
String ^ UnitConverterViewModel::Serialize()
{
wstringstream out(wstringstream::out);
const wchar_t * delimiter = L"[;;;]";
const wchar_t* delimiter = L"[;;;]";
out << std::to_wstring(m_resettingTimer) << delimiter;
out << std::to_wstring(static_cast<int>(m_value1cp)) << delimiter;
out << m_Value1Active << delimiter << m_Value2Active << delimiter;
@@ -639,14 +625,14 @@ String^ UnitConverterViewModel::Serialize()
if (!unitConverterSerializedData.empty())
{
out << m_model->Serialize() << L"[###]";
String^ serializedData = ref new String(wstring(out.str()).c_str());
String ^ serializedData = ref new String(wstring(out.str()).c_str());
return serializedData;
}
return nullptr;
}
void UnitConverterViewModel::Deserialize(Platform::String^ state)
void UnitConverterViewModel::Deserialize(Platform::String ^ state)
{
wstring serializedData = wstring(state->Data());
vector<wstring> tokens = UCM::UnitConverter::StringToVector(serializedData, L"[###]");
@@ -668,7 +654,7 @@ void UnitConverterViewModel::Deserialize(Platform::String^ state)
}
m_model->DeSerialize(modelData.str());
InitializeView();
RaisePropertyChanged(nullptr); // Update since all props have been updated.
RaisePropertyChanged(nullptr); // Update since all props have been updated.
}
// Saving User Preferences of Category and Associated-Units across Sessions.
@@ -676,7 +662,7 @@ void UnitConverterViewModel::SaveUserPreferences()
{
if (UnitsAreValid())
{
ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings;
ApplicationDataContainer ^ localSettings = ApplicationData::Current->LocalSettings;
if (!m_IsCurrencyCurrentCategory)
{
auto userPreferences = m_model->SaveUserPreferences();
@@ -697,10 +683,10 @@ void UnitConverterViewModel::RestoreUserPreferences()
{
if (!IsCurrencyCurrentCategory)
{
ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings;
ApplicationDataContainer ^ localSettings = ApplicationData::Current->LocalSettings;
if (localSettings->Values->HasKey(ref new String(L"UnitConverterPreferences")))
{
String^ userPreferences = safe_cast<String^>(localSettings->Values->Lookup(ref new String(L"UnitConverterPreferences")));
String ^ userPreferences = safe_cast<String ^>(localSettings->Values->Lookup(ref new String(L"UnitConverterPreferences")));
m_model->RestoreUserPreferences(userPreferences->Data());
}
}
@@ -715,7 +701,7 @@ void UnitConverterViewModel::OnCurrencyDataLoadFinished(bool didLoad)
ResetCategory();
StringReference key = didLoad ? UnitConverterResourceKeys::CurrencyRatesUpdated : UnitConverterResourceKeys::CurrencyRatesUpdateFailed;
String^ announcement = AppResourceProvider::GetInstance().GetResourceString(key);
String ^ announcement = AppResourceProvider::GetInstance().GetResourceString(key);
Announcement = CalculatorAnnouncement::GetUpdateCurrencyRatesAnnouncement(announcement);
}
@@ -730,18 +716,19 @@ void UnitConverterViewModel::RefreshCurrencyRatios()
m_isCurrencyDataLoaded = false;
IsCurrencyLoadingVisible = true;
String^ announcement = AppResourceProvider::GetInstance().GetResourceString(UnitConverterResourceKeys::UpdatingCurrencyRates);
String ^ announcement = AppResourceProvider::GetInstance().GetResourceString(UnitConverterResourceKeys::UpdatingCurrencyRates);
Announcement = CalculatorAnnouncement::GetUpdateCurrencyRatesAnnouncement(announcement);
auto refreshTask = create_task(m_model->RefreshCurrencyRatios());
refreshTask.then([this](const pair<bool, wstring>& refreshResult)
{
bool didLoad = refreshResult.first;
wstring timestamp = refreshResult.second;
refreshTask.then(
[this](const pair<bool, wstring>& refreshResult) {
bool didLoad = refreshResult.first;
wstring timestamp = refreshResult.second;
OnCurrencyTimestampUpdated(timestamp, false /*isWeekOldData*/);
OnCurrencyDataLoadFinished(didLoad);
}, task_continuation_context::use_current());
OnCurrencyTimestampUpdated(timestamp, false /*isWeekOldData*/);
OnCurrencyDataLoadFinished(didLoad);
},
task_continuation_context::use_current());
}
void UnitConverterViewModel::OnNetworkBehaviorChanged(_In_ NetworkAccessBehavior newBehavior)
@@ -806,12 +793,12 @@ UnitConversionManager::Command UnitConverterViewModel::CommandFromButtonId(Numbe
return command;
}
void UnitConverterViewModel::SupplementaryResultsTimerTick(ThreadPoolTimer^ timer)
void UnitConverterViewModel::SupplementaryResultsTimerTick(ThreadPoolTimer ^ timer)
{
timer->Cancel();
}
void UnitConverterViewModel::SupplementaryResultsTimerCancel(ThreadPoolTimer^ timer)
void UnitConverterViewModel::SupplementaryResultsTimerCancel(ThreadPoolTimer ^ timer)
{
if (!m_resettingTimer)
{
@@ -824,14 +811,12 @@ void UnitConverterViewModel::RefreshSupplementaryResults()
m_cacheMutex.lock();
m_SupplementaryResults->Clear();
vector<SupplementaryResult^> whimsicals;
vector<SupplementaryResult ^> whimsicals;
for (tuple<wstring, UCM::Unit> suggestedValue : m_cachedSuggestedValues)
{
SupplementaryResult^ result =
ref new SupplementaryResult(
this->ConvertToLocalizedString(get<0>(suggestedValue), false),
ref new Unit(get<1>(suggestedValue)));
SupplementaryResult ^ result =
ref new SupplementaryResult(this->ConvertToLocalizedString(get<0>(suggestedValue), false), ref new Unit(get<1>(suggestedValue)));
if (result->IsWhimsical())
{
whimsicals.push_back(result);
@@ -849,7 +834,7 @@ void UnitConverterViewModel::RefreshSupplementaryResults()
m_cacheMutex.unlock();
RaisePropertyChanged(SupplementaryResultsPropertyName);
//EventWriteConverterSupplementaryResultsUpdated();
// EventWriteConverterSupplementaryResultsUpdated();
}
// When UpdateDisplay is called, the ViewModel will remember the From/To unlocalized display values
@@ -858,16 +843,13 @@ void UnitConverterViewModel::RefreshSupplementaryResults()
// values are not both zero.
void UnitConverterViewModel::AnnounceConversionResult()
{
if ((m_valueFromUnlocalized != m_lastAnnouncedFrom
|| m_valueToUnlocalized != m_lastAnnouncedTo)
&& Unit1 != nullptr
&& Unit2 != nullptr)
if ((m_valueFromUnlocalized != m_lastAnnouncedFrom || m_valueToUnlocalized != m_lastAnnouncedTo) && Unit1 != nullptr && Unit2 != nullptr)
{
m_lastAnnouncedFrom = m_valueFromUnlocalized;
m_lastAnnouncedTo = m_valueToUnlocalized;
Unit^ unitFrom = Value1Active ? Unit1 : Unit2;
Unit^ unitTo = (unitFrom == Unit1) ? Unit2 : Unit1;
Unit ^ unitFrom = Value1Active ? Unit1 : Unit2;
Unit ^ unitTo = (unitFrom == Unit1) ? Unit2 : Unit1;
m_lastAnnouncedConversionResult = GetLocalizedConversionResultStringFormat(ValueFrom, unitFrom->Name, ValueTo, unitTo->Name);
Announcement = CalculatorAnnouncement::GetDisplayUpdatedAnnouncement(m_lastAnnouncedConversionResult);
@@ -878,16 +860,14 @@ void UnitConverterViewModel::UpdateInputBlocked(_In_ const wstring& currencyInpu
{
// currencyInput is in en-US and has the default decimal separator, so this is safe to do.
auto posOfDecimal = currencyInput.find(L'.');
m_isInputBlocked = false;
m_isInputBlocked = false;
if (posOfDecimal != wstring::npos && IsCurrencyCurrentCategory)
{
m_isInputBlocked = (posOfDecimal + static_cast<size_t>(m_currencyMaxFractionDigits) + 1 == currencyInput.length());
}
}
NumbersAndOperatorsEnum UnitConverterViewModel::MapCharacterToButtonId(
const wchar_t ch,
bool& canSendNegate)
NumbersAndOperatorsEnum UnitConverterViewModel::MapCharacterToButtonId(const wchar_t ch, bool& canSendNegate)
{
static_assert(NumbersAndOperatorsEnum::Zero < NumbersAndOperatorsEnum::One, "NumbersAndOperatorsEnum order is invalid");
static_assert(NumbersAndOperatorsEnum::One < NumbersAndOperatorsEnum::Two, "NumbersAndOperatorsEnum order is invalid");
@@ -937,7 +917,8 @@ NumbersAndOperatorsEnum UnitConverterViewModel::MapCharacterToButtonId(
{
if (LocalizationSettings::GetInstance().IsLocalizedDigit(ch))
{
mappedValue = NumbersAndOperatorsEnum::Zero + static_cast<NumbersAndOperatorsEnum>(ch - LocalizationSettings::GetInstance().GetDigitSymbolFromEnUsDigit(L'0'));
mappedValue = NumbersAndOperatorsEnum::Zero
+ static_cast<NumbersAndOperatorsEnum>(ch - LocalizationSettings::GetInstance().GetDigitSymbolFromEnUsDigit(L'0'));
canSendNegate = true;
}
}
@@ -945,7 +926,7 @@ NumbersAndOperatorsEnum UnitConverterViewModel::MapCharacterToButtonId(
return mappedValue;
}
void UnitConverterViewModel::OnPaste(String^ stringToPaste, ViewMode mode)
void UnitConverterViewModel::OnPaste(String ^ stringToPaste, ViewMode mode)
{
// If pastedString is invalid("NoOp") then display pasteError else process the string
if (stringToPaste == StringReference(CopyPasteManager::PasteErrorString))
@@ -1013,9 +994,9 @@ void UnitConverterViewModel::OnPaste(String^ stringToPaste, ViewMode mode)
}
}
String^ UnitConverterViewModel::GetLocalizedAutomationName(_In_ String^ displayvalue, _In_ String^ unitname, _In_ String^ format)
String ^ UnitConverterViewModel::GetLocalizedAutomationName(_In_ String ^ displayvalue, _In_ String ^ unitname, _In_ String ^ format)
{
String^ valueToLocalize = displayvalue;
String ^ valueToLocalize = displayvalue;
if (displayvalue == ValueFrom && Utils::IsLastCharacterTarget(m_valueFromUnlocalized, m_decimalSeparator))
{
// Need to compute a second localized value for the automation
@@ -1028,9 +1009,13 @@ String^ UnitConverterViewModel::GetLocalizedAutomationName(_In_ String^ displayv
return ref new String(localizedResult.c_str());
}
String^ UnitConverterViewModel::GetLocalizedConversionResultStringFormat(_In_ String^ fromValue, _In_ String^ fromUnit, _In_ String^ toValue, _In_ String^ toUnit)
String
^ UnitConverterViewModel::GetLocalizedConversionResultStringFormat(_In_ String ^ fromValue, _In_ String ^ fromUnit, _In_ String ^ toValue,
_In_ String ^ toUnit)
{
String^ localizedString = ref new String(LocalizationStringUtil::GetLocalizedString(m_localizedConversionResultFormat->Data(), fromValue->Data(), fromUnit->Data(), toValue->Data(), toUnit->Data()).c_str());
String ^ localizedString = ref new String(LocalizationStringUtil::GetLocalizedString(m_localizedConversionResultFormat->Data(), fromValue->Data(),
fromUnit->Data(), toValue->Data(), toUnit->Data())
.c_str());
return localizedString;
}
@@ -1052,7 +1037,7 @@ void UnitConverterViewModel::UpdateValue2AutomationName()
void UnitConverterViewModel::OnMaxDigitsReached()
{
String^ format = AppResourceProvider::GetInstance().GetResourceString(UnitConverterResourceKeys::MaxDigitsReachedFormat);
String ^ format = AppResourceProvider::GetInstance().GetResourceString(UnitConverterResourceKeys::MaxDigitsReachedFormat);
const wstring& announcement = LocalizationStringUtil::GetLocalizedString(format->Data(), m_lastAnnouncedConversionResult->Data());
Announcement = CalculatorAnnouncement::GetMaxDigitsReachedAnnouncement(StringReference(announcement.c_str()));
}
@@ -1064,27 +1049,18 @@ bool UnitConverterViewModel::UnitsAreValid()
void UnitConverterViewModel::StartConversionResultTimer()
{
m_conversionResultTaskHelper = make_unique<ConversionResultTaskHelper>(
CONVERSION_FINALIZED_DELAY_IN_MS, [this]()
{
m_conversionResultTaskHelper = make_unique<ConversionResultTaskHelper>(CONVERSION_FINALIZED_DELAY_IN_MS, [this]() {
if (UnitsAreValid())
{
String^ valueFrom = m_Value1Active ? m_Value1 : m_Value2;
String^ valueTo = m_Value1Active ? m_Value2 : m_Value1;
TraceLogger::GetInstance().LogConversionResult(
valueFrom->Data(),
UnitFrom->ToString()->Data(),
valueTo->Data(),
UnitTo->ToString()->Data());
String ^ valueFrom = m_Value1Active ? m_Value1 : m_Value2;
String ^ valueTo = m_Value1Active ? m_Value2 : m_Value1;
TraceLogger::GetInstance().LogConversionResult(valueFrom->Data(), UnitFrom->ToString()->Data(), valueTo->Data(), UnitTo->ToString()->Data());
}
});
}
String^ SupplementaryResult::GetLocalizedAutomationName()
String ^ SupplementaryResult::GetLocalizedAutomationName()
{
auto format = AppResourceProvider::GetInstance().GetResourceString("SupplementaryUnit_AutomationName");
return ref new String(LocalizationStringUtil::GetLocalizedString(
format->Data(),
this->Value->Data(),
this->Unit->Name->Data()).c_str());
return ref new String(LocalizationStringUtil::GetLocalizedString(format->Data(), this->Value->Data(), this->Unit->Name->Data()).c_str());
}