/// <summary> /// Replaces the current version with a new version. /// </summary> /// <param name="change">Change from current version to new version</param> public void AppendChange(TextChangeEventArgs change) { if (change == null) throw new ArgumentNullException("change"); currentVersion.change = change; currentVersion.next = new Version(currentVersion); currentVersion = currentVersion.next; }
void PerformChange(TextChangeEventArgs change) { // Ensure that all changes take place inside an update group. // Will also take care of throwing an exception if isInChange is set. StartUndoableAction(); try { isInChange = true; try { if (TextChanging != null) { TextChanging(this, change); } // Perform changes to document and Version property documentSnapshot = null; cachedText = null; b.Remove(change.Offset, change.RemovalLength); b.Insert(change.Offset, change.InsertedText.Text); versionProvider.AppendChange(change); // Update anchors and fire Deleted events UpdateAnchors(change); if (TextChanged != null) { TextChanged(this, change); } } finally { isInChange = false; } } finally { EndUndoableAction(); } }
public void Update(TextChangeEventArgs change) { if (SurviveDeletion || offset <= change.Offset || offset >= change.Offset + change.RemovalLength) { offset = change.GetNewOffset(offset, MovementType); } else { offset = -1; } }
void UpdateAnchors(TextChangeEventArgs change) { // First update all anchors, then fire the deleted events. List<int> deletedAnchors = new List<int>(); for (int i = 0; i < anchors.Count; i++) { var anchor = anchors[i].Target as SimpleAnchor; if (anchor != null) { anchor.Update(change); if (anchor.IsDeleted) deletedAnchors.Add(i); } } deletedAnchors.Reverse(); foreach (var index in deletedAnchors) { var anchor = anchors[index].Target as SimpleAnchor; if (anchor != null) anchor.RaiseDeletedEvent(); anchors.RemoveAt(index); } }
void PerformChange(TextChangeEventArgs change) { // Ensure that all changes take place inside an update group. // Will also take care of throwing an exception if isInChange is set. StartUndoableAction(); try { isInChange = true; try { if (TextChanging != null) TextChanging(this, change); // Perform changes to document and Version property documentSnapshot = null; cachedText = null; b.Remove(change.Offset, change.RemovalLength); b.Insert(change.Offset, change.InsertedText.Text); versionProvider.AppendChange(change); // Update anchors and fire Deleted events UpdateAnchors(change); if (TextChanged != null) TextChanged(this, change); } finally { isInChange = false; } } finally { EndUndoableAction(); } }
/// <summary> /// Replaces the current version with a new version. /// </summary> /// <param name="change">Change from current version to new version</param> public void AppendChange(TextChangeEventArgs change) { currentVersion.change = change ?? throw new ArgumentNullException("change"); currentVersion.next = new Version(currentVersion); currentVersion = currentVersion.next; }
public TextChangingEvent(TextChangeEventArgs args) { this.args = args; }