本文整理汇总了C#中System.Windows.FontWeight类的典型用法代码示例。如果您正苦于以下问题:C# FontWeight类的具体用法?C# FontWeight怎么用?C# FontWeight使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FontWeight类属于System.Windows命名空间,在下文中一共展示了FontWeight类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GraphicsText
public GraphicsText(
string text,
double left,
double top,
double right,
double bottom,
Color objectColor,
double textFontSize,
string textFontFamilyName,
FontStyle textFontStyle,
FontWeight textFontWeight,
FontStretch textFontStretch,
double actualScale)
{
this.text = text;
this.rectangleLeft = left;
this.rectangleTop = top;
this.rectangleRight = right;
this.rectangleBottom = bottom;
this.graphicsObjectColor = objectColor;
this.textFontSize = textFontSize;
this.textFontFamilyName = textFontFamilyName;
this.textFontStyle = textFontStyle;
this.textFontWeight = textFontWeight;
this.textFontStretch = textFontStretch;
this.graphicsActualScale = actualScale;
graphicsLineWidth = 2; // used for drawing bounding rectangle when selected
//RefreshDrawng();
}
示例2: CreateHyperLink
/// <summary>
/// Tworzy linka i ustawia jego właściwości
/// </summary>
/// <param name="linkText"></param>
/// <param name="linkAdress"></param>
/// <param name="toolTip"></param>
/// <returns></returns>
private static Hyperlink CreateHyperLink(string linkText, string linkAdress, string toolTip, FontWeight weight,
Brush linkColor, RoutedCommand command)
{
System.Windows.Controls.ToolTip tip = new ToolTip();
tip.Content = toolTip;
tip.StaysOpen = true;
tip.Style = (Style) Application.Current.FindResource("YellowToolTipStyle");
Hyperlink hyperlink = new Hyperlink(new Run(linkText))
{
NavigateUri = new Uri(linkAdress),
TextDecorations = null,
FontWeight = weight,
//FontWeights.SemiBold,
Foreground = linkColor,
ToolTip = tip
};
hyperlink.Command = command;
hyperlink.CommandParameter = linkAdress;
ToolTipService.SetInitialShowDelay(hyperlink,700);
ToolTipService.SetShowDuration(hyperlink,15000);
//hyperlink.AddHandler(Hyperlink.RequestNavigateEvent,
// new RequestNavigateEventHandler(HyperLinkRequestNavigate));
return hyperlink;
}
示例3: FontInfo
/// <summary>
/// Initializes a new instance of the <see cref="FontInfo"/> class.
/// </summary>
/// <param name="family">The family.</param>
/// <param name="size">The size.</param>
/// <param name="style">The style.</param>
/// <param name="weight">The weight.</param>
public FontInfo(FontFamily family, double size, FontStyle style, FontWeight weight)
{
FontFamily = family;
FontSize = size;
FontStyle = style;
FontWeight = weight;
}
示例4: MeasureText
internal Size MeasureText(string text, FontFamily fontFamily, FontStyle fontStyle,
FontWeight fontWeight,
FontStretch fontStretch, double fontSize)
{
var typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);
GlyphTypeface glyphTypeface;
if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
{
return MeasureTextSize(text, fontFamily, fontStyle, fontWeight, fontStretch, fontSize);
}
double totalWidth = 0;
double height = 0;
foreach (var t in text)
{
var glyphIndex = glyphTypeface.CharacterToGlyphMap[t];
var width = glyphTypeface.AdvanceWidths[glyphIndex] * fontSize;
var glyphHeight = glyphTypeface.AdvanceHeights[glyphIndex] * fontSize;
if (glyphHeight > height)
{
height = glyphHeight;
}
totalWidth += width;
}
return new Size(totalWidth, height);
}
示例5: WpfFontFamilyInfo
public WpfFontFamilyInfo(FontFamily family, FontWeight weight,
FontStyle style, FontStretch stretch)
{
_family = family;
_weight = weight;
_style = style;
_stretch = stretch;
}
示例6: ToHighlightingColor
public static HighlightingColor ToHighlightingColor(this Color color, FontWeight? fontWeight = null)
{
return new HighlightingColor
{
Foreground = new SimpleHighlightingBrush(color),
FontWeight = fontWeight
};
}
示例7: WpfRichTextBoxWordColoringRule
public WpfRichTextBoxWordColoringRule(string text, string textColor, string backgroundColor, FontStyle fontStyle, FontWeight fontWeight)
{
Text = text;
FontColor = textColor;
BackgroundColor = backgroundColor;
Style = fontStyle;
Weight = fontWeight;
}
示例8: WpfRichTextBoxRowColoringRule
public WpfRichTextBoxRowColoringRule(string condition, string fontColor, string backColor, FontStyle fontStyle, FontWeight fontWeight)
{
Condition = condition;
FontColor = fontColor;
BackgroundColor = backColor;
Style = fontStyle;
Weight = fontWeight;
}
示例9: WpfRichTextBoxWordColoringRule
public WpfRichTextBoxWordColoringRule(string text, string textColor, string backgroundColor, FontStyle fontStyle, FontWeight fontWeight)
{
this.Text = text;
this.FontColor = textColor;
this.BackgroundColor = backgroundColor;
this.Style = fontStyle;
this.Weight = fontWeight;
}
示例10: ColorRule
public ColorRule(string condition, Brush foregroundColor, Brush backgroundColor, FontStyle fontStyle, FontWeight fontWeight)
{
this.Condition = condition;
this.ForegroundColor = foregroundColor;
this.BackgroundColor = backgroundColor;
this.FontStyle = fontStyle;
this.FontWeight = fontWeight;
}
示例11: WpfRichTextBoxRowColoringRule
public WpfRichTextBoxRowColoringRule(string condition, string fontColor, string backColor, FontStyle fontStyle, FontWeight fontWeight)
{
this.Condition = condition;
this.FontColor = fontColor;
this.BackgroundColor = backColor;
this.Style = fontStyle;
this.Weight = fontWeight;
}
示例12: ToFontAwesomeIcon
public static ImageSource ToFontAwesomeIcon(this string text, Brush foreBrush, FontStyle fontStyle, FontWeight fontWeight, FontStretch fontStretch)
{
var fontFamily = new FontFamily("/GitWorkItems;component/Resources/#FontAwesome");
if (fontFamily != null && !String.IsNullOrEmpty(text))
{
//premier essai, on charge la police directement
Typeface typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);
GlyphTypeface glyphTypeface;
if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
{
//si ça ne fonctionne pas (et pour le mode design dans certains cas) on ajoute l'uri pack://application
typeface = new Typeface(new FontFamily(new Uri("pack://application:,,,"), fontFamily.Source), fontStyle, fontWeight, fontStretch);
if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
throw new InvalidOperationException("No glyphtypeface found");
}
//détermination des indices/tailles des caractères dans la police
ushort[] glyphIndexes = new ushort[text.Length];
double[] advanceWidths = new double[text.Length];
for (int n = 0; n < text.Length; n++)
{
ushort glyphIndex;
try
{
glyphIndex = glyphTypeface.CharacterToGlyphMap[text[n]];
}
catch (Exception)
{
glyphIndex = 42;
}
glyphIndexes[n] = glyphIndex;
double width = glyphTypeface.AdvanceWidths[glyphIndex] * 1.0;
advanceWidths[n] = width;
}
try
{
//création de l'objet DrawingImage (compatible avec Imagesource) à partir d'un glyphrun
GlyphRun gr = new GlyphRun(glyphTypeface, 0, false, 1.0, glyphIndexes,
new Point(0, 0), advanceWidths, null, null, null, null, null, null);
GlyphRunDrawing glyphRunDrawing = new GlyphRunDrawing(foreBrush, gr);
return new DrawingImage(glyphRunDrawing);
}
catch (Exception ex)
{
// ReSharper disable LocalizableElement
Console.WriteLine("Error in generating Glyphrun : " + ex.Message);
// ReSharper restore LocalizableElement
}
}
return null;
}
示例13: avAddressCtrl_Loaded
private void avAddressCtrl_Loaded(object sender, EventArgs e)
{
_initBackBrush = _wpfAddressCtrl.MyControlBackground;
_initForeBrush = _wpfAddressCtrl.MyControlForeground;
_initFontFamily = _wpfAddressCtrl.MyControlFontFamily;
_initFontSize = _wpfAddressCtrl.MyControlFontSize;
_initFontWeight = _wpfAddressCtrl.MyControlFontWeight;
_initFontStyle = _wpfAddressCtrl.MyControlFontStyle;
}
示例14: avAddressCtrl_Loaded
void avAddressCtrl_Loaded(object sender, EventArgs e)
{
initBackBrush = (SolidColorBrush)wpfAddressCtrl.MyControl_Background;
initForeBrush = wpfAddressCtrl.MyControl_Foreground;
initFontFamily = wpfAddressCtrl.MyControl_FontFamily;
initFontSize = wpfAddressCtrl.MyControl_FontSize;
initFontWeight = wpfAddressCtrl.MyControl_FontWeight;
initFontStyle = wpfAddressCtrl.MyControl_FontStyle;
}
示例15: FontInfo
public FontInfo(FontFamily fam, double sz, FontStyle style, FontStretch strc, FontWeight weight, SolidColorBrush c)
{
this.Family = fam;
this.Size = sz;
this.Style = style;
this.Stretch = strc;
this.Weight = weight;
this.BrushColor = c;
}