CustomCommand Class

This class represents a user defined command.

Definition

Namespace: Firefly.Box
Assembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
C#
public class CustomCommand : Command
Inheritance
Object    Command    CustomCommand

Remarks

This command can be raised using the [!:UIController.Raise(CustomCommand,object[])] and can be handled using the [!:HandlerCollection.Add(CommandBase)]

Example

Demo raise and invoke of custom command
C#
using System;
using System.Collections.Generic;
using System.Text;

using Firefly.Box;
using Firefly.Box.Testing;

namespace TestFirefly.Box.Documentation
{
    public class DifferenceBetweenRaiseAndInvoke
    {
        public void DemoRaiseAndInvoke()
        {
            var uic = new UIController
            {
                View = new Firefly.Box.UI.Form()
            };
            var myCommand = new CustomCommand();
            var h = uic.Handlers.Add(myCommand);
            h.Invokes += e =>
            {
                e.Handled = false;
                System.Windows.Forms.MessageBox.Show("First Handler");
            };
            var h2 = uic.Handlers.Add(myCommand);
            h2.Invokes += e =>
            {
                e.Handled = false;
                System.Windows.Forms.MessageBox.Show("Second Handler");
            };
            var invokeButton = new Firefly.Box.UI.Button
            {
                Text = "Invoke"
            };
            invokeButton.Click += (a, b) =>
            {
                System.Windows.Forms.MessageBox.Show("Before Invoke");
                uic.Invoke(myCommand);
                System.Windows.Forms.MessageBox.Show("After Invoke");
            };

            uic.View.Controls.Add(invokeButton);

            var raiseButton = new Firefly.Box.UI.Button
            {
                Text = "Raise",
                Top = invokeButton.Bottom + 5
            };
            raiseButton.Click += (a, b) =>
            {
                System.Windows.Forms.MessageBox.Show("Before Raise");
                uic.Raise(myCommand);
                System.Windows.Forms.MessageBox.Show("After Raise");
            };
            uic.View.Controls.Add(raiseButton);
            uic.Run();

        }
    }
}

Constructors

CustomCommandInitializes a new instance of the CustomCommand class.
CustomCommand(Boolean)Initializes a new instance of the CustomCommand class.
CustomCommand(Command)Initializes a new instance of the CustomCommand class.
CustomCommand(String)Initializes a new instance of the CustomCommand class.
CustomCommand(Command, Boolean)Initializes a new instance of the CustomCommand class.
CustomCommand(String, Command)Initializes a new instance of the CustomCommand class.
CustomCommand(String, Boolean)Initializes a new instance of the CustomCommand class.
CustomCommand(String, Command, Boolean)Initializes a new instance of the CustomCommand class.

Properties

AdditionalShortcuts Gets or sets an array of additional shortcut keys for this command.
(Inherited from Command)
AllowInvokeByKey 
CancelTrigger 
Enabled Gets a value indicating whether the Command is Enabled.
(Inherited from Command)
IgnoreIfUnhandledWithinBusinessProcess
(Overrides CommandIgnoreIfUnhandledWithinBusinessProcess)
Key 
Name The Command Name
(Inherited from Command)
Precondition 
Shortcut Gets or sets a value indicating the shortcut key for this command.
(Inherited from Command)

Methods

AllowParentViewAccordingToHandlerContext
(Inherited from Command)
BindMenuItem(ToolStripButton)Used to bind between the Command and a menuItem.
(Inherited from Command)
BindMenuItem(ToolStripMenuItem)Used to bind between the Command and a menuItem.
(Inherited from Command)
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetDefaultBehavior 
GetHashCodeServes as a hash function for a particular type.
(Inherited from Command)
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
RefreshBoundMenus
(Inherited from Command)
SendObjectColumnEventName
(Inherited from Command)
ToStringReturns a string that represents the current object.
(Inherited from Command)
UnbindMenuItem
(Inherited from Command)
UnhandledWithinBusinessProcess
(Inherited from Command)

Events

EnabledChanged Occurs when the Enabled property has changed.
(Inherited from Command)

See Also