-
Notifications
You must be signed in to change notification settings - Fork 1
/
CustomEvents.vb
313 lines (295 loc) · 11.4 KB
/
CustomEvents.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
' 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
Imports System.ComponentModel
Imports System.Drawing
Namespace PrintingViaReports
Public Class CustomEvent
Implements IEditableObject
Private fStart As Date
Private fEnd As Date
Private fSubject As String
Private fStatus As Integer
Private fDescription As String
Private fLabel As Integer
Private fLocation As String
Private fAllday As Boolean
Private fEventType As Integer
Private fRecurrenceInfo As String
Private fReminderInfo As String
Private fOwnerId As Object
Private fCustomText As String
Private fCustomColor As Color
Private events As CustomEventList
Private committed As Boolean = False
Public Sub New(ByVal events As CustomEventList)
Me.events = events
End Sub
Private Sub OnListChanged()
Dim index As Integer = events.IndexOf(Me)
events.OnListChanged(New ListChangedEventArgs(ListChangedType.ItemChanged, index))
End Sub
Public Property StartTime() As Date
Get
Return fStart
End Get
Set(ByVal value As Date)
fStart = value
End Set
End Property
Public Property EndTime() As Date
Get
Return fEnd
End Get
Set(ByVal value As Date)
fEnd = value
End Set
End Property
Public Property Subject() As String
Get
Return fSubject
End Get
Set(ByVal value As String)
fSubject = value
End Set
End Property
Public Property Status() As Integer
Get
Return fStatus
End Get
Set(ByVal value As Integer)
fStatus = value
End Set
End Property
Public Property Description() As String
Get
Return fDescription
End Get
Set(ByVal value As String)
fDescription = value
End Set
End Property
Public Property Label() As Integer
Get
Return fLabel
End Get
Set(ByVal value As Integer)
fLabel = value
End Set
End Property
Public Property Location() As String
Get
Return fLocation
End Get
Set(ByVal value As String)
fLocation = value
End Set
End Property
Public Property AllDay() As Boolean
Get
Return fAllday
End Get
Set(ByVal value As Boolean)
fAllday = value
End Set
End Property
Public Property EventType() As Integer
Get
Return fEventType
End Get
Set(ByVal value As Integer)
fEventType = value
End Set
End Property
Public Property RecurrenceInfo() As String
Get
Return fRecurrenceInfo
End Get
Set(ByVal value As String)
fRecurrenceInfo = value
End Set
End Property
Public Property ReminderInfo() As String
Get
Return fReminderInfo
End Get
Set(ByVal value As String)
fReminderInfo = value
End Set
End Property
Public Property OwnerId() As Object
Get
Return fOwnerId
End Get
Set(ByVal value As Object)
fOwnerId = value
End Set
End Property
Public Property CustomText() As String
Get
Return fCustomText
End Get
Set(ByVal value As String)
fCustomText = value
End Set
End Property
Public Property CustomColor() As Color
Get
Return fCustomColor
End Get
Set(ByVal value As Color)
fCustomColor = value
End Set
End Property
Public Sub BeginEdit() Implements IEditableObject.BeginEdit
End Sub
Public Sub CancelEdit() Implements IEditableObject.CancelEdit
If Not committed Then
DirectCast(events, IList).Remove(Me)
End If
End Sub
Public Sub EndEdit() Implements IEditableObject.EndEdit
committed = True
End Sub
End Class
Public Class CustomEventList
Inherits CollectionBase
Implements IBindingList
Default Public ReadOnly Property Item(ByVal idx As Integer) As CustomEvent
Get
Return DirectCast(MyBase.List(idx), CustomEvent)
End Get
End Property
Public Shadows Sub Clear() Implements System.Collections.IList.Clear
MyBase.Clear()
OnListChanged(New ListChangedEventArgs(ListChangedType.Reset, -1))
End Sub
Public Sub Add(ByVal appointment As CustomEvent)
MyBase.List.Add(appointment)
End Sub
Public Function IndexOf(ByVal appointment As CustomEvent) As Integer
Return List.IndexOf(appointment)
End Function
Public Function AddNew() As Object Implements IBindingList.AddNew
Dim app As New CustomEvent(Me)
List.Add(app)
Return app
End Function
Public ReadOnly Property AllowEdit() As Boolean Implements IBindingList.AllowEdit
Get
Return True
End Get
End Property
Public ReadOnly Property AllowNew() As Boolean Implements IBindingList.AllowNew
Get
Return True
End Get
End Property
Public ReadOnly Property AllowRemove() As Boolean Implements IBindingList.AllowRemove
Get
Return True
End Get
End Property
Private listChangedHandler As ListChangedEventHandler
Public Custom Event ListChanged As ListChangedEventHandler Implements IBindingList.ListChanged
AddHandler(ByVal value As ListChangedEventHandler)
listChangedHandler = DirectCast(System.Delegate.Combine(listChangedHandler, value), ListChangedEventHandler)
End AddHandler
RemoveHandler(ByVal value As ListChangedEventHandler)
listChangedHandler = DirectCast(System.Delegate.Remove(listChangedHandler, value), ListChangedEventHandler)
End RemoveHandler
RaiseEvent(ByVal sender As System.Object, ByVal e As System.ComponentModel.ListChangedEventArgs)
If listChangedHandler IsNot Nothing Then
For Each d As ListChangedEventHandler In listChangedHandler.GetInvocationList()
d.Invoke(sender, e)
Next d
End If
End RaiseEvent
End Event
Friend Sub OnListChanged(ByVal args As ListChangedEventArgs)
If listChangedHandler IsNot Nothing Then
listChangedHandler(Me, args)
End If
End Sub
Protected Overrides Sub OnRemoveComplete(ByVal index As Integer, ByVal value As Object)
OnListChanged(New ListChangedEventArgs(ListChangedType.ItemDeleted, index))
End Sub
Protected Overrides Sub OnInsertComplete(ByVal index As Integer, ByVal value As Object)
OnListChanged(New ListChangedEventArgs(ListChangedType.ItemAdded, index))
End Sub
Public Sub AddIndex(ByVal pd As PropertyDescriptor) Implements IBindingList.AddIndex
Throw New NotSupportedException()
End Sub
Public Sub ApplySort(ByVal pd As PropertyDescriptor, ByVal dir As ListSortDirection) Implements IBindingList.ApplySort
Throw New NotSupportedException()
End Sub
Public Function Find(ByVal [property] As PropertyDescriptor, ByVal key As Object) As Integer Implements IBindingList.Find
Throw New NotSupportedException()
End Function
Public ReadOnly Property IsSorted() As Boolean Implements IBindingList.IsSorted
Get
Return False
End Get
End Property
Public Sub RemoveIndex(ByVal pd As PropertyDescriptor) Implements IBindingList.RemoveIndex
Throw New NotSupportedException()
End Sub
Public Sub RemoveSort() Implements IBindingList.RemoveSort
Throw New NotSupportedException()
End Sub
Public ReadOnly Property SortDirection() As ListSortDirection Implements IBindingList.SortDirection
Get
Throw New NotSupportedException()
End Get
End Property
Public ReadOnly Property SortProperty() As PropertyDescriptor Implements IBindingList.SortProperty
Get
Throw New NotSupportedException()
End Get
End Property
Public ReadOnly Property SupportsChangeNotification() As Boolean Implements IBindingList.SupportsChangeNotification
Get
Return True
End Get
End Property
Public ReadOnly Property SupportsSearching() As Boolean Implements IBindingList.SupportsSearching
Get
Return False
End Get
End Property
Public ReadOnly Property SupportsSorting() As Boolean Implements IBindingList.SupportsSorting
Get
Return False
End Get
End Property
End Class
End Namespace