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 p_strKey, FilterState p_oFilterState, bool p_bIsEnabled, string p_strLabelText) { Text = p_strLabelText; IsEnabled = p_bIsEnabled; State = p_oFilterState; Key = p_strKey; m_bIsActivatedSwitch = p_bIsEnabled && p_oFilterState == 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; } } }