本文整理汇总了C#中System.Windows.Media.TextFormatting.TextRunProperties类的典型用法代码示例。如果您正苦于以下问题:C# TextRunProperties类的具体用法?C# TextRunProperties怎么用?C# TextRunProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextRunProperties类属于System.Windows.Media.TextFormatting命名空间,在下文中一共展示了TextRunProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTextRunProperties
public TextRunProperties GetTextRunProperties(TextRunProperties defaultTextRunProperties)
{
var item = (CompletionItem as DescriptionModifyingCompletionItem)?.CompletionItem ?? CompletionItem;
return (item.CompletionProvider as ICustomCompletionItemFormatter)?.GetTextRunProperties(item, defaultTextRunProperties)
?? defaultTextRunProperties;
}
示例2: Update
internal void Update(
string text,
ITextViewLine line,
IWpfTextView view,
TextRunProperties formatting,
double marginWidth,
double verticalOffset)
{
LineTag = line.IdentityTag;
if (_text == null || !string.Equals(_text, text, StringComparison.Ordinal))
{
_text = text;
_formattedText = new FormattedText(
_text,
CultureInfo.InvariantCulture,
FlowDirection.LeftToRight,
formatting.Typeface,
formatting.FontRenderingEmSize,
formatting.ForegroundBrush);
_horizontalOffset = Math.Round(marginWidth - _formattedText.Width);
InvalidateVisual();
}
var num = line.TextTop - view.ViewportTop + verticalOffset;
// ReSharper disable once CompareOfFloatsByEqualityOperator
if (num == _verticalOffset) return;
_verticalOffset = num;
InvalidateVisual();
}
示例3: GetGlobalTextRunProperties
public static TextRunProperties GetGlobalTextRunProperties() {
if (textRunProperties == null) {
textRunProperties = CreateGlobalTextRunProperties();
}
return textRunProperties;
}
示例4: Equals
public static bool Equals(TextRunProperties a, TextRunProperties b) {
if (a == b)
return true;
if (a == null || b == null)
return false;
if (a.FontHintingEmSize != b.FontHintingEmSize)
return false;
if (a.FontRenderingEmSize != b.FontRenderingEmSize)
return false;
if (a.TextDecorations != b.TextDecorations) // We don't use it so this is enough
return false;
if (a.TextEffects != b.TextEffects) // We don't use it so this is enough
return false;
if (!a.CultureInfo.Equals(b.CultureInfo))
return false;
if (!a.Typeface.Equals(b.Typeface))
return false;
if (!Equals(a.BackgroundBrush, b.BackgroundBrush))
return false;
if (!Equals(a.ForegroundBrush, b.ForegroundBrush))
return false;
if (a.BaselineAlignment != b.BaselineAlignment)
return false;
if (!Equals(a.NumberSubstitution, b.NumberSubstitution))
return false;
if (!Equals(a.TypographyProperties, b.TypographyProperties))
return false;
return true;
}
示例5: UpdateVisual
/// <summary>
/// Store <paramref name="timeStamp"/> and updates the text for the visual.
/// </summary>
/// <param name="timeStamp">Time of the event.</param>
/// <param name="line">The line that this time stamp corresponds to.</param>
/// <param name="view">The <see cref="IWpfTextView"/> to whom the <paramref name="line"/> belongs.</param>
/// <param name="formatting">Properties for the time stamp text.</param>
/// <param name="marginWidth">Used to calculate the horizontal offset for <see cref="OnRender(DrawingContext)"/>.</param>
/// <param name="verticalOffset">Used to calculate the vertical offset for <see cref="OnRender(DrawingContext)"/>.</param>
/// <param name="showHours">Option to show hours on the time stamp.</param>
/// <param name="showMilliseconds">Option to show milliseconds on the time stamp.</param>
internal void UpdateVisual(DateTime timeStamp, ITextViewLine line, IWpfTextView view, TextRunProperties formatting, double marginWidth, double verticalOffset,
bool showHours, bool showMilliseconds)
{
this.LineTag = line.IdentityTag;
if (timeStamp != this.TimeStamp)
{
this.TimeStamp = timeStamp;
string text = GetFormattedTime(timeStamp, showHours, showMilliseconds);
TextFormattingMode textFormattingMode = view.FormattedLineSource.UseDisplayMode ? TextFormattingMode.Display : TextFormattingMode.Ideal;
_text = new FormattedText(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight,
formatting.Typeface, formatting.FontRenderingEmSize, formatting.ForegroundBrush,
InvariantNumberSubstitution, textFormattingMode);
_horizontalOffset = Math.Round(marginWidth - _text.Width);
this.InvalidateVisual(); // force redraw
}
double newVerticalOffset = line.TextTop - view.ViewportTop + verticalOffset;
if (newVerticalOffset != _verticalOffset)
{
_verticalOffset = newVerticalOffset;
this.InvalidateVisual(); // force redraw
}
}
示例6: ModifyProperties
/// <summary>
/// Modifies the properties of a text run.
/// </summary>
/// <param name="properties">Properties of a text run or the return value of
/// ModifyProperties for a nested text modifier.</param>
/// <returns>Returns the actual text run properties to be used for formatting,
/// subject to further modification by text modifiers at outer scopes.</returns>
public sealed override TextRunProperties ModifyProperties(TextRunProperties properties)
{
// Get the text decorations applied to the text modifier run. If there are
// none, we don't change anything.
if (properties == null || _modifierDecorations == null || _modifierDecorations.Count == 0)
return properties;
// Let brush be the foreground brush for the text modifier run. Any text
// decorations defined at the text modifier scope that have a null Pen
// should be drawn using this brush, which means we may need to copy some
// TextDecoration objects and set the Pen property on the copies. We can
// elide this if the same brush is used at both scopes. We shouldn't miss
// too many optimization opportunities by using the (lower cost) reference
// comparison here because in most cases where the brushes are equal it's
// because it's an inherited property.
Brush brush = _modifierBrush;
if (object.ReferenceEquals(brush, properties.ForegroundBrush))
{
// No need to set the pen property.
brush = null;
}
// We're going to create a merged set of text decorations.
TextDecorationCollection mergedDecorations;
// Get the text decorations of the affected run, if any.
TextDecorationCollection runDecorations = properties.TextDecorations;
if (runDecorations == null || runDecorations.Count == 0)
{
// Only the text modifier run defines text decorations so
// we don't need to merge anything.
if (brush == null)
{
// Use the text decorations of the modifier run.
mergedDecorations = _modifierDecorations;
}
else
{
// The foreground brushes differ so copy the text decorations to a
// new collection and make sure each has a non-null pen.
mergedDecorations = CopyTextDecorations(_modifierDecorations, brush);
}
}
else
{
// Add the modifier decorations first because we want text decorations
// defined at the inner scope (e.g., by the run) to be drawn on top.
mergedDecorations = CopyTextDecorations(_modifierDecorations, brush);
// Add the text decorations defined at the inner scope; we never need
// to set the pen for these because they should be drawn using the
// foreground brush.
foreach (TextDecoration td in runDecorations)
{
mergedDecorations.Add(td);
}
}
return new MergedTextRunProperties(properties, mergedDecorations);
}
示例7: TextTrailingWordEllipsis
/// <summary>
/// Construct a text trailing word ellipsis collapsing properties
/// </summary>
/// <param name="width">width in which collapsing is constrained to</param>
/// <param name="textRunProperties">text run properties of ellispis symbol</param>
public TextTrailingWordEllipsis(
double width,
TextRunProperties textRunProperties
)
{
_width = width;
_ellipsis = new TextCharacters(StringHorizontalEllipsis, textRunProperties);
}
示例8: GetLine
protected TextLine GetLine(TextRunProperties runProperties, TextSource textSource, int column = 0) {
return TextFormatter.Create().FormatLine(
textSource,
column,
96 * 6,
new SimpleParagraphProperties { defaultTextRunProperties = runProperties },
null);
}
示例9: InlineObjectRun
/// <summary>
/// Constructor.
/// </summary>
/// <param name="cch">Number of text position in the text array occupied by the inline object.</param>
/// <param name="element">UIElement representing the inline object.</param>
/// <param name="textProps">Text run properties for the inline object.</param>
/// <param name="host">Paragraph - the host of the inline object.</param>
internal InlineObjectRun(int cch, UIElement element, TextRunProperties textProps, TextParagraph host)
{
_cch = cch;
_textProps = textProps;
_host = host;
_inlineUIContainer = (InlineUIContainer)LogicalTreeHelper.GetParent(element);
}
示例10: InlineObject
/// <summary>
/// Constructor.
/// </summary>
/// <param name="dcp">Text position of the inline object in the text array.</param>
/// <param name="cch">Number of text position in the text array occupied by the inline object.</param>
/// <param name="element">UIElement representing the inline object.</param>
/// <param name="textProps">Text run properties for the inline object.</param>
/// <param name="host">TextBlock element - the host of the inline object.</param>
internal InlineObject(int dcp, int cch, UIElement element, TextRunProperties textProps, System.Windows.Controls.TextBlock host)
{
_dcp = dcp;
_cch = cch;
_element = element;
_textProps = textProps;
_host = host;
}
示例11: ModifyProperties
/// <summary>
/// Modifies the specified text run properties by invoking the modifier at
/// the current scope and all containing scopes.
/// </summary>
/// <param name="properties">Properties to modify.</param>
/// <returns>Returns the text run properties after modification.</returns>
internal TextRunProperties ModifyProperties(TextRunProperties properties)
{
for (TextModifierScope scope = this; scope != null; scope = scope._parentScope)
{
properties = scope._modifier.ModifyProperties(properties);
}
return properties;
}
示例12: FormattedTextRun
/// <summary>
/// Creates a new FormattedTextRun.
/// </summary>
public FormattedTextRun(FormattedTextElement element, TextRunProperties properties)
{
if (element == null)
throw new ArgumentNullException("element");
if (properties == null)
throw new ArgumentNullException("properties");
this.properties = properties;
this.element = element;
}
示例13: TextEndOfParagraph
/// <summary>
/// Construct a paragraph break run
/// </summary>
/// <param name="length">number of characters</param>
/// <param name="textRunProperties">linebreak text run properties</param>
public TextEndOfParagraph(
int length,
TextRunProperties textRunProperties
)
: base(
length,
textRunProperties
)
{}
示例14: GetFormattedText
protected FormattedText GetFormattedText(string text, TextRunProperties runProperties) {
return new FormattedText(
text,
CultureInfo.CurrentUICulture,
FlowDirection.LeftToRight,
runProperties.Typeface,
runProperties.FontRenderingEmSize,
Brushes.Black);
}
示例15: HexLinePart
public HexLinePart(int index, int column, VST.Span span, TextRunProperties textRunProperties) {
Debug.Assert(!span.IsEmpty);
Debug.Assert(textRunProperties != null);
Index = index;
Column = column;
Span = span;
AdornmentElement = null;
TextRunProperties = textRunProperties;
}