protected void InvokeExecuting(CancelCommandEventArgs args) { CancelCommandEventHandler executing = Executing; // Call the executed event. if (executing != null) executing(this, args); }
/// <summary> /// Executes the command. /// </summary> /// <param name="param">The param.</param> public virtual void DoExecute(object param) { // Invoke the executing command, allowing the command to be cancelled. CancelCommandEventArgs args = new CancelCommandEventArgs() { Parameter = param, Cancel = false }; InvokeExecuting(args); // If the event has been cancelled, bail now. if (args.Cancel) return; // Call the action or the parameterized action, whichever has been set. InvokeAction(param); // Call the executed function. InvokeExecuted(new CommandEventArgs() { Parameter = param }); }