这一节的内容,不难,但是很重要。在SDX中使用字体,是应用程序经常会用到的的实际功能。
基本操作过程如下:
声明资源 — 初始化 — 打印
代码如下:
TxFactory txFactory;
TextFormat txTittleFormat;
RawRectangleF txTittleRectf;
SolidColorBrush txTittleBrush;
txFactory = new TxFactory();
txTittleFormat = new TextFormat(txFactory, PlotProperty.TittleFont.Name, PlotProperty.TittleFont.Size)
{ TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center };
txTittleBrush = new SolidColorBrush(dxTarget, dxc.ToColor4(PlotProperty.TittleColor));
txTittleRectf = new RawRectangleF(1, 1, Width - 1, pymax - 1);
txFormat = new TextFormat(txFactory, PlotProperty.AxisFont.Name, PlotProperty.AxisFont.Size)
{ TextAlignment = TextAlignment.Trailing, ParagraphAlignment = ParagraphAlignment.Center };
txBrush = new SolidColorBrush(dxTarget, dxc.ToColor4(PlotProperty.AxisTextColor));
txRectf = new RawRectangleF(1, 1, pxmin-5, pymax);
mkrTextFormat = new TextFormat(txFactory, PlotProperty.MarkerFont.Name, PlotProperty.MarkerFont.Size)
{ TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center };
dxTarget.DrawText(PlotProperty.TittleText, txTittleFormat, txTittleRectf, txTittleBrush);