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


C# Windows.FontStyle类代码示例

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


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

示例1: MeasureText

        internal Size MeasureText(string text, FontFamily fontFamily, FontStyle fontStyle,
            FontWeight fontWeight,
            FontStretch fontStretch, double fontSize)
        {
            var typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);
            GlyphTypeface glyphTypeface;

            if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                return MeasureTextSize(text, fontFamily, fontStyle, fontWeight, fontStretch, fontSize);
            }

            double totalWidth = 0;
            double height = 0;

            foreach (var t in text)
            {
                var glyphIndex = glyphTypeface.CharacterToGlyphMap[t];
                var width = glyphTypeface.AdvanceWidths[glyphIndex] * fontSize;
                var glyphHeight = glyphTypeface.AdvanceHeights[glyphIndex] * fontSize;

                if (glyphHeight > height)
                {
                    height = glyphHeight;
                }
                totalWidth += width;
            }
            return new Size(totalWidth, height);
        }
开发者ID:LionFree,项目名称:Cush,代码行数:29,代码来源:MRUTextHelper.cs

示例2: GraphicsText

        public GraphicsText(
            string text,
            double left, 
            double top, 
            double right, 
            double bottom,
            Color objectColor,
            double textFontSize,
            string textFontFamilyName,
            FontStyle textFontStyle,
            FontWeight textFontWeight,
            FontStretch textFontStretch,
            double actualScale)
        {
            this.text = text;
            this.rectangleLeft = left;
            this.rectangleTop = top;
            this.rectangleRight = right;
            this.rectangleBottom = bottom;
            this.graphicsObjectColor = objectColor;
            this.textFontSize = textFontSize;
            this.textFontFamilyName = textFontFamilyName;
            this.textFontStyle = textFontStyle;
            this.textFontWeight = textFontWeight;
            this.textFontStretch = textFontStretch;
            this.graphicsActualScale = actualScale;

            graphicsLineWidth = 2;      // used for drawing bounding rectangle when selected

            //RefreshDrawng();
        }
开发者ID:ritnorthstar,项目名称:Minimap-Control,代码行数:31,代码来源:GraphicsText.cs

示例3: SetStyle

 public object SetStyle(object handle, FontStyle style)
 {
     var font = (FontData)handle;
     font = font.Clone ();
     font.Style = DataConverter.ToWpfFontStyle (style);
     return font;
 }
开发者ID:joncham,项目名称:xwt,代码行数:7,代码来源:FontBackendHandler.cs

示例4: FontInfo

 /// <summary>
 /// Initializes a new instance of the <see cref="FontInfo"/> class.
 /// </summary>
 /// <param name="family">The family.</param>
 /// <param name="size">The size.</param>
 /// <param name="style">The style.</param>
 /// <param name="weight">The weight.</param>
 public FontInfo(FontFamily family, double size, FontStyle style, FontWeight weight)
 {
     FontFamily = family;
     FontSize = size;
     FontStyle = style;
     FontWeight = weight;
 }
开发者ID:EmptyKeys,项目名称:UI_Generator,代码行数:14,代码来源:FontInfo.cs

示例5: ToWpfFontStyle

        public static SW.FontStyle ToWpfFontStyle(FontStyle value)
        {
            if (value == FontStyle.Italic) return SW.FontStyles.Italic;
            if (value == FontStyle.Oblique) return SW.FontStyles.Oblique;

            return SW.FontStyles.Normal;
        }
开发者ID:pixelmeister,项目名称:xwt,代码行数:7,代码来源:DataConverter.cs

示例6: Font

 public Font()
 {
     Weight = FontWeights.Normal;
     Family = Fonts.SystemFontFamilies.ToArray<FontFamily>()[0];
     Size = 15;
     Stretch = FontStretches.Normal;
     Style = FontStyles.Normal;
 }
开发者ID:mlnlover11,项目名称:IExtendFramework,代码行数:8,代码来源:Font.cs

示例7: WpfRichTextBoxWordColoringRule

 public WpfRichTextBoxWordColoringRule(string text, string textColor, string backgroundColor, FontStyle fontStyle, FontWeight fontWeight)
 {
     this.Text = text;
     this.FontColor = textColor;
     this.BackgroundColor = backgroundColor;
     this.Style = fontStyle;
     this.Weight = fontWeight;
 }
开发者ID:WinMustDie,项目名称:TradingStation,代码行数:8,代码来源:WpfRichTextBoxWordColoringRule.cs

示例8: WpfFontFamilyInfo

 public WpfFontFamilyInfo(FontFamily family, FontWeight weight, 
     FontStyle style, FontStretch stretch)
 {
     _family  = family;
     _weight  = weight;
     _style   = style;
     _stretch = stretch;
 }
开发者ID:udayanroy,项目名称:SvgSharp,代码行数:8,代码来源:WpfFontFamilyInfo.cs

示例9: WpfRichTextBoxRowColoringRule

 public WpfRichTextBoxRowColoringRule(string condition, string fontColor, string backColor, FontStyle fontStyle, FontWeight fontWeight)
 {
     this.Condition = condition;
     this.FontColor = fontColor;
     this.BackgroundColor = backColor;
     this.Style = fontStyle;
     this.Weight = fontWeight;
 }
开发者ID:SaintCat,项目名称:VkBot,代码行数:8,代码来源:WpfRichTextBoxRowColoringRule.cs

示例10: WpfRichTextBoxWordColoringRule

 public WpfRichTextBoxWordColoringRule(string text, string textColor, string backgroundColor, FontStyle fontStyle, FontWeight fontWeight)
 {
     Text = text;
     FontColor = textColor;
     BackgroundColor = backgroundColor;
     Style = fontStyle;
     Weight = fontWeight;
 }
开发者ID:pmlyon,项目名称:BitSharp,代码行数:8,代码来源:WpfRichTextBoxWordColoringRule.cs

示例11: ColorRule

 public ColorRule(string condition, Brush foregroundColor, Brush backgroundColor, FontStyle fontStyle, FontWeight fontWeight)
 {
     this.Condition = condition;
     this.ForegroundColor = foregroundColor;
     this.BackgroundColor = backgroundColor;
     this.FontStyle = fontStyle;
     this.FontWeight = fontWeight;
 }
开发者ID:dEMonaRE,项目名称:HearthstoneTracker,代码行数:8,代码来源:ColorRule.cs

示例12: WpfRichTextBoxRowColoringRule

 public WpfRichTextBoxRowColoringRule(string condition, string fontColor, string backColor, FontStyle fontStyle, FontWeight fontWeight)
 {
     Condition = condition;
     FontColor = fontColor;
     BackgroundColor = backColor;
     Style = fontStyle;
     Weight = fontWeight;
 }
开发者ID:csvelasq,项目名称:PowerSystemPlanning,代码行数:8,代码来源:WpfRichTextBoxRowColoringRule.cs

示例13: ToFontAwesomeIcon

        public static ImageSource ToFontAwesomeIcon(this string text, Brush foreBrush, FontStyle fontStyle, FontWeight fontWeight, FontStretch fontStretch)
        {
            var fontFamily = new FontFamily("/GitWorkItems;component/Resources/#FontAwesome");
            if (fontFamily != null && !String.IsNullOrEmpty(text))
            {
                //premier essai, on charge la police directement
                Typeface typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);

                GlyphTypeface glyphTypeface;
                if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
                {
                    //si ça ne fonctionne pas (et pour le mode design dans certains cas) on ajoute l'uri pack://application
                    typeface = new Typeface(new FontFamily(new Uri("pack://application:,,,"), fontFamily.Source), fontStyle, fontWeight, fontStretch);
                    if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
                        throw new InvalidOperationException("No glyphtypeface found");
                }

                //détermination des indices/tailles des caractères dans la police
                ushort[] glyphIndexes = new ushort[text.Length];
                double[] advanceWidths = new double[text.Length];

                for (int n = 0; n < text.Length; n++)
                {
                    ushort glyphIndex;
                    try
                    {
                        glyphIndex = glyphTypeface.CharacterToGlyphMap[text[n]];

                    }
                    catch (Exception)
                    {
                        glyphIndex = 42;
                    }
                    glyphIndexes[n] = glyphIndex;

                    double width = glyphTypeface.AdvanceWidths[glyphIndex] * 1.0;
                    advanceWidths[n] = width;
                }

                try
                {

                    //création de l'objet DrawingImage (compatible avec Imagesource) à partir d'un glyphrun
                    GlyphRun gr = new GlyphRun(glyphTypeface, 0, false, 1.0, glyphIndexes,
                                                                         new Point(0, 0), advanceWidths, null, null, null, null, null, null);

                    GlyphRunDrawing glyphRunDrawing = new GlyphRunDrawing(foreBrush, gr);
                    return new DrawingImage(glyphRunDrawing);
                }
                catch (Exception ex)
                {
                    // ReSharper disable LocalizableElement
                    Console.WriteLine("Error in generating Glyphrun : " + ex.Message);
                    // ReSharper restore LocalizableElement
                }
            }
            return null;
        }
开发者ID:run00,项目名称:GitToWork,代码行数:58,代码来源:ExtensionsForString.cs

示例14: Create

 public override object Create(string fontName, double size, FontStyle style, FontWeight weight, FontStretch stretch)
 {
     size = GetPointsFromDeviceUnits (size);
     return new FontData (new FontFamily (fontName), size) {
         Style = style.ToWpfFontStyle (),
         Weight = weight.ToWpfFontWeight (),
         Stretch = stretch.ToWpfFontStretch ()
     };
 }
开发者ID:modulexcite,项目名称:xwt,代码行数:9,代码来源:FontBackendHandler.cs

示例15: Font

 public Font(FontFamily family, double size, FontStyle style, FontWeight weight, FontStretch stretch)
     : this()
 {
     this.Family = family;
     this.Size = size;
     this.Style = style;
     this.Weight = weight;
     this.Stretch = stretch;
 }
开发者ID:catwalkagogo,项目名称:Heron,代码行数:9,代码来源:Font.cs


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