예제 #1
0
        public TaskGroupModel(DateTime rangeStart, DateTime rangeEnd,
                              ICollection <ITask> tasks, IPreferences preferences)
        {
            if (preferences == null)
            {
                throw new ArgumentNullException("preferences");
            }
            if (tasks == null)
            {
                throw new ArgumentNullException("tasks");
            }

            this.timeRangeStart = rangeStart;
            this.timeRangeEnd   = rangeEnd;

            taskChangeLog = new List <MementoTask> ();

            showCompletedTasks = preferences.GetBool(
                PreferencesKeys.ShowCompletedTasksKey);

            originalTasks = tasks;
            ((INotifyCollectionChanged)tasks).CollectionChanged += HandleCollectionChanged;

            // register change events for each task
            foreach (var item in tasks)
            {
                item.PropertyChanging += HandlePropertyChanging;
                item.PropertyChanged  += HandlePropertyChanged;
            }
        }