-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTask.vb
97 lines (89 loc) · 3.93 KB
/
Task.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
' Developer Express Code Central Example:
' Printing appointment details using the XtraReports Suite
'
' This example illustrates how you can print the appointment details for the
' appointments currently displayed in the Scheduler by means of the XtraReports
' Suite.
' The key point is to obtain a collection of appointments and assign it to
' the report's DataSource
' (http://documentation.devexpress.com/#XtraReports/DevExpressXtraReportsUIXtraReportBase_DataSourcetopic).
' To accomplish this, the GetAppointments
' (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerStorageBase_GetAppointmentstopic)
' method is used to get a collection of appointments which fall within the time
' range specified by the GetVisibleIntervals
' (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerViewBase_GetVisibleIntervalstopic)
' method.
' To display custom fields in the report, the custom fields
' (http://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraSchedulerNativeCustomFieldtopic)
' should be exposed as common object properties. So a wrapper class Task is
' implemented solely for this purpose. Using the SetAppointmentFactory
' (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerAppointmentStorageBase_SetAppointmentFactorytopic)
' method, Scheduler's Appointment objects are replaced with the Task class
' instances. A TaskCollection class holds Task objects and can be used as the
' report's data source.
' Note that you should have a valid license to the
' XtraReports Suite
' (http://documentation.devexpress.com/#XtraReports/CustomDocument2162) to be able
' to use this approach in your application.
'
' You can find sample updates and versions for different programming languages here:
' http://www.devexpress.com/example=E1183
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports DevExpress.XtraScheduler
Imports System.Drawing
'using DevExpress.XtraScheduler.Native;
Namespace PrintingViaReports
#Region "#appointmentfactory"
Public Class TaskFactory
Implements IAppointmentFactory
Public Function CreateAppointment(type As AppointmentType) As Appointment Implements IAppointmentFactory.CreateAppointment
Dim task As New Task(type)
Return task
End Function
End Class
Public Class Task
Inherits DevExpress.XtraScheduler.Internal.Implementations.AppointmentInstance
Public Sub New()
End Sub
Public Sub New(ByVal type As AppointmentType)
MyBase.New(type)
End Sub
' Convert custom fields into the Task properties
Public Property CustomText() As String
Get
Return CStr(MyBase.CustomFields("CustomTextField"))
End Get
Set(ByVal value As String)
MyBase.CustomFields("CustomTextField") = value
End Set
End Property
Public Property CustomColor() As Color
Get
Return CType(MyBase.CustomFields("CustomColorField"), Color)
End Get
Set(ByVal value As Color)
MyBase.CustomFields("CustomColorField") = value
End Set
End Property
Public ReadOnly Property CustomColorARGB() As Integer
Get
Return CType(MyBase.CustomFields("CustomColorField"), Color).ToArgb()
End Get
End Property
End Class
Public Class TaskCollection
Inherits List(Of Task)
Public Sub AddAppointment(ByVal appointment As Appointment)
Dim task As Task = CType(appointment, Task)
MyBase.Add(task)
End Sub
Public Overridable Sub AddAppointmentRange(ByVal collection As AppointmentBaseCollection)
For Each item As Appointment In collection
Me.AddAppointment(item)
Next item
End Sub
End Class
#End Region ' #appointmentfactory
End Namespace