|
|
|
@ -20,6 +20,7 @@ namespace ICSharpCode.AvalonEdit.Utils
@@ -20,6 +20,7 @@ namespace ICSharpCode.AvalonEdit.Utils
|
|
|
|
|
/// </summary>
|
|
|
|
|
static class TextFormatterFactory |
|
|
|
|
{ |
|
|
|
|
#if !DOTNET4
|
|
|
|
|
readonly static DependencyProperty TextFormattingModeProperty; |
|
|
|
|
|
|
|
|
|
static TextFormatterFactory() |
|
|
|
@ -30,6 +31,7 @@ namespace ICSharpCode.AvalonEdit.Utils
@@ -30,6 +31,7 @@ namespace ICSharpCode.AvalonEdit.Utils
|
|
|
|
|
TextFormattingModeProperty = textOptionsType.GetField("TextFormattingModeProperty").GetValue(null) as DependencyProperty; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a <see cref="TextFormatter"/> using the formatting mode used by the specified owner object.
|
|
|
|
@ -38,7 +40,9 @@ namespace ICSharpCode.AvalonEdit.Utils
@@ -38,7 +40,9 @@ namespace ICSharpCode.AvalonEdit.Utils
|
|
|
|
|
{ |
|
|
|
|
if (owner == null) |
|
|
|
|
throw new ArgumentNullException("owner"); |
|
|
|
|
// return TextFormatter.Create(TextOptions.GetTextFormattingMode(this));
|
|
|
|
|
#if DOTNET4
|
|
|
|
|
return TextFormatter.Create(TextOptions.GetTextFormattingMode(owner)); |
|
|
|
|
#else
|
|
|
|
|
if (TextFormattingModeProperty != null) { |
|
|
|
|
object formattingMode = owner.GetValue(TextFormattingModeProperty); |
|
|
|
|
return (TextFormatter)typeof(TextFormatter).InvokeMember( |
|
|
|
@ -50,6 +54,7 @@ namespace ICSharpCode.AvalonEdit.Utils
@@ -50,6 +54,7 @@ namespace ICSharpCode.AvalonEdit.Utils
|
|
|
|
|
} else { |
|
|
|
|
return TextFormatter.Create(); |
|
|
|
|
} |
|
|
|
|
#endif
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -58,8 +63,11 @@ namespace ICSharpCode.AvalonEdit.Utils
@@ -58,8 +63,11 @@ namespace ICSharpCode.AvalonEdit.Utils
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static bool PropertyChangeAffectsTextFormatter(DependencyProperty dp) |
|
|
|
|
{ |
|
|
|
|
// return dp == TextOptions.TextFormattingModeProperty;
|
|
|
|
|
#if DOTNET4
|
|
|
|
|
return dp == TextOptions.TextFormattingModeProperty; |
|
|
|
|
#else
|
|
|
|
|
return dp == TextFormattingModeProperty && TextFormattingModeProperty != null; |
|
|
|
|
#endif
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -83,6 +91,18 @@ namespace ICSharpCode.AvalonEdit.Utils
@@ -83,6 +91,18 @@ namespace ICSharpCode.AvalonEdit.Utils
|
|
|
|
|
emSize = TextBlock.GetFontSize(element); |
|
|
|
|
if (foreground == null) |
|
|
|
|
foreground = TextBlock.GetForeground(element); |
|
|
|
|
#if DOTNET4
|
|
|
|
|
return new FormattedText( |
|
|
|
|
text, |
|
|
|
|
CultureInfo.CurrentCulture, |
|
|
|
|
FlowDirection.LeftToRight, |
|
|
|
|
typeface, |
|
|
|
|
emSize.Value, |
|
|
|
|
foreground, |
|
|
|
|
null, |
|
|
|
|
TextOptions.GetTextFormattingMode(element) |
|
|
|
|
); |
|
|
|
|
#else
|
|
|
|
|
if (TextFormattingModeProperty != null) { |
|
|
|
|
object formattingMode = element.GetValue(TextFormattingModeProperty); |
|
|
|
|
return (FormattedText)Activator.CreateInstance( |
|
|
|
@ -106,6 +126,7 @@ namespace ICSharpCode.AvalonEdit.Utils
@@ -106,6 +126,7 @@ namespace ICSharpCode.AvalonEdit.Utils
|
|
|
|
|
foreground |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
#endif
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|