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

C# Media.Typeface类代码示例

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

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



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

示例1: DrawHelpText

        /// <summary>
        /// Draw some helpful text.
        /// </summary>
        /// <param name="dc"></param>
        protected virtual void DrawHelpText(DrawingContext dc)
        {
            System.Windows.Media.Typeface backType =
                new System.Windows.Media.Typeface(new System.Windows.Media.FontFamily("sans courier"),
                                                  FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
            System.Windows.Media.FormattedText formatted = new System.Windows.Media.FormattedText(
                                                            "Click & move the mouse to select a capture area.\nENTER/F10: Capture\nBACKSPACE/DEL: Start over\nESC: Exit",
                                                            System.Globalization.CultureInfo.CurrentCulture,
                                                            FlowDirection.LeftToRight,
                                                            backType,
                                                            32.0f,
                                                            new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White));
            // Make sure the text shows at 0,0 on the primary screen
            System.Drawing.Point primScreen = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Location;
            Point clientBase = PointFromScreen(new Point(primScreen.X + 5, primScreen.Y + 5));
            Geometry textGeo = formatted.BuildGeometry(clientBase);
            dc.DrawGeometry(
                System.Windows.Media.Brushes.White,
                null,
                textGeo);

            dc.DrawGeometry(
                null,
                new System.Windows.Media.Pen(System.Windows.Media.Brushes.White, 1),
                textGeo);
        }
开发者ID:biki3507,项目名称:FreeCapture,代码行数:30,代码来源:CaptureSurface.cs


示例2: FontInfo

 public FontInfo(String Name, double Size, FontFamily Family)
 {
     this.Name = Name;
     this.Size = Size;
     
     this.Family = Family;
     this.Typeface = Family.GetTypefaces().First();
     
 }
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:9,代码来源:FontInfo.cs


示例3: ValueToProcessConverter

 static ValueToProcessConverter()
 {
     NormalBrush = new SolidColorBrush(Colors.Orange);
     WarnBrush = new SolidColorBrush(Colors.White);
     TextBrush = new SolidColorBrush(Color.FromRgb(0x74,0x74,0x74));
     SuccessRateTypeface = new Typeface(new FontFamily("MSYH"), new FontStyle(), new FontWeight(), new FontStretch());
 }
开发者ID:lee-icebow,项目名称:CREM.EVO,代码行数:7,代码来源:ValueToProcessConverter.cs


示例4: Font

 /// <summary>Creates a new <see cref="Font"/> instance from the given typeface and size.</summary>
 public Font(Typeface typeface, double fontSize) {
    Family = typeface.FontFamily;
    Size = fontSize;
    Stretch = typeface.Stretch;
    Style = typeface.Style;
    Weight = typeface.Weight;
 }
开发者ID:borkaborka,项目名称:gmit,代码行数:8,代码来源:Font.cs


示例5: GoBoardPainter

        public GoBoardPainter()
        {
            Resources.Source = new Uri("pack://application:,,,/gui_wpf;component/GoBoardPainterResources.xaml");

            m_BlackStoneBrush = (Brush)TryFindResource("blackStoneBrush");
            m_WhiteStoneBrush = (Brush)TryFindResource("whiteStoneBrush");
            m_BoardBrush = (Brush)TryFindResource("boardBrush");
            m_StoneShadowBrush = (Brush)TryFindResource("stoneShadowBrush");
            m_WhiteStoneAnnotationPen = (Pen)TryFindResource("whiteStoneAnnotationPen");
            m_BlackStoneAnnotationPen = (Pen)TryFindResource("blackStoneAnnotationPen");
            m_BoardBlackPen = (Pen)TryFindResource("boardBlackPen");
            m_BlackPen = (Pen)TryFindResource("blackPen");
            m_RedPen = (Pen)TryFindResource("redPen");
            m_BlackStoneShadowBrush = (Brush)TryFindResource("blackStoneShadowBrush");
            m_WhiteStoneShadowBrush = (Brush)TryFindResource("whiteStoneShadowBrush");

            m_BoardTypeface = new Typeface("Arial");
            KoPoint.X = -1;
            LastMove.X = -1;
            ForbiddenMove.X = -1;
            DisplayCountedStones = false;
            DisplayMouseOver = true;

            InitializeBoard(this.BoardSize - 1);

            // init tick for clock update
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(100);
            timer.Tick += timer_Tick;
            timer.Start();
        }
开发者ID:nyoshi,项目名称:strasgo,代码行数:31,代码来源:GoBoardPainter.cs


示例6: TypefaceListItem

        public TypefaceListItem(Typeface typeface)
        {
            _displayName = GetDisplayName(typeface);
            _simulated = typeface.IsBoldSimulated || typeface.IsObliqueSimulated;

            this.FontFamily = typeface.FontFamily;
            this.FontWeight = typeface.Weight;
            this.FontStyle = typeface.Style;
            this.FontStretch = typeface.Stretch;

            string itemLabel = _displayName;

            //if (_simulated)
            //{
            //    string formatString = EpiDashboard.Properties.Resources.ResourceManager.GetString(
            //        "simulated",
            //        CultureInfo.CurrentUICulture
            //        );
            //    itemLabel = string.Format(formatString, itemLabel);
            //}

            this.Text = itemLabel;
            this.ToolTip = itemLabel;

            // In the case of symbol font, apply the default message font to the text so it can be read.
            if (FontFamilyListItem.IsSymbolFont(typeface.FontFamily))
            {
                TextRange range = new TextRange(this.ContentStart, this.ContentEnd);
                range.ApplyPropertyValue(TextBlock.FontFamilyProperty, SystemFonts.MessageFontFamily);
            }
        }
开发者ID:NALSS,项目名称:epiinfo-82474,代码行数:31,代码来源:TypefaceListItem.cs


示例7: Transform

		public override void Transform()
		{
			base.Transform();
			IElementTextBlock elementText = (IElementTextBlock)Element;
			var height = Rect.Height > Element.BorderThickness ? Rect.Height - Element.BorderThickness : 0;
			var width = Rect.Width > Element.BorderThickness ? Rect.Width - Element.BorderThickness : 0;
			Rect bound = new Rect(Rect.Left + Element.BorderThickness / 2, Rect.Top + Element.BorderThickness / 2, width, height);
			var typeface = new Typeface(new FontFamily(elementText.FontFamilyName), elementText.FontItalic ? FontStyles.Italic : FontStyles.Normal, elementText.FontBold ? FontWeights.Bold : FontWeights.Normal, new FontStretch());
			var formattedText = new FormattedText(elementText.Text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, elementText.FontSize, PainterCache.BlackBrush);
			formattedText.TextAlignment = (TextAlignment)elementText.TextAlignment;
			Point point = bound.TopLeft;
			switch (formattedText.TextAlignment)
			{
				case TextAlignment.Right:
					point = bound.TopRight;
					break;
				case TextAlignment.Center:
					point = new Point(bound.Left + bound.Width / 2, bound.Top);
					break;
			}
			if (_clipGeometry != null)
				_clipGeometry.Rect = bound;
			if (_scaleTransform != null)
			{
				_scaleTransform.CenterX = point.X;
				_scaleTransform.CenterY = point.Y;
				_scaleTransform.ScaleX = bound.Width / formattedText.Width;
				_scaleTransform.ScaleY = bound.Height / formattedText.Height;
			}
			_textDrawing.Geometry = formattedText.BuildGeometry(point);
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:31,代码来源:TextBlockPainter.cs


示例8: TypefaceListItem

        public TypefaceListItem(Typeface typeface)
        {
            _displayName = GetDisplayName(typeface);
            _simulated = typeface.IsBoldSimulated || typeface.IsObliqueSimulated;

            FontFamily = typeface.FontFamily;
            FontWeight = typeface.Weight;
            FontStyle = typeface.Style;
            FontStretch = typeface.Stretch;

            var itemLabel = _displayName;

            if (_simulated)
            {
                var formatString = Properties.Resources.ResourceManager.GetString(
                    "simulated",
                    CultureInfo.CurrentUICulture
                    );
                itemLabel = string.Format(formatString, itemLabel);
            }

            Text = itemLabel;
            ToolTip = itemLabel;

            // In the case of symbol font, apply the default message font to the text so it can be read.
            if (FontFamilyListItem.IsSymbolFont(typeface.FontFamily))
            {
                var range = new TextRange(ContentStart, ContentEnd);
                range.ApplyPropertyValue(FontFamilyProperty, SystemFonts.MessageFontFamily);
            }
        }
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:31,代码来源:TypefaceListItem.cs


示例9: GetPage

        public override DocumentPage GetPage(int pageNumber)
        {
            // Get the requested page.
            DocumentPage page = flowDocumentPaginator.GetPage(pageNumber);

            // Wrap the page in a Visual. You can then add a transformation and extras.
            ContainerVisual newVisual = new ContainerVisual();
            newVisual.Children.Add(page.Visual);

            // Create a header. 
            DrawingVisual header = new DrawingVisual();
            using (DrawingContext context = header.RenderOpen())
            {
                Typeface typeface = new Typeface("Times New Roman");                
                FormattedText text = new FormattedText("Page " + (pageNumber + 1).ToString(),
                  CultureInfo.CurrentCulture, FlowDirection.LeftToRight,
                  typeface, 14, Brushes.Black);
                
                // Leave a quarter-inch of space between the page edge and this text.
                context.DrawText(text, new Point(96*0.25, 96*0.25));
            }
            // Add the title to the visual.
            newVisual.Children.Add(header);

            // Wrap the visual in a new page.
            DocumentPage newPage = new DocumentPage(newVisual);
            return newPage;            
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:28,代码来源:HeaderedFlowDocumentPaginator.cs


示例10: CalculateIsTextTrimmed

        /// <summary>
        ///     Determines whether or not the text in <paramref name="textBlock" /> is currently being
        ///     trimmed due to width or height constraints.
        /// </summary>
        /// <remarks>Does not work properly when TextWrapping is set to WrapWithOverflow.</remarks>
        /// <param name="textBlock"><see cref="TextBlock" /> to evaluate</param>
        /// <returns><c>true</c> if the text is currently being trimmed; otherwise <c>false</c></returns>
        static bool CalculateIsTextTrimmed(TextBlock textBlock) {
            if (!textBlock.IsArrangeValid)
                return GetIsTextTrimmed(textBlock);

            var typeface = new Typeface(
                textBlock.FontFamily,
                textBlock.FontStyle,
                textBlock.FontWeight,
                textBlock.FontStretch);

            // FormattedText is used to measure the whole width of the text held up by TextBlock container
            var formattedText = new FormattedText(
                textBlock.Text,
                Thread.CurrentThread.CurrentCulture,
                textBlock.FlowDirection,
                typeface,
                textBlock.FontSize,
                textBlock.Foreground) {MaxTextWidth = textBlock.ActualWidth};

            // When the maximum text width of the FormattedText instance is set to the actual
            // width of the textBlock, if the textBlock is being trimmed to fit then the formatted
            // text will report a larger height than the textBlock. Should work whether the
            // textBlock is single or multi-line.
            return formattedText.Height > textBlock.ActualHeight;
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:32,代码来源:TextBlockTrimmedTooltip.cs


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


示例12: GetTypeface

        public static Typeface GetTypeface() {
            if (typeface == null) {
                typeface = CreateTypeface();
            }

            return typeface;
        }
开发者ID:mmalek06,项目名称:FunkyCodeEditor,代码行数:7,代码来源:TextConfiguration.cs


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


示例14: CreateTypeface

 /// <summary>
 /// Creates a typeface.
 /// </summary>
 public static Typeface CreateTypeface(XFontFamily family, XFontStyle style)
 {
   FontStyle fontStyle = FontStyleFromStyle(style);
   FontWeight fontWeight = FontWeightFromStyle(style);
   Typeface typeface = new Typeface(family.wpfFamily, fontStyle, fontWeight, FontStretches.Normal);
   return typeface;
 }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:10,代码来源:FontHelper.cs


示例15: Convert

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var list = value as IReadOnlyCollection<FontFamily>;

            if (list == null)
                return DependencyProperty.UnsetValue;

            var returnList = new List<FontFamily>();
            foreach (FontFamily font in list)
            {
                try
                {
                    // Instantiate a TypeFace object with the font settings you want to use
                    Typeface ltypFace = new Typeface(font, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);

                    // Try to create a GlyphTypeface object from the TypeFace object
                    GlyphTypeface lglyphTypeFace;
                    if (ltypFace.TryGetGlyphTypeface(out lglyphTypeFace))
                    {
                        returnList.Add(font);
                    }
                }
                catch (Exception) {}
            }

            return returnList;
        }
开发者ID:dbremner,项目名称:ScreenToGif,代码行数:27,代码来源:FontToSupportedGliph.cs


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


示例17: DrawVisualThumbnail

        protected override void DrawVisualThumbnail(System.Windows.Media.DrawingContext drawingContext, out string title, ref BitmapSource icon)
        {
            var aeroColor = (Color)Application.Current.Resources["AeroColor"];
            var aeroBrush = new SolidColorBrush(aeroColor);
            var aeroPen = new Pen(aeroBrush, 7);

            var grayBrush = new SolidColorBrush(Color.FromArgb(255, 0xaf, 0xaf, 0xaf));

            var fontFamily = (FontFamily)Application.Current.Resources["CuprumFont"];
            var typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Light, FontStretches.Normal);

            const int sourceTextOffset = VisualThumbnailMargin;

            var sourceText = new FormattedText(Name, CultureInfo.CurrentCulture, FlowDirection.LeftToRight,
                                         typeface, 14, grayBrush);
            sourceText.MaxTextWidth = VisualThumbnailWidth - sourceTextOffset - VisualThumbnailMargin;
            sourceText.MaxTextHeight = 32;

            var imageRectangle = new Rect(VisualThumbnailWidth / 2 - 64 / 2, VisualThumbnailHeight / 2 - 64 / 2, 64, 64);

            drawingContext.DrawRectangle(Brushes.White, aeroPen, new Rect(-1, -1, VisualThumbnailWidth + 2, VisualThumbnailHeight + 2));
            drawingContext.DrawImage(Icon, imageRectangle);

            drawingContext.DrawText(sourceText, new Point(sourceTextOffset, VisualThumbnailHeight - VisualThumbnailMargin - 16));

            title = Name + " from " + Source.ApplicationName;
        }
开发者ID:Zargess,项目名称:Shapeshifter-old,代码行数:27,代码来源:ClipboardCustomData.cs


示例18: GenericTextRunProperties

        public GenericTextRunProperties(
            Typeface typeface,
            double size,
            double hintingSize,
            TextDecorationCollection textDecorations,
            Brush forgroundBrush,
            Brush backgroundBrush,
            BaselineAlignment baselineAlignment,
            TextEffectCollection textEffects,
            CultureInfo culture)
        {
            if (typeface == null)
                throw new ArgumentNullException("typeface");

            ValidateCulture(culture);

            _typeface = typeface;
            _emSize = size;
            _emHintingSize = hintingSize;
            _textDecorations = textDecorations;
            _foregroundBrush = forgroundBrush;
            _backgroundBrush = backgroundBrush;
            _baselineAlignment = baselineAlignment;
            _textEffects = textEffects;
            _culture = culture;
        }
开发者ID:erdao,项目名称:Temp,代码行数:26,代码来源:GenericTextRunProperties.cs


示例19: ChatFormatter

		public ChatFormatter(Typeface typeface, double fontSize, Brush foreground, IDictionary<string,Brush> palette)
		{
			_runProperties = new CustomTextRunProperties(typeface, fontSize, foreground, Brushes.Transparent, false);
			_paraProperties = new CustomParagraphProperties(_runProperties);
			_formatter = TextFormatter.Create(TextFormattingMode.Display);
			_palette = palette;
		}
开发者ID:derrickcreamer,项目名称:Floe,代码行数:7,代码来源:ChatFormatter.cs


示例20: Measure

        public Size Measure(string text, double fontSize, Typeface typeface, double maxWidth)
        {
            if (htmlElement == null)
            {
                htmlElement = Document.CreateElement("div");
                style = new HtmlStyleDictionary(htmlElement);

                Document.Body.AppendChild(htmlElement);
            }

            style.SetValue("position", "absolute");
            style.SetValue("visibility", "hidden");
            style.SetFontSize(fontSize, converter);
            style.SetFontFamily(typeface.FontFamily, converter);
            style.SetFontStretch(typeface.Stretch, converter);
            style.SetFontStyle(typeface.Style, converter);
            style.SetFontWeight(typeface.Weight, converter);

            if (maxWidth.IsNaN() || !Double.IsFinite(maxWidth))
            {
                style.SetTextWrapping(TextWrapping.NoWrap, converter);
                style.ClearValue("max-width");
            }
            else
            {
                style.SetTextWrapping(TextWrapping.Wrap, converter);
                style.SetValue("max-width", converter.ToPixelString(maxWidth));
            }

            style.Apply();

            htmlElement.InnerHTML = converter.ToHtmlContentString(text.DefaultIfNullOrEmpty("A"));

            return new Size(text.IsNullOrEmpty() ? 0 : htmlElement.OffsetWidth + 2, htmlElement.OffsetHeight);
        }
开发者ID:highzion,项目名称:Granular,代码行数:35,代码来源:TextMeasurementService.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Media.VideoBrush类代码示例发布时间:2022-05-26
下一篇:
C# Media.TranslateTransform类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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