WINFORM学习手册——画线、椭圆、馅饼、多边形

一、线条:

/// <summary>
        /// 画直线
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PaintLine(object sender, PaintEventArgs e)
        {
            Pen pen = new Pen(Color.Red, 5);//创建一只红色的画笔
            pen.DashStyle = DashStyle.Dash;//画笔样式,-.-.-.-.-.-.
            e.Graphics.DrawLine(pen, 60, 60, 100, 200); //直线的两头分别是(60,60)和(100,200)
        }

image

二、椭圆:

/// <summary>
        /// 画椭圆
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PaintCircle(object sender, PaintEventArgs e)
        {
            Pen pen = new Pen(Color.Blue, 10);//创建一只蓝色的画笔
            pen.DashStyle = DashStyle.DashDotDot;//画笔样式,-..-..-..-..
            e.Graphics.DrawEllipse(pen, 70, 70, 50, 50);
        }

image

三、馅饼:

/// <summary>
        /// 画馅饼
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PaintPie(object sender, PaintEventArgs e)
        {
            Pen pen = new Pen(Color.Black, 1);//创建一只黑色的画笔
            pen.DashStyle = DashStyle.Dot;//画笔样式,................
            e.Graphics.DrawPie(pen, 90, 80, 140, 40, 120, 100);
        }
image

四、多边形:

image

posted @ 2014-01-18 20:25  争世不悔  阅读(2549)  评论(0编辑  收藏  举报