Exemple #1
0
        // 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: 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));
            }
        }
Exemple #4
0
        // -----------------------------------------------------------
        //
        // 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));
            }
        }