-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomSchedulerCommandFactoryService.cs
68 lines (63 loc) · 2.41 KB
/
CustomSchedulerCommandFactoryService.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Commands;
using DevExpress.XtraScheduler.Operations;
using DevExpress.XtraScheduler.Native;
using DevExpress.XtraScheduler.Services;
using DevExpress.Utils;
namespace WindowsFormsApplication1
{
public class CustomSchedulerCommandFactoryService : ISchedulerCommandFactoryService
{
readonly ISchedulerCommandFactoryService service;
readonly SchedulerControl control;
public CustomSchedulerCommandFactoryService(SchedulerControl control,
ISchedulerCommandFactoryService service)
{
Guard.ArgumentNotNull(control, "control");
Guard.ArgumentNotNull(service, "service");
this.control = control;
this.service = service;
}
#region ISchedulerCommandFactoryService Members
public SchedulerCommand CreateCommand(SchedulerCommandId id)
{
if (id == SchedulerCommandId.SplitAppointment)
{
CustomSplitAppointmentOperationCommand cmd = new CustomSplitAppointmentOperationCommand(control);
cmd.SplitAppointmentCommandStep = TimeSpan.FromHours(12);
return cmd;
}
return service.CreateCommand(id);
}
#endregion
}
public class CustomSplitAppointmentOperationCommand : SplitAppointmentOperationCommand
{
public CustomSplitAppointmentOperationCommand(ISchedulerCommandTarget target) : base(target) { }
public CustomSplitAppointmentOperationCommand(SchedulerControl control) : base(control) { }
private TimeSpan splitInterval = TimeSpan.FromMinutes(10);
public TimeSpan SplitAppointmentCommandStep
{
get
{
return splitInterval;
}
set
{
splitInterval = value;
}
}
protected override IOperation CreateOperation()
{
//TimeScaleCollection timeScales = CreateTimeScaleCollection();
TimeScaleCollection timeScales = new TimeScaleCollection();
timeScales.Add(new TimeScaleFixedInterval(SplitAppointmentCommandStep));
return new SplitAppointmentOperation(SchedulerControl, timeScales, SchedulerControl.SelectedAppointments[0]);
}
}
}