#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace DevComponents.Schedule.Model
{
    /// 
    /// Defines weekly recurrence settings.
    /// 
    public class WeeklyRecurrenceSettings : INotifyPropertyChanged, INotifySubPropertyChanged
    {
        #region Internal Implementation
        private AppointmentRecurrence _Recurrence = null;
        /// 
        /// Initializes a new instance of the WeeklyRecurrenceSettings class.
        /// 
        /// 
        public WeeklyRecurrenceSettings(AppointmentRecurrence recurrence)
        {
            _Recurrence = recurrence;
        }
        private eDayOfWeekRecurrence _RepeatOnDaysOfWeek = eDayOfWeekRecurrence.All;
        /// 
        /// Gets or sets the days of week on which appointment is repeated. This property is represented by bit-flag enum
        /// which means that you can combine the values from eDayOfWeekRecurrence enum using OR operator to specify multiple values.
        /// Default value is All.
        /// 
        /// This property value cannot be set to eDayOfWeekRecurrence.None. 
        /// 
        /// 
        [DefaultValue(eDayOfWeekRecurrence.All)]
        public eDayOfWeekRecurrence RepeatOnDaysOfWeek
        {
            get { return _RepeatOnDaysOfWeek; }
            set
            {
                if (value == eDayOfWeekRecurrence.None)
                    throw new ArgumentException("RepeatOnDaysOfWeek cannot be set to eDayOfWeekRecurrence.None");
                if (value != _RepeatOnDaysOfWeek)
                {
                    eDayOfWeekRecurrence oldValue = _RepeatOnDaysOfWeek;
                    _RepeatOnDaysOfWeek = value;
                    OnRepeatOnDaysOfWeekChanged(oldValue, value);
                }
            }
        }
        private void OnRepeatOnDaysOfWeekChanged(eDayOfWeekRecurrence oldValue, eDayOfWeekRecurrence newValue)
        {
            OnPropertyChanged(new PropertyChangedEventArgs("RepeatOnDaysOfWeek"));
        }
        private int _RepeatInterval = 1;
        /// 
        /// Gets or sets the interval between recurring appointments. Default value is 1.
        /// 
        /// For example, setting RepeatInterval to 2 means that appointment will recur every 2 weeks.
        /// 
        /// 
        [DefaultValue(1)]
        public int RepeatInterval
        {
            get { return _RepeatInterval; }
            set
            {
                if (value != _RepeatInterval)
                {
                    int oldValue = _RepeatInterval;
                    _RepeatInterval = value;
                    OnRepeatIntervalChanged(oldValue, value);
                }
            }
        }
        private void OnRepeatIntervalChanged(int oldValue, int newValue)
        {
            OnPropertyChanged(new PropertyChangedEventArgs("RepeatInterval"));
        }
        #endregion
        #region INotifyPropertyChanged Members
        /// 
        /// Occurs when property value has changed.
        /// 
        public event PropertyChangedEventHandler PropertyChanged;
        /// 
        /// Raises the PropertyChanged event.
        /// 
        /// Event arguments
        protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            PropertyChangedEventHandler eh = PropertyChanged;
            if (eh != null) eh(this, e);
            OnSubPropertyChanged(new SubPropertyChangedEventArgs(this, e));
        }
        #endregion
        #region INotifySubPropertyChanged Members
        /// 
        /// Occurs when property or property of child objects has changed. This event is similar to PropertyChanged event with key
        /// difference that it occurs for the property changed of child objects as well.
        /// 
        public event SubPropertyChangedEventHandler SubPropertyChanged;
        /// 
        /// Raises the SubPropertyChanged event.
        /// 
        /// Event arguments
        protected virtual void OnSubPropertyChanged(SubPropertyChangedEventArgs e)
        {
            SubPropertyChangedEventHandler eh = SubPropertyChanged;
            if (eh != null) eh(this, e);
        }
        #endregion
    }
}
#endif