本文整理汇总了C#中FontStyle.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# FontStyle.ToString方法的具体用法?C# FontStyle.ToString怎么用?C# FontStyle.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FontStyle
的用法示例。
在下文中一共展示了FontStyle.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFont
private void CreateFont (string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical)
{
#if ONLY_1_1
if (familyName == null)
throw new ArgumentNullException ("familyName");
#endif
originalFontName = familyName;
FontFamily family;
// NOTE: If family name is null, empty or invalid,
// MS creates Microsoft Sans Serif font.
try {
family = new FontFamily (familyName);
}
catch (Exception){
family = FontFamily.GenericSansSerif;
}
setProperties (family, emSize, style, unit, charSet, isVertical);
Status status = GDIPlus.GdipCreateFont (family.NativeObject, emSize, style, unit, out fontObject);
if (status == Status.FontStyleNotFound)
throw new ArgumentException (Locale.GetText ("Style {0} isn't supported by font {1}.", style.ToString (), familyName));
GDIPlus.CheckStatus (status);
}
示例2: GetPdfFontStyle
private PdfFontStyle GetPdfFontStyle(FontStyle style)
{
return (PdfFontStyle)Enum.Parse(typeof(PdfFontStyle), style.ToString(), false);
}
示例3: MeasureTextNoTrim
private Size MeasureTextNoTrim(string text, int size, FontStyle style)
{
var closest = GetClosestFontSize(size);
var scale = size / (float) closest;
var measure = GetFont(Path.Combine(style.ToString(), closest.ToString())).MeasureString(text);
return new Size((int) (Math.Round(measure.X * scale)), (int) (Math.Round(measure.Y * scale)));
}
示例4: DrawString
public override void DrawString(string text, Point point, Brush brush, int size, FontStyle style,
Rectangle bounds,
bool ignoreFormatting = false)
{
SetClipArea(bounds);
var pos = new Vector2((int) Math.Round(point.X), (int) Math.Round(point.Y));
var closest = GetClosestFontSize(size);
var colorBrush = brush as ColorBrush;
var gradientBrush = brush as GradientBrush;
var defaultColor = Color.Black;
if (colorBrush != null)
defaultColor = colorBrush.Color;
if (gradientBrush != null)
{
UseMaskStencil(bounds);
}
if (!ignoreFormatting) // If formatting is enabled, parse it and render each part.
{
var parts = ParseFormattedText(text, defaultColor, style);
foreach (var part in parts)
{
var font = GetFont(Path.Combine(part.Style.ToString(), closest.ToString()));
var measure = MeasureTextNoTrim(part.Text, size, part.Style);
var col = new ColorXNA(part.Color.R, part.Color.G, part.Color.B, defaultColor.A);
manager.SpriteBatch.DrawString(font, part.Text, pos,
col * (defaultColor.A / 255f), 0,
Vector2.Zero, size / (float) closest, SpriteEffects.None, 0);
pos = new Vector2(pos.X + (float) measure.Width, pos.Y);
}
}
else // Draw plain string
{
var font = GetFont(Path.Combine(style.ToString(), closest.ToString()));
var col = new ColorXNA(defaultColor.R, defaultColor.G, defaultColor.B, defaultColor.A);
manager.SpriteBatch.DrawString(font, text, pos,
col * (defaultColor.A / 255f), 0,
Vector2.Zero, size / (float) closest, SpriteEffects.None, 0);
}
// If using a gradient brush, draw a gradient over the mask.
if (gradientBrush != null)
{
UseRenderStencil();
DrawGradient(bounds, gradientBrush);
EndStencil();
}
ResetClipArea();
}
示例5: GetFontStyleEnum
protected string GetFontStyleEnum(FontStyle fontStyle)
{
return fontStyle.ToString();
}
示例6: WriteFontStyleProperty
private static void WriteFontStyleProperty(System.Xml.XmlWriter writer, FontStyle font)
{
writer.WriteString(font.ToString());
}
示例7: createHashString
private static string createHashString(string fontFamilyName, float pointSize, FontStyle style)
{
return (fontFamilyName + pointSize.ToString() + style.ToString());
}
示例8: GetDescription
public static string GetDescription(string name, float size, FontStyle style, GraphicsUnit unit,
string nameAndPropertiesFormat)
{
string properties = string.Format("{0} {1}{2}",
size,
unit.ToString().ToLower(),
style != FontStyle.Regular ? ", " + style.ToString().ToLower() : "");
return string.Format(nameAndPropertiesFormat, name, properties);
}