本文整理汇总了C#中System.Windows.Media.FormattedText.TopExtra方法的典型用法代码示例。如果您正苦于以下问题:C# FormattedText.TopExtra方法的具体用法?C# FormattedText.TopExtra怎么用?C# FormattedText.TopExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.FormattedText
的用法示例。
在下文中一共展示了FormattedText.TopExtra方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDecoratedCharWidth
private double GetDecoratedCharWidth(FormattedText ft, List<CharacterDecorationInfo> decorationList,
int index, out double charLeft, out double hCenter)
{
charLeft = 0;
double width = ft.GetFullWidth();
hCenter = width / 2;
double charWidth = width;
var lhList = from d in decorationList where d.Position == Position.TopLeft select d;
var rhList = from d in decorationList where d.Position == Position.TopRight select d;
var topList = from d in decorationList where d.Position == Position.Top select d;
var bottomList = from d in decorationList where d.Position == Position.Bottom select d;
//var vList = from d in decorationList where d.Position == Position.Top || d.Position == Position.Bottom select d;
var oList = from d in decorationList where d.Position == Position.Over select d;
string text = "";
foreach (var v in lhList)
{
text += v.UnicodeString;
}
if (text.Length > 0)
{
var t = textManager.GetFormattedText(text, textManager.GetFormatIdForNewStyle(formats[index], FontStyles.Normal));
width += t.GetFullWidth();
charLeft = t.GetFullWidth();
hCenter += charLeft;
}
foreach (var v in topList)
{
var f = textManager.GetFormattedText("f", formats[index]);
var fTop = f.TopExtra();
var ftTop = ft.TopExtra();
if (fTop < ftTop)
{
var t = textManager.GetFormattedText(v.UnicodeString, formats[index]);
double diff = t.GetFullWidth() - charWidth;
if (diff > 0)
{
charWidth += diff;
charLeft += diff / 2;
hCenter += diff / 2;
}
}
}
foreach (var v in bottomList)
{
var t = textManager.GetFormattedText(v.UnicodeString, formats[index]);
double diff = t.GetFullWidth() - charWidth;
if (diff > 0)
{
charWidth += diff;
charLeft += diff / 2;
hCenter += diff / 2;
}
}
width = Math.Max(width, charWidth);
foreach (var v in oList)
{
if (v.DecorationType == CharacterDecorationType.Cross || v.DecorationType == CharacterDecorationType.DoubleStrikeThrough ||
v.DecorationType == CharacterDecorationType.LeftCross || v.DecorationType == CharacterDecorationType.RightCross ||
v.DecorationType == CharacterDecorationType.StrikeThrough)
{
double diff = (ft.GetFullWidth() + FontSize * .1) - width;
if (diff > 0)
{
width = ft.GetFullWidth() + FontSize * .1;
charLeft += diff / 2;
hCenter += diff / 2;
}
}
}
text = "";
foreach (var v in rhList)
{
text += v.UnicodeString;
}
if (text.Length > 0)
{
var t = textManager.GetFormattedText(text, formats[index]);
width += t.GetFullWidth();
}
return width;
}