Пример #1
0
        private void LoadGanttModel(GanttModel gantt)
        {
            _selectedTask = null;
            _project      = gantt;
            _filePath     = null;
            _TaskList     = new BoundObservableCollection <GanttTaskViewModel, GanttTaskModel>(
                gantt.Tasks,
                m => new GanttTaskViewModel(m),          // creates a ViewModel from a Model
                vm => vm.GanttTaskModel,                 // retrieve the source object
                (vm, m) => vm.GanttTaskModel.Equals(m)); // checks if the ViewModel corresponds to the specified model
            _MilestoneList = new BoundObservableCollection <MilestoneViewModel, MilestoneModel>(
                gantt.Milestones,
                m => new MilestoneViewModel(m),          // creates a ViewModel from a Model
                vm => vm.MilestoneModel,                 // retrieve the source object
                (vm, m) => vm.MilestoneModel.Equals(m)); // checks if the ViewModel corresponds to the specified model

            // this allow to track modifications on project (this is basic, should be improved)
            _TaskList.CollectionChanged      += (sender, e) => { Saved = false; };
            _MilestoneList.CollectionChanged += (sender, e) => { Saved = false; };

            UpdateDuration();

            OnPropertyChanged(null); //update all fields

            Saved = true;            // no modification has pending !
        }
Пример #2
0
        public GanttModel GetGantt()
        {
            var tasks = db.Tasks.ToList();
            var links = db.TaskLines.Where(l => tasks.Any(t => t.TaskID == l.FromID || t.TaskID == l.ToID));
            var gantt = new GanttModel(tasks, links);

            return(gantt);
        }
Пример #3
0
 public GanttViewModel(GanttModel gantt)
 {
     LoadGanttModel(gantt);
 }