110,571
社区成员
发帖
与我相关
我的任务
分享
public void CreatETFPriceFrame(string[] x, int width, int height, Graphics graphics)
{
graphics.Clear(Color.White);
Font font = new Font("Arial", 9, FontStyle.Regular);
LinearGradientBrush lgBrush = new LinearGradientBrush(new Rectangle(0, 0, width, height), Color.Blue, Color.Blue, 1.2f, true);
Pen framePen = new Pen(Color.Blue, 1);
Pen buildPen = new Pen(lgBrush, 1);
int leftX = 60; //最左边的纵线距离图像左边的距离
// 画纵线
for (int i = 0; i < 9; i++)
{
graphics.DrawLine(buildPen, leftX, 50, leftX, height - 32);
leftX += (width - 60 - 50) / 8;
}
//graphics.DrawLine(framePen, width - 50, 50, width - 50, height - 100); //最右边的纵线
int topY = 50; //最上边的横线距离图像顶部的距离
// 画横线
for (int i = 0; i < 8; i++)
{
graphics.DrawLine(buildPen, 60, topY, width - 56, topY);
topY += (height - 50 - 30) / 8;
}
graphics.DrawLine(framePen, 60, topY, width - 56, topY); //最底下的横线
leftX = 35; //最左边文字距离图像左边的距离
// 设置X轴文字内容及输出位置
for (int i = 0; i < x.Length; i++)
{
graphics.DrawString(x[i].ToString(), font, Brushes.Red, leftX, height - 24);
leftX += (width - 60 - 50) / 8;
}
}