public UndoTransactionImpl(ITextUndoHistory history, ITextUndoTransaction parent, string description) { if (history == null) { throw new ArgumentNullException("history", String.Format(CultureInfo.CurrentUICulture, "Strings.ArgumentCannotBeNull", "UndoTransactionImpl", "history")); } if (String.IsNullOrEmpty(description)) { throw new ArgumentNullException("description", String.Format(CultureInfo.CurrentUICulture, "Strings.ArgumentCannotBeNull", "UndoTransactionImpl", "description")); } this.history = history as UndoHistoryImpl; if (this.history == null) { throw new ArgumentException("Strings.InvalidHistoryInTransaction"); } this.parent = parent as UndoTransactionImpl; if (this.parent == null && parent != null) { throw new ArgumentException("Strings.InvalidParentInTransaction"); } this.description = description; this.state = UndoTransactionState.Open; this.primitives = new List <ITextUndoPrimitive>(); this.mergePolicy = NullMergeUndoTransactionPolicy.Instance; this.IsReadOnly = true; }
public TextUndoTransaction(TextUndoHistory textUndoHistory, ITextUndoTransaction parent) { _textUndoHistory = textUndoHistory; _state = UndoTransactionState.Open; _parent = parent; MergePolicy = new Policy(); }
public UndoTransactionImpl(ITextUndoHistory history, ITextUndoTransaction parent, string description) { if (history == null) { throw new ArgumentNullException(nameof(history)); } if (string.IsNullOrEmpty(description)) { throw new ArgumentNullException(nameof(description)); } this.history = history as UndoHistoryImpl; if (this.history == null) { throw new ArgumentException("Strings.InvalidHistoryInTransaction"); } this.parent = parent as UndoTransactionImpl; if (this.parent == null && parent != null) { throw new ArgumentException("Strings.InvalidParentInTransaction"); } this.description = description; this.state = UndoTransactionState.Open; this.primitives = new List <ITextUndoPrimitive>(); this.mergePolicy = NullMergeUndoTransactionPolicy.Instance; this.IsReadOnly = true; }
public UndoTransactionImpl(ITextUndoHistory history, ITextUndoTransaction parent, string description) { if (history == null) { throw new ArgumentNullException(nameof(history)); } if (string.IsNullOrEmpty(description)) { throw new ArgumentNullException(nameof(description)); } _history = history as UndoHistoryImpl; if (_history == null) { throw new ArgumentException("Invalid history in registry"); } _parent = parent as UndoTransactionImpl; if (_parent == null && parent != null) { throw new ArgumentException("Invalid parent in transaction"); } Description = description; _state = UndoTransactionState.Open; _primitives = new List <ITextUndoPrimitive>(); _mergePolicy = NullMergeUndoTransactionPolicy.Instance; IsReadOnly = true; }
public UndoTransactionImpl(ITextUndoHistory history, ITextUndoTransaction parent, string description) { if (history == null) { throw new ArgumentNullException(nameof(history)); } if (string.IsNullOrEmpty(description)) { throw new ArgumentNullException(nameof(description)); } _history = history as UndoHistoryImpl; if (_history == null) { throw new ArgumentException("Invalid history in registry"); } _parent = parent as UndoTransactionImpl; if (_parent == null && parent != null) { throw new ArgumentException("Invalid parent in transaction"); } Description = description; _state = UndoTransactionState.Open; _primitives = new List<ITextUndoPrimitive>(); _mergePolicy = NullMergeUndoTransactionPolicy.Instance; IsReadOnly = true; }
/// <summary> /// Cancel marks an Open transaction Canceled, and Undoes and clears any primitives that have been added. /// </summary> public void Cancel() { for (var i = _primitives.Count - 1; i >= 0; --i) { _primitives[i].Undo(); } _primitives.Clear(); _state = UndoTransactionState.Canceled; }
/// <summary> /// Complete marks the transaction finished and eligible for Undo. /// </summary> public void Complete() { if (State != UndoTransactionState.Open) { throw new InvalidOperationException("Complete called on transaction that is not opened"); } _state = UndoTransactionState.Completed; // now we need to pump these primitives into the parent, if the parent exists. FlattenPrimitivesToParent(); }
/// <summary> /// Cancel marks an Open transaction Canceled, and Undoes and clears any primitives that have been added. /// </summary> public void Cancel() { Check.InvalidOperation(() => State == UndoTransactionState.Open, "Cancel called on transation that is not opened"); for (var i = _primitives.Count - 1; i >= 0; --i) { _primitives[i].Undo(); } _primitives.Clear(); _state = UndoTransactionState.Canceled; }
public MockTextUndoTransaction(ITextUndoHistory history, ITextUndoTransaction parent, string description) { _history = history as MockTextUndoHistory; _parent = parent as MockTextUndoTransaction; Description = description; _state = UndoTransactionState.Open; _primitives = new List<ITextUndoPrimitive>(); MergePolicy = NullMergeUndoTransactionPolicy.Instance; IsReadOnly = true; }
/// <summary> /// Complete marks the transaction finished and eligible for Undo. /// </summary> public void Complete() { if (this.State != UndoTransactionState.Open) { throw new InvalidOperationException("Strings.CompleteCalledOnTransationThatIsNotOpened"); } this.state = UndoTransactionState.Completed; // now we need to pump these primitives into the parent, if the parent exists. FlattenPrimitivesToParent(); }
/// <summary> /// Cancel marks an Open transaction Canceled, and Undoes and clears any primitives that have been added. /// </summary> public void Cancel() { if (State != UndoTransactionState.Open) { throw new InvalidOperationException("Strings.CancelCalledOnTransationThatIsNotOpened"); } for (int i = _primitives.Count - 1; i >= 0; --i) { _primitives[i].Undo(); } _primitives.Clear(); _state = UndoTransactionState.Canceled; }
/// <summary> /// /// </summary> public void Do() { if (_state == UndoTransactionState.Invalid) { return; } if (!CanRedo) { throw new InvalidOperationException("Strings.DoCalledButCanRedoFalse"); } _state = UndoTransactionState.Redoing; for (var i = 0; i < _primitives.Count; ++i) { _primitives[i].Do(); } _state = UndoTransactionState.Completed; }
/// <summary> /// This defers to the linked transaction if there is one. /// </summary> public void Undo() { if (_state == UndoTransactionState.Invalid) { return; } if (!CanUndo) { throw new InvalidOperationException("Strings.UndoCalledButCanUndoFalse"); } _state = UndoTransactionState.Undoing; for (var i = _primitives.Count - 1; i >= 0; --i) { _primitives[i].Undo(); } _state = UndoTransactionState.Undone; }
public UndoTransactionImpl(ITextUndoHistory history, ITextUndoTransaction parent, string description) { Check.ArgumentNull(nameof(history), history); Check.ArgumentStringNullOrEmpty(nameof(description), description); _history = history as UndoHistoryImpl; Check.ArgumentNull(nameof(history), _history); _parent = parent as UndoTransactionImpl; Check.Argument(nameof(parent), () => _parent != null || parent == null); Description = description; _state = UndoTransactionState.Open; _primitives = new List <ITextUndoPrimitive>(); _mergePolicy = NullMergeUndoTransactionPolicy.Instance; IsReadOnly = true; }
public void Complete() { _state = UndoTransactionState.Completed; MaybeClearCurrent(); }
public void Cancel() { _state = UndoTransactionState.Canceled; MaybeClearCurrent(); }
/// <summary> /// This is how you turn transaction into "Invalid" state. Use it to indicate that this transaction is retired forever, /// such as when clearing transactions from the redo stack. /// </summary> internal void Invalidate() { _state = UndoTransactionState.Invalid; }
/// <summary> /// This defers to the linked transaction if there is one. /// </summary> public void Undo() { if (_state == UndoTransactionState.Invalid) { return; } if (!CanUndo) { throw new InvalidOperationException("Strings.UndoCalledButCanUndoFalse"); } _state = UndoTransactionState.Undoing; for (int i = _primitives.Count - 1; i >= 0; --i) { _primitives[i].Undo(); } _state = UndoTransactionState.Undone; }
/// <summary> /// Cancel marks an Open transaction Canceled, and Undoes and clears any primitives that have been added. /// </summary> public void Cancel() { if (State != UndoTransactionState.Open) { throw new InvalidOperationException("Strings.CancelCalledOnTransationThatIsNotOpened"); } for (int i = _primitives.Count - 1; i >= 0; --i) { _primitives[i].Undo(); } _primitives.Clear(); _state = UndoTransactionState.Canceled; }
/// <summary> /// Complete marks the transaction finished and eligible for Undo. /// </summary> public void Complete() { if (State != UndoTransactionState.Open) { throw new InvalidOperationException("Complete called on transaction that is not opened"); } _state = UndoTransactionState.Completed; // now we need to pump these primitives into the parent, if the parent exists. FlattenPrimitivesToParent(); }
/// <summary> /// This is how you turn transaction into "Invalid" state. Use it to indicate that this transaction is retired forever, /// such as when clearing transactions from the redo stack. /// </summary> internal void Invalidate() { _state = UndoTransactionState.Invalid; }
/// <summary> /// /// </summary> public void Do() { if (_state == UndoTransactionState.Invalid) { return; } if (!CanRedo) { throw new InvalidOperationException("Strings.DoCalledButCanRedoFalse"); } _state = UndoTransactionState.Redoing; for (int i = 0; i < _primitives.Count; ++i) { _primitives[i].Do(); } _state = UndoTransactionState.Completed; }