This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Form1.vb
60 lines (49 loc) · 2.41 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
Imports DevExpress.Utils
Imports DevExpress.XtraEditors
Imports DevExpress.XtraScheduler
Imports DevExpress.XtraScheduler.Drawing
Imports System
Imports System.Drawing
Imports System.IO
Imports System.Windows.Forms
Namespace DateNavigatorCustomized
Partial Public Class Form1
Inherits XtraForm
Private Const aptDataFileName As String = "..\..\Data\appointments.xml"
Private Const resDataFileName As String = "..\..\Data\resources.xml"
Public Sub New()
InitializeComponent()
schedulerControl1.Start = New Date(2010, 7, 11)
FillData()
dateNavigator1.SelectionBehavior = DevExpress.XtraEditors.Controls.CalendarSelectionBehavior.Simple
End Sub
#Region "FillData"
Private Sub FillData()
Dim customNameMapping As New AppointmentCustomFieldMapping("CustomName", "CustomName")
Dim customStatusMapping As New AppointmentCustomFieldMapping("CustomStatus", "CustomStatus")
schedulerStorage1.Appointments.CustomFieldMappings.Add(customNameMapping)
schedulerStorage1.Appointments.CustomFieldMappings.Add(customStatusMapping)
FillResourcesStorage(schedulerStorage1.Resources.Items, resDataFileName)
FillAppointmentsStorage(schedulerStorage1.Appointments.Items, aptDataFileName)
End Sub
Private Shared Function GetFileStream(ByVal fileName As String) As Stream
Return (New StreamReader(fileName)).BaseStream
End Function
Private Shared Sub FillAppointmentsStorage(ByVal c As AppointmentCollection, ByVal fileName As String)
Using stream As Stream = GetFileStream(fileName)
c.ReadXml(stream)
stream.Close()
End Using
End Sub
Private Shared Sub FillResourcesStorage(ByVal c As ResourceCollection, ByVal fileName As String)
Using stream As Stream = GetFileStream(fileName)
c.ReadXml(stream)
stream.Close()
End Using
End Sub
#End Region
Private Sub schedulerStorage_AppointmentsChanged(ByVal sender As Object, ByVal e As PersistentObjectsEventArgs) Handles schedulerStorage1.AppointmentsInserted, schedulerStorage1.AppointmentsChanged, schedulerStorage1.AppointmentsDeleted
schedulerStorage1.Appointments.Items.WriteXml(aptDataFileName)
End Sub
End Class
End Namespace