Skip to content

Replace a default command with a custom command in the WinForms Scheduler control.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/winforms-scheduler-replace-default-command

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms Scheduler - Replace a default Scheduler command with a custom command

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]);
    }
}

Implementation Details

  • 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 ISchedulerCommandFactoryService interface. In this class, you need to implement the CreateCommand method 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 ISchedulerCommandFactoryService interface to substitute the default command service. In this case, the Scheduler control will use the custom command instead of the default command.

Files to Review

Documentation