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


C# FontFamily类代码示例

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


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


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