示例#1
0
 /// <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");
     }
     this.Foreground = (HighlightingBrush)info.GetValue("Foreground", typeof(HighlightingBrush));
     this.Background = (HighlightingBrush)info.GetValue("Background", typeof(HighlightingBrush));
 }
示例#2
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)
     {
         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;
     }
 }