All commands are contained by a NDockingFrameworkCommander instance, member of the NDockManager. It contains methods for command execution by keys, by id, by name, etc. All the commands are kept by id and if you attempt to register a command which has an id already contained the previous command will be removed.
The following code demonstrates how to create and register a custom command:
C# |
Copy Code
|
---|---|
NDockingFrameworkCommand command = new NDockingFrameworkCommand(); command.ID = (int)MyCommandIdEnum.Command1; //add a shortcut combination command.Shortcuts.Add(new NShortcut(Keys.Q, Keys.Control | Keys.Shift)); //hook to the executed event command.Executed += new EventHandler(OnMyCommandCommandExecuted); this.nDockManager1.Commander.RegisterCommand(command); private void OnMyCommandCommandExecuted(object sender, EventArgs e) { MessageBox.Show("My command is executed..."); } |
Visual Basic |
Copy Code
|
---|---|
Dim command As NDockingFrameworkCommand = New NDockingFrameworkCommand() command.ID = CInt(MyCommandIdEnum.Command1) 'add a shortcut combination command.Shortcuts.Add(new NShortcut(Keys.Q, Keys.Control Or Keys.Shift)) 'hook to the executed event AddHandler command.Executed, AddressOf OnMyCommandCommandExecuted Me.nDockManager1.Commander.RegisterCommand(command) Private Sub OnMyCommandCommandExecuted(ByVal sender As Object, ByVal e As EventArgs) Handles commandExecuted MessageBox.Show("My command is executed...") End Sub |
The following table describes the predefined commands registered with the framework:
ID | Command Name | Shortcut(s) |
---|---|---|
0 | NextPanel | Alt + F6 |
1 | NextDocument | Ctrl + Tab, Ctrl + F6 |
2 | NextPanelTab | Ctrl + Num+ |
3 | NextDocumentTab | Ctrl + Shift + Num+ |
4 | PreviousPanel | Alt + Shift + F6 |
5 | PreviousDocument | Ctrl + Shift + Tab, Ctrl + Shift + F6 |
6 | PreviousPanelTab | Ctrl + Num- |
7 | PreviousDocumentTab | Ctrl + Shift + Num- |
8 | ClosePanel | Shift + Esc |
9 | CloseDocument | Ctrl + F4 |
10 | CloseAllDocuments | None |
11 | DocumentTileHorizontal | None |
12 | DocumentTileVertical | None |
13 | DocumentCascade | None |
14 | DocumentArrangeIcons | None |
The NDockingFrameworkCommander comes with a built-in editor which visually allows to edit the shortcut combinations associated with a command.
The following code demonstrates how to display this editor:
C# |
Copy Code
|
---|---|
this.nDockManager1.Commander.ShowKeyboardEditor();
|
Visual Basic |
Copy Code
|
---|---|
Me.nDockManager1.Commander.ShowKeyboardEditor()
|