If you want to provide additional functionality to your users, you should to create your own custom commands and command actions, which inherit from the NScheduleCommandAction class. The following example demonstrates how to create a custom command action that shows a message box when executed. This command action is used in the rest of the topics in this chapter for a custom command added to the commanding UI of the schedule.
Create custom command action |
Copy Code
|
---|---|
public class CustomCommandAction : NScheduleCommandAction { public CustomCommandAction() { } static CustomCommandAction() { CustomCommandActionSchema = NSchema.Create(typeof(CustomCommandAction), NScheduleCommandAction.NScheduleCommandActionSchema); } public override NCommand GetCommand() { return MyCustomType.CustomCommand; } public override void Execute(NNode target, object parameter) { NScheduleView scheduleView = GetScheduleView(target); NMessageBox.Show("Schedule Custom Command executed!", "Custom Command", ENMessageBoxButtons.OK, ENMessageBoxIcon.Information); } public static readonly NSchema CustomCommandActionSchema; } |
You will also have to add your custom command actions to the Commander of the schedule view:
Add a custom command action |
Copy Code
|
---|---|
scheduleView.Commander.Add(new CustomCommandAction());
|
You should also define a custom command, which you should later use in custom builders:
Define a custom command |
Copy Code
|
---|---|
public static readonly NCommand CustomCommand = NCommand.Create(typeof(MyCustomType), "CustomCommand", "Custom Command"); |
For more information about commanding and command builders, check out the topics in the "See Also" section below.