以下代码是我在WINCE下用C#进行画图的程序,希望给一些朋友有点帮助,由于代码写的时候注释太少了,如代码有有读不懂可以联系我,
int temp = 135;
private void timer1_Tick(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(150, 125);
System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Black);
Graphics ghp = Graphics.FromImage(bmp);
ghp.Clear(Color.DodgerBlue);
Brush br = new SolidBrush(Color.Black);
ghp.DrawString("ug/L", new Font("宋体", 10, FontStyle.Regular), br, 0, 0);
ghp.DrawString("h", new Font("宋体", 10, FontStyle.Regular), br, 140, 105);
//X轴
ghp.DrawString("13", new Font("宋体", 8, FontStyle.Regular), br, 15, 110);
ghp.DrawString("19", new Font("宋体", 8, FontStyle.Regular), br, 40, 110);
ghp.DrawString("1", new Font("宋体", 8, FontStyle.Regular), br, 65, 110);
ghp.DrawString("7", new Font("宋体", 8, FontStyle.Regular), br, 90, 110);
ghp.DrawString("12", new Font("宋体", 8, FontStyle.Regular), br, 115, 110);
//Y轴
ghp.DrawString("0", new Font("宋体", 8, FontStyle.Regular), br, 0, 100);
ghp.DrawString("100", new Font("宋体", 8, FontStyle.Regular), br, 0, 20);
ghp.DrawString("75", new Font("宋体", 8, FontStyle.Regular), br, 0, 40);
ghp.DrawString("50", new Font("宋体", 8, FontStyle.Regular), br, 0, 60);
ghp.DrawString("25", new Font("宋体", 8, FontStyle.Regular), br, 0, 80);
ghp.DrawLine(myPen, 20, 15, 20, 110);
ghp.DrawLine(myPen, 20, 110, 135, 110);
//通道6
myPen = new System.Drawing.Pen(System.Drawing.Color.SpringGreen);
ghp.DrawLine(myPen, temp, 105, temp + 10, 105);
ghp.DrawLine(myPen, temp + 10, 105, temp + 10, 95);
ghp.DrawLine(myPen, temp + 10, 95, temp + 30, 95);
ghp.DrawLine(myPen, temp + 30, 95, temp + 30, 105);
ghp.DrawLine(myPen, temp + 30, 105, temp + 115, 105);
//通道5
myPen = new System.Drawing.Pen(System.Drawing.Color.Black);
ghp.DrawLine(myPen, temp, 90, temp + 20, 90);
ghp.DrawLine(myPen, temp + 20, 90, temp + 20, 80);
ghp.DrawLine(myPen, temp + 20, 80, temp + 40, 80);
ghp.DrawLine(myPen, temp + 40, 80, temp + 40, 90);
ghp.DrawLine(myPen, temp + 40, 90, temp + 115, 90);
//通道4
myPen = new System.Drawing.Pen(System.Drawing.Color.Chartreuse);
ghp.DrawLine(myPen, temp, 75, temp + 30, 75);
ghp.DrawLine(myPen, temp + 30, 75, temp + 30, 65);
ghp.DrawLine(myPen, temp + 30, 65, temp + 50, 65);
ghp.DrawLine(myPen, temp + 50, 65, temp + 50, 75);
ghp.DrawLine(myPen, temp + 50, 75, temp + 115, 75);
//通道3
myPen = new System.Drawing.Pen(System.Drawing.Color.Olive);
ghp.DrawLine(myPen, temp, 60, temp + 40, 60);
ghp.DrawLine(myPen, temp + 40, 60, temp + 40, 50);
ghp.DrawLine(myPen, temp + 40, 50, temp + 60, 50);
ghp.DrawLine(myPen, temp + 60, 50, temp + 60, 60);
ghp.DrawLine(myPen, temp + 60, 60, temp + 115, 60);
//通道2
myPen = new System.Drawing.Pen(System.Drawing.Color.Orange);
ghp.DrawLine(myPen, temp, 45, temp + 50, 45);
ghp.DrawLine(myPen, temp + 50, 45, temp + 50, 35);
ghp.DrawLine(myPen, temp + 50, 35, temp + 70, 35);
ghp.DrawLine(myPen, temp + 70, 35, temp + 70, 45);
ghp.DrawLine(myPen, temp + 70, 45, temp + 115, 45);
//通道1
myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
ghp.DrawLine(myPen, temp, 30, temp + 60, 30);
ghp.DrawLine(myPen, temp + 60, 30, temp + 60, 20);
ghp.DrawLine(myPen, temp + 60, 20, temp + 80, 20);
ghp.DrawLine(myPen, temp + 80, 20, temp + 80, 30);
ghp.DrawLine(myPen, temp + 80, 30, temp + 115, 30);
temp = temp - 5;
if (temp == 20) temp = 135;
myPen.Dispose();
ghp.Dispose();
pictureBox1.Image = bmp;
}
}