public override ValueSize MeasureString(String s, IFont font)
        {
            var useFont = GdiTypeConverter.GetFont(font);
            var sz      = Graphics.MeasureString(s, useFont);

            return(new ValueSize(sz.Width, sz.Height));
        }
Пример #2
0
        public override void DrawString <TFont, TBrush, TRectangle>(String s,
                                                                    TFont font,
                                                                    TRectangle location,
                                                                    TBrush brush)
        {
            var rect = GetAbsoluteGdiRectangle(location);

            var useBrush = GdiTypeConverter.GetBrush(brush);
            var useFont  = GdiTypeConverter.GetFont(font);

            Graphics.DrawString(s, useFont, useBrush, rect, StringFormat.GenericDefault);
            // text renderer doesn't wrap the text
            //TextRenderer.DrawText(Graphics, s, useFont, rect, color);
        }
Пример #3
0
        public override void DrawString <TFont, TBrush, TPoint>(String s,
                                                                TFont font,
                                                                TBrush brush,
                                                                TPoint location)
        {
            var loc = GetAbsoluteGdiPoint(location);

            if (!(brush is SolidColorBrush scb))
            {
                throw new NotSupportedException(nameof(DrawString) +
                                                " - " + brush);
            }

            var color   = GdiTypeConverter.GetColor(scb.Color);
            var useFont = GdiTypeConverter.GetFont(font);

            TextRenderer.DrawText(Graphics, s, useFont, loc, color,
                                  TextFormatFlags.PreserveGraphicsClipping);
        }