Пример #1
0
        public void DrawString(string str, double x, double y, StringAlignment align, Size layoutRect, StringColorType colorType = StringColorType.Forground)
        {
            TextAlignment TextAlign = TextAlignment.Left;

            switch (align)
            {
            case StringAlignment.Left:
                TextAlign = TextAlignment.Left;
                break;

            case StringAlignment.Center:
                TextAlign = TextAlignment.Center;
                break;

            case StringAlignment.Right:
                TextAlign = TextAlignment.Right;
                break;
            }
            TextLayout layout = new TextLayout(str, this.FontFamily, this.FontSize, this.Brushes[this.ForegroundColor], layoutRect.Width, TextAlign);

            layout.FlowDirection = this.RightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
            layout.Draw(this.Context, x, y);
            layout.Dispose();
        }