Ejemplo n.º 1
0
 /// <summary>
 /// Deserializes a HighlightingColor.
 /// </summary>
 protected HighlightingColor(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     Name = info.GetString("Name");
     if (info.GetBoolean("HasWeight"))
     {
         FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(info.GetInt32("Weight"));
     }
     if (info.GetBoolean("HasStyle"))
     {
         FontStyle = (FontStyle?)new FontStyleConverter().ConvertFromInvariantString(info.GetString("Style"));
     }
     if (info.GetBoolean("HasUnderline"))
     {
         Underline = info.GetBoolean("Underline");
     }
     if (info.GetBoolean("HasStrikethrough"))
     {
         Strikethrough = info.GetBoolean("Strikethrough");
     }
     Foreground = (HighlightingBrush)info.GetValue("Foreground", typeof(SimpleHighlightingBrush));
     Background = (HighlightingBrush)info.GetValue("Background", typeof(SimpleHighlightingBrush));
     if (info.GetBoolean("HasFamily"))
     {
         FontFamily = new FontFamily(info.GetString("Family"));
     }
     if (info.GetBoolean("HasSize"))
     {
         FontSize = info.GetInt32("Size");
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the background brush on the specified text segment.
        /// </summary>
        public void SetBackground(int offset, int length, HighlightingBrush brush)
        {
            int startIndex = GetIndexForOffset(offset);
            int endIndex   = GetIndexForOffset(offset + length);

            for (int i = startIndex; i < endIndex; i++)
            {
                stateChanges[i].Background = brush;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Overwrites the properties in this HighlightingColor with those from the given color;
 /// but maintains the current values where the properties of the given color return <c>null</c>.
 /// </summary>
 public void MergeWith(HighlightingColor color)
 {
     FreezableHelper.ThrowIfFrozen(this);
     if (color.fontWeight != null)
     {
         fontWeight = color.fontWeight;
     }
     if (color.fontStyle != null)
     {
         fontStyle = color.fontStyle;
     }
     if (color.foreground != null)
     {
         foreground = color.foreground;
     }
     if (color.background != null)
     {
         background = color.background;
     }
     if (color.underline != null)
     {
         underline = color.underline;
     }
     if (color.strikethrough != null)
     {
         strikethrough = color.strikethrough;
     }
     if (color.fontFamily != null)
     {
         fontFamily = color.fontFamily;
     }
     if (color.fontSize != null)
     {
         fontSize = color.fontSize;
     }
 }