/// <summary>
 /// Creates a new instance of the UndoableDelegateCommand with the specified delegates providing logic for the class.
 /// </summary>
 /// <param name="execute">A delegate that takes a TCommandData object, and returns a TUndoRedoData object. This delegate is called when the command is executed.</param>
 /// <param name="canExecute">A delegate that takes a TCommandData object and returns a bool. This delegate is called to determine when the command can be executed.</param>
 /// <param name="undo">A delegate that takes a TUndoRedoData object, undoes the actions executed during the execute logic, and returns another TUndoRedoData object to assist in redoing this command.</param>
 /// <param name="redo">A delegate that takes a TUndoRedoData object, redoes the actions executed during the undo logic, and returns another TUndoRedoData object to assist in re-undoing this command.</param>
 /// <param name="name">The name of the command. If left blank, a System.Guid is used.</param>
 /// <param name="context">The context that is used to manage this UndoableCommand</param>
 public UndoableDelegateCommand(Func <TCommandData, TUndoRedoData> execute = null,
                                Func <TCommandData, bool> canExecute       = null,
                                Func <TUndoRedoData, TUndoRedoData> undo   = null,
                                Func <TUndoRedoData, TUndoRedoData> redo   = null,
                                string name = "",
                                IUndoRedoContext context = null)
     : base(execute, canExecute, undo, redo, name, context)
 {
 }
        /// <summary>
        /// This internal contructor is designed to prevent external code from continuing this inheritance chain. This should never be called from external code.
        /// </summary>
        /// <param name="execute"></param>
        /// <param name="canExecute"></param>
        /// <param name="undo"></param>
        /// <param name="redo"></param>
        /// <param name="name"></param>
        /// <param name="context"></param>
        internal UndoableDelegateCommandBase(Func <TCommandData, TUndoRedoData> execute = null,
                                             Func <TCommandData, bool> canExecute       = null,
                                             Func <TUndoRedoData, TUndoRedoData> undo   = null,
                                             Func <TUndoRedoData, TUndoRedoData> redo   = null,
                                             string name = "",
                                             IUndoRedoContext context = null)
            : base(name, context)
        {
            this.ExecuteOverride = execute;

            this.CanExecuteOverride = canExecute;

            this.UndoOverride = undo;

            this.RedoOverride = redo;
        }
Пример #3
0
        /// <summary>
        /// This constructor prevents external code from inheriting from this class.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="context"></param>
        internal UndoableActionBase(string name = "", IUndoRedoContext context = null)
        {
            this.Context = context;
            if (this.Context == null)
            {
                this.Context = UndoRedoContext.GetDefaultContext();
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                this.Name = Guid.NewGuid().ToString();
            }
            else
            {
                this.Name = name.Trim();
            }

            this.Context.RegisterAction(this);
        }
Пример #4
0
        /// <summary>
        /// Creates a new UndoableProperty.
        /// </summary>
        /// <param name="associatedObject">The object containing the property.</param>
        /// <param name="propertyName">The name of the property as a string.</param>
        /// <param name="context">The context which manages this UndoableProperty.</param>
        /// <param name="startingValue">The starting value for the property backer.</param>
        public UndoableProperty(INotifyPropertyChanged associatedObject,
                                string propertyName,
                                IUndoRedoContext context    = null,
                                TPropertyType startingValue = default(TPropertyType))
            : base(propertyName, context)
        {
            args = new PropertyChangedEventArgs(propertyName);

            if (associatedObject == null)
            {
                throw new NotImplementedException();
            }
            else
            {
                this.associatedObject = associatedObject;
            }

            this._internalStore = startingValue;

            this.BatchingTimeout = 1500;
        }