C#课程设计 班级:实验项目名称:画图工具实现 学 号: 学生姓名: 一、实验目的 (本次实验所涉及并要求掌握的知识点) 1.通过实验掌握 w indow s 程序设计的基础,以及常见 w indow s 控件的使用; 2.学习掌握画图工具实现的思想以及编程方法; 二、实验内容与设计思想 (设计思路、主要数据结构、主要代码结构、主要代码段分析、电路图等) 实现记事本的 Window 运用程序,其功能能够实现画图工具的功能(可参见 Window 附件中的画图工具基本格式); 三、实验使用环境 (本次实验所使用的平台和相关软件) Window s 操作系统 Microsoft Visual Studio 2010 编程软件 四、实验步骤和调试过程(实验步骤、测试数据设计、测试结果分析) 画图工具的实现:设计过程主要通过运用 Window 工具, 其实现代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace mydrawingpicture { public partial class Form1 : Form { Graphics g; Point pStart, pEnd;//定义画图的起始终点 int ChoiceGrap; //所选择图形枚举 int penWidth; //画笔宽度 enum mySelected { Pencil, //铅笔 Line, //直线 Ellipse, //空心椭圆 FillEllipse, //填充椭圆 Rec, //空心矩形 FillRec, //填充矩形 Eraser //橡皮擦 }; public Form1() { InitializeComponent(); g= this.CreateGraphics(); } private void pictureBox1_Paint(object sender, PaintEventArgs e) { } private void Form1_Load(object sender, EventArgs e) { g = this.pictureBox1.CreateGraphics(); ChoiceGrap = (int)mySelected.Pencil;//默认选择画笔工具 penWidth = 1; } private void button1_Click(object sender, EventArgs e) { } private void btnTool_Click(object sender, EventArgs e) { ChoiceGrap = Convert.ToInt32(((Button)sender).Tag); } private void btnLine(object sender, EventArgs e) { //把所有按钮的背景颜色都设为Black button9.BackColor = Color.White; button10.BackColor = Color.White; button11.BackColor = Color.White; button12.BackC...