Exemplo n.º 1
0
        protected void InvokeExecuting(CancelCommandEventArgs args)
        {
            CancelCommandEventHandler executing = Executing;

            //  Call the executed event.
            if (executing != null)
            {
                executing(this, args);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="param">The param.</param>
        protected void DoExecute(object param)
        {
            //  Invoke the executing command, allowing the command to be cancelled.
            var 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
            });
        }