/// <summary>
        /// Tworzy linka i ustawia jego właściwości
        /// </summary>
        /// <param name="linkText"></param>
        /// <param name="linkAdress"></param>
        /// <param name="toolTip"></param>
        /// <returns></returns>
        private static Hyperlink CreateHyperLink(string linkText, string linkAdress, string toolTip, FontWeight weight,
                                                 Brush linkColor, RoutedCommand command)
        {
            System.Windows.Controls.ToolTip tip = new ToolTip();
            tip.Content = toolTip;
            tip.StaysOpen = true;

            tip.Style = (Style) Application.Current.FindResource("YellowToolTipStyle");

            Hyperlink hyperlink = new Hyperlink(new Run(linkText))
                                      {
                                          NavigateUri = new Uri(linkAdress),
                                          TextDecorations = null,
                                          FontWeight = weight,
                                          //FontWeights.SemiBold,
                                          Foreground = linkColor,
                                          ToolTip = tip
                                      };

            hyperlink.Command = command;
            hyperlink.CommandParameter = linkAdress;

            ToolTipService.SetInitialShowDelay(hyperlink,700);
            ToolTipService.SetShowDuration(hyperlink,15000);

            //hyperlink.AddHandler(Hyperlink.RequestNavigateEvent,
            //                        new RequestNavigateEventHandler(HyperLinkRequestNavigate));
            return hyperlink;
        }
Exemple #2
0
 public FontHandler(swm.FontFamily family, double size, sw.FontStyle style, sw.FontWeight weight)
 {
     Family        = new FontFamily(new FontFamilyHandler(family));
     Size          = size;
     WpfFontStyle  = style;
     WpfFontWeight = weight;
 }
Exemple #3
0
        public bool DrawString(
            System.Windows.Media.DrawingContext graphics,
            System.Windows.Media.FontFamily fontFamily,
            System.Windows.FontStyle fontStyle,
            System.Windows.FontWeight fontWeight,
            double fontSize,
            string strText,
            System.Windows.Point ptDraw,
            System.Globalization.CultureInfo ci)
        {
            Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci);

            for (int i = 1; i <= m_nThickness; ++i)
            {
                SolidColorBrush solidbrush = new SolidColorBrush(m_clrOutline);

                Pen pen = new Pen(solidbrush, i);
                pen.LineJoin = PenLineJoin.Round;
                if (m_bClrText)
                {
                    SolidColorBrush brush = new SolidColorBrush(m_clrText);
                    graphics.DrawGeometry(brush, pen, path);
                }
                else
                {
                    graphics.DrawGeometry(m_brushText, pen, path);
                }
            }

            return(true);
        }
Exemple #4
0
        /// <summary>
        /// 计算文本显示宽、高
        /// </summary>
        public static MeasureSize MeasureText(string text,
                                              System.Windows.Media.FontFamily fontFamily,
                                              System.Windows.FontStyle fontStyle,
                                              System.Windows.FontWeight fontWeight,
                                              System.Windows.FontStretch fontStretch,
                                              double fontSize)
        {
            System.Windows.Media.Typeface      typeface = new System.Windows.Media.Typeface(fontFamily, fontStyle, fontWeight, fontStretch);
            System.Windows.Media.GlyphTypeface glyphTypeface;
            if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                return(MeasureTextSize(text, fontFamily, fontStyle, fontWeight, fontStretch, fontSize));
            }
            double totalWidth = 0;
            double height     = 0;

            for (int n = 0; n < text.Length; n++)
            {
                ushort glyphIndex  = glyphTypeface.CharacterToGlyphMap[text[n]];
                double width       = glyphTypeface.AdvanceWidths[glyphIndex] * fontSize;
                double glyphHeight = glyphTypeface.AdvanceHeights[glyphIndex] * fontSize;
                if (glyphHeight > height)
                {
                    height = glyphHeight;
                }
                totalWidth += width;
            }
            return(new MeasureSize(totalWidth, height));
        }
Exemple #5
0
        public static FontWeight ToXwtFontWeight(SW.FontWeight value)
        {
            // No, SW.FontWeights is not an enum
            if (value == SW.FontWeights.UltraLight)
            {
                return(FontWeight.Ultralight);
            }
            if (value == SW.FontWeights.Light)
            {
                return(FontWeight.Light);
            }
            if (value == SW.FontWeights.SemiBold)
            {
                return(FontWeight.Semibold);
            }
            if (value == SW.FontWeights.Bold)
            {
                return(FontWeight.Bold);
            }
            if (value == SW.FontWeights.UltraBold)
            {
                return(FontWeight.Ultrabold);
            }
            if (value == SW.FontWeights.Black)
            {
                return(FontWeight.Heavy);
            }

            return(FontWeight.Normal);
        }
Exemple #6
0
 /// <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;
 }
        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();
        }
Exemple #8
0
 public FontHandler(Eto.Generator generator, swm.FontFamily family, double size, sw.FontStyle style, sw.FontWeight weight)
 {
     Family        = new FontFamily(generator, new FontFamilyHandler(family));
     Size          = size;
     WpfFontStyle  = style;
     WpfFontWeight = weight;
 }
Exemple #9
0
        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);
        }
Exemple #10
0
        public bool DrawString(
            System.Windows.Media.DrawingContext graphics,
            System.Windows.Media.FontFamily fontFamily,
            System.Windows.FontStyle fontStyle,
            System.Windows.FontWeight fontWeight,
            double fontSize,
            string strText,
            System.Windows.Point ptDraw,
            System.Globalization.CultureInfo ci)
        {
            Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci);

            if (m_bClrText)
            {
                SolidColorBrush brush = new SolidColorBrush(m_clrText);
                Pen             pen   = new Pen(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), 1.0);
                graphics.DrawGeometry(brush, pen, path);
            }
            else
            {
                Pen pen = new Pen(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), 1.0);
                graphics.DrawGeometry(m_brushText, pen, path);
            }
            return(true);
        }
 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;
 }
 public WpfRichTextBoxWordColoringRule(string text, string textColor, string backgroundColor, FontStyle fontStyle, FontWeight fontWeight)
 {
     Text = text;
     FontColor = textColor;
     BackgroundColor = backgroundColor;
     Style = fontStyle;
     Weight = fontWeight;
 }
 public static HighlightingColor ToHighlightingColor(this Color color, FontWeight? fontWeight = null)
 {
     return new HighlightingColor
     {
         Foreground = new SimpleHighlightingBrush(color),
         FontWeight = fontWeight
     };
 }
 public WpfRichTextBoxRowColoringRule(string condition, string fontColor, string backColor, FontStyle fontStyle, FontWeight fontWeight)
 {
     Condition = condition;
     FontColor = fontColor;
     BackgroundColor = backColor;
     Style = fontStyle;
     Weight = fontWeight;
 }
 public WpfFontFamilyInfo(FontFamily family, FontWeight weight, 
     FontStyle style, FontStretch stretch)
 {
     _family  = family;
     _weight  = weight;
     _style   = style;
     _stretch = stretch;
 }
 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;
 }
 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;
 }
        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;
        }
Exemple #19
0
 void avAddressCtrl_Loaded(object sender, EventArgs e)
 {
     initBackBrush  = (SolidColorBrush)wpfAddressCtrl.MyControl_Background;
     initForeBrush  = wpfAddressCtrl.MyControl_Foreground;
     initFontFamily = wpfAddressCtrl.MyControl_FontFamily;
     initFontSize   = wpfAddressCtrl.MyControl_FontSize;
     initFontWeight = wpfAddressCtrl.MyControl_FontWeight;
     initFontStyle  = wpfAddressCtrl.MyControl_FontStyle;
 }
Exemple #20
0
 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 ()
     };
 }
        public static Size GetScreenSize(this string text, FontFamily fontFamily, double fontSize, FontStyle fontStyle, FontWeight fontWeight, FontStretch fontStretch) {
            fontFamily = fontFamily ?? new TextBlock().FontFamily;
            fontSize = fontSize > 0 ? fontSize : new TextBlock().FontSize;

            var typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);
            var ft = new FormattedText(text ?? string.Empty, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, fontSize, Brushes.Black);

            return new Size(ft.Width, ft.Height);
        }
Exemple #22
0
 void avAddressCtrl_Loaded(object sender, EventArgs e)
 {
     initBackBrush = (SolidColorBrush)wpfAddressCtrl.MyControl_Background;
     initForeBrush = wpfAddressCtrl.MyControl_Foreground;
     initFontFamily = wpfAddressCtrl.MyControl_FontFamily;
     initFontSize = wpfAddressCtrl.MyControl_FontSize;
     initFontWeight = wpfAddressCtrl.MyControl_FontWeight;
     initFontStyle = wpfAddressCtrl.MyControl_FontStyle;
 }
Exemple #23
0
		public FontInfo(FontFamily fam, double sz, FontStyle style, FontStretch strc, FontWeight weight, SolidColorBrush c)
		{
			this.Family = fam;
			this.Size = sz;
			this.Style = style;
			this.Stretch = strc;
			this.Weight = weight;
			this.BrushColor = c;
		}
 void Reset()
 {
     root.Blocks.Clear();
     currentFontStyle = FontStyles.Normal;
     currentFontWeight = FontWeights.Normal;
     currentUnderline = false;
     currentStrike = false;
     isHyperlink = false;
 }
Exemple #25
0
 public MapCell(string text, Brush foreground, Brush background, FontWeight bold, Color yorishiroColor)
 {
     this.Text = text;
     this.Foreground = foreground;
     this.Background = background;
     this.fontWeight = bold;
     this.YorishiroColor = yorishiroColor;
     this.AttributeColor = Colors.Transparent;
 }
Exemple #26
0
 private void avAddressCtrl_Loaded(object sender, EventArgs e)
 {
     _initBackBrush = _wpfAddressCtrl.MyControlBackground;
     _initForeBrush = _wpfAddressCtrl.MyControlForeground;
     _initFontFamily = _wpfAddressCtrl.MyControlFontFamily;
     _initFontSize = _wpfAddressCtrl.MyControlFontSize;
     _initFontWeight = _wpfAddressCtrl.MyControlFontWeight;
     _initFontStyle = _wpfAddressCtrl.MyControlFontStyle;
 }
Exemple #27
0
 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;
 }
Exemple #28
0
 public Font(FontFamily family, double size, FontStretch stretch, FontStyle style, FontWeight weight, Color foreground)
     : this()
 {
     this.Family = family;
     this.Size = size;
     this.Stretch = stretch;
     this.Style = style;
     this.Weight = weight;
     this.Foreground = foreground;
 }
 public FontStyleData(string name, FontStyle fontStyle, FontWeight fontWeight, TextDecorationLocation? textDecoration, FontVariants fontVariant, FontCapitals fontCapitals, double fontSize)
 {
     _name = name;
     _fontStyle = fontStyle;
     _fontWeight = fontWeight;
     _textDecoration = textDecoration;
     _fontVariant = fontVariant;
     _fontCapitals = fontCapitals;
     _fontSize = fontSize;
 }
Exemple #30
0
 public static Size MeasureText(string text, FontFamily fontFamily, FontStyle fontStyle, FontWeight fontWeight, FontStretch fontStretch, double fontSize)
 {
     FormattedText ft = new FormattedText(text,
                                          CultureInfo.CurrentCulture,
                                          FlowDirection.LeftToRight,
                                          new Typeface(fontFamily, fontStyle, fontWeight, fontStretch),
                                          fontSize,
                                          Brushes.Black);
     return new Size(ft.Width, ft.Height);
 }
Exemple #31
0
        public static SW.FontWeight ToWpfFontWeight(FontWeight value)
        {
            if (value == FontWeight.Ultralight) return SW.FontWeights.UltraLight;
            if (value == FontWeight.Light) return SW.FontWeights.Light;
            if (value == FontWeight.Semibold) return SW.FontWeights.SemiBold;
            if (value == FontWeight.Bold) return SW.FontWeights.Bold;
            if (value == FontWeight.Ultrabold) return SW.FontWeights.UltraBold;
            if (value == FontWeight.Heavy) return SW.FontWeights.Black;

            return SW.FontWeights.Normal;
        }
Exemple #32
0
        internal static IDictionary<XmlLanguage, string> ConstructFaceNamesByStyleWeightStretch(
            FontStyle style,
            FontWeight weight,
            FontStretch stretch)
        {
            string faceName = BuildFaceName(style, weight, stretch);

            // Default comparer calls CultureInfo.Equals, which works for our purposes.
            Dictionary<XmlLanguage, string> faceNames = new Dictionary<XmlLanguage, string>(1);
            faceNames.Add(XmlLanguage.GetLanguage("en-us"), faceName);
            return faceNames;
        }
Exemple #33
0
        private static string BuildFaceName(
            FontStyle fontStyle,
            FontWeight fontWeight,
            FontStretch fontStretch
            )
        {
            string parsedStyleName   = null;
            string parsedWeightName  = null;
            string parsedStretchName = null;
            string regularFaceName   = "Regular";
            if (fontWeight != FontWeights.Normal)
                parsedWeightName = ((IFormattable)fontWeight).ToString(null, CultureInfo.InvariantCulture);

            if (fontStretch != FontStretches.Normal)
                parsedStretchName = ((IFormattable)fontStretch).ToString(null, CultureInfo.InvariantCulture);

            if (fontStyle != FontStyles.Normal)
                parsedStyleName = ((IFormattable)fontStyle).ToString(null, CultureInfo.InvariantCulture);

            // Build correct face string.
            // Set the initial capacity to be able to hold the word "Regular".
            StringBuilder faceNameBuilder = new StringBuilder(7);

            if (parsedStretchName != null)
            {
                faceNameBuilder.Append(parsedStretchName);
            }

            if (parsedWeightName != null)
            {
                if (faceNameBuilder.Length > 0)
                {
                    faceNameBuilder.Append(" ");
                }
                faceNameBuilder.Append(parsedWeightName);
            }

            if (parsedStyleName != null)
            {
                if (faceNameBuilder.Length > 0)
                {
                    faceNameBuilder.Append(" ");
                }
                faceNameBuilder.Append(parsedStyleName);
            }

            if (faceNameBuilder.Length == 0)
            {
                faceNameBuilder.Append(regularFaceName);
            }

            return faceNameBuilder.ToString();
        }         
 internal MatchingStyle(
     FontStyle       style,
     FontWeight      weight,
     FontStretch     stretch
     )
 {
     _vector = new Vector(
         (stretch.ToOpenTypeStretch() - FontStretches.Normal.ToOpenTypeStretch()) * FontStretchScale,
         style.GetStyleForInternalConstruction() * FontStyleScale,
         (weight.ToOpenTypeWeight() - FontWeights.Normal.ToOpenTypeWeight()) / 100.0 * FontWeightScale
         );
 }
Exemple #35
0
 public TrayIconRenderer()
 {
     this.iconSize = System.Windows.Forms.SystemInformation.IconSize.Height / 2;
     double scalingFactor = this.iconSize / DefaultTrayIconSize;
     this.fontSize = DefaultTrayFontSize * scalingFactor;
     this.foreground = new SolidColorBrush(Colors.White);
     this.CultureInfo = new CultureInfo("en-us");
     this.fontFamily = new FontFamily(DefaultFontFamily);
     this.fontStyle = FontStyles.Normal;
     this.fontWeight = FontWeights.SemiBold;
     UpdateTypeface();
 }
Exemple #36
0
        /// <summary>
        /// Creates a typeface.
        /// </summary>
        public static Typeface CreateTypeface(WpfFontFamily family, XFontStyle style)
        {
            // BUG: does not work with fonts that have others than the four default styles
            WpfFontStyle  fontStyle  = FontStyleFromStyle(style);
            WpfFontWeight fontWeight = FontWeightFromStyle(style);

#if !SILVERLIGHT
            WpfTypeface typeface = new WpfTypeface(family, fontStyle, fontWeight, FontStretches.Normal);
#else
            WpfTypeface typeface = null;
#endif
            return(typeface);
        }
Exemple #37
0
        public FontTypeface GetFamilyTypeface(sw.FontStyle fontStyle, sw.FontWeight fontWeight)
        {
            var typefaces = Control.GetTypefaces();

            foreach (var type in typefaces)
            {
                if (type.Style == fontStyle && type.Weight == fontWeight)
                {
                    return(new FontTypeface(Widget, new FontTypefaceHandler(type)));
                }
            }
            return(new FontTypeface(Widget, new FontTypefaceHandler(typefaces.First())));
        }
 public TextFormat(double size, FontType ft, FontStyle fs, FontWeight fw, SolidColorBrush brush, bool useUnderline)
 {
     this.FontSize = Math.Round(size, 1);
     this.FontType = ft;
     this.FontFamily = FontFactory.GetFontFamily(ft);
     this.FontStyle = fs;
     this.UseUnderline = useUnderline;
     this.FontWeight = fw;
     this.TextBrush = brush;
     this.TypeFace = new Typeface(FontFamily, fs, fw, FontStretches.Normal, FontFactory.GetFontFamily(FontType.STIXGeneral));
     BrushConverter bc = new BrushConverter();
     TextBrushString = bc.ConvertToString(brush);
 }
Exemple #39
0
 public static double MeasureTextWidth(string text, double fontSize, string fontFamily, FontWeight fontWeight)
 {
     var formattedText = new FormattedText(
         text,
         System.Globalization.CultureInfo.InvariantCulture,
         FlowDirection.LeftToRight,
         new Typeface(fontFamily.ToString()),
         fontSize,
         Brushes.Black
     );
     formattedText.SetFontWeight(fontWeight);
     return formattedText.WidthIncludingTrailingWhitespace;
 }
Exemple #40
0
        public bool DrawString(
            System.Windows.Media.DrawingContext graphics,
            System.Windows.Media.FontFamily fontFamily,
            System.Windows.FontStyle fontStyle,
            System.Windows.FontWeight fontWeight,
            double fontSize,
            string strText,
            System.Windows.Point ptDraw,
            System.Globalization.CultureInfo ci)
        {
            int nOffset = Math.Abs(m_nOffsetX);

            if (Math.Abs(m_nOffsetX) == Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetX);
            }
            else if (Math.Abs(m_nOffsetX) > Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetY);
            }
            else if (Math.Abs(m_nOffsetX) < Math.Abs(m_nOffsetY))
            {
                nOffset = Math.Abs(m_nOffsetX);
            }

            for (int i = 0; i < nOffset; ++i)
            {
                Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize,
                                                           new Point(ptDraw.X + ((i * (-m_nOffsetX)) / nOffset), ptDraw.Y + ((i * (-m_nOffsetY)) / nOffset)), ci);

                SolidColorBrush solidbrush = new SolidColorBrush(m_clrOutline);

                Pen pen = new Pen(solidbrush, m_nThickness);
                pen.LineJoin = PenLineJoin.Round;

                if (m_bClrText)
                {
                    SolidColorBrush brush = new SolidColorBrush(m_clrText);
                    graphics.DrawGeometry(brush, pen, path);
                }
                else
                {
                    graphics.DrawGeometry(m_brushText, pen, path);
                }
            }

            return(true);
        }
Exemple #41
0
 /// <summary>
 /// 计算文本显示宽、高
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="fontFamily">The font family.</param>
 /// <param name="fontStyle">The font style.</param>
 /// <param name="fontWeight">The font weight.</param>
 /// <param name="fontStretch">The font stretch.</param>
 /// <param name="fontSize">Size of the font.</param>
 /// <returns></returns>
 public static MeasureSize MeasureTextSize(
     string text,
     System.Windows.Media.FontFamily fontFamily,
     System.Windows.FontStyle fontStyle,
     System.Windows.FontWeight fontWeight,
     System.Windows.FontStretch fontStretch,
     double fontSize)
 {
     System.Windows.Media.FormattedText ft = new System.Windows.Media.FormattedText(text,
                                                                                    System.Globalization.CultureInfo.CurrentCulture,
                                                                                    System.Windows.FlowDirection.LeftToRight,
                                                                                    new System.Windows.Media.Typeface(fontFamily, fontStyle, fontWeight, fontStretch),
                                                                                    fontSize,
                                                                                    System.Windows.Media.Brushes.Black);
     return(new MeasureSize(ft.Width, ft.Height));
 }
Exemple #42
0
        public static FontStyle Convert(sw.FontStyle fontStyle, sw.FontWeight fontWeight)
        {
            var style = FontStyle.None;

            if (fontStyle == sw.FontStyles.Italic)
            {
                style |= FontStyle.Italic;
            }
            if (fontStyle == sw.FontStyles.Oblique)
            {
                style |= FontStyle.Italic;
            }
            if (fontWeight == sw.FontWeights.Bold)
            {
                style |= FontStyle.Bold;
            }
            return(style);
        }
        public Rect MeasureString(
            System.Windows.Media.DrawingContext graphics,
            System.Windows.Media.FontFamily fontFamily,
            System.Windows.FontStyle fontStyle,
            System.Windows.FontWeight fontWeight,
            double fontSize,
            string strText,
            System.Windows.Point ptDraw,
            System.Globalization.CultureInfo ci,
            ref double fStartX,
            ref double fStartY,
            ref double fDestWidth,
            ref double fDestHeight)
        {
            Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci);

            Pen pen = new Pen(new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)), m_nThickness1 + m_nThickness2);

            return(path.GetRenderBounds(pen));
        }
Exemple #44
0
        public bool DrawString(
            System.Windows.Media.DrawingContext graphics,
            System.Windows.Media.FontFamily fontFamily,
            System.Windows.FontStyle fontStyle,
            System.Windows.FontWeight fontWeight,
            double fontSize,
            string strText,
            System.Windows.Point ptDraw,
            System.Globalization.CultureInfo ci)
        {
            Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci);

            SolidColorBrush solidbrush = new SolidColorBrush(m_clrOutline);
            Pen             pen        = new Pen(solidbrush, m_nThickness);

            pen.LineJoin = PenLineJoin.Round;
            SolidColorBrush transbrush = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

            graphics.DrawGeometry(transbrush, pen, path);

            return(true);
        }
Exemple #45
0
        public bool DrawString(
            System.Windows.Media.DrawingContext graphics,
            System.Windows.Media.FontFamily fontFamily,
            System.Windows.FontStyle fontStyle,
            System.Windows.FontWeight fontWeight,
            double fontSize,
            string strText,
            System.Windows.Point ptDraw,
            System.Globalization.CultureInfo ci)
        {
            Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci);

            List <Color> list = new List <Color>();

            CalculateGradient(
                m_clrOutline1,
                m_clrOutline2,
                m_nThickness,
                list);

            for (int i = m_nThickness; i >= 1; --i)
            {
                SolidColorBrush solidbrush = new SolidColorBrush(list[i - 1]);

                Pen pen1 = new Pen(solidbrush, i);
                pen1.LineJoin = PenLineJoin.Round;
                if (m_bClrText)
                {
                    SolidColorBrush brush = new SolidColorBrush(m_clrText);
                    graphics.DrawGeometry(brush, pen1, path);
                }
                else
                {
                    graphics.DrawGeometry(m_brushText, pen1, path);
                }
            }

            return(true);
        }
 public static int Compare(FontWeight left, FontWeight right)
 {
     return(default(int));
 }
 public static T FontWeight <T>(this T target, FontWeight value) where T : DataGridTextColumn
 {
     target.FontWeight = value;
     return(target);
 }
 public bool Equals(FontWeight obj)
 {
     return(default(bool));
 }
Exemple #49
0
 /// <summary>
 /// Checks whether the object is equal to another FontWeight object.
 /// </summary>
 /// <param name="obj">FontWeight object to compare with.</param>
 /// <returns>Returns true when the object is equal to the input object,
 /// and false otherwise.</returns>
 public bool Equals(FontWeight obj)
 {
     return(this == obj);
 }
Exemple #50
0
 /// <summary>
 /// Compares two font weight values and returns an indication of their relative values.
 /// </summary>
 /// <param name="left">First object to compare.</param>
 /// <param name="right">Second object to compare.</param>
 /// <returns>A 32-bit signed integer indicating the lexical relationship between the two comparands.
 /// When the return value is less than zero this means that left is less than right.
 /// When the return value is zero this means that left is equal to right.
 /// When the return value is greater than zero this means that left is greater than right.
 /// </returns>
 public static int Compare(FontWeight left, FontWeight right)
 {
     return(left._weight - right._weight);
 }
 public static TextBlock FontWeight(this TextBlock target, FontWeight weight)
 {
     target.FontWeight = weight;
     return(target);
 }