public Root(TaskData taskData, IEnumerable<Color> folderColorOptions) { Contract.Requires(null != taskData, "taskData"); m_taskData = taskData; Contract.Requires(null != folderColorOptions, "folderColorOptions"); m_folderColorOptions = folderColorOptions.ToReadOnlyCollection(); Tasks = new TaskListViewModel(taskData, filter); Timeline = new TimelineViewModel(Tasks.AllTasks); Filters = new Filters(taskData); Folders = new Folders(taskData); taskData.PropertyChanged += (sender, args) => { if (args.PropertyName == "CurrentFolder" || args.PropertyName == "Filter") { Tasks.RefreshFilter(); } }; DispatcherTimer dateChanger = new DispatcherTimer(); dateChanger.Interval = TimeSpan.FromMinutes(1); dateChanger.Tick += new EventHandler(dateChanger_Tick); Tasks.RefreshFilter(); }
private static void AssertGoodRoundTrip(TaskData taskData) { var xml = taskData.ToXml(); var newTaskData = XmlHelper.GetTaskData(xml); TestUtil.AssertTaskDataEqual(taskData, newTaskData); }
public Folders(TaskData taskData) { Contract.Requires(null != taskData, "taskList"); m_taskData = taskData; m_setCurrentCommand = new DelegateCommand<BaseFolder>( val => m_taskData.CurrentFolder = val, val => m_taskData.CurrentFolder != val); m_setCurrentColorCommand = new DelegateCommand<Color?>( var => m_taskData.CurrentFolder.Color = var.Value, var => IsCurrentUserFolder ); }
public Filters(TaskData taskList) { Contract.Requires(null != taskList, "taskList"); m_taskList = taskList; m_items = new Dictionary<string, Func<Task, bool>>(); m_items.Add("All Tasks", task => true); m_items.Add("Not Completed", task => !task.IsComplete); m_items.Add("Important Tasks", task => task.IsImportant == true); m_items.Add("Unimportant Tasks", task => task.IsImportant == false); m_items.Add("No Unimportant Tasks", task => task.IsImportant != false); m_items.Add("Due Today", task => { if (task.IsComplete) return false; if (!task.Due.HasValue) return false; return task.Due.Value.Date == DateTime.Today; }); m_items.Add("Due Soon", task => { if (task.IsComplete) return false; if (!task.Due.HasValue) return false; return task.Due.Value.Date >= DateTime.Today && task.Due.Value <= DateTime.Today.AddDays(3); }); m_items.Add("Overdue", task => task.Due < DateTime.Now && !task.IsComplete); m_items.Add("Not Scheduled", task => task.Due == null); m_items.Add("Completed", task => task.IsComplete); m_setCurrentCommand = new DelegateCommand<string>( filterName => Current = filterName, filterName => Current != filterName && m_items.ContainsKey(filterName)); var current = m_taskList.Filter; if (current == null || !m_items.ContainsKey(current)) current = Items[0]; Current = current; }
public static void AssertTaskDataEqual(TaskData a, TaskData b) { Assert.AreEqual(a.CurrentFolder, b.CurrentFolder); Assert.AreEqual(a.AllFolders.Count, b.AllFolders.Count); System.Threading.Tasks.Parallel.For(0, a.AllFolders.Count, i => { Assert.AreEqual(a.AllFolders[i], b.AllFolders[i]); }); Assert.AreEqual(a.Tasks.Count, b.Tasks.Count); System.Threading.Tasks.Parallel.For(0, a.Tasks.Count, i => { Assert.IsTrue(ArraysEqual(GetArray(a.Tasks[i]), GetArray(b.Tasks[i]))); }); }
public TaskListViewModel(TaskData taskList, Func<Task, bool> filter) { Contract.Requires(null != taskList, "taskList"); m_taskList = taskList; ((INotifyCollectionChanged)m_taskList.Tasks).CollectionChanged += (sender, args) => RefreshFilter(); Contract.Requires(null != filter, "filter"); m_filter = filter; m_unfilteredTaskList = new ObservableCollectionPlus<TaskViewModel>(); m_taskList.Tasks.ForEach(t => m_unfilteredTaskList.Add(new TaskViewModel(t))); // Tasks m_newTaskCommand = new DelegateCommand(ShowNewTask, () => m_newTask == null); m_cancelNewTaskCommand = new DelegateCommand(() => CancelNewTask(), () => m_newTask != null); m_deleteTaskCommand = new DelegateCommand<Task>(task => DeleteTask(task), task => true); }
public static void Save(TaskData data, XmlWriter writer) { data.ToXml().Save(writer); }