Represents named action executed on the editor control. Each command is bound to the editor control instance it was created by.
For a list of all members of this type, see Command Members.
System.Object
Aspose.Editor.Client.Command
[Visual Basic]
Public Class Command
Remarks
You do not create instances of this class directly. Use methods of the Commands class instead.
Example
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
Command Members | Aspose.Editor.Client Namespace | Commands