本文整理汇总了C#中System.Windows.TextDecorationCollection类的典型用法代码示例。如果您正苦于以下问题:C# TextDecorationCollection类的具体用法?C# TextDecorationCollection怎么用?C# TextDecorationCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextDecorationCollection类属于System.Windows命名空间,在下文中一共展示了TextDecorationCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GameLogWrite
public void GameLogWrite(String text, SolidColorBrush brush, TextDecorationCollection decorations)
{
// FIXME: probably more invalid characters...
text = text.Replace((Char)0x17, ' ');
//text = System.Security.SecurityElement.Escape(text).Replace((Char)0x17, ' ');
XmlElement run = GameLogCreateXmlElement("Run");
run.InnerText = text;
Procedure<String, String> addXmlAttribute = (name, value) =>
{
XmlAttribute attribute = gameLog.CreateAttribute(name);
attribute.InnerXml = value;
run.Attributes.Append(attribute);
};
if (brush != Brushes.Black)
{
addXmlAttribute("Foreground", brush.ToString());
}
if (decorations != null)
{
// TODO: fixme for multiple attributes, what's the XML for that?
addXmlAttribute("TextDecorations", decorations[0].Location.ToString());
}
gameLogParagraph.AppendChild(run);
}
示例2: GenericTextRunProperties
public GenericTextRunProperties(
Typeface typeface,
double size,
double hintingSize,
TextDecorationCollection textDecorations,
Brush forgroundBrush,
Brush backgroundBrush,
BaselineAlignment baselineAlignment,
TextEffectCollection textEffects,
CultureInfo culture)
{
if (typeface == null)
throw new ArgumentNullException("typeface");
ValidateCulture(culture);
_typeface = typeface;
_emSize = size;
_emHintingSize = hintingSize;
_textDecorations = textDecorations;
_foregroundBrush = forgroundBrush;
_backgroundBrush = backgroundBrush;
_baselineAlignment = baselineAlignment;
_textEffects = textEffects;
_culture = culture;
}
示例3: MarkdownHeaderFormatDefinition
public MarkdownHeaderFormatDefinition()
{
IsBold = true;
TextDecorations = new TextDecorationCollection();
TextDecorations.Add(new TextDecoration());
DisplayName = "Markdown Headers";
}
示例4: AddAttribute
public override void AddAttribute(object backend, TextAttribute attribute)
{
var t = (TextLayoutBackend)backend;
if (attribute is FontStyleTextAttribute) {
var xa = (FontStyleTextAttribute)attribute;
t.FormattedText.SetFontStyle (xa.Style.ToWpfFontStyle (), xa.StartIndex, xa.Count);
}
else if (attribute is FontWeightTextAttribute) {
var xa = (FontWeightTextAttribute)attribute;
t.FormattedText.SetFontWeight (xa.Weight.ToWpfFontWeight (), xa.StartIndex, xa.Count);
}
else if (attribute is ColorTextAttribute) {
var xa = (ColorTextAttribute)attribute;
t.FormattedText.SetForegroundBrush (new SolidColorBrush (xa.Color.ToWpfColor ()), xa.StartIndex, xa.Count);
}
else if (attribute is StrikethroughTextAttribute) {
var xa = (StrikethroughTextAttribute)attribute;
var dec = new TextDecoration (TextDecorationLocation.Strikethrough, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended);
TextDecorationCollection col = new TextDecorationCollection ();
col.Add (dec);
t.FormattedText.SetTextDecorations (col, xa.StartIndex, xa.Count);
}
else if (attribute is UnderlineTextAttribute) {
var xa = (UnderlineTextAttribute)attribute;
var dec = new TextDecoration (TextDecorationLocation.Underline, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended);
TextDecorationCollection col = new TextDecorationCollection ();
col.Add (dec);
t.FormattedText.SetTextDecorations (col, xa.StartIndex, xa.Count);
}
}
示例5: GetTextDecorations
private TextDecorationCollection GetTextDecorations()
{
TextDecorationCollection textDecorations = new TextDecorationCollection();
if (Strikeout)
textDecorations.Add(TextDecorations.Strikethrough);
if (Underline)
textDecorations.Add(TextDecorations.Underline);
return textDecorations;
}
示例6: FontRendering
public FontRendering()
{
_fontSize = 12.0f;
_alignment = TextAlignment.Left;
_textDecorations = new TextDecorationCollection();
_textColor = Brushes.Black;
_typeface = new Typeface(new FontFamily("Arial"),
FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
}
示例7: FontProperties
public FontProperties(TextRange range)
{
__FontWeight = range.GetPropertyValue(RichTextBox.FontWeightProperty);
__FontSize = range.GetPropertyValue(RichTextBox.FontSizeProperty);
__FontStyle = range.GetPropertyValue(RichTextBox.FontStyleProperty);
__TextDecorations = range.GetPropertyValue(TextBlock.TextDecorationsProperty) as TextDecorationCollection;
__FontFamily = range.GetPropertyValue(RichTextBox.FontFamilyProperty) as FontFamily;
__ForegroundColor = range.GetPropertyValue(RichTextBox.ForegroundProperty) as Brush;
}
示例8: CreateUnderlinedTextBlock
private TextBlock CreateUnderlinedTextBlock(string text)
{
var myUnderline = new TextDecoration
{
Pen = new Pen(Brushes.Blue, 1),
PenThicknessUnit = TextDecorationUnit.FontRecommended
};
var myCollection = new TextDecorationCollection {myUnderline};
var blockHead = new TextBlock {TextDecorations = myCollection, Text = text};
return blockHead;
}
示例9: FontRendering
public FontRendering()
{
_fontSize = 64f;
_alignment = TextAlignment.Left;
_textDecorations = new TextDecorationCollection();
_typeface = new Typeface(new FontFamily("Arial"),
FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
_foregroundBrush = Brushes.Black;
_backgroundBrush = Brushes.Transparent;
_textEffects = new TextEffectCollection();
}
示例10: CustomTextRunProperties
public CustomTextRunProperties(Typeface typeface, double fontSize, Brush foreground, Brush background, bool underline)
{
_typeface = typeface;
_fontSize = fontSize;
_foreground = foreground;
_background = background;
if (underline)
{
_decorations = new TextDecorationCollection(1);
_decorations.Add(System.Windows.TextDecorations.Underline);
}
}
示例11: GetTextBlock
public TextBlock GetTextBlock(MatchString matchedText, TextDecorationCollection matchDecoration, Brush matchColor)
{
TextBlock textBlock = new TextBlock();
textBlock.HorizontalAlignment = HorizontalAlignment.Left;
foreach (MatchSubstring matchSubstring in matchedText)
{
Run substringControl = new Run(matchSubstring.Value);
if (matchSubstring.IsMatched)
{
substringControl.TextDecorations = matchDecoration;
substringControl.Foreground = matchColor;
}
textBlock.Inlines.Add(substringControl);
}
return textBlock;
}
示例12: ValueEquals
[FriendAccessAllowed] // used by Framework
internal bool ValueEquals(TextDecorationCollection textDecorations)
{
if (textDecorations == null)
return false; // o is either null or not TextDecorations object
if (this == textDecorations)
return true; // Reference equality.
if ( this.Count != textDecorations.Count)
return false; // Two counts are different.
// To be considered equal, TextDecorations should be same in the exact order.
// Order matters because they imply the Z-order of the text decorations on screen.
// Same set of text decorations drawn with different orders may have different result.
for (int i = 0; i < this.Count; i++)
{
if (!this[i].ValueEquals(textDecorations[i]))
return false;
}
return true;
}
示例13: PascalSyntaxHighlighterFormat
public PascalSyntaxHighlighterFormat()
{
var firstCharacterUnderline = new TextDecoration();
var underlinePen = new Pen
{
Brush =
new LinearGradientBrush(
Colors.Black, Colors.White, new Point(0.75, 0.5), new Point(1, 0.5)) { Opacity = 0.5 },
Thickness = 1.75,
DashStyle = DashStyles.Solid
};
firstCharacterUnderline.Pen = underlinePen;
firstCharacterUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
var textDecorations = new TextDecorationCollection { firstCharacterUnderline };
this.TextDecorations = textDecorations;
this.DisplayName = "Pascal Syntax Highlighter";
this.IsBold = true;
}
示例14: GenericTextRunProperties
/// <summary>
/// Constructing TextRunProperties
/// </summary>
/// <param name="typeface">typeface</param>
/// <param name="size">text size</param>
/// <param name="hintingSize">text size for Truetype hinting program</param>
/// <param name="culture">text culture info</param>
/// <param name="textDecorations">TextDecorations </param>
/// <param name="foregroundBrush">text foreground brush</param>
/// <param name="backgroundBrush">highlight background brush</param>
/// <param name="baselineAlignment">text vertical alignment to its container</param>
/// <param name="substitution">number substitution behavior to apply to the text; can be null,
/// in which case the default number substitution method for the text culture is used</param>
public GenericTextRunProperties(
Typeface typeface,
double size,
double hintingSize,
TextDecorationCollection textDecorations,
Brush foregroundBrush,
Brush backgroundBrush,
BaselineAlignment baselineAlignment,
CultureInfo culture,
NumberSubstitution substitution
)
{
_typeface = typeface;
_emSize = size;
_emHintingSize = hintingSize;
_textDecorations = textDecorations;
_foregroundBrush = foregroundBrush;
_backgroundBrush = backgroundBrush;
_baselineAlignment = baselineAlignment;
_culture = culture;
_numberSubstitution = substitution;
}
示例15: GetTextDecorationsForInlineObject
// -----------------------------------------------------------------
// Retrieve text properties from specified inline object.
//
// WORKAROUND: see PS task #13486 & #3399.
// For inline object go to its parent and retrieve text decoration
// properties from there.
// ------------------------------------------------------------------
internal static TextDecorationCollection GetTextDecorationsForInlineObject(DependencyObject element, TextDecorationCollection textDecorations)
{
Debug.Assert(element != null);
DependencyObject parent = LogicalTreeHelper.GetParent(element);
TextDecorationCollection parentTextDecorations = null;
if (parent != null)
{
// Get parent text decorations if it is non-null
parentTextDecorations = GetTextDecorations(parent);
}
// see if the two text decorations are equal.
bool textDecorationsEqual = (textDecorations == null) ?
parentTextDecorations == null
: textDecorations.ValueEquals(parentTextDecorations);
if (!textDecorationsEqual)
{
if (parentTextDecorations == null)
{
textDecorations = null;
}
else
{
textDecorations = new TextDecorationCollection();
int count = parentTextDecorations.Count;
for (int i = 0; i < count; ++i)
{
textDecorations.Add(parentTextDecorations[i]);
}
}
}
return textDecorations;
}