日期:2014-05-17  浏览次数:21109 次

C# winform 绘制刻度表
想自制一个温度的刻度表,不知道该从何下手,上来问问,有实例的给小弟一个研究一下,谢谢

------解决方案--------------------
C# code

private void MainForm_Paint(object sender, PaintEventArgs e)
        {
            //画圆
            Pen redPen = new Pen(Color.Red, 1);
            int n = 100;//n圆的直径
            Rectangle r = new Rectangle(10, 10, n, n);//标识圆的大小
            e.Graphics.DrawEllipse(redPen, r);

            //画圆心
            Pen bluepen = new Pen(Color.Blue, 5);
            Rectangle rr = new Rectangle(r.Left + n / 2, r.Top + n / 2, 5, 5);
            e.Graphics.DrawEllipse(bluepen, rr);

            //画刻度
            Point pN=new Point (r.Left+r.Height/2,r.Top);//12点钟刻度点
            Point pS = new Point(r.Left + r.Height / 2, r.Top + r.Height);//6点钟刻度点
            Point pW = new Point(r.Left, r.Top + r.Height / 2);//9点钟刻度点
            Point pE = new Point(r.Right, r.Top + r.Height / 2);//3点钟刻度点
            e.Graphics.DrawLine(bluepen, pN, new Point(pN.X, pN.Y + 5));//12点钟刻度
            e.Graphics.DrawLine(bluepen, pE, new Point(pE.X-5, pE.Y));//3点钟刻度
            e.Graphics.DrawLine(bluepen, pS, new Point(pS.X, pS.Y - 5));//6点钟刻度
            e.Graphics.DrawLine(bluepen, pW, new Point(pW.X+5, pW.Y));//9点钟刻度
        }