// Token: 0x06003525 RID: 13605 RVA: 0x000F0C7C File Offset: 0x000EEE7C private static void OnTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Run run = (Run)d; if (run._changeEventNestingCount > 0) { return; } Invariant.Assert(!e.NewEntry.IsDeferredReference); string text = (string)e.NewValue; if (text == null) { text = string.Empty; } run._changeEventNestingCount++; try { TextContainer textContainer = run.TextContainer; textContainer.BeginChange(); try { TextPointer contentStart = run.ContentStart; if (!run.IsEmpty) { textContainer.DeleteContentInternal(contentStart, run.ContentEnd); } contentStart.InsertTextInRun(text); } finally { textContainer.EndChange(); } } finally { run._changeEventNestingCount--; } FlowDocument flowDocument = run.TextContainer.Parent as FlowDocument; if (flowDocument != null) { RichTextBox richTextBox = flowDocument.Parent as RichTextBox; if (richTextBox != null && run.HasExpression(run.LookupEntry(Run.TextProperty.GlobalIndex), Run.TextProperty)) { UndoManager undoManager = richTextBox.TextEditor._GetUndoManager(); if (undoManager != null && undoManager.IsEnabled) { undoManager.Clear(); } } } }
/// <summary>Clears all items from the collection.</summary> // Token: 0x06003979 RID: 14713 RVA: 0x001048F8 File Offset: 0x00102AF8 public void Clear() { TextContainer textContainer = this.TextContainer; textContainer.BeginChange(); try { textContainer.DeleteContentInternal(this.ContentStart, this.ContentEnd); } finally { textContainer.EndChange(); } }
/// <summary> /// </summary> public void Clear() { // Note: We need to remember the textcontainer for any delete operations in this collection. // This is important for the case when the owner of the collection is a sibling member. // In a scenario where you remove the owner itself from the collection, // the owner belongs to another tree after the reposition. TextContainer textContainer = this.TextContainer; textContainer.BeginChange(); try { textContainer.DeleteContentInternal(this.ContentStart, this.ContentEnd); } finally { textContainer.EndChange(); } }
private void UpdateText(string text) { if (text == null) { text = string.Empty; } _accessKeyLocated = false; _accessKey = null; TextContainer.BeginChange(); try { TextContainer.DeleteContentInternal((TextPointer)TextContainer.Start, TextContainer.End); Run run = Inline.CreateImplicitRun(this); ((TextPointer)TextContainer.End).InsertTextElement(run); run.Text = text; } finally { TextContainer.EndChange(); } }
//------------------------------------------------------------------- // // Private Methods // //------------------------------------------------------------------- #region Private Methods /// <summary> /// Changed handler for the Text property. /// </summary> /// <param name="d">The source of the event.</param> /// <param name="e">A PropertyChangedEventArgs that contains the event data.</param> /// <remarks> /// We can't assume the value is a string here -- it may be a DeferredRunTextReference. /// </remarks> private static void OnTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Run run = (Run)d; // Return if this update was caused by a TextContainer change or a reentrant change. if (run._changeEventNestingCount > 0) { return; } Invariant.Assert(!e.NewEntry.IsDeferredReference); // CoerceText will have already converted null -> String.Empty, but our default // CoerceValueCallback could be overridden by a derived class. So check again here. string newText = (string)e.NewValue; if (newText == null) { newText = String.Empty; } // Run.TextProperty has changed. Update the backing store. run._changeEventNestingCount++; try { TextContainer textContainer = run.TextContainer; textContainer.BeginChange(); try { TextPointer contentStart = run.ContentStart; if (!run.IsEmpty) { textContainer.DeleteContentInternal(contentStart, run.ContentEnd); } contentStart.InsertTextInRun(newText); } finally { textContainer.EndChange(); } } finally { run._changeEventNestingCount--; } // We need to clear undo stack if we are in a RichTextBox and the value comes from // data binding or some other expression. FlowDocument document = run.TextContainer.Parent as FlowDocument; if (document != null) { RichTextBox rtb = document.Parent as RichTextBox; if (rtb != null && run.HasExpression(run.LookupEntry(Run.TextProperty.GlobalIndex), Run.TextProperty)) { UndoManager undoManager = rtb.TextEditor._GetUndoManager(); if (undoManager != null && undoManager.IsEnabled) { undoManager.Clear(); } } } }