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
public bool Underline { public bool Underline {
get { get {
return color.Underline; return color.Underline == true;
} }
set { set {
throw new NotSupportedException(); throw new NotSupportedException();

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

@ -146,6 +146,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
this.FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(info.GetInt32("Weight")); this.FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(info.GetInt32("Weight"));
if (info.GetBoolean("HasStyle")) if (info.GetBoolean("HasStyle"))
this.FontStyle = (FontStyle?)new FontStyleConverter().ConvertFromInvariantString(info.GetString("Style")); 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.Foreground = (HighlightingBrush)info.GetValue("Foreground", typeof(HighlightingBrush));
this.Background = (HighlightingBrush)info.GetValue("Background", typeof(HighlightingBrush)); this.Background = (HighlightingBrush)info.GetValue("Background", typeof(HighlightingBrush));
} }
@ -169,6 +171,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting
info.AddValue("HasStyle", this.FontStyle.HasValue); info.AddValue("HasStyle", this.FontStyle.HasValue);
if (this.FontStyle.HasValue) if (this.FontStyle.HasValue)
info.AddValue("Style", this.FontStyle.Value.ToString()); 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("Foreground", this.Foreground);
info.AddValue("Background", this.Background); info.AddValue("Background", this.Background);
} }
@ -196,6 +201,12 @@ namespace ICSharpCode.AvalonEdit.Highlighting
b.Append(FontStyle.Value.ToString().ToLowerInvariant()); b.Append(FontStyle.Value.ToString().ToLowerInvariant());
b.Append("; "); b.Append("; ");
} }
if (Underline != null)
{
b.Append("text-decoration: ");
b.Append(Underline.Value ? "underline" : "none");
b.Append("; ");
}
return b.ToString(); return b.ToString();
} }
@ -247,7 +258,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting
{ {
if (other == null) if (other == null)
return false; 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/> /// <inheritdoc/>
@ -282,11 +295,14 @@ namespace ICSharpCode.AvalonEdit.Highlighting
this.foreground = color.foreground; this.foreground = color.foreground;
if (color.background != null) if (color.background != null)
this.background = color.background; this.background = color.background;
if (color.underline != null)
this.underline = color.underline;
} }
internal bool IsEmptyForMerge { internal bool IsEmptyForMerge {
get { 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 @@
<xsd:simpleType name="FontStyle"> <xsd:simpleType name="FontStyle">
<xsd:restriction base="xsd:string"> <xsd:restriction base="xsd:string">
<xsd:enumeration value="italic"/> <xsd:enumeration value="italic"/>
<xsd:enumeration value="underlined"/>
<xsd:enumeration value="normal"/> <xsd:enumeration value="normal"/>
<xsd:enumeration value="oblique"/> <xsd:enumeration value="oblique"/>
</xsd:restriction> </xsd:restriction>

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

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

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

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

Loading…
Cancel
Save