用C#编写画笔程序,请大家帮帮忙

解决方案 »

  1.   

    System.Drawing namespace
      

  2.   

    Graphics g = e.Graphics; 
    Pen p = new Pen(Color.Blue, 2);
    g.DrawLine(p, 10, 10, 100, 100);
    http://www.codeproject.com/KB/graphics/drawtools.aspx
      

  3.   

    这是一个比较典型的WINFORM程序
    1.首先你要在所选择的控件上建立一个绘图平面(比如你想在Panel控件上作画)
    Graphics grpPanel=this.Panel.CreateGraphics();
    2.建立好绘图平面后(相当于有了纸,现在你还需要一只笔),所以现在你需要一只笔或刷,这里以笔为例
    Pen p=new Pen(Color.颜色,画笔粗细);
    3.开始绘画(以画矩形为例)
    grpPanel.DrawRectangle(p,new Rectangle(0,0,矩形宽度width,长形高度height))
    这只是一个很简单的例子,还有很多图形类,画笔,以及他们的方法要你自己去积累
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace 画画
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            Point p1, p2;
            bool b=true;
            Random ran = new Random();
            private void Form1_MouseDown(object sender, MouseEventArgs e)
            {
                b = false;
                p1.X = e.X;
                p1.Y = e.Y;
            }        private void Form1_MouseMove(object sender, MouseEventArgs e)
            {
                Pen pen = new Pen(Color.Black, 2f);
                if (b) return;
                Graphics g = CreateGraphics();
                p2.X = e.X;
                p2.Y = e.Y;
                g.DrawLine(pen, p1, p2);
                p1.X=p2.X;
                p1.Y=p2.Y;
            }        private void Form1_MouseUp(object sender, MouseEventArgs e)
            {
                b = true;
            }
        }
    }