private void ResetValueToDefaultOnReleasedEvent() { if (IsSelected) { SettingsVM.ResetSettingsValue(SettingPropertyDefinition.Id); } }
public SettingsPropertyVM(ISettingsPropertyDefinition definition, SettingsVM settingsVM) { SettingsVM = settingsVM; SettingPropertyDefinition = definition; ValueFormatProvider = SettingPropertyDefinition.CustomFormatter is not null ? Activator.CreateInstance(SettingPropertyDefinition.CustomFormatter) as IFormatProvider : null; // Moved to constructor IsInt = SettingType == SettingType.Int; IsFloat = SettingType == SettingType.Float; IsBool = SettingType == SettingType.Bool; IsString = SettingType == SettingType.String; IsDropdownDefault = SettingType == SettingType.Dropdown && SettingsUtils.IsForTextDropdown(PropertyReference.Value); IsDropdownCheckbox = SettingType == SettingType.Dropdown && SettingsUtils.IsForCheckboxDropdown(PropertyReference.Value); IsDropdown = IsDropdownDefault || IsDropdownCheckbox; IsButton = SettingType == SettingType.Button; IsNotNumeric = !(IsInt || IsFloat); NumericValueToggle = IsInt || IsFloat; // Moved to constructor PropertyReference.PropertyChanged += PropertyReference_OnPropertyChanged; if (IsDropdown) { DropdownValue.PropertyChanged += DropdownValue_PropertyChanged; DropdownValue.PropertyChangedWithValue += DropdownValue_PropertyChangedWithValue; } RefreshValues(); if (MCMUISubModule.ResetValueToDefault is { } key) { key.OnReleasedEvent += ResetValueToDefaultOnReleasedEvent; } }
private void PropertyReference_OnPropertyChanged(object?obj, PropertyChangedEventArgs args) { RefreshValues(); SettingsVM.RecalculateIndex(); //SettingsVM.RefreshValues(); }