예제 #1
0
        // Helper to clear formatting properties from passed inline element, preserving only non-formatting ones 
        private static void ClearFormattingInlineProperties(Inline inline)
        { 
            // Clear all properties from this inline element 
            LocalValueEnumerator properties = inline.GetLocalValueEnumerator();
            while (properties.MoveNext()) 
            {
                DependencyProperty property = properties.Current.Property;

                // Skip readonly and non-formatting properties 
                if (property.ReadOnly || TextSchema.IsNonFormattingCharacterProperty(property))
                { 
                    continue; 
                }
 
                inline.ClearValue(properties.Current.Property);
            }
        }
예제 #2
0
        // Copies all structural properties from source (clearing the property) to destination. 
        private static void TransferStructuralProperties(Inline source, Inline destination)
        { 
            bool sourceIsChild = (source.Parent == destination); 

            for (int i = 0; i < TextSchema.StructuralCharacterProperties.Length; i++) 
            {
                DependencyProperty property = TextSchema.StructuralCharacterProperties[i];
                if ((sourceIsChild && HasLocalInheritableStructuralPropertyValue(source)) ||
                    (!sourceIsChild && HasLocalStructuralPropertyValue(source))) 
                {
                    object value = source.GetValue(property); 
                    source.ClearValue(property); 
                    destination.SetValue(property, value);
                } 
            }
        }