/// <summary> /// Creates a redo unit from an undo unit. /// </summary> protected TextParentUndoUnit(TextParentUndoUnit undoUnit) : base(String.Empty) { _selection = undoUnit._selection; _undoAnchorPositionOffset = undoUnit._redoAnchorPositionOffset; _undoAnchorPositionDirection = undoUnit._redoAnchorPositionDirection; _undoMovingPositionOffset = undoUnit._redoMovingPositionOffset; _undoMovingPositionDirection = undoUnit._redoMovingPositionDirection; // Bug 1706768: we are seeing unitialized values when the undo // undo is pulled off the undo stack. _redoAnchorPositionOffset // and _redoMovingPositionOffset are supposed to be initialized // with calls to RecordRedoSelectionState before that happens. // // This code path is being left enabled in DEBUG to help track down // the underlying bug post V1. #if DEBUG _redoAnchorPositionOffset = -1; _redoMovingPositionOffset = -1; #else _redoAnchorPositionOffset = 0; _redoMovingPositionOffset = 0; #endif }
protected void MergeRedoSelectionState(TextParentUndoUnit undoUnit) { _redoAnchorPositionOffset = undoUnit._redoAnchorPositionOffset; _redoAnchorPositionDirection = undoUnit._redoAnchorPositionDirection; _redoMovingPositionOffset = undoUnit._redoMovingPositionOffset; _redoMovingPositionDirection = undoUnit._redoMovingPositionDirection; }
// Token: 0x060039C4 RID: 14788 RVA: 0x001065B0 File Offset: 0x001047B0 protected TextParentUndoUnit(TextParentUndoUnit undoUnit) : base(string.Empty) { this._selection = undoUnit._selection; this._undoAnchorPositionOffset = undoUnit._redoAnchorPositionOffset; this._undoAnchorPositionDirection = undoUnit._redoAnchorPositionDirection; this._undoMovingPositionOffset = undoUnit._redoMovingPositionOffset; this._undoMovingPositionDirection = undoUnit._redoMovingPositionDirection; this._redoAnchorPositionOffset = 0; this._redoMovingPositionOffset = 0; }
/// <summary> /// Creates a redo unit from an undo unit. /// </summary> protected TextParentUndoUnit(TextParentUndoUnit undoUnit) : base(String.Empty) { _selection = undoUnit._selection; _undoAnchorPositionOffset = undoUnit._redoAnchorPositionOffset; _undoAnchorPositionDirection = undoUnit._redoAnchorPositionDirection; _undoMovingPositionOffset = undoUnit._redoMovingPositionOffset; _undoMovingPositionDirection = undoUnit._redoMovingPositionDirection; // #if DEBUG _redoAnchorPositionOffset = -1; _redoMovingPositionOffset = -1; #else _redoAnchorPositionOffset = 0; _redoMovingPositionOffset = 0; #endif }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors // Constructor, called when a change block is opening. internal ChangeBlockUndoRecord(ITextContainer textContainer, string actionDescription) { if (textContainer.UndoManager != null) { _undoManager = textContainer.UndoManager; if (_undoManager.IsEnabled) { // Don't bother opening an undo unit if the owning control is // still being initialized (ie, programmatic load by parser). if (textContainer.TextView != null) { // Don't bother opening a new undo unit if we're already nested // inside another. if (_undoManager.OpenedUnit == null) { if (textContainer.TextSelection != null) { _parentUndoUnit = new TextParentUndoUnit(textContainer.TextSelection); } else { _parentUndoUnit = new ParentUndoUnit(actionDescription); } _undoManager.Open(_parentUndoUnit); } } else { // If the owning control isn't initialized (parser is still running), // don't add anything to the undo record. Instead, clear it. _undoManager.Clear(); } } } }
// Close the text parent undo unit private void CloseTextParentUndoUnit(TextParentUndoUnit textParentUndoUnit, UndoCloseAction undoCloseAction) { if (textParentUndoUnit != null) { UndoManager undoManager = UndoManager.GetUndoManager(this.TextContainer.Parent); // Close the text parent undo unit undoManager.Close(textParentUndoUnit, undoCloseAction); } }
// Open the text parent undo unit private TextParentUndoUnit OpenTextParentUndoUnit() { UndoManager undoManager = UndoManager.GetUndoManager(this.TextContainer.Parent); // Create the text parent undo unit TextParentUndoUnit textParentUndoUnit = new TextParentUndoUnit(this.TextSelection, this.TextSelection.Start, this.TextSelection.Start); // Open the text parent undo unit undoManager.Open(textParentUndoUnit); return textParentUndoUnit; }
// Opens a composition undo unit. Opens the compsed composition undo unit if it exist on the top // of the stack. Otherwise, create new composition undo unit and add it to the undo manager and // making it as the opened undo unit. private void OpenCompositionUndoUnit() { UndoManager undoManager; DependencyObject parent; parent = _editor.TextContainer.Parent; undoManager = UndoManager.GetUndoManager(parent); if (undoManager != null && undoManager.IsEnabled && undoManager.OpenedUnit == null) { if (_compositionUndoUnit != null && _compositionUndoUnit == undoManager.LastUnit && !_compositionUndoUnit.Locked) { // Opens a closed composition undo unit on the top of the stack. undoManager.Reopen(_compositionUndoUnit); } else { _compositionUndoUnit = new TextParentUndoUnit(_editor.Selection); // Add the given composition undo unit to the undo manager and making it // as the opened undo unit. undoManager.Open(_compositionUndoUnit); } } else { _compositionUndoUnit = null; } }