Ejemplo n.º 1
0
        /// <summary>
        /// Inits the filters.
        /// </summary>
        /// <remarks>the filters are initialized to contain : the built-in filters (todo, done, all) plus the custom task lists.</remarks>
        /// <param name="tasks">The tasks.</param>
        private void InitFilters(ObservableCollection <Task> tasks)
        {
            Filters.Clear();

            var filterAllViewModel = new FiltersViewModel(o => o, tasks)
            {
                FilterName = "all"
            };

            Filters.Add(filterAllViewModel);

            var filterTodoViewModel = new FiltersViewModel(o => o.Where(x => x.IsDone == false), tasks)
            {
                FilterName = "to do"
            };

            Filters.Add(filterTodoViewModel);

            var filterDoneViewModel = new FiltersViewModel(o => o.Where(x => x.IsDone), tasks)
            {
                FilterName = "done"
            };

            Filters.Add(filterDoneViewModel);

            foreach (var taskList in _taskLists)
            {
                Guid listId = taskList.ListId;
                var  taskListFilterViewModel = new FiltersViewModel(o => o.Where(x => x.TaskListId == listId), tasks)
                {
                    FilterName = taskList.Name
                };

                Filters.Add(taskListFilterViewModel);
            }

            OnPropertyChanged("Filters");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Inits the filters.
        /// </summary>
        /// <remarks>the filters are initialized to contain : the built-in filters (todo, done, all) plus the custom task lists.</remarks>
        /// <param name="tasks">The tasks.</param>
        private void InitFilters(ObservableCollection<Task> tasks)
        {
            Filters.Clear();

            var filterAllViewModel = new FiltersViewModel(o => o, tasks) { FilterName = "all" };
            Filters.Add(filterAllViewModel);

            var filterTodoViewModel = new FiltersViewModel(o=> o.Where(x => x.IsDone == false), tasks) { FilterName = "to do"};
            Filters.Add(filterTodoViewModel);

            var filterDoneViewModel = new FiltersViewModel(o=> o.Where(x => x.IsDone), tasks) { FilterName = "done" };
            Filters.Add(filterDoneViewModel);

            foreach (var taskList in _taskLists)
            {
                Guid listId = taskList.ListId;
                var taskListFilterViewModel = new FiltersViewModel(o=>o.Where(x=> x.TaskListId == listId),tasks) { FilterName = taskList.Name };

                Filters.Add(taskListFilterViewModel);
            }

            OnPropertyChanged("Filters");
        }