in src/CalcViewModel/UnitConverterViewModel.cpp [557:629]
void UnitConverterViewModel::OnPropertyChanged(Platform::String ^ prop)
{
static bool isCategoryChanging = false;
if (prop == CurrentCategoryPropertyName)
{
isCategoryChanging = true;
CategoryChanged->Execute(nullptr);
isCategoryChanging = false;
}
else if (prop == Unit1PropertyName || prop == Unit2PropertyName)
{
// Category changes will handle updating units after they've both been updated.
// This event should only be used to update units from explicit user interaction.
if (!isCategoryChanging)
{
UnitChanged->Execute(nullptr);
}
// Get the localized automation name for each CalculationResults field
if (prop == Unit1PropertyName)
{
UpdateValue1AutomationName();
}
else
{
UpdateValue2AutomationName();
}
}
else if (prop == Value1PropertyName)
{
UpdateValue1AutomationName();
}
else if (prop == Value2PropertyName)
{
UpdateValue2AutomationName();
}
else if (prop == Value1ActivePropertyName || prop == Value2ActivePropertyName)
{
// if one of the values is activated, and as a result both are true, it means
// that we're trying to switch.
if (Value1Active && Value2Active)
{
SwitchActive->Execute(nullptr);
}
UpdateValue1AutomationName();
UpdateValue2AutomationName();
}
else if (prop == SupplementaryResultsPropertyName)
{
RaisePropertyChanged(SupplementaryVisibilityPropertyName);
}
else if (prop == Value1AutomationNamePropertyName)
{
m_isValue1Updating = false;
if (!m_isValue2Updating)
{
AnnounceConversionResult();
}
}
else if (prop == Value2AutomationNamePropertyName)
{
m_isValue2Updating = false;
if (!m_isValue1Updating)
{
AnnounceConversionResult();
}
}
else if (prop == CurrencySymbol1PropertyName || prop == CurrencySymbol2PropertyName)
{
RaisePropertyChanged(CurrencySymbolVisibilityPropertyName);
}
}