/// <summary>
 /// Deserializes a HighlightingColor.
 /// </summary>
 protected HighlightingColor(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     this.Name = info.GetString("Name");
     if (info.GetBoolean("HasWeight"))
     {
         this.FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(info.GetInt32("Weight"));
     }
     if (info.GetBoolean("HasStyle"))
     {
         this.FontStyle = (FontStyle?)new FontStyleConverter().ConvertFromInvariantString(info.GetString("Style"));
     }
     if (info.GetBoolean("HasUnderline"))
     {
         this.Underline = info.GetBoolean("Underline");
     }
     if (info.GetBoolean("HasStrikethrough"))
     {
         this.Strikethrough = info.GetBoolean("Strikethrough");
     }
     this.Foreground = (HighlightingBrush)info.GetValue("Foreground", typeof(SimpleHighlightingBrush));
     this.Background = (HighlightingBrush)info.GetValue("Background", typeof(SimpleHighlightingBrush));
     if (info.GetBoolean("HasFamily"))
     {
         this.FontFamily = new FontFamily(info.GetString("Family"));
     }
     if (info.GetBoolean("HasSize"))
     {
         this.FontSize = info.GetInt32("Size");
     }
 }
示例#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;
            }
        }
 /// <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)
     {
         this.fontWeight = color.fontWeight;
     }
     if (color.fontStyle != null)
     {
         this.fontStyle = color.fontStyle;
     }
     if (color.foreground != null)
     {
         this.foreground = color.foreground;
     }
     if (color.background != null)
     {
         this.background = color.background;
     }
     if (color.underline != null)
     {
         this.underline = color.underline;
     }
     if (color.strikethrough != null)
     {
         this.strikethrough = color.strikethrough;
     }
     if (color.fontFamily != null)
     {
         this.fontFamily = color.fontFamily;
     }
     if (color.fontSize != null)
     {
         this.fontSize = color.fontSize;
     }
 }