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


C# FormattedText.GetFullWidth方法代码示例

本文整理汇总了C#中System.Windows.Media.FormattedText.GetFullWidth方法的典型用法代码示例。如果您正苦于以下问题:C# FormattedText.GetFullWidth方法的具体用法?C# FormattedText.GetFullWidth怎么用?C# FormattedText.GetFullWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.FormattedText的用法示例。


在下文中一共展示了FormattedText.GetFullWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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

示例2: DrawAllDecorations

 private void DrawAllDecorations(DrawingContext dc, double left, double hCenter, double top, double charLeft,
                                 FormattedText charFt, int index, List<CharacterDecorationInfo> decorationList)
 {
     DrawRightDecorations(dc, decorationList, top, left + charLeft + charFt.GetFullWidth(), formats[index]);
     DrawLeftDecorations(dc, decorationList, top, left + charLeft, formats[index]);
     DrawFaceDecorations(dc, charFt, decorationList, top, left + hCenter);
     DrawTopDecorations(dc, charFt, decorationList, top, left + hCenter, formats[index]);
     DrawBottomDecorations(dc, charFt, decorationList, top, left + hCenter, formats[index]);
 }
开发者ID:JackWangCUMT,项目名称:math-editor,代码行数:9,代码来源:TextEquation.cs

示例3: DrawFaceDecorations

        //index = index of the decorated character in this.textData
        private void DrawFaceDecorations(DrawingContext dc, FormattedText charText, List<CharacterDecorationInfo> cdiList, double top, double hCenter)
        {
            var decorations = (from x in cdiList where x.Position == Position.Over select x).ToList();
            if (decorations.Count > 0)
            {
                double offset = 0;
                top += charText.Height + charText.OverhangAfter - charText.Extent; //ft.Baseline - ft.Extent + descent;
                double bottom = top + charText.Extent; //charText.Height - charText.Baseline + charText.OverhangAfter;
                double vCenter = top + charText.Extent / 2;
                double left = hCenter - charText.GetFullWidth() / 2 - offset;
                double right = hCenter + charText.GetFullWidth() / 2 + offset;

                Pen pen = PenManager.GetPen(FontSize * .035);
                foreach (var d in decorations)
                {
                    switch (d.DecorationType)
                    {
                        case CharacterDecorationType.Cross:
                            dc.DrawLine(pen, new Point(left, top), new Point(right, bottom));
                            dc.DrawLine(pen, new Point(left, bottom), new Point(right, top));
                            break;
                        case CharacterDecorationType.LeftCross:
                            dc.DrawLine(pen, new Point(left, top), new Point(right, bottom));
                            break;
                        case CharacterDecorationType.RightCross:
                            dc.DrawLine(pen, new Point(left, bottom), new Point(right, top));
                            break;
                        case CharacterDecorationType.LeftUprightCross:
                            dc.DrawLine(pen, new Point(hCenter - FontSize * .08, top - FontSize * 0.04), new Point(hCenter + FontSize * .08, bottom + FontSize * 0.04));
                            break;
                        case CharacterDecorationType.RightUprightCross:
                            dc.DrawLine(pen, new Point(hCenter + FontSize * .08, top - FontSize * 0.04), new Point(hCenter - FontSize * .08, bottom + FontSize * 0.04));
                            break;
                        case CharacterDecorationType.StrikeThrough:
                            dc.DrawLine(pen, new Point(left, vCenter), new Point(right, vCenter));
                            break;
                        case CharacterDecorationType.DoubleStrikeThrough:
                            dc.DrawLine(pen, new Point(left, vCenter - FontSize * .05), new Point(right, vCenter - FontSize * .05));
                            dc.DrawLine(pen, new Point(left, vCenter + FontSize * .05), new Point(right, vCenter + FontSize * .05));
                            break;
                        case CharacterDecorationType.VStrikeThrough:
                            dc.DrawLine(pen, new Point(hCenter, top - FontSize * .05), new Point(hCenter, bottom + FontSize * .05));
                            break;
                        case CharacterDecorationType.VDoubleStrikeThrough:
                            dc.DrawLine(pen, new Point(hCenter - FontSize * .05, top - FontSize * .05), new Point(hCenter - FontSize * .05, bottom + FontSize * .05));
                            dc.DrawLine(pen, new Point(hCenter + FontSize * .05, top - FontSize * .05), new Point(hCenter + FontSize * .05, bottom + FontSize * .05));
                            break;
                    }
                }
            }
        }
开发者ID:JackWangCUMT,项目名称:math-editor,代码行数:52,代码来源:TextEquation.cs

示例4: ReformatSign

 protected void ReformatSign()
 {
     formattedText = FontFactory.GetFormattedText(Text, FontType, FontSize * FontSizeFactor, FontWeight);
     Width = formattedText.GetFullWidth() + LeftMarginFactor * FontSize + RightMarginFactor * FontSize; // * WidthFactor;
     Height = formattedText.Extent;
 }
开发者ID:JackWangCUMT,项目名称:math-editor,代码行数:6,代码来源:StaticText.cs


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