using TINK.Model; namespace TINK.ViewModel.Settings { /// Holds filter item incluting full state (avaialble, activated, name, ...). public class FilterItemMutable { /// Switch value private bool m_bIsActivatedSwitch; /// Constructs a filter object. /// Key of the filter state. /// State of filter, on or off. /// If filter does not apply because user does not belong to group (TINK, Konrad, ...) filter is deactivated. /// Text of the switch describing the filter. public FilterItemMutable( string key, FilterState filterState, bool isEnabled, string labelText) { Text = labelText; IsEnabled = isEnabled; State = filterState; Key = key; m_bIsActivatedSwitch = isEnabled && filterState == FilterState.On; } /// Text describing the filter. public string Text { get; } /// True if switch can be toggeled. public bool IsEnabled { get; } /// True if switch is on. public bool IsActivated { get { return m_bIsActivatedSwitch; } set { m_bIsActivatedSwitch = value; if (!IsEnabled) { // Nothing to do if filter does not apply to user account. return; } State = m_bIsActivatedSwitch ? FilterState.On : FilterState.Off; } } /// Key of the filter. public string Key { get; } /// State of the filter. public FilterState State { get; private set; } } }