-
Notifications
You must be signed in to change notification settings - Fork 1
/
Form1.vb
85 lines (72 loc) · 3.82 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
84
85
Imports DevExpress.Xpo
Imports DevExpress.XtraScheduler
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Namespace XPO_XtraScheduler_Simple_Example
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
session1.ConnectionString = DevExpress.Xpo.DB.AccessConnectionProvider.GetConnectionString("XPO_XtraScheduler_Simple_Example.mdb")
schedulerStorage1.Appointments.DataSource = xpAppointmentCollection
schedulerStorage1.Resources.DataSource = xpResourceCollection
CreateMappings()
InitData()
AddHandler schedulerStorage1.AppointmentsChanged, AddressOf OnAppointmentsChanged
AddHandler schedulerStorage1.AppointmentsInserted, AddressOf OnAppointmentsChanged
schedulerStorage1.Appointments.ResourceSharing = False
schedulerControl1.Views.DayView.GroupType = SchedulerGroupType.Resource
schedulerControl1.Views.DayView.TopRowTime = Date.Now.TimeOfDay
End Sub
Private Sub InitData()
If xpResourceCollection.Count = 0 Then
Dim res1 As Resource = schedulerStorage1.CreateResource(1)
res1.Caption = "First Resource"
res1.ColorValue = "LightSkyBlue"
schedulerStorage1.Resources.Add(res1)
Dim res2 As Resource = schedulerStorage1.CreateResource(2)
res2.Caption = "Next Resource"
res2.ColorValue = "LightYellow"
schedulerStorage1.Resources.Add(res2)
session1.Save(xpResourceCollection)
End If
If schedulerStorage1.Appointments.Count = 0 Then
Dim apt1 As Appointment = schedulerStorage1.CreateAppointment(AppointmentType.Normal)
apt1.Start = Date.Now
apt1.End = apt1.Start.AddHours(2.5F)
apt1.Subject = "First Appointment"
apt1.LabelKey = 1
apt1.ResourceId = schedulerStorage1.Resources(0).Id
schedulerStorage1.Appointments.Add(apt1)
session1.Save(xpAppointmentCollection)
End If
End Sub
Private Sub CreateMappings()
Me.schedulerStorage1.Appointments.Mappings.AllDay = "AllDay"
Me.schedulerStorage1.Appointments.Mappings.Description = "Description"
Me.schedulerStorage1.Appointments.Mappings.End = "Finish"
Me.schedulerStorage1.Appointments.Mappings.Label = "Label"
Me.schedulerStorage1.Appointments.Mappings.Location = "Location"
Me.schedulerStorage1.Appointments.Mappings.RecurrenceInfo = "Recurrence"
Me.schedulerStorage1.Appointments.Mappings.ReminderInfo = "Reminder"
Me.schedulerStorage1.Appointments.Mappings.ResourceId = "Resource!Key"
Me.schedulerStorage1.Appointments.Mappings.Start = "Created"
Me.schedulerStorage1.Appointments.Mappings.Status = "Status"
Me.schedulerStorage1.Appointments.Mappings.Subject = "Subject"
Me.schedulerStorage1.Appointments.Mappings.Type = "AppointmentType"
Me.schedulerStorage1.Resources.Mappings.Caption = "Name"
Me.schedulerStorage1.Resources.Mappings.Color = "Color"
Me.schedulerStorage1.Resources.Mappings.Id = "Oid"
Me.schedulerStorage1.Resources.Mappings.Image = "Image"
End Sub
Private Sub OnAppointmentsChanged(ByVal sender As Object, ByVal e As PersistentObjectsEventArgs)
For Each apt As Appointment In e.Objects
Dim o As XPBaseObject = TryCast(apt.GetSourceObject(DirectCast(sender, SchedulerStorage)), XPBaseObject)
If o IsNot Nothing Then
o.Save()
End If
Next apt
End Sub
End Class
End Namespace