diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx
index c6d41f1639..8737392f68 100644
--- a/data/resources/StringResources.resx
+++ b/data/resources/StringResources.resx
@@ -1729,6 +1729,9 @@ Examples: "120", "MainClass", "Main.cs, 120".
Italic
+
+ Underlined
+
Export highlighting colors
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizedHighlightingColor.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizedHighlightingColor.cs
index a5df6f78c6..c113ed576c 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizedHighlightingColor.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizedHighlightingColor.cs
@@ -43,6 +43,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
public bool Bold { get; set; }
public bool Italic { get; set; }
+ public bool Underline { get; set; }
public Color? Foreground { get; set; }
public Color? Background { get; set; }
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CustomizedHighlightingItem.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CustomizedHighlightingItem.cs
index ce076196b5..e18c5be58a 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CustomizedHighlightingItem.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CustomizedHighlightingItem.cs
@@ -66,6 +66,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
{
OnPropertyChanged("Bold");
OnPropertyChanged("Italic");
+ OnPropertyChanged("Underline");
OnPropertyChanged("Foreground");
OnPropertyChanged("UseDefaultForeground");
OnPropertyChanged("Background");
@@ -73,7 +74,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
OnPropertyChanged("IsCustomized");
}
- void SetCustomization(bool? bold = null, bool? italic = null,
+ void SetCustomization(bool? bold = null, bool? italic = null, bool? underline = null,
Color? foreground = null, bool? useDefaultForeground = null,
Color? background = null, bool? useDefaultBackground = null)
{
@@ -82,6 +83,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
newColor.Name = this.Name;
newColor.Bold = bold ?? this.Bold;
newColor.Italic = italic ?? this.Italic;
+ newColor.Underline = underline ?? this.Underline;
if (useDefaultBackground ?? this.UseDefaultBackground)
newColor.Background = null;
@@ -99,7 +101,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
else if (customization != null)
customizationList.Remove(customization);
- if (newColor.Bold == original.Bold && newColor.Italic == original.Italic &&
+ if (newColor.Bold == original.Bold && newColor.Italic == original.Italic && newColor.Underline == original.Underline &&
(newColor.Background == null) == original.UseDefaultBackground &&
(newColor.Background == null || newColor.Background == original.Background) &&
(newColor.Foreground == null) == original.UseDefaultForeground &&
@@ -140,6 +142,15 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
}
}
+ public bool Underline {
+ get {
+ return (customization != null) ? customization.Underline : original.Underline;
+ }
+ set {
+ SetCustomization(underline: value);
+ }
+ }
+
public Color Foreground {
get {
return (customization != null) ? (customization.Foreground ?? original.Foreground) : original.Foreground;
@@ -191,7 +202,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
public void Reset()
{
original.Reset();
- SetCustomization(original.Bold, original.Italic, original.Foreground, original.UseDefaultForeground, original.Background, original.UseDefaultBackground);
+ SetCustomization(original.Bold, original.Italic, original.Underline, original.Foreground, original.UseDefaultForeground, original.Background, original.UseDefaultBackground);
AllPropertiesChanged();
}
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml
index 93508d4370..b78fff3c35 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml
@@ -44,6 +44,8 @@
Content="{core:Localize Dialog.HighlightingEditor.ColorDlg.Bold}"/>
+
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/IHighlightingItem.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/IHighlightingItem.cs
index 29d342a800..7852173772 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/IHighlightingItem.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/IHighlightingItem.cs
@@ -43,6 +43,11 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
///
bool Italic { get; set; }
+ ///
+ /// Gets/Sets whether the element uses an underlined font.
+ ///
+ bool Underline { get; set; }
+
Color Foreground { get; set; }
bool UseDefaultForeground { get; set; }
Color Background { get; set; }
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/NamedColorHighlightingItem.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/NamedColorHighlightingItem.cs
index c2e158f526..5bc0f4cd7f 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/NamedColorHighlightingItem.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/NamedColorHighlightingItem.cs
@@ -68,6 +68,15 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
}
}
+ public bool Underline {
+ get {
+ return color.Underline;
+ }
+ set {
+ throw new NotSupportedException();
+ }
+ }
+
public Color Foreground {
get {
Color? c = color.Foreground != null ? color.Foreground.GetColor(null) : null;
@@ -161,7 +170,12 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
marker.ForegroundColor = item.Foreground;
marker.FontStyle = item.Italic ? FontStyles.Italic : FontStyles.Normal;
marker.FontWeight = item.Bold ? FontWeights.Bold : FontWeights.Normal;
- });
+ if(item.Underline)
+ {
+ marker.MarkerColor = item.Foreground;
+ marker.MarkerTypes = TextMarkerTypes.NormalUnderline;
+ }
+ });
}
} else {
exampleTextArea.Document.Text = exampleText;
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/SimpleHighlightingItem.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/SimpleHighlightingItem.cs
index 99376357d7..8c165207ec 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/SimpleHighlightingItem.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/SimpleHighlightingItem.cs
@@ -40,6 +40,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
public string Name { get; private set; }
public bool Bold { get; set; }
public bool Italic { get; set; }
+ public bool Underline { get; set; }
public Color Foreground { get; set; }
public bool UseDefaultForeground { get; set; }
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxHighlighting/CustomizingHighlighter.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxHighlighting/CustomizingHighlighter.cs
index 0ababb9de6..8f70e0b457 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxHighlighting/CustomizingHighlighter.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxHighlighting/CustomizingHighlighter.cs
@@ -267,7 +267,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
Background = CreateBrush(customization.Background),
Foreground = CreateBrush(customization.Foreground),
FontWeight = customization.Bold ? FontWeights.Bold : FontWeights.Normal,
- FontStyle = customization.Italic ? FontStyles.Italic : FontStyles.Normal
+ FontStyle = customization.Italic ? FontStyles.Italic : FontStyles.Normal,
+ Underline = customization.Underline
};
}
}
diff --git a/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditOptionsPanel.xaml.cs b/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditOptionsPanel.xaml.cs
index f1978f6747..8026d1672c 100644
--- a/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditOptionsPanel.xaml.cs
+++ b/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditOptionsPanel.xaml.cs
@@ -103,6 +103,8 @@ namespace HexEditor.View
preview.FontWeight = FontWeights.Bold;
else
preview.FontWeight = FontWeights.Normal;
+ if (font.Underline)
+ preview.TextDecorations = TextDecorations.Underline;
}
}
}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs
index e5f2e24bba..97ada1628a 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs
@@ -113,7 +113,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
{
if (color == null)
throw new ArgumentNullException("color");
- if (color.Foreground == null && color.Background == null && color.FontStyle == null && color.FontWeight == null) {
+ if (color.Foreground == null && color.Background == null && color.FontStyle == null && color.FontWeight == null && color.Underline == null) {
// Optimization: don't split the HighlightingState when we're not changing
// any property. For example, the "Punctuation" color in C# is
// empty by default.
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs
index f8f13182a7..2acaf80a8d 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColor.cs
@@ -38,6 +38,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
string name;
FontWeight? fontWeight;
FontStyle? fontStyle;
+ bool? underline;
HighlightingBrush foreground;
HighlightingBrush background;
bool frozen;
@@ -84,6 +85,20 @@ namespace ICSharpCode.AvalonEdit.Highlighting
}
}
+ ///
+ /// Gets/sets the underline flag. Null if the underline status does not change the font style.
+ ///
+ public bool? Underline {
+ get {
+ return underline;
+ }
+ set {
+ if (frozen)
+ throw new InvalidOperationException();
+ underline = value;
+ }
+ }
+
///
/// Gets/sets the foreground color applied by the highlighting.
///
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs
index 68a625745e..10527b3843 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs
@@ -18,6 +18,7 @@
using System;
using System.Diagnostics;
+using System.Windows;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
@@ -231,7 +232,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
if (color == null)
return true;
return color.Background == null && color.Foreground == null
- && color.FontStyle == null && color.FontWeight == null;
+ && color.FontStyle == null && color.FontWeight == null
+ && color.Underline == null;
}
///
@@ -254,7 +256,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
if (b != null)
element.BackgroundBrush = b;
}
- if (color.FontStyle != null || color.FontWeight != null) {
+ if (color.FontStyle != null || color.FontWeight != null || color.Underline != null) {
Typeface tf = element.TextRunProperties.Typeface;
element.TextRunProperties.SetTypeface(new Typeface(
tf.FontFamily,
@@ -263,6 +265,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
tf.Stretch
));
}
+ if(color.Underline ?? false)
+ element.TextRunProperties.SetTextDecorations(TextDecorations.Underline);
}
///
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs
index 7a239d8196..70b2539dc8 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/V2Loader.cs
@@ -297,6 +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";
return color;
}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XmlHighlightingDefinition.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XmlHighlightingDefinition.cs
index 62128c81fa..9743277ba8 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XmlHighlightingDefinition.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XmlHighlightingDefinition.cs
@@ -204,6 +204,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
c.Name = color.Name;
c.Foreground = color.Foreground;
c.Background = color.Background;
+ c.Underline = color.Underline;
c.FontStyle = color.FontStyle;
c.FontWeight = color.FontWeight;
return c;
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XshdColor.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XshdColor.cs
index 3812a57e71..7ec202641e 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XshdColor.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XshdColor.cs
@@ -49,6 +49,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
///
public FontWeight? FontWeight { get; set; }
+ ///
+ /// Gets/sets the underline flag
+ ///
+ public bool Underline { get; set; }
+
///
/// Gets/sets the font style.
///
@@ -81,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");
+ this.Underline = info.GetBoolean("Underline");
}
///
@@ -99,6 +105,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
info.AddValue("Foreground", this.Foreground);
info.AddValue("Background", this.Background);
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);