Exemplo n.º 1
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="referenceImage">The 'current' (or reference) <see cref="IPresentationImage"/>.</param>
		/// <param name="operation">The operation to be performed on the current <see cref="IPresentationImage"/> and/or its linked images.</param>
		public ImageOperationApplicator(IPresentationImage referenceImage, IUndoableOperation<IPresentationImage> operation)
		{
			Platform.CheckForNullReference(referenceImage, "referenceImage");
			Platform.CheckForNullReference(operation, "operation");

			_imageEnumerator = new LinkedImageEnumerator(referenceImage);
			_operation = operation;
		}
Exemplo n.º 2
0
		/// <summary>
		/// Call this method to push an UndoableOperation on the undostack, the redostack
		/// will be cleared, if you use this method.
		/// </summary>
		public void Push(IUndoableOperation operation) 
		{
			if (operation == null) {
				throw new ArgumentNullException("UndoStack.Push(UndoableOperation operation) : operation can't be null");
			}
			
			if (AcceptChanges) {
				undostack.Push(operation);
				ClearRedoStack();
			}
		}
Exemplo n.º 3
0
		/// <summary>
		/// Call this method to push an UndoableOperation on the undostack, the redostack
		/// will be cleared, if you use this method.
		/// </summary>
		public void Push(IUndoableOperation operation) 
		{
			if (operation == null) {
				throw new ArgumentNullException("操作不能为空.");
			}
			
			if (AcceptChanges) {
				undostack.Push(operation);
				if (TextEditorControl != null) {
					undostack.Push(new UndoableSetCaretPosition(this, TextEditorControl.ActiveTextAreaControl.Caret.Position));
					UndoLast(2);
				}
				ClearRedoStack();
			}
		}
Exemplo n.º 4
0
        /// <summary>
        /// Call this method to push an UndoableOperation on the undostack, the redostack
        /// will be cleared, if you use this method.
        /// </summary>
        public void Push(IUndoableOperation operation)
        {
            if (operation == null)
            {
                throw new ArgumentNullException("UndoStack.Push(UndoableOperation operation) : operation can't be null");
            }

            if (AcceptChanges)
            {
                StartUndoGroup();
                undostack.Push(operation);
                actionCountInUndoGroup++;
                if (TextEditorControl != null)
                {
                    undostack.Push(new UndoableSetCaretPosition(this, TextEditorControl.ActiveTextAreaControl.Caret.Position));
                    actionCountInUndoGroup++;
                }
                EndUndoGroup();
                ClearRedoStack();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Redoes the last undone operation.
        /// </summary>
        public void Redo()
        {
            AssertNoUndoGroupOpen();
            if (InternalRedoStack.Count > 0)
            {
                IUndoableOperation operation = InternalRedoStack.DequeueHead();
                InternalUndoStack.EnqueueHead(operation);
                operation.Do();
                OnOperationRedone();

                if (InternalRedoStack.Count == 0)
                {
                    OnPropertyChanged(new PropertyChangedEventArgs("CanRedo"));
                }

                if (InternalUndoStack.Count == 1)
                {
                    OnPropertyChanged(new PropertyChangedEventArgs("CanUndo"));
                }

                EnforceSizeLimit();
            }
        }
Exemplo n.º 6
0
        private void Push(IUndoableOperation operation, bool isOptional)
        {
            if (operation == null)
            {
                throw new ArgumentNullException("operation");
            }

            if (state == StateListen && sizeLimit > 0)
            {
                bool wasEmpty = undostack.Count == 0;

                bool needsUndoGroup = undoGroupDepth == 0;
                if (needsUndoGroup)
                {
                    StartUndoGroup();
                }
                undostack.PushBack(operation);
                actionCountInUndoGroup++;
                if (isOptional)
                {
                    optionalActionCount++;
                }
                else
                {
                    FileModified(1);
                }
                if (needsUndoGroup)
                {
                    EndUndoGroup();
                }
                if (wasEmpty)
                {
                    NotifyPropertyChanged("CanUndo");
                }
                ClearRedoStack();
            }
        }
 /// <summary>
 /// Call this method to redo the last undone operation
 /// </summary>
 public void Redo()
 {
     ThrowIfUndoGroupOpen();
     if (redostack.Count > 0)
     {
         lastGroupDescriptor = null; allowContinue = false;
         IUndoableOperation uedit = redostack.PopBack();
         undostack.PushBack(uedit);
         state = StatePlayback;
         try {
             RunRedo(uedit);
         } finally {
             state = StateListen;
         }
         if (redostack.Count == 0)
         {
             NotifyPropertyChanged("CanRedo");
         }
         if (undostack.Count == 1)
         {
             NotifyPropertyChanged("CanUndo");
         }
     }
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="operation">The <see cref="IUndoableOperation{T}"/> that is to be applied to <paramref name="item"/>.</param>
 /// <param name="item">The item to which the <paramref name="operation"/> should be applied.</param>
 public DrawableUndoableOperationCommand(IUndoableOperation <T> operation, T item)
     : base(operation, item)
 {
 }
Exemplo n.º 9
0
 public OperationEventArgs(IUndoableOperation op)
 {
     this.op = op;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Call this method to push an UndoableOperation on the undostack.
 /// The redostack will be cleared if you use this method.
 /// </summary>
 public void Push(IUndoableOperation operation)
 {
     Push(operation, false);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Call this method to push an UndoableOperation on the undostack, the redostack
        /// will be cleared, if you use this method.
        /// </summary>
        public void Push(IUndoableOperation operation)
        {
            if (operation == null) {
                throw new ArgumentNullException("operation");
            }

            if (AcceptChanges) {
                StartUndoGroup();
                undostack.Push(operation);
                actionCountInUndoGroup++;
                if (TextEditorControl != null) {
                    undostack.Push(new UndoableSetCaretPosition(this, TextEditorControl.ActiveTextAreaControl.Caret.Position));
                    actionCountInUndoGroup++;
                }
                EndUndoGroup();
                ClearRedoStack();
            }
        }
Exemplo n.º 12
0
 public OperationEventArgs(IUndoableOperation op)
 {
     this.op = op;
 }
Exemplo n.º 13
0
        void Push(IUndoableOperation operation, bool isOptional)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            if (state == StateListen && sizeLimit > 0)
            {
                bool wasEmpty = undostack.Count == 0;

                bool needsUndoGroup = undoGroupDepth == 0;
                if (needsUndoGroup) StartUndoGroup();
                undostack.PushBack(operation);
                actionCountInUndoGroup++;
                if (isOptional)
                    optionalActionCount++;
                else
                    FileModified(1);
                if (needsUndoGroup) EndUndoGroup();
                if (wasEmpty)
                    NotifyPropertyChanged("CanUndo");
                ClearRedoStack();
            }
        }
Exemplo n.º 14
0
 public OperationEventArgs(IUndoableOperation op)
 {
     Operation = op;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Call this method to push an UndoableOperation on the undostack.
 /// The redostack will be cleared if you use this method.
 /// </summary>
 public void Push(IUndoableOperation operation)
 {
     Push(operation, false);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Call this method to push an UndoableOperation on the undostack.
 /// However, the operation will be only stored if the undo group contains a
 /// non-optional operation.
 /// Use this method to store the caret position/selection on the undo stack to
 /// prevent having only actions that affect only the caret and not the document.
 /// </summary>
 public void PushOptional(IUndoableOperation operation)
 {
     if (undoGroupDepth == 0)
         throw new InvalidOperationException("Cannot use PushOptional outside of undo group");
     Push(operation, true);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="operation">The <see cref="IUndoableOperation{T}"/> that is to be applied to <paramref name="items"/>.</param>
 /// <param name="items">The items to which the <paramref name="operation"/> should be applied.</param>
 public DrawableUndoableOperationCommand(IUndoableOperation <T> operation, IEnumerable <T> items)
     : base(operation, items)
 {
 }
Exemplo n.º 18
0
 internal void RunRedo(IUndoableOperation op)
 {
     IUndoableOperationWithContext opWithCtx = op as IUndoableOperationWithContext;
     if (opWithCtx != null)
         opWithCtx.Redo(this);
     else
         op.Redo();
 }
Exemplo n.º 19
0
        /// <summary>
        /// Adds an operation to the undo buffer.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <remarks>
        /// <para>
        /// This methods needs to be called for every <see cref="IUndoableOperation"/> before or after
        /// it is executed by calling its <see cref="IUndoableOperation.Do"/> method. Note: 
        /// <see cref="Add"/> does not execute the <see cref="IUndoableOperation"/> it will only record
        /// the operation.
        /// </para>
        /// <para>
        /// After the operation is recorded in the undo buffer it can be undone and redone by calling
        /// <see cref="Undo"/> and <see cref="Redo"/>.
        /// </para>
        /// <para>
        /// The recording of operations in the undo buffer can be temporarily disabled by setting
        /// <see cref="AcceptChanges"/> to <see langword="false"/>.
        /// </para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="operation"/> is <see langword="null"/>.
        /// </exception>
        /// <seealso cref="AcceptChanges"/>
        public void Add(IUndoableOperation operation)
        {
            if (operation == null)
            throw new ArgumentNullException("operation");

              if (AcceptChanges)
              {
            InternalUndoStack.EnqueueHead(operation);

            if (IsUndoGroupOpen)
              _numberOfOperationsInGroup++;

            if (InternalUndoStack.Count == 1)
              OnPropertyChanged(new PropertyChangedEventArgs("CanUndo"));

            ClearRedoStack();

            if (!IsUndoGroupOpen)
              EnforceSizeLimit();
              }
        }
Exemplo n.º 20
0
		void Push(IUndoableOperation operation, bool isOptional)
		{
			if (operation == null) {
				throw new ArgumentNullException("operation");
			}
			
			if (acceptChanges) {
				bool wasEmpty = undostack.Count == 0;
				
				StartUndoGroup();
				undostack.Push(operation);
				actionCountInUndoGroup++;
				if (isOptional)
					optionalActionCount++;
				EndUndoGroup();
				if (wasEmpty)
					NotifyPropertyChanged("CanUndo");
				ClearRedoStack();
			}
		}
Exemplo n.º 21
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="operation">The <see cref="IUndoableOperation{T}"/> that is to be applied to <paramref name="item"/>.</param>
 /// <param name="item">The item to which the <paramref name="operation"/> should be applied.</param>
 public UndoableOperationCommand(IUndoableOperation <T> operation, T item)
     : this(operation, ToEnumerable(item))
 {
 }
Exemplo n.º 22
0
		public void PushOptional(IUndoableOperation operation) 
		{ 
			//TODO: UndoStack.PushOptional()
			throw new NotImplementedException();
		}
Exemplo n.º 23
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="operation">The <see cref="IUndoableOperation{T}"/> that is to be applied to <paramref name="items"/>.</param>
 /// <param name="items">The items to which the <paramref name="operation"/> should be applied.</param>
 public UndoableOperationCommand(IUndoableOperation <T> operation, IEnumerable <T> items)
 {
     _operation = operation;
     _items     = items;
 }