コード例 #1
0
ファイル: Command.cs プロジェクト: whitemike889/CSharpMath
        /// <summary>
        /// Defines the method to be called when the command is invoked.
        /// </summary>
        /// <param name="parameter">Data used by the command.
        ///  If the command does not require data to be passed,
        ///  this object can be set to null.</param>
        public virtual void Execute(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
            });
        }
コード例 #2
0
ファイル: Command.cs プロジェクト: whitemike889/CSharpMath
 protected void InvokeExecuting(CancelCommandEventArgs args)
 {
     Executing?.Invoke(this, args);
 }