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


C# FormattedText.SetFontStyle方法代码示例

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


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

示例1: escribeTexto

        private void escribeTexto()
        {
            string texto = "";
            FormattedText frmTxt = new FormattedText(texto,
                 CultureInfo.GetCultureInfo("en-us"),
            FlowDirection.LeftToRight, new Typeface("Verdana"), 32, Brushes.Black);
            // Set a maximum width and height. If the text overflows these values, an ellipsis "..." appears.
            frmTxt.MaxTextWidth = 300;
            frmTxt.MaxTextHeight = 240;

            // Use a larger font size beginning at the first (zero-based) character and continuing for 5 characters.
            // The font size is calculated in terms of points -- not as device-independent pixels.
            frmTxt.SetFontSize(36 * (96.0 / 72.0), 0, 5);

            // Use a Bold font weight beginning at the 6th character and continuing for 11 characters.
            frmTxt.SetFontWeight(FontWeights.Bold, 6, 11);

            // Use a linear gradient brush beginning at the 6th character and continuing for 11 characters.
            frmTxt.SetForegroundBrush(
                                    new LinearGradientBrush(
                                    Colors.Orange,
                                    Colors.Teal,
                                    90.0),
                                    6, 11);

            // Use an Italic font style beginning at the 28th character and continuing for 28 characters.
            frmTxt.SetFontStyle(FontStyles.Italic, 28, 28);

            //// Draw the formatted text string to the DrawingContext of the control.
            //drawingContext.DrawText(frmTxt, new Point(10, 0));
        }
开发者ID:amarodev,项目名称:PantallasCC,代码行数:31,代码来源:CuboHorario.xaml.cs

示例2: GetFormattedText

        public static FormattedText GetFormattedText(this FlowDocument doc)
        {
            if (doc == null)
            {
                throw new ArgumentNullException("doc");
            }

            FormattedText output = new FormattedText(
              GetText(doc),
              CultureInfo.CurrentCulture,
              doc.FlowDirection,
              new Typeface(doc.FontFamily, doc.FontStyle, doc.FontWeight, doc.FontStretch),
              doc.FontSize,
              doc.Foreground);

            int offset = 0;

            foreach (TextElement el in GetRunsAndParagraphs(doc))
            {
                Run run = el as Run;

                if (run != null)
                {
                    int count = run.Text.Length;

                    output.SetFontFamily(run.FontFamily, offset, count);
                    output.SetFontStyle(run.FontStyle, offset, count);
                    output.SetFontWeight(run.FontWeight, offset, count);
                    output.SetFontSize(run.FontSize, offset, count);
                    output.SetForegroundBrush(run.Foreground, offset, count);
                    output.SetFontStretch(run.FontStretch, offset, count);
                    output.SetTextDecorations(run.TextDecorations, offset, count);

                    offset += count;
                }
                else
                {
                    offset += Environment.NewLine.Length;
                }
            }

            return output;
        }
开发者ID:RagingBigFemaleBird,项目名称:sgs,代码行数:43,代码来源:FlowDocumentExtensions.cs

示例3: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            //drawingContext.DrawRectangle(Brushes.Crimson, null, new Rect(new Point(0, 0), new Point(500, 500)));
            //base.OnRender(drawingContext);

            //return;

            string testString = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor";

            // Create the initial formatted text string.
            FormattedText formattedText = new FormattedText(
                testString,
                CultureInfo.GetCultureInfo("en-us"),
                FlowDirection.LeftToRight,
                new Typeface("Verdana"),
                32,
                Brushes.Black);

            // Set a maximum width and height. If the text overflows these values, an ellipsis "..." appears.
            formattedText.MaxTextWidth = 300;
            formattedText.MaxTextHeight = 240;

            // Use a larger font size beginning at the first (zero-based) character and continuing for 5 characters.
            // The font size is calculated in terms of points -- not as device-independent pixels.
            formattedText.SetFontSize(36 * (96.0 / 72.0), 0, 5);

            // Use a Bold font weight beginning at the 6th character and continuing for 11 characters.
            formattedText.SetFontWeight(FontWeights.Bold, 6, 11);

            // Use a linear gradient brush beginning at the 6th character and continuing for 11 characters.
            formattedText.SetForegroundBrush(
                                    new LinearGradientBrush(
                                    Colors.Orange,
                                    Colors.Teal,
                                    90.0),
                                    6, 11);

            // Use an Italic font style beginning at the 28th character and continuing for 28 characters.
            formattedText.SetFontStyle(FontStyles.Italic, 28, 28);

            // Draw the formatted text string to the DrawingContext of the control.
            drawingContext.DrawText(formattedText, new Point(10, 0));
        }
开发者ID:aistrate,项目名称:Throwaways,代码行数:43,代码来源:Window1.xaml.cs

示例4: GetTextHeight

 // Get the height of the text element
 private double GetTextHeight(TextBlock tb)
 {
     FormattedText ft = new FormattedText(tb.Text,
                                          CultureInfo.GetCultureInfo("en-us"),
                                          FlowDirection.LeftToRight,
                                          new Typeface(tb.FontFamily.ToString()),
                                          tb.FontSize,
                                          tb.Background);
                                          //BackColorPicker.CurrentColor);
                                          //GetFontColor(customBackgroundCP.SelectedColor));
     ft.SetFontWeight(tb.FontWeight);
     ft.SetFontStyle(tb.FontStyle);
     
     double widthMul = ft.Width / (MaxTextWidth * Image.ScaleFactor);
     if (widthMul > 1)
     {
         return ft.Height * Math.Ceiling(widthMul);
     }
     else
     {
         return ft.Height;
     }
     
 }
开发者ID:vforget,项目名称:blip,代码行数:25,代码来源:UserControl8.xaml.cs

示例5: Self_DrawText

        public void Self_DrawText()
        {
            DrawingContext dc = drawvis.RenderOpen();
            renderbit.Clear();

            // 글씨 쓰기
            string testString = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor";

            // Create the initial formatted text string.
            FormattedText formattedText = new FormattedText(
                testString,
                System.Globalization.CultureInfo.GetCultureInfo("en-us"),
                FlowDirection.LeftToRight,
                new Typeface("Verdana"),
                30,
                Brushes.Black);

            // Set a maximum width and height. If the text overflows these values, an ellipsis "..." appears.
            formattedText.MaxTextWidth = 300;
            formattedText.MaxTextHeight = 240;

            // Use a larger font size beginning at the first (zero-based) character and continuing for 5 characters.
            // The font size is calculated in terms of points -- not as device-independent pixels.
            formattedText.SetFontSize(36 * (96.0 / 72.0), 0, 5);

            // Use a Bold font weight beginning at the 6th character and continuing for 11 characters.
            formattedText.SetFontWeight(FontWeights.Bold, 2, 3);

            // Use a linear gradient brush beginning at the 6th character and continuing for 11 characters.
            formattedText.SetForegroundBrush(
                                    new LinearGradientBrush(
                                    Colors.Orange,
                                    Colors.Teal,
                                    90.0),
                                    6, 11);

            // Use an Italic font style beginning at the 28th character and continuing for 28 characters.
            formattedText.SetFontStyle(FontStyles.Italic, 28, 28);

            // Draw the formatted text string to the DrawingContext of the control.
            dc.DrawText(formattedText, new Point(100, 150));

            dc.Close();
            renderbit.Render(drawvis);
        }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:45,代码来源:main.cs

示例6: CreateDescription

        private Rectangle CreateDescription(Point origin, out Visual visual)
        {
            if (_vsGraphNodeInfo != null)
            {
                DrawingVisual desc = new DrawingVisual();
                DrawingContext context = desc.RenderOpen();

                string properties = "";
                foreach (KeyValuePair<GraphProperty, object> kvp in _vsGraphNodeInfo.Properties)
                {
                    string name = kvp.Key.ToString();
                    bool value = (kvp.Value is bool && ((bool)kvp.Value) == true);
                    if (name.StartsWith("CodeSchemaProperty_Is") && value)
                    {
                        properties += (properties.Length > 0 ? " : " : "") + name.Replace("CodeSchemaProperty_Is", "");
                    }
                }

                FormattedText fText = new FormattedText(properties, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Calibri"), _fontSize * 0.8, Brushes.Black);
                fText.SetFontStyle(FontStyles.Italic);
                fText.TextAlignment = TextAlignment.Center;

                context.DrawText(fText, CommonX.WpfPoint(origin));
                context.Close();

                _textMeasurer.FontSize = _fontSize * 0.8;
                _textMeasurer.Text = properties;
                Size size = CommonX.Measure(_textMeasurer);

                visual = desc;
                return new Rectangle(origin.X-size.Width/2, origin.Y, origin.X+size.Width/2, origin.Y+size.Height);
            }
            visual = null;
            return new Rectangle();
        }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:35,代码来源:XNode.cs

示例7: OnRender

        protected override void OnRender(DrawingContext dc)
        {
            var propertyName = GetContentProperty(AdornedElement);
            var value = AdornedElement.GetProperty(propertyName);
            if (value == null || string.IsNullOrEmpty(value.ToString()))
            {
                var fmt = new FormattedText(GetText(AdornedElement),
                CultureInfo.CurrentCulture,
                (AdornedElement as Control).FlowDirection,
                (AdornedElement as Control).FontFamily.GetTypefaces().FirstOrDefault(),
                (AdornedElement as Control).FontSize,
                GetForeground(AdornedElement));
                fmt.SetFontStyle(GetFontStyle(AdornedElement));

                dc.DrawRectangle(GetBackground(AdornedElement), null, new Rect(
                    new Point((AdornedElement as Control).Padding.Left + 4, (AdornedElement as Control).Padding.Top + 1),
                    new Size(fmt.Width, fmt.Height)));

                dc.DrawText(fmt, new Point((AdornedElement as Control).Padding.Left + 4, (AdornedElement as Control).Padding.Top + 1));
            }
        }
开发者ID:MagicWang,项目名称:WYJ,代码行数:21,代码来源:WatermarkAdorner.cs

示例8: Highlight

            public int Highlight(FormattedText text, int previousBlockCode)
            {
                //
                // WORDS RULES
                //
                Regex wordsRgx = new Regex("[a-zA-Z_][a-zA-Z0-9_]*");
                foreach (Match m in wordsRgx.Matches(text.Text))
                {
                  foreach (HighlightWordsRule rule in wordsRules)
                  {
                foreach (string word in rule.Words)
                {
                  if (rule.Options.IgnoreCase)
                  {
                if (m.Value.Equals(word, StringComparison.InvariantCultureIgnoreCase))
                {
                  text.SetForegroundBrush(rule.Options.Foreground, m.Index, m.Length);
                  text.SetFontWeight(rule.Options.FontWeight, m.Index, m.Length);
                  text.SetFontStyle(rule.Options.FontStyle, m.Index, m.Length);
                }
                  }
                  else
                  {
                if (m.Value == word)
                {
                  text.SetForegroundBrush(rule.Options.Foreground, m.Index, m.Length);
                  text.SetFontWeight(rule.Options.FontWeight, m.Index, m.Length);
                  text.SetFontStyle(rule.Options.FontStyle, m.Index, m.Length);
                }
                  }
                }
                  }
                }

                //
                // REGEX RULES
                //
                foreach (AdvancedHighlightRule rule in regexRules)
                {
                  Regex regexRgx = new Regex(rule.Expression);
                  foreach (Match m in regexRgx.Matches(text.Text))
                  {
                text.SetForegroundBrush(rule.Options.Foreground, m.Index, m.Length);
                text.SetFontWeight(rule.Options.FontWeight, m.Index, m.Length);
                text.SetFontStyle(rule.Options.FontStyle, m.Index, m.Length);
                  }
                }

                //
                // LINES RULES
                //
                foreach (HighlightLineRule rule in lineRules)
                {
                  Regex lineRgx = new Regex(Regex.Escape(rule.LineStart) + ".*");
                  foreach (Match m in lineRgx.Matches(text.Text))
                  {
                text.SetForegroundBrush(rule.Options.Foreground, m.Index, m.Length);
                text.SetFontWeight(rule.Options.FontWeight, m.Index, m.Length);
                text.SetFontStyle(rule.Options.FontStyle, m.Index, m.Length);
                  }
                }

                return -1;
            }
开发者ID:menozz,项目名称:mirelle,代码行数:64,代码来源:HighlighterManager.cs

示例9: _formatBody

      private void _formatBody() {
         var showMembers = Canvas.DisplayOptions.Has(DisplayOptions.DisplayClassMembers);
         var showInherited = Canvas.DisplayOptions.Has(DisplayOptions.DisplayInheritedMembers);
         var sortMembers = Canvas.DisplayOptions.Has(DisplayOptions.SortMembersByName);
         if (!showMembers) {
            _bodyText = null;
            return;
         }

         var bodyParts = new List<string>();
         var bodyStyles = new List<TextStyle>();

         Action<string, TextStyle> addPart = (t, s) => { bodyParts.Add(t); bodyStyles.Add(s); };
         Action addSpacer = () => addPart("-\n", TextStyle.Spacer);
         Action<BplClass> addProperties = bplClass => {
            var properties = (showInherited ? bplClass.Properties : bplClass.OwnProperties);
            if (sortMembers) {
               properties = properties.OrderBy(p => p.Name);
            }
            foreach (var prop in properties) {
               var name = prop.Name.At(0).ToUpper() + prop.Name.After(0);
               var type = String.Empty;
               if (prop.IsPrimitive) {
                  type = prop.PrimitiveType.Name;
               } else {
                  if (prop.IsReference) {
                     type = prop.UnderlyingType.Name;
                  } else if (prop.IsCollection) {
                     type = prop.UnderlyingItemType.Name + "*";
                  }
               }
               addPart("\u2022 " + name, (prop == bplClass.IdentityProperty ? TextStyle.Identity : TextStyle.FieldName));
               addPart(" (" + type + ")\n", TextStyle.DataType);
            }
         };

         var operation = Class.Operation;
         if (operation == null) {
            addProperties(Class);
         } else {
            addPart("INPUT:\n", TextStyle.Subtitle);
            addSpacer();
            addProperties(Class);
            if (operation.Output != null) {
               addSpacer();
               addSpacer();
               addPart("OUTPUT:\n", TextStyle.Subtitle);
               addSpacer();
               addProperties(operation.Output);
            }
         }

         _bodyText = ToFormattedText(bodyParts.ToArray().Join(), 14, _normalFG);
         for (int i = 0, j = 0; i < bodyParts.Count; i++) {
            var k = bodyParts[i].Length;
            switch(bodyStyles[i]) {
               case TextStyle.Identity:
                  _bodyText.SetTextDecorations(TextDecorations.Underline, j + 2, k - 2);
                  break;
               case TextStyle.DataType:
                  _bodyText.SetForegroundBrush(_lightFG, j, k);
                  _bodyText.SetFontStyle(FontStyles.Italic, j + 2, k - 4);
                  break;
               case TextStyle.Subtitle:
                  _bodyText.SetFontSize(13, j, k);
                  _bodyText.SetTextDecorations(TextDecorations.Underline, j, k);
                  break;
               case TextStyle.Spacer:
                  _bodyText.SetForegroundBrush(_bodyBG.Fill, j, k);
                  _bodyText.SetFontSize(3, j, k);
                  break;
            }
            j += k;
         }
      }
开发者ID:borkaborka,项目名称:gmit,代码行数:75,代码来源:DiagramNode.cs

示例10: GetFormattedText

        private static FormattedText GetFormattedText(FlowDocument doc)
        {
            var output = new FormattedText(
                GetText(doc),
                CultureInfo.CurrentCulture,
                doc.FlowDirection,
                new Typeface(doc.FontFamily, doc.FontStyle, doc.FontWeight, doc.FontStretch),
                doc.FontSize,
                doc.Foreground);

            int offset = 0;

            foreach (TextElement textElement in GetRunsAndParagraphs(doc))
            {
                var run = textElement as Run;

                if (run != null)
                {
                    int count = run.Text.Length;

                    output.SetFontFamily(run.FontFamily, offset, count);
                    output.SetFontSize(run.FontSize, offset, count);
                    output.SetFontStretch(run.FontStretch, offset, count);
                    output.SetFontStyle(run.FontStyle, offset, count);
                    output.SetFontWeight(run.FontWeight, offset, count);
                    output.SetForegroundBrush(run.Foreground, offset, count);
                    output.SetTextDecorations(run.TextDecorations, offset, count);

                    offset += count;
                }
                else
                {
                    offset += Environment.NewLine.Length;
                }
            }

            return output;
        }
开发者ID:nick121212,项目名称:xima_desktop3,代码行数:38,代码来源:AutoSizeRichTextBox.cs

示例11: _formatTitle

 private void _formatTitle() {
    var title = (Class.Operation != null ? Class.Operation.Name : Class.Name);
    _titleText = ToFormattedText(title, 20, _normalFG);
    if (Canvas.DisplayOptions.Has(DisplayOptions.DisplayClassNamespace)) {
       var subtitle = "(" + Class.Namespace.Name + ")";
       _subtitleText = ToFormattedText(subtitle, 14, _lightFG);
       _subtitleText.SetFontStyle(FontStyles.Italic, 1, subtitle.Length - 2);
    } else {
       _subtitleText = null;
    }
 }
开发者ID:borkaborka,项目名称:gmit,代码行数:11,代码来源:DiagramNode.cs

示例12: setStyle

        public void setStyle(CharDisplayInfo fs, int count, FormattedText ft)
        {
            if ((fs.Style & (int)ZStyles.BOLDFACE_STYLE) > 0)
            {
                ft.SetFontWeight(FontWeights.Bold);
            }

            if ((fs.Style & (int)ZStyles.REVERSE_STYLE) > 0)
            {
                ft.SetFontWeight(FontWeights.Bold);
                ft.SetForegroundBrush(ZColorCheck.ZColorToBrush(fs.BackgroundColor, ColorType.Background));
            }
            else
            {
                ft.SetForegroundBrush(ZColorCheck.ZColorToBrush(fs.ForegroundColor, ColorType.Foreground));
            }

            if ((fs.Style & (int)ZStyles.EMPHASIS_STYLE) > 0)
            {
                ft.SetFontStyle(FontStyles.Italic);
            }

            if ((fs.Style & (int)ZStyles.FIXED_WIDTH_STYLE) > 0)
            {
                ft.SetFontFamily(_fixedFont.Family);
            }
        }
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:27,代码来源:ScreenBase.cs

示例13: setStyle

        public void setStyle(CharDisplayInfo fs, FontChanges fc, FormattedText ft, DrawingContext dc)
        {
            int startPos = fc.Offset + fc.StartCol;

            if ((fs.Style & (int)ZStyles.BOLDFACE_STYLE) > 0)
            {
                ft.SetFontWeight(FontWeights.Bold, startPos, fc.Count);
            }

            int rectColor = -1;
            ColorType type = ColorType.Foreground;

            if ((fs.Style & (int)ZStyles.REVERSE_STYLE) > 0)
            {
                ft.SetFontWeight(FontWeights.Bold, startPos, fc.Count);
                ft.SetForegroundBrush(ZColorCheck.ZColorToBrush(fs.BackgroundColor, ColorType.Background), startPos, fc.Count);

                rectColor = fs.ForegroundColor;
            }
            else
            {
                ft.SetForegroundBrush(ZColorCheck.ZColorToBrush(fs.ForegroundColor, ColorType.Foreground), startPos, fc.Count);
                if (fs.BackgroundColor > 1 && fs.BackgroundColor != bColor)
                {
                    rectColor = fs.BackgroundColor;
                    type = ColorType.Background;
                }
            }

            if ((fs.Style & (int)ZStyles.EMPHASIS_STYLE) > 0)
            {
                ft.SetFontStyle(FontStyles.Italic, startPos, fc.Count);
            }

            if ((fs.Style & (int)ZStyles.FIXED_WIDTH_STYLE) > 0)
            {
                ft.SetFontFamily(_fixedFont.Family, startPos, fc.Count);
            }

            if (dc != null && rectColor != -1)
            {
                Brush b = ZColorCheck.ZColorToBrush(rectColor, type);

                dc.DrawRectangle(b, null,
                    new Rect(fc.StartCol * charWidth, fc.Line * charHeight,
                        fc.Count * charWidth, charHeight));
            }
        }
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:48,代码来源:TextControlScreen.xaml.cs

示例14: ApplyFormat

 /// <summary>
 /// Applies a format in rule options to the formatted text
 /// </summary>
 /// <param name="text"></param>
 /// <param name="options"></param>
 /// <param name="index"></param>
 /// <param name="length"></param>
 public void ApplyFormat(FormattedText text, RuleOptions options, int index, int length)
 {
     text.SetForegroundBrush(options.Foreground, index, length);
     text.SetFontWeight(options.FontWeight, index, length);
     text.SetFontStyle(options.FontStyle, index, length);
 }
开发者ID:diegoRodriguezAguila,项目名称:SGAM.Elfec.Admin,代码行数:13,代码来源:BaseHighlighter.cs

示例15: ComposeValue

        private void ComposeValue(DrawingContext drawingContext)
        {
            Brush backgroundColor = null;
            Pen borderPen = null;
            if (!previewType.HasFlag(PreviewTypes.Extended))  // only need to condensed bubble
            {
                string text = Configurations.PreviewBubbleTextDefault;
                string text2 = "";
                if (condensedString != null && condensedString.Count > 0)
                {
                    text = condensedString[0];
                    if (condensedString.Count() > 1)
                        text2 = condensedString[1];
                }

                FormattedText newText;
                FormattedText newText2;
                double textLength;

                SolidColorBrush textColor;
                int textHorizontalMargin = Configurations.InfoBubbleMargin;
                int textVerticalMargin = Configurations.InfoBubbleMargin;

                textColor = Configurations.PreviewBubbleCondensedTextColor;

                newText = new FormattedText(text,
                                         Configurations.culture,
                                         FlowDirection.LeftToRight,
                                         Configurations.TypeFace,
                                         Configurations.InfoBubbleText,
                                         textColor);
                newText2 = new FormattedText(text2,
                                         Configurations.culture,
                                         FlowDirection.LeftToRight,
                                         Configurations.TypeFace,
                                         Configurations.InfoBubbleText,
                                         textColor);

                if (this.content == null)
                    newText.SetFontStyle(FontStyles.Italic);

                newText.LineHeight = Configurations.InfoBubbleText;
                textLength = Math.Max(newText.WidthIncludingTrailingWhitespace, newText2.WidthIncludingTrailingWhitespace);

                rectWidth = (int)(textLength + 2 * textHorizontalMargin);
                if (rectWidth < Configurations.InfoBubbleMinWidth)
                {
                    rectWidth = Configurations.InfoBubbleMinWidth;
                }
                if (this.previewType.HasFlag(PreviewTypes.Extended))
                {
                    rectWidth += Configurations.PreviewBubbleExtendedScrollBarWidth;
                    if (rectWidth > Configurations.InfoBubbleMaxWidth)
                        rectWidth = Configurations.InfoBubbleMaxWidth;
                }

                rectHeight = (int)(textVerticalMargin * 2 + newText.Height);
                if (text2 != "")
                    rectHeight += Configurations.InfoBubbleText + textVerticalMargin;
                if (rectHeight > Configurations.InfoBubbleMaxHeight)
                    rectHeight = Configurations.InfoBubbleMaxHeight;

                backgroundColor = Configurations.PreviewBubbleCondensedBackground;
                borderPen = Configurations.PreviewBubbleCondensedBorderPen;

                rectPoint = new Point((int)(anchorPoint.X - rectWidth / 2) + 0.5, (int)(anchorPoint.Y + Configurations.InfoBubbleArrowHeight) + 0.5);

                //Draw Bubble
                base.DrawBubble(drawingContext, backgroundColor, borderPen, !this.previewType.HasFlag(PreviewTypes.Collapsed));

                if (!this.previewType.HasFlag(PreviewTypes.Collapsed))
                {
                    //Draw text only in the condensed mode
                    double newTextWidth = newText.WidthIncludingTrailingWhitespace;
                    double newText2Width = newText2.WidthIncludingTrailingWhitespace;

                    if (text2 == "")
                    {
                        drawingContext.DrawText(newText, new Point(anchorPoint.X - newTextWidth / 2, rectPoint.Y + textVerticalMargin));
                    }
                    else
                    {
                        drawingContext.DrawText(newText, new Point(rectPoint.X + Configurations.InfoBubbleMargin, rectPoint.Y + textVerticalMargin));
                        drawingContext.DrawText(newText2, new Point(rectPoint.X + Configurations.InfoBubbleMargin, rectPoint.Y + textVerticalMargin + newText.Height));
                    }

                    //Draw Context Menu
                    Point p = new Point(rectPoint.X + rectWidth, rectPoint.Y);
                    p.Offset(0, Configurations.ContextMenuMargin);
                    DrawingUtilities.DrawDots(drawingContext, DotTypes.Top | DotTypes.TopRight | DotTypes.MiddleRight, p, Core.AnchorPoint.TopRight, false);
                }
            }
        }
开发者ID:samuto,项目名称:designscript,代码行数:93,代码来源:PreviewBubble.cs


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