-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
83 lines (65 loc) · 3.02 KB
/
Form1.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
78
79
80
81
82
83
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraScheduler
Imports System.Collections.Generic
Namespace SchedulerSortResources
Partial Public Class Form1
Inherits Form
Private dataModel_Renamed As New DataModel()
Public Property CurrentSortOrder() As ResourcesSortOrder
Get
Return CType(comboBox1.SelectedIndex, ResourcesSortOrder)
End Get
Set(ByVal value As ResourcesSortOrder)
comboBox1.SelectedIndex = CInt(value)
End Set
End Property
Public Sub New()
InitializeComponent()
FillResources()
CurrentSortOrder = ResourcesSortOrder.Ascending
End Sub
Private Sub comboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles comboBox1.SelectedIndexChanged
If CurrentSortOrder = ResourcesSortOrder.None Then
schedulerControl1.RefreshData()
Else
ApplySorting()
End If
End Sub
Private Sub schedulerStorage1_ResourceCollectionLoaded(ByVal sender As Object, ByVal e As System.EventArgs) Handles schedulerStorage1.ResourceCollectionLoaded
ApplySorting()
End Sub
Private Sub AppointmentsModified(ByVal sender As Object, ByVal e As PersistentObjectsEventArgs) Handles schedulerStorage1.AppointmentsChanged, schedulerStorage1.AppointmentsInserted, schedulerStorage1.AppointmentsDeleted
ApplySorting()
End Sub
Private Sub ApplySorting()
Dim comparer As IComparer(Of Resource) = Nothing
If CurrentSortOrder = ResourcesSortOrder.Ascending Then
comparer = New ResourceCaptionComparer()
ElseIf CurrentSortOrder = ResourcesSortOrder.Descending Then
comparer = New ResourceCaptionReverseComparer()
ElseIf CurrentSortOrder = ResourcesSortOrder.NOfAppointments Then
comparer = New ResourceNOfAppointmentsComparer(schedulerStorage1)
Else
Return
End If
schedulerStorage1.Resources.Items.Sort(comparer)
schedulerControl1.ActiveView.LayoutChanged()
End Sub
Private Sub FillResources()
Dim users() As String = { "Peter Dolan", "Ryan Fischer", "Andrew Miller", "Tom Hamlett", "Jerry Campbell", "Carl Lucas" }
dataModel_Renamed.Resources.AddResourcesRow("Unassigned", Color.DarkGray.ToArgb())
For i As Integer = 0 To users.Length - 1
dataModel_Renamed.Resources.AddResourcesRow(users(i), schedulerControl1.ResourceColorSchemas(i).Cell.ToArgb())
Next i
schedulerStorage1.Resources.ColorSaving = ColorSavingType.ArgbColor
schedulerStorage1.Resources.DataSource = dataModel_Renamed
End Sub
End Class
Public Enum ResourcesSortOrder
None = 0
Ascending = 1
Descending = 2
NOfAppointments = 3
End Enum
End Namespace