• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FontFamily类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ExamineKeystrokes

        public ExamineKeystrokes()
        {
            Title = "Examine Keystrokes";
            FontFamily = new FontFamily("Courier New");

            Grid grid = new Grid();
            Content = grid;

            // Make one row "auto" and the other fill the remaining space.
            RowDefinition rowdef = new RowDefinition();
            rowdef.Height = GridLength.Auto;
            grid.RowDefinitions.Add(rowdef);
            grid.RowDefinitions.Add(new RowDefinition());

            // Display header text.
            TextBlock textHeader = new TextBlock();
            textHeader.FontWeight = FontWeights.Bold;
            textHeader.Text = strHeader;
            grid.Children.Add(textHeader);

            // Create StackPanel as child of ScrollViewer for displaying events.
            scroll = new ScrollViewer();
            grid.Children.Add(scroll);
            Grid.SetRow(scroll, 1);

            stack = new StackPanel();
            scroll.Content = stack;
        }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:28,代码来源:ExamineKeystrokes.cs


示例2: SetCustomData

        /// <summary>
        /// Main windows에 적용 할 수 있는 간략한 Data 테스트
        /// </summary>
        private void SetCustomData()
        {
            // 제목
            Title = "Display Some Text";

            //// 현재 창에 나타날 data
            //Content = "Content can be simple text!";

            // font 지정
            FontFamily = new FontFamily("Comic Sans MS");

            FontSize = 48;

            // gradient 효과가 적용된 Brush
            Brush brush = new LinearGradientBrush(Colors.Black, Colors.White, new Point(0,0), new Point(1,1));

            Background = brush;
            Foreground = brush;

            // 현재 창의 content 내용에 따라 창의 크기를 조절 할 수 있는 값
            SizeToContent = SizeToContent.WidthAndHeight;

            // 현재 창의 Resizing 방법 지정
            ResizeMode = ResizeMode.CanMinimize;
        }
开发者ID:yoosuphwang,项目名称:DotNet_App,代码行数:28,代码来源:MainWindow.xaml.cs


示例3: MakeSingleLineItem

        public static FrameworkElement MakeSingleLineItem(string message, bool halfSize = false, bool fullWidth = true)
        {
            var size = halfSize ? 7 : 12;
            var font = new FontFamily(halfSize ? "Lucida Console" : "Arial");
            Brush color = Brushes.White;
            var element = new TextBlock()
            {
                Text = message,
                Background = Brushes.Transparent,
                FontSize = size,
                Margin = halfSize ? new Thickness(0, 0, 0, -1) : new Thickness(0, -2, 0, 0),
                FontFamily = font,
                TextWrapping = TextWrapping.NoWrap,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                TextAlignment = System.Windows.TextAlignment.Center,
                Foreground = color,
                MinWidth = !fullWidth || halfSize ? 0 : BadgeCaps.Width,
                UseLayoutRounding = true,
                SnapsToDevicePixels = true
            };
            TextOptions.SetTextFormattingMode(element, TextFormattingMode.Display);
            TextOptions.SetTextRenderingMode(element, TextRenderingMode.Aliased);
            TextOptions.SetTextHintingMode(element, TextHintingMode.Fixed);

            return element;
        }
开发者ID:Effix,项目名称:LedBadge,代码行数:26,代码来源:WPF.cs


示例4: CreateScheduleClass

 public CreateScheduleClass(string AppDirectory)
 {
     //create the formatting items
     FontFamily AdobeJenson = new FontFamily(AppDirectory + AdobeJensonPath);
     FontFamily Georgia = new FontFamily("Georgia");
     fontFamily = Georgia;
 }
开发者ID:hrichardlee,项目名称:LessonSchedules,代码行数:7,代码来源:CreateScheduleClass.cs


示例5: ChatDocument

        public ChatDocument(IInlineUploadViewFactory factory, IWebBrowser browser, IPasteViewFactory pasteViewFactory)
        {
            _factory = factory;
            _browser = browser;
            _pasteViewFactory = pasteViewFactory;
            _handlers = new Dictionary<MessageType, Action<Message, User, Paragraph>>
                {
                    {MessageType.TextMessage, FormatUserMessage},
                    {MessageType.TimestampMessage, FormatTimestampMessage},
                    {MessageType.LeaveMessage, FormatLeaveMessage},
                    {MessageType.KickMessage, FormatKickMessage},
                    {MessageType.PasteMessage, FormatPasteMessage},
                    {MessageType.EnterMessage, FormatEnterMessage},
                    {MessageType.UploadMessage, FormatUploadMessage},
                    {MessageType.TweetMessage, FormatTweetMessage},
                    {MessageType.AdvertisementMessage, FormatAdvertisementMessage},
                    {MessageType.TopicChangeMessage, FormatTopicChangeMessage}

                };

            FontSize = 14;
            FontFamily = new FontFamily("Segoe UI");

            AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(NavigateToLink));
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:25,代码来源:ChatDocument.cs


示例6: 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


示例7: FontInfo

        public FontInfo(FontFamily fontFamily, double fontSize)
        {
            FontFamily = fontFamily;
            Size = fontSize;
            LineHeight = fontSize * FontFamily.LineSpacing;

            var fixedWidthCharacter = new FormattedText("X",
                CultureInfo.CurrentCulture,
                FlowDirection.LeftToRight,
                new Typeface(FontFamily.Source),
                fontSize,
                Brushes.Black);

            CharacterWidth = fixedWidthCharacter.Width;

            var tabCharacter = new FormattedText("\t",
                CultureInfo.CurrentCulture,
                FlowDirection.LeftToRight,
                new Typeface(FontFamily.Source),
                fontSize,
                Brushes.Black);

            TabWidth = tabCharacter.WidthIncludingTrailingWhitespace;

            LeftOffset = 0;
        }
开发者ID:tomhunter-gh,项目名称:SourceLog,代码行数:26,代码来源:FontInfo.cs


示例8: FontChanged

 private void FontChanged(object sender, PrefChangeEventArgs e)
 {
     if (e.PrefName == "fiddler.ui.font.face")
     {
         var font = e.ValueString;
         var fontFamily = new FontFamily(font);
         _panel.Dispatcher.BeginInvoke((Action)(() =>
         {
             var style = new Style(typeof(StackPanel), _panel.Style);
             style.Setters.Add(new Setter(TextBlock.FontFamilyProperty, fontFamily));
             style.Seal();
             _panel.Style = style;
         }));
     }
     if (e.PrefName == "fiddler.ui.font.size")
     {
         double value;
         if (double.TryParse(e.ValueString, out value))
         {
             _panel.Dispatcher.BeginInvoke((Action) (() =>
             {
                 var fontSizeInPoints = value*96d/72d;
                 var style = new Style(typeof (StackPanel), _panel.Style);
                 style.Setters.Add(new Setter(TextBlock.FontSizeProperty, fontSizeInPoints));
                 style.Seal();
                 _panel.Style = style;
             }));
         }
     }
 }
开发者ID:modulexcite,项目名称:FiddlerCert,代码行数:30,代码来源:CertInspector.cs


示例9: AugmentQuickInfoSession

        public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> qiContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;

            if (!EnsureTreeInitialized() || session == null || qiContent == null)
                return;

            // Map the trigger point down to our buffer.
            SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
            if (!point.HasValue)
                return;

            ParseItem item = _tree.StyleSheet.ItemBeforePosition(point.Value.Position);
            if (item == null || !item.IsValid)
                return;

            Declaration dec = item.FindType<Declaration>();
            if (dec == null || !dec.IsValid || !_allowed.Contains(dec.PropertyName.Text.ToUpperInvariant()))
                return;

            string fontName = item.Text.Trim('\'', '"');

            if (fonts.Families.SingleOrDefault(f => f.Name.Equals(fontName, StringComparison.OrdinalIgnoreCase)) != null)
            {
                FontFamily font = new FontFamily(fontName);

                applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(item.Start, item.Length, SpanTrackingMode.EdgeNegative);
                qiContent.Add(CreateFontPreview(font, 10));
                qiContent.Add(CreateFontPreview(font, 11));
                qiContent.Add(CreateFontPreview(font, 12));
                qiContent.Add(CreateFontPreview(font, 14));
                qiContent.Add(CreateFontPreview(font, 25));
                qiContent.Add(CreateFontPreview(font, 40));
            }
        }
开发者ID:joeriks,项目名称:WebEssentials2013,代码行数:35,代码来源:FontQuickInfo.cs


示例10: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        string fName = ConfigurationManager.AppSettings["Code39Barcode.FontFamily"];

        PrivateFontCollection fCollection = new PrivateFontCollection();
        fCollection.AddFontFile(ConfigurationManager.AppSettings["Code39Barcode.FontFile"]);
        FontFamily fFamily = new FontFamily(fName, fCollection);
        Font f = new Font(fFamily, FontSize);

        Bitmap bmp = new Bitmap(Width, Height);
        Graphics g = Graphics.FromImage(bmp);
        g.Clear(Color.White);
        Brush b = new SolidBrush(Color.Black);
        g.DrawString("*" + strPortfolioID + "*", f, b, 0, 0);

        //PNG format has no visible compression artifacts like JPEG or GIF, so use this format, but it needs you to copy the bitmap into a new bitmap inorder to display the image properly.  Weird MS bug.
        Bitmap bm = new Bitmap(bmp);
        System.IO.MemoryStream ms = new System.IO.MemoryStream();

        Response.ContentType = "image/png";
        bm.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
        ms.WriteTo(Response.OutputStream);

        b.Dispose();
        bm.Dispose();
        Response.End();
    }
开发者ID:nehawadhwa,项目名称:ccweb,代码行数:27,代码来源:CP_Barcode.ascx.cs


示例11: PFont

 public PFont(string name, double size, bool smooth, char [] charset)
 {
     Family = new FontFamily (name);
     Size = size;
     Smooth = smooth;
     Charset = charset;
 }
开发者ID:atsushieno,项目名称:tsukimi,代码行数:7,代码来源:StandardLibrary.Typography.cs


示例12: MainWindowViewModel

 public MainWindowViewModel()
 {
     BackgroundColor = new SolidColorBrush(Settings.Background);
     ForegroundColor = new SolidColorBrush(Settings.Foreground);
     FontFamily = new FontFamily(Settings.FontFamily);
     FontSize = Settings.FontSize;
 }
开发者ID:igilham,项目名称:EditRoom,代码行数:7,代码来源:MainWindowViewModel.cs


示例13: GenerateBarcodeImage

    public Bitmap GenerateBarcodeImage(string text, FontFamily fontFamily, int fontSizeInPoints)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("*");
        sb.Append(text);
        sb.Append("*");

        Bitmap bmp = new Bitmap(1, 1, PixelFormat.Format32bppArgb);

        Font font = new Font(fontFamily, fontSizeInPoints, FontStyle.Regular, GraphicsUnit.Point);

        Graphics graphics = Graphics.FromImage(bmp);

        SizeF textSize = graphics.MeasureString(sb.ToString(), font);

        bmp = new Bitmap(bmp, textSize.ToSize());

        graphics = Graphics.FromImage(bmp);
        graphics.Clear(Color.White);
        graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
        graphics.DrawString(sb.ToString(), font, new SolidBrush(Color.Black), 0, 0);
        graphics.Flush();

        font.Dispose();
        graphics.Dispose();

        return bmp;
    }
开发者ID:rid50,项目名称:PSCBioOffice,代码行数:28,代码来源:Helper.cs


示例14: 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


示例15: GetFontData

        public FontData GetFontData(string fontFamilyName, bool isItalic, bool isBold)
        {
            FontData data = new FontData()
            {
                IsValid = false,
                Bytes = null,
                FontFamilyName = fontFamilyName,
                IsItalic = isItalic,
                IsBold = isBold
            };

            FontFamily fontFamily = new FontFamily(fontFamilyName);
            FontStyle fontStyle = isItalic ? FontStyles.Italic : FontStyles.Normal;
            FontWeight fontWeight = isBold ? FontWeights.Bold : FontWeights.Normal;
            Typeface typeface = new Typeface(fontFamily, fontStyle, fontWeight, FontStretches.Normal);
            GlyphTypeface glyphTypeface;
            if (typeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                using (var memoryStream = new MemoryStream())
                {
                    glyphTypeface.GetFontStream().CopyTo(memoryStream);
                    data.Bytes = memoryStream.ToArray();
                    data.IsValid = true;
                }
            }

            return data;
        }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:28,代码来源:PdfFontsService.svc.cs


示例16: AddVisualText

        public void AddVisualText(String text, String name_of_element, FontFamily fontFamily, Double fontSize, Point location, Double rotateAngle, Brush brush)
        {
            Typeface typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
            DrawingContext dc;

            DrawingVisual dv = new DrawingVisual();
            FormattedText ft1 = new FormattedText(text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, fontSize, brush);

            if (location.X == -1)
            {
                location = new Point(this.Width / 2 - ft1.Width / 2, location.Y);
            }
            if (location.Y == -1)
            {
                location = new Point(location.X, this.Height / 2 - ft1.Height / 2);
            }

            RotateTransform rt = new RotateTransform(rotateAngle, location.X + ft1.Width / 2, location.Y + ft1.Height / 2);

            dc = dv.RenderOpen();
            dc.PushTransform(rt);
            dc.DrawText(ft1, location);
            dc.Close();

            this.visuals.Add(new NamedVisual(name_of_element, dv));
            this.AddVisualChild(dv);

        }
开发者ID:Deiwos3,项目名称:IMS,代码行数:28,代码来源:MyDecorator.cs


示例17: GenerateImage

 private void GenerateImage(
     HttpResponse response,
     string textToInsert,
     int width,
     int height,
     Color backgroundColor,
     FontFamily fontFamily,
     float emSize,
     Brush brush,
     float x,
     float y,
     string contentType,
     ImageFormat imageFormat)
 {
     using (Bitmap bitmap = new Bitmap(width, height))
     {
         using (Graphics graphics = Graphics.FromImage(bitmap))
         {
             graphics.Clear(backgroundColor);
             graphics.DrawString(textToInsert, new Font(fontFamily, emSize), brush, x, y);
             response.ContentType = contentType;
             bitmap.Save(response.OutputStream, imageFormat);
         }
     }
 }
开发者ID:nikolaynikolov,项目名称:Telerik,代码行数:25,代码来源:TextToImageHttpHandler.cs


示例18: Typeface

 public Typeface(FontFamily fontFamily, FontStyle style, FontWeight weight, FontStretch stretch)
 {
     this.FontFamily = fontFamily;
     this.Style = style;
     this.Weight = weight;
     this.Stretch = stretch;
 }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:7,代码来源:Typeface.cs


示例19: SetFont

        /// <summary>
        /// Helper function that converts the values stored in the settings into the font values
        /// and then sets the tasklist font values.
        /// </summary>
		public void SetFont()
        {
            var family = new FontFamily(User.Default.TaskListFontFamily);

            double size = User.Default.TaskListFontSize;

            var styleConverter = new FontStyleConverter();

            FontStyle style = (FontStyle)styleConverter.ConvertFromString(User.Default.TaskListFontStyle);

            var stretchConverter = new FontStretchConverter();
            FontStretch stretch = (FontStretch)stretchConverter.ConvertFromString(User.Default.TaskListFontStretch);

            var weightConverter = new FontWeightConverter();
            FontWeight weight = (FontWeight)weightConverter.ConvertFromString(User.Default.TaskListFontWeight);

            Color color = (Color)ColorConverter.ConvertFromString(User.Default.TaskListFontBrushColor);

			lbTasks.FontFamily = family;
			lbTasks.FontSize = size;
			lbTasks.FontStyle = style;
			lbTasks.FontStretch = stretch;
			lbTasks.FontWeight = weight;
			lbTasks.Foreground = new SolidColorBrush(color);
        }
开发者ID:umarinam,项目名称:todotxt.net,代码行数:29,代码来源:MainWindow.xaml.cs


示例20: ZTextBufferWindow

        public ZTextBufferWindow(ZWindowManager manager, FontAndColorService fontAndColorService)
            : base(manager, fontAndColorService)
        {
            this.normalFontFamily = new FontFamily("Cambria");
            this.fixedFontFamily = new FontFamily("Consolas");

            var zero = new FormattedText(
                textToFormat: "0",
                culture: CultureInfo.InstalledUICulture,
                flowDirection: FlowDirection.LeftToRight,
                typeface: new Typeface(normalFontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
                emSize: this.FontSize,
                foreground: Brushes.Black);

            this.fontCharSize = new Size(zero.Width, zero.Height);

            this.document = new FlowDocument
            {
                FontFamily = normalFontFamily,
                FontSize = this.FontSize,
                PagePadding = new Thickness(8.0)
            };

            this.paragraph = new Paragraph();
            this.document.Blocks.Add(this.paragraph);

            this.scrollViewer = new FlowDocumentScrollViewer
            {
                FocusVisualStyle = null,
                Document = this.document
            };

            this.Children.Add(this.scrollViewer);
        }
开发者ID:modulexcite,项目名称:NZag,代码行数:34,代码来源:ZTextBufferWindow.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FontSize类代码示例发布时间:2022-05-24
下一篇:
C# Font类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap