Represets collection of the commands registered with the editor control. Commands exist for convenience and in order to expose predefined set of methods application can use.
For a list of all members of this type, see Commands Members.
System.Object
Aspose.Editor.Client.Commands
[Visual Basic]Public Class Commands
Remarks
You do not create instances of this class directly. Use the Commands property to access commands list.
Commands added to the collection will work only with the instance of the EditorControl which was used to obtain this collection.
Example
Shows how to invoke a standard command.
[C#]
// Normally this code is generated by Visual Studio .NET when you drag and drop
// the editor control into your Windows Form, but you can also code it youself.
EditorControl editorControl = new EditorControl();
editorControl.Dock = DockStyle.Fill;
// Create new document using standard command "New"
editorControl.Commands["New"].Invoke();
[Visual Basic]
' Normally this code is generated by Visual Studio .NET when you drag and drop
' the editor control into your Windows Form, but you can also code it youself.
Dim editorControl As New EditorControl()
editorControl.Dock = DockStyle.Fill
' Create new document using standard command "New"
editorControl.Commands("New").Invoke()Shows how to get and modify a standard command.
[C#]
private void ModifyStandardCommand()
{
// Normally this code is generated by Visual Studio .NET when you drag and drop
// the editor control into your Windows Form, but you can also code it youself.
EditorControl editorControl = new EditorControl();
editorControl.Dock = DockStyle.Fill;
// Get standard command "New"
Command cmdNew = editorControl.Commands["New"];
// Change command procedure
cmdNew.InvokeHandler = new CommandHandler(NewCommandNew);
}
private void NewCommandNew(EditorControl editor)
{
// Create new document and fill in some text
editor.Document = new Document();
editor.Document.GetRange().Text = "Hello, World!";
}
[Visual Basic]
Private Sub ModifyStandardCommand()
' Normally this code is generated by Visual Studio .NET when you drag and drop
' the editor control into your Windows Form, but you can also code it youself.
Dim editorControl As New EditorControl()
editorControl.Dock = DockStyle.Fill
' Get standard command "New"
Dim cmdNew As Command = editorControl.Commands("New")
' Change command procedure
cmdNew.InvokeHandler = New CommandHandler(AddressOf NewCommandNew)
End Sub
Private Sub NewCommandNew(ByVal editor As EditorControl)
' Create new document and fill in some text
editor.Document = New Document()
editor.Document.GetRange().Text = "Hello, World!"
End SubShows how to implement custom command and assign a menu item for it.
[C#]
private void CreateCustomCommand()
{
// Normally this code is generated by Visual Studio .NET when you drag and drop
// the editor control into your Windows Form, but you can also code it youself.
EditorControl editorControl = new EditorControl();
editorControl.Dock = DockStyle.Fill;
// Create new command
Command cmdAllCaps =
editorControl.Commands.Add("AllCaps",
"All &Caps",
"Applies AllCaps to the selection.",
new CommandHandler(CommandAllCaps));
// Add new command to the end of the first submenu in main menu
StandardMenuBar menu = editorControl.Bars.Menu as StandardMenuBar;
menu.GetItemAt(0).MenuItems.Add(cmdAllCaps.GetMenuItem());
}
private void CommandAllCaps(EditorControl editor)
{
editor.Selection.Range.Font.AllCaps = true;
}
[Visual Basic]
Private Sub CreateCustomCommand()
' Normally this code is generated by Visual Studio .NET when you drag and drop
' the editor control into your Windows Form, but you can also code it youself.
Dim editorControl As New EditorControl()
editorControl.Dock = DockStyle.Fill
' Create new command
Dim cmdAllCaps As Command = editorControl.Commands.Add("AllCaps", "All &Caps", "Applies AllCaps to the selection.", New CommandHandler(AddressOf CommandAllCaps))
' Add new command to the end of the first submenu in main menu
Dim menu As StandardMenuBar = CType(IIf(TypeOf editorControl.Bars.Menu Is StandardMenuBar, editorControl.Bars.Menu, Nothing), StandardMenuBar)
menu.GetItemAt(0).MenuItems.Add(cmdAllCaps.GetMenuItem())
End Sub
Private Sub CommandAllCaps(ByVal editor As EditorControl)
editor.Selection.Range.Font.AllCaps = True
End SubRequirements
Namespace: Aspose.Editor.Client
Assembly: Aspose.Editor.Client (in Aspose.Editor.Client.dll)
See Also
Commands Members | Aspose.Editor.Client Namespace | Command