using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace GDI
{
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.Container components = null;
        public int a,b,MoveX,MoveY;
        public bool flag=false;
        private System.Windows.Forms.Button button1;
        public Form1()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();
            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }
        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if (components != null) 
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }
        #region Windows 窗体设计器生成的代码
        /// <summary>
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
         }
        #endregion
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main() 
        {
            Application.Run(new Form1());
        }
        private void Form1_Load(object sender, System.EventArgs e)
        {
        
        }
        private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            if(flag ==true)
            {                
                Graphics graphics=this.CreateGraphics ();
                graphics.Clear (Color.Yellow  );               
                Pen red=new Pen (Color.Red ,3);
                graphics.DrawLine (red,a,b,MoveX,MoveY);
    
            }
        
        }
        private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            a=e.X;
            b=e.Y ;
}
        private void button1_Click(object sender, System.EventArgs e)
        {
            flag =true;
            
        }
        private void button1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            MoveX=e.X;
            MoveY=e.Y ;
        }
    }
}
我的想法是让鼠标在窗体是画一条线,用a,b记录起点坐标,movex,movey记录重点坐标,点击按扭画出图形,坐标都能记录下来,就是画不出图形,请帮忙!



 
											





 
	    

 
	
