Beispiel #1
0
 /// <summary>
 /// Creates a new VisualLineElementTextRunProperties instance that copies its values
 /// from the specified <paramref name="textRunProperties"/>.
 /// For the <see cref="TextDecorations"/> and <see cref="TextEffects"/> collections, deep copies
 /// are created if those collections are not frozen.
 /// </summary>
 public VisualLineElementTextRunProperties(TextRunProperties textRunProperties)
 {
     if (textRunProperties == null)
     {
         throw new ArgumentNullException("textRunProperties");
     }
     backgroundBrush     = textRunProperties.BackgroundBrush;
     baselineAlignment   = textRunProperties.BaselineAlignment;
     cultureInfo         = textRunProperties.CultureInfo;
     fontHintingEmSize   = textRunProperties.FontHintingEmSize;
     fontRenderingEmSize = textRunProperties.FontRenderingEmSize;
     foregroundBrush     = textRunProperties.ForegroundBrush;
     typeface            = textRunProperties.Typeface;
     textDecorations     = textRunProperties.TextDecorations;
     if (textDecorations != null && !textDecorations.IsFrozen)
     {
         textDecorations = textDecorations.Clone();
     }
     textEffects = textRunProperties.TextEffects;
     if (textEffects != null && !textEffects.IsFrozen)
     {
         textEffects = textEffects.Clone();
     }
     typographyProperties = textRunProperties.TypographyProperties;
     numberSubstitution   = textRunProperties.NumberSubstitution;
 }
Beispiel #2
0
        public static void RemoveTextDecoration(TextDecorationCollection decoration)
        {
            object _decorations = GetRTBValue(TextBlock.TextDecorationsProperty);

            if (_decorations != DependencyProperty.UnsetValue)
            {
                TextDecorationCollection textdecorations = (TextDecorationCollection)_decorations;

                if (textdecorations.IsFrozen)
                {
                    textdecorations = textdecorations.Clone();
                }

                foreach (TextDecoration each in decoration)
                {
                    textdecorations.Remove(each);
                }

                SetRTBValue(TextBlock.TextDecorationsProperty, textdecorations, false);
            }
        }