当前位置: 首页>>代码示例>>C#>>正文


C# FormattedText.TopExtra方法代码示例

本文整理汇总了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;
 }
开发者ID:JackWangCUMT,项目名称:math-editor,代码行数:81,代码来源:TextEquation.cs


注:本文中的System.Windows.Media.FormattedText.TopExtra方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。