示例#1
0
        public override FlowDocument Build()
        {
            FlowDocument flowDocument = new FlowDocument();

            flowDocument.Blocks.Add(FlowDocumentHelper.BuildTitle(Title));

            Dictionary <string, Tuple <string, string> > columnDefinitions = new Dictionary <string, Tuple <string, string> >()
            {
                { "Title", new Tuple <string, string>("Title", null) },
                { "StatusDescription", new Tuple <string, string>("Status", null) },
                { "PriorityDescription", new Tuple <string, string>("Priority", null) },
                { "CreatedDate", new Tuple <string, string>("Date Created", null) },
                { "CompletedDate", new Tuple <string, string>("Date Completed", null) }
            };

            using (TaskData tData = new TaskData())
            {
                List <Task>          activeTasks = tData.GetActiveTasks();
                List <TaskViewModel> rowData     = new List <TaskViewModel>();
                foreach (Task task in activeTasks)
                {
                    rowData.Add(new TaskViewModel(task, tData));
                }

                flowDocument.Blocks.Add(FlowDocumentHelper.BuildTable <TaskViewModel>(columnDefinitions, rowData));

                foreach (TaskViewModel taskVm in rowData)
                {
                    taskVm.Dispose();
                }
            }

            return(flowDocument);
        }
示例#2
0
        public void GetActiveTasks()
        {
            for (int i = (ActiveTasks.Count - 1); i >= 0; i--)
            {
                TaskViewModel taskVm = ActiveTasks[i];
                this.ActiveTasks.Remove(taskVm);
                taskVm.Dispose();
            }

            List <TaskViewModel> active =
                (from task in _taskData.GetActiveTasks()
                 select new TaskViewModel(task, _taskData)).ToList();

            foreach (TaskViewModel tvm in active)
            {
                tvm.PropertyChanged += this.OnTaskViewModelPropertyChanged;
            }

            for (int i = 0; i < active.Count; i++)
            {
                this.ActiveTasks.Add(active[i]);
            }
        }