本文整理汇总了C#中System.Windows.TextDecorationCollection类的典型用法代码示例。如果您正苦于以下问题:C# TextDecorationCollection类的具体用法?C# TextDecorationCollection怎么用?C# TextDecorationCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextDecorationCollection类属于System.Windows命名空间,在下文中一共展示了TextDecorationCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Traderain,项目名称:coldemoplayer,代码行数:29,代码来源:AnalysisWindowInterface.cs
示例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;
}
开发者ID:erdao,项目名称:Temp,代码行数:26,代码来源:GenericTextRunProperties.cs
示例3: MarkdownHeaderFormatDefinition
public MarkdownHeaderFormatDefinition()
{
IsBold = true;
TextDecorations = new TextDecorationCollection();
TextDecorations.Add(new TextDecoration());
DisplayName = "Markdown Headers";
}
开发者ID:ncl-dmoreira,项目名称:WebEssentials2013,代码行数:7,代码来源:MarkdownClassificationTypes.cs
示例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);
}
}
开发者ID:shines77,项目名称:xwt,代码行数:30,代码来源:TextLayoutBackendHandler.cs
示例5: GetTextDecorations
private TextDecorationCollection GetTextDecorations()
{
TextDecorationCollection textDecorations = new TextDecorationCollection();
if (Strikeout)
textDecorations.Add(TextDecorations.Strikethrough);
if (Underline)
textDecorations.Add(TextDecorations.Underline);
return textDecorations;
}
开发者ID:sitdap,项目名称:dynamic-image,代码行数:9,代码来源:Font.cs
示例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);
}
开发者ID:abdulbaruwa,项目名称:GapBuffer,代码行数:9,代码来源:FontRendering.cs
示例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;
}
开发者ID:fednep,项目名称:UV-Outliner,代码行数:9,代码来源:FontProperties.cs
示例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;
}
开发者ID:henrybond158,项目名称:elinor,代码行数:11,代码来源:AboutWindow.xaml.cs
示例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();
}
开发者ID:erdao,项目名称:Temp,代码行数:11,代码来源:FontRendering.cs
示例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);
}
}
开发者ID:derrickcreamer,项目名称:Floe,代码行数:12,代码来源:ChatFormatter.cs
示例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;
}
开发者ID:VasiliBaranov,项目名称:navigation-assistant,代码行数:19,代码来源:MatchModelMapper.cs
示例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;
}
开发者ID:JianwenSun,项目名称:cc,代码行数:22,代码来源:TextDecorationCollection.cs
示例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;
}
开发者ID:rajwilkhu,项目名称:GherkinSyntaxHighlighter,代码行数:22,代码来源:PascalSyntaxHighlighterFormat.cs
示例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;
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:35,代码来源:GenericTextProperties.cs
示例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;
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:43,代码来源:DynamicPropertyReader.cs
示例16: BuildDecoration
private TextDecorationCollection BuildDecoration()
{
var result = new TextDecorationCollection();
if (HasFlag(0x01))
{
result.Add(new TextDecoration(TextDecorationLocation.Underline, null, 0.0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended));
}
else if (HasFlag(0x08))
{
result.Add(new TextDecoration(TextDecorationLocation.Strikethrough, null, 0.0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended));
}
else if (HasFlag(0x100))
{
result.Add(new TextDecoration() { Location = TextDecorationLocation.Underline, PenOffset = 1 });
result.Add(new TextDecoration() { Location = TextDecorationLocation.Underline, PenOffset = -1 });
}
else if (HasFlag(0x200))
{
result.Add(new TextDecoration() { Location = TextDecorationLocation.Strikethrough, PenOffset = 0.5 });
result.Add(new TextDecoration() { Location = TextDecorationLocation.Strikethrough, PenOffset = 0} );
}
return result;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:24,代码来源:FormatPreviewBindingTarget.cs
示例17: TextDecorationsFixup
private static string TextDecorationsFixup(TextDecorationCollection textDecorations)
{
string stringValue = null;
// Work around for incorrect serialization for TextDecorations property
//
// Special case for TextDecorations serialization
if (TextDecorations.Underline.ValueEquals(textDecorations))
{
stringValue = "Underline";
}
else if (TextDecorations.Strikethrough.ValueEquals(textDecorations))
{
stringValue = "Strikethrough";
}
else if (TextDecorations.OverLine.ValueEquals(textDecorations))
{
stringValue = "OverLine";
}
else if (TextDecorations.Baseline.ValueEquals(textDecorations))
{
stringValue = "Baseline";
}
else if (textDecorations.Count == 0)
{
stringValue = string.Empty;
}
return stringValue;
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:30,代码来源:DPTypeDescriptorContext.cs
示例18: OutlinedTextBlock
public OutlinedTextBlock()
{
TextDecorations = new TextDecorationCollection();
}
开发者ID:christopher7694,项目名称:Hearthstone-Deck-Tracker,代码行数:4,代码来源:OutlinedTextBlock.cs
示例19: Draw
/// <inheritdoc/>
public override void Draw(object dc, XText text, double dx, double dy, ImmutableArray<XProperty> db, XRecord r)
{
var _dc = dc as DrawingContext;
var style = text.Style;
if (style == null)
return;
var tbind = text.BindText(db, r);
if (string.IsNullOrEmpty(tbind))
return;
double thickness = style.Thickness / _state.ZoomX;
double half = thickness / 2.0;
Tuple<Brush, Pen> styleCached = _styleCache.Get(style);
Brush fill;
Pen stroke;
if (styleCached != null)
{
fill = styleCached.Item1;
stroke = styleCached.Item2;
}
else
{
fill = CreateBrush(style.Fill);
stroke = CreatePen(style, thickness);
_styleCache.Set(style, Tuple.Create(fill, stroke));
}
var rect = CreateRect(text.TopLeft, text.BottomRight, dx, dy);
Tuple<string, FormattedText, ShapeStyle> tcache = _textCache.Get(text);
FormattedText ft;
string ct;
if (tcache != null && string.Compare(tcache.Item1, tbind) == 0 && tcache.Item3 == style)
{
ct = tcache.Item1;
ft = tcache.Item2;
_dc.DrawText(ft, GetTextOrigin(style, ref rect, ft));
}
else
{
var ci = CultureInfo.InvariantCulture;
var fontStyle = System.Windows.FontStyles.Normal;
var fontWeight = FontWeights.Regular;
if (style.TextStyle.FontStyle != null)
{
if (style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Italic))
{
fontStyle = System.Windows.FontStyles.Italic;
}
if (style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Bold))
{
fontWeight = FontWeights.Bold;
}
}
var tf = new Typeface(new FontFamily(style.TextStyle.FontName), fontStyle, fontWeight, FontStretches.Normal);
ft = new FormattedText(
tbind,
ci,
ci.TextInfo.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight,
tf,
style.TextStyle.FontSize > 0.0 ? style.TextStyle.FontSize : double.Epsilon,
stroke.Brush, null, TextFormattingMode.Ideal);
if (style.TextStyle.FontStyle != null)
{
if (style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Underline)
|| style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Strikeout))
{
var decorations = new TextDecorationCollection();
if (style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Underline))
{
decorations = new TextDecorationCollection(
decorations.Union(TextDecorations.Underline));
}
if (style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Strikeout))
{
decorations = new TextDecorationCollection(
decorations.Union(TextDecorations.Strikethrough));
}
ft.SetTextDecorations(decorations);
}
}
_textCache.Set(text, Tuple.Create(tbind, ft, style));
_dc.DrawText(ft, GetTextOrigin(style, ref rect, ft));
}
}
开发者ID:Core2D,项目名称:Core2D,代码行数:100,代码来源:WpfRenderer.cs
示例20: Link
/// <summary>
/// Constructor.
/// </summary>
public Link (string title, string address)
{
FontSize = 11;
Cursor = Cursors.Hand;
Foreground = new SolidColorBrush (Color.FromRgb (135, 178, 227));
TextDecoration underline = new TextDecoration () {
Pen = new Pen (new SolidColorBrush (Color.FromRgb (135, 178, 227)), 1),
PenThicknessUnit = TextDecorationUnit.FontRecommended
};
TextDecorationCollection collection = new TextDecorationCollection ();
collection.Add (underline);
TextBlock text_block = new TextBlock () {
Text = title,
TextDecorations = collection
};
Content = text_block;
MouseUp += delegate {
Process.Start (new ProcessStartInfo (address));
};
}
开发者ID:emrul,项目名称:CmisSync,代码行数:28,代码来源:About.cs
注:本文中的System.Windows.TextDecorationCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论