當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。