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.vb
77 lines (67 loc) · 2.47 KB
/
ProjectTaskViewModel.vb
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
72
73
74
75
76
77
Imports System.Collections.ObjectModel
Imports DevExpress.Mvvm.Gantt
Imports DevExpress.Xpf.Gantt
Public Class ProjectTaskViewModel
Public Sub New()
Selector = New PredecessorLinksSelector()
Tasks = New ObservableCollection(Of GanttTask) From {
New GanttTask() With {
.Id = 0,
.Name = "Add a new feature",
.StartDate = DateTime.Now.AddDays(-1),
.FinishDate = DateTime.Now.AddDays(6)
},
New GanttTask() With {
.Id = 1,
.ParentId = 0,
.Name = "Write the code",
.StartDate = DateTime.Now.AddDays(-1),
.FinishDate = DateTime.Now.AddDays(2)
},
New GanttTask() With {
.Id = 2,
.ParentId = 0,
.Name = "Write the docs",
.StartDate = DateTime.Now.AddDays(2),
.FinishDate = DateTime.Now.AddDays(5),
.Tag = "1"
},
New GanttTask() With {
.Id = 3,
.ParentId = 0,
.Name = "Test the new feature",
.StartDate = DateTime.Now.AddDays(2),
.FinishDate = DateTime.Now.AddDays(5),
.Tag = "1"
},
New GanttTask() With {
.Id = 4,
.ParentId = 0,
.Name = "Release the new feature",
.StartDate = DateTime.Now.AddDays(5),
.FinishDate = DateTime.Now.AddDays(5),
.Tag = "2;3"
}
}
End Sub
Public Property Tasks As ObservableCollection(Of GanttTask)
Public Property Selector As PredecessorLinksSelector
End Class
Public Class PredecessorLinksSelector
Implements IPredecessorLinksSelector
Public Function SelectLinks(ByVal item As Object) As IEnumerable Implements IPredecessorLinksSelector.SelectLinks
Dim task = CType(item, GanttTask)
If task.Tag Is Nothing Then
Return Nothing
End If
Dim links As String() = (CStr(task.Tag)).Split(";"c)
Dim selectedLinks As List(Of Object) = New List(Of Object)()
For Each link In links
selectedLinks.Add(New GanttPredecessorLink() With {
.PredecessorTaskId = Convert.ToInt32(link),
.LinkType = PredecessorLinkType.FinishToStart
})
Next
Return selectedLinks
End Function
End Class