WINCE下C#画图

       以下代码是我在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;           
        }
    }

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值