This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProjectTaskViewModel.cs
71 lines (68 loc) · 2.59 KB
/
ProjectTaskViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using DevExpress.Mvvm.Gantt;
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace GanttControlDemoApp {
public class ProjectTaskViewModel {
public ProjectTaskViewModel() {
Selector = new PredecessorLinksSelector();
Tasks = new ObservableCollection<GanttTask> {
new GanttTask() {
Id = 0,
Name = "Add a new feature",
StartDate = DateTime.Now.AddDays(-1),
FinishDate = DateTime.Now.AddDays(6)//,
},
new GanttTask() {
Id = 1,
ParentId = 0,
Name = "Write the code",
StartDate = DateTime.Now.AddDays(-1),
FinishDate = DateTime.Now.AddDays(2)
},
new GanttTask() {
Id = 2,
ParentId = 0,
Name = "Write the docs",
StartDate = DateTime.Now.AddDays(2),
FinishDate = DateTime.Now.AddDays(5),
Tag = "1"
},
new GanttTask() {
Id = 3,
ParentId = 0,
Name = "Test the new feature",
StartDate = DateTime.Now.AddDays(2),
FinishDate = DateTime.Now.AddDays(5),
Tag = "1"
},
new GanttTask() {
Id = 4,
ParentId = 0,
Name = "Release the new feature",
StartDate = DateTime.Now.AddDays(5),
FinishDate = DateTime.Now.AddDays(5),
Tag = "2;3"
}
};
}
public ObservableCollection<GanttTask> Tasks { get; set; }
public PredecessorLinksSelector Selector { get; set; }
}
public class PredecessorLinksSelector : DevExpress.Xpf.Gantt.IPredecessorLinksSelector {
public IEnumerable SelectLinks(object item) {
var task = (GanttTask)item;
if (task.Tag == null) {
return null;
}
string[] links = ((string)task.Tag).Split(';');
List<object> selectedLinks = new List<object>();
foreach (var link in links) {
selectedLinks.Add(new GanttPredecessorLink() { PredecessorTaskId = Convert.ToInt32(link), LinkType = PredecessorLinkType.FinishToStart });
}
return selectedLinks;
}
}
}