The WinForms Scheduler Control exposes the ISchedulerCommandFactoryService interface that enables you to substitute the default command with your own (custom) command. This example replaces the default SplitAppointmentOperationCommand with a custom command. The custom command has the SplitAppointmentCommandStep property that specifies a fixed split operation's step.
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 = new TimeScaleCollection();
timeScales.Add(new TimeScaleFixedInterval(SplitAppointmentCommandStep));
return new SplitAppointmentOperation(SchedulerControl, timeScales, SchedulerControl.SelectedAppointments[0]);
}
}- Create a custom command class inherited from the command that you wish to replace.
- Override required methods of the command.
- Create a class that implements the
ISchedulerCommandFactoryServiceinterface. In this class, you need to implement theCreateCommandmethod to instantiate a custom command class. An identifier of the currently processed command is passed as a parameter of this method. - Use the custom class that implements the
ISchedulerCommandFactoryServiceinterface to substitute the default command service. In this case, the Scheduler control will use the custom command instead of the default command.
- CustomSchedulerCommandFactoryService.cs (VB: CustomSchedulerCommandFactoryService.vb)
- Form1.cs (VB: Form1.vb)
(you will be redirected to DevExpress.com to submit your response)