本文整理汇总了C#中IGraphics.MeasureCharacterRanges方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphics.MeasureCharacterRanges方法的具体用法?C# IGraphics.MeasureCharacterRanges怎么用?C# IGraphics.MeasureCharacterRanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphics
的用法示例。
在下文中一共展示了IGraphics.MeasureCharacterRanges方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MeasureDisplayStringWidthExact
static private int MeasureDisplayStringWidthExact(IGraphics graphics, string text, Font font)
{
CharacterRange[] ranges = new[] { new CharacterRange(0, text.Length) };
StringFormat format = new StringFormat();
format.SetMeasurableCharacterRanges(ranges);
RectangleF rect = new RectangleF(0, 0, 1000, 1000);
rect = graphics.MeasureCharacterRanges(text, font, rect, format);
return (int)(rect.Right + 1.0f);
}
示例2: StringRegionValue
private RectangleF StringRegionValue(IGraphics g, int textpos)
{
var measureString = Text.Substring(textpos, 1);
var numChars = measureString.Length;
var characterRanges = new CharacterRange[numChars + 1];
var stringFormat = new StringFormat
{
Trimming = StringTrimming.None,
FormatFlags =
StringFormatFlags.NoClip | StringFormatFlags.NoWrap |
StringFormatFlags.LineLimit
};
var size = g.MeasureString(Text, _font, LetterSpacePercentage);
var layoutRect = new RectangleF(0f, 0f, size.Width, size.Height);
characterRanges[0] = new CharacterRange(0, 1);
stringFormat.FormatFlags = StringFormatFlags.NoClip;
stringFormat.SetMeasurableCharacterRanges(characterRanges);
stringFormat.Alignment = StringAlignment.Center;
return g.MeasureCharacterRanges(Text.Substring(textpos), _font, layoutRect, stringFormat);
}