// Transfer all properties from the current context to this // implicit document - to simulate inheritance. // This is how implicit document gets its initial values - // from the context. // After that RichTextBox will maintain such inheritance simulation // (for implicit document only) by listening for property // change notifications. private void TransferInheritedPropertiesToFlowDocument() { // Implicit document needs all formatting properties be transferred to it if (_implicitDocument) { DependencyProperty[] inheritableFormattingProperties = TextSchema.GetInheritableProperties(typeof(FlowDocument)); for (int i = 0; i < inheritableFormattingProperties.Length; i++) { DependencyProperty property = inheritableFormattingProperties[i]; TransferFormattingProperty(property, this.GetValue(property)); } } // Behavioral properties must be transferred to any document whether it has Standalone // or Inherited FormattingDefaults. All such values are set as local values even // in case when they are equal to the ones inherited from the UI context // (see TransferBehavioralProperty method implementation). // Such strong logic is needed to work correctly in any sequence of // setting FormattingDefaults property and adding children. DependencyProperty[] inheritableBehavioralProperties = TextSchema.BehavioralProperties; for (int i = 0; i < inheritableBehavioralProperties.Length; i++) { DependencyProperty property = inheritableBehavioralProperties[i]; TransferBehavioralProperty(property, this.GetValue(property)); } }
// Token: 0x060054CC RID: 21708 RVA: 0x001778B4 File Offset: 0x00175AB4 private void TransferInheritedPropertiesToFlowDocument() { if (this._implicitDocument) { foreach (DependencyProperty dependencyProperty in TextSchema.GetInheritableProperties(typeof(FlowDocument))) { this.TransferFormattingProperty(dependencyProperty, base.GetValue(dependencyProperty)); } } foreach (DependencyProperty dependencyProperty2 in TextSchema.BehavioralProperties) { this.TransferBehavioralProperty(dependencyProperty2, base.GetValue(dependencyProperty2)); } }
// Token: 0x060054CE RID: 21710 RVA: 0x00177958 File Offset: 0x00175B58 private void TransferFormattingProperty(DependencyProperty property, object inheritedValue) { Invariant.Assert(this._implicitDocument, "We only supposed to do this for implicit documents"); object value = this._document.GetValue(property); if (!TextSchema.ValuesAreEqual(inheritedValue, value)) { this._document.ClearValue(property); value = this._document.GetValue(property); if (!TextSchema.ValuesAreEqual(inheritedValue, value)) { this._document.SetValue(property, inheritedValue); } } }
// Token: 0x060054CB RID: 21707 RVA: 0x00177820 File Offset: 0x00175A20 private static void HookupInheritablePropertyListeners() { PropertyChangedCallback propertyChangedCallback = new PropertyChangedCallback(RichTextBox.OnFormattingPropertyChanged); DependencyProperty[] inheritableProperties = TextSchema.GetInheritableProperties(typeof(FlowDocument)); for (int i = 0; i < inheritableProperties.Length; i++) { inheritableProperties[i].OverrideMetadata(typeof(RichTextBox), new FrameworkPropertyMetadata(propertyChangedCallback)); } PropertyChangedCallback propertyChangedCallback2 = new PropertyChangedCallback(RichTextBox.OnBehavioralPropertyChanged); DependencyProperty[] behavioralProperties = TextSchema.BehavioralProperties; for (int j = 0; j < behavioralProperties.Length; j++) { behavioralProperties[j].OverrideMetadata(typeof(RichTextBox), new FrameworkPropertyMetadata(propertyChangedCallback2)); } }
// ----------------------------------------------------------- // // Private Methods // // ----------------------------------------------------------- #region Private Methods // ........................................................... // // Transferring Properties from RichTextBox down to FlowDocument // // ........................................................... // We need to transfer all character formatting properties from RichTextBox level into its FlowDocument. // // Note that we have to set all properties explicitly - not even trying // to bypass some of them when using assumptions about their default values (for non-implicit document) // or a coincidence with the current context values (for implicit document) - // the FlowDocument mast have all properties explicitly set to keep them intact // after being moved to another contextual location (both in Save-Load and in Print scenarios). // For this purpose we set listeners for all these properties: private static void HookupInheritablePropertyListeners() { // All inhgeriting formatting properties need to be transferred over the implicit document boundary. // This is required for treating UIContext as default setting for implicit document. // Note that mechanism is not applied to explicit document. PropertyChangedCallback formattingPropertyCallback = new PropertyChangedCallback(OnFormattingPropertyChanged); DependencyProperty[] inheritableFormattingProperties = TextSchema.GetInheritableProperties(typeof(FlowDocument)); for (int i = 0; i < inheritableFormattingProperties.Length; i++) { inheritableFormattingProperties[i].OverrideMetadata(typeof(RichTextBox), new FrameworkPropertyMetadata(formattingPropertyCallback)); } // Inheriting behavioral properties need to be transferred over any Standalone document boundary. PropertyChangedCallback behavioralPropertyCallback = new PropertyChangedCallback(OnBehavioralPropertyChanged); DependencyProperty[] inheritableBehavioralProperties = TextSchema.BehavioralProperties; for (int i = 0; i < inheritableBehavioralProperties.Length; i++) { inheritableBehavioralProperties[i].OverrideMetadata(typeof(RichTextBox), new FrameworkPropertyMetadata(behavioralPropertyCallback)); } }
public TextDataReader(TextSchema schema, System.IO.TextReader reader) { this._Schema = schema; this._Reader = reader; }
// Token: 0x06007CED RID: 31981 RVA: 0x0023255C File Offset: 0x0023075C private static FlowDirection GetTextFlowDirection(ITextPointer pointer) { Invariant.Assert(pointer != null, "Null pointer passed."); Invariant.Assert(pointer.IsAtInsertionPosition, "Pointer is not an insertion position"); int num = 0; LogicalDirection logicalDirection = pointer.LogicalDirection; TextPointerContext pointerContext = pointer.GetPointerContext(logicalDirection); FlowDirection result; if ((pointerContext == TextPointerContext.ElementEnd || pointerContext == TextPointerContext.ElementStart) && !TextSchema.IsFormattingType(pointer.ParentType)) { result = (FlowDirection)pointer.GetValue(FrameworkElement.FlowDirectionProperty); } else { Rect anchorRectangle = TextSelectionHelper.GetAnchorRectangle(pointer); ITextPointer textPointer = pointer.GetNextInsertionPosition(logicalDirection); if (textPointer != null) { textPointer = textPointer.CreatePointer((logicalDirection == LogicalDirection.Backward) ? LogicalDirection.Forward : LogicalDirection.Backward); if (logicalDirection == LogicalDirection.Forward) { if (pointerContext == TextPointerContext.ElementEnd && textPointer.GetPointerContext(textPointer.LogicalDirection) == TextPointerContext.ElementStart) { return((FlowDirection)pointer.GetValue(FrameworkElement.FlowDirectionProperty)); } } else if (pointerContext == TextPointerContext.ElementStart && textPointer.GetPointerContext(textPointer.LogicalDirection) == TextPointerContext.ElementEnd) { return((FlowDirection)pointer.GetValue(FrameworkElement.FlowDirectionProperty)); } Rect anchorRectangle2 = TextSelectionHelper.GetAnchorRectangle(textPointer); if (anchorRectangle2 != Rect.Empty && anchorRectangle != Rect.Empty) { num = Math.Sign(anchorRectangle2.Left - anchorRectangle.Left); if (logicalDirection == LogicalDirection.Backward) { num = -num; } } } if (num == 0) { result = (FlowDirection)pointer.GetValue(FrameworkElement.FlowDirectionProperty); } else { result = ((num > 0) ? FlowDirection.LeftToRight : FlowDirection.RightToLeft); } } return(result); }