Browse Source

Fix bugs in #505

pull/522/merge
Daniel Grunwald 12 years ago
parent
commit
8ace2341fb
  1. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/NamedColorHighlightingItem.cs
  2. 20
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs
  3. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd
  4. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs
  5. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XshdColor.cs

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/NamedColorHighlightingItem.cs

@ -70,7 +70,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -70,7 +70,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
public bool Underline {
get {
return color.Underline;
return color.Underline == true;
}
set {
throw new NotSupportedException();

20
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs

@ -146,6 +146,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -146,6 +146,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
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));
}
@ -169,6 +171,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -169,6 +171,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting
info.AddValue("HasStyle", this.FontStyle.HasValue);
if (this.FontStyle.HasValue)
info.AddValue("Style", this.FontStyle.Value.ToString());
info.AddValue("HasUnderline", this.Underline.HasValue);
if (this.Underline.HasValue)
info.AddValue("Underline", this.Underline.Value);
info.AddValue("Foreground", this.Foreground);
info.AddValue("Background", this.Background);
}
@ -196,6 +201,12 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -196,6 +201,12 @@ namespace ICSharpCode.AvalonEdit.Highlighting
b.Append(FontStyle.Value.ToString().ToLowerInvariant());
b.Append("; ");
}
if (Underline != null)
{
b.Append("text-decoration: ");
b.Append(Underline.Value ? "underline" : "none");
b.Append("; ");
}
return b.ToString();
}
@ -247,7 +258,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -247,7 +258,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting
{
if (other == null)
return false;
return this.name == other.name && this.fontWeight == other.fontWeight && this.fontStyle == other.fontStyle && object.Equals(this.foreground, other.foreground) && object.Equals(this.background, other.background);
return this.name == other.name && this.fontWeight == other.fontWeight
&& this.fontStyle == other.fontStyle && this.underline == other.underline
&& object.Equals(this.foreground, other.foreground) && object.Equals(this.background, other.background);
}
/// <inheritdoc/>
@ -282,11 +295,14 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -282,11 +295,14 @@ namespace ICSharpCode.AvalonEdit.Highlighting
this.foreground = color.foreground;
if (color.background != null)
this.background = color.background;
if (color.underline != null)
this.underline = color.underline;
}
internal bool IsEmptyForMerge {
get {
return fontWeight == null && fontStyle == null && foreground == null && background == null;
return fontWeight == null && fontStyle == null && underline == null
&& foreground == null && background == null;
}
}
}

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ModeV2.xsd

@ -24,7 +24,6 @@ @@ -24,7 +24,6 @@
<xsd:simpleType name="FontStyle">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="italic"/>
<xsd:enumeration value="underlined"/>
<xsd:enumeration value="normal"/>
<xsd:enumeration value="oblique"/>
</xsd:restriction>

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs

@ -297,7 +297,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd @@ -297,7 +297,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
color.Background = ParseColor(position, reader.GetAttribute("background"));
color.FontWeight = ParseFontWeight(reader.GetAttribute("fontWeight"));
color.FontStyle = ParseFontStyle(reader.GetAttribute("fontStyle"));
color.Underline = reader.GetAttribute("underline") == "true";
color.Underline = reader.GetBoolAttribute("underline");
return color;
}

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XshdColor.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd @@ -52,7 +52,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
/// <summary>
/// Gets/sets the underline flag
/// </summary>
public bool Underline { get; set; }
public bool? Underline { get; set; }
/// <summary>
/// Gets/sets the font style.
@ -86,6 +86,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd @@ -86,6 +86,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
if (info.GetBoolean("HasStyle"))
this.FontStyle = (FontStyle?)new FontStyleConverter().ConvertFromInvariantString(info.GetString("Style"));
this.ExampleText = info.GetString("ExampleText");
if (info.GetBoolean("HasUnderline"))
this.Underline = info.GetBoolean("Underline");
}
@ -104,9 +105,10 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd @@ -104,9 +105,10 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
info.AddValue("Name", this.Name);
info.AddValue("Foreground", this.Foreground);
info.AddValue("Background", this.Background);
info.AddValue("HasUnderline", this.Underline.HasValue);
if (this.Underline.HasValue)
info.AddValue("Underline", this.Underline.Value);
info.AddValue("HasWeight", this.FontWeight.HasValue);
if (this.Underline)
info.AddValue("Underline", this.Underline);
if (this.FontWeight.HasValue)
info.AddValue("Weight", this.FontWeight.Value.ToOpenTypeWeight());
info.AddValue("HasStyle", this.FontStyle.HasValue);

Loading…
Cancel
Save