误打误撞
本来想画方格图,结果成这样
代码如下:
private void PaintMe()
{
int tWidth = this.Width;
int tHeight = this.Height;
Graphics g = this.CreateGraphics();
g.FillRectangle(new SolidBrush(this.BackColor), 0, 0, tWidth, tHeight);
int x = tWidth / m_GridSize.Width;
int y = tHeight / m_GridSize.Height;
Pen pGrid = new Pen(m_GridColor);
int pos;
for (int i = 0 ; i <= x ; i++ )
{
pos = tWidth - (i * m_GridSize.Width + m_GridStartPos - 1);
g.DrawLine(pGrid, 0, pos, pos, tHeight);
}
for (int i=0; i <= y; i++ )
{
pos = i * m_GridSize.Height - 1;
g.DrawLine(pGrid, 0, pos, tWidth, pos);
}
int px = tWidth - m_GridMoveStep;
int start = aList.Count - 2;
Pen lGrid = new Pen(m_LineColor);
while (start >= 0)
{
float f = (float)aList[start];
float fPre = (float)aList[start+1];
int h = (int)(tHeight - (tHeight * f));
int hPre = (int)(tHeight - tHeight * fPre);
g.DrawLine(lGrid, px, h, px + m_GridMoveStep, hPre);
if (px < 0)
{
break;
}
px -= m_GridMoveStep;
start--;
}
g.Dispose();
}