-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomSchedulerCommandFactoryService.vb
64 lines (59 loc) · 2.29 KB
/
CustomSchedulerCommandFactoryService.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
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Linq
Imports DevExpress.XtraScheduler
Imports DevExpress.XtraScheduler.Commands
Imports DevExpress.XtraScheduler.Operations
Imports DevExpress.XtraScheduler.Native
Imports DevExpress.XtraScheduler.Services
Imports DevExpress.Utils
Namespace WindowsFormsApplication1
Public Class CustomSchedulerCommandFactoryService
Implements ISchedulerCommandFactoryService
Private ReadOnly service As ISchedulerCommandFactoryService
Private ReadOnly control As SchedulerControl
Public Sub New(ByVal control As SchedulerControl, ByVal service As ISchedulerCommandFactoryService)
Guard.ArgumentNotNull(control, "control")
Guard.ArgumentNotNull(service, "service")
Me.control = control
Me.service = service
End Sub
#Region "ISchedulerCommandFactoryService Members"
Public Function CreateCommand(ByVal id As SchedulerCommandId) As SchedulerCommand Implements ISchedulerCommandFactoryService.CreateCommand
If id = SchedulerCommandId.SplitAppointment Then
Dim cmd As New CustomSplitAppointmentOperationCommand(control)
cmd.SplitAppointmentCommandStep = TimeSpan.FromHours(12)
Return cmd
End If
Return service.CreateCommand(id)
End Function
#End Region
End Class
Public Class CustomSplitAppointmentOperationCommand
Inherits SplitAppointmentOperationCommand
Public Sub New(ByVal target As ISchedulerCommandTarget)
MyBase.New(target)
End Sub
Public Sub New(ByVal control As SchedulerControl)
MyBase.New(control)
End Sub
Private splitInterval As TimeSpan = TimeSpan.FromMinutes(10)
Public Property SplitAppointmentCommandStep() As TimeSpan
Get
Return splitInterval
End Get
Set(ByVal value As TimeSpan)
splitInterval = value
End Set
End Property
Protected Overrides Function CreateOperation() As IOperation
'TimeScaleCollection timeScales = CreateTimeScaleCollection();
Dim timeScales As New TimeScaleCollection()
timeScales.Add(New TimeScaleFixedInterval(SplitAppointmentCommandStep))
Return New SplitAppointmentOperation(SchedulerControl, timeScales, SchedulerControl.SelectedAppointments(0))
End Function
End Class
End Namespace