C#课程设计-画图工具.doc





《C#课程设计-画图工具.doc》由会员分享,可在线阅读,更多相关《C#课程设计-画图工具.doc(10页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、C#课程设计班级:实验项目名称:画图工具实现学 号: 学生姓名: 一、实验目的(本次实验所涉及并要求掌握的知识点)1.通过实验掌握windows程序设计的基础,以及常见windows控件的使用;2.学习掌握画图工具实现的思想以及编程方法;二、实验内容与设计思想(设计思路、主要数据结构、主要代码结构、主要代码段分析、电路图等) 实现记事本的Window运用程序,其功能能够实现画图工具的功能(可参见Window附件中的画图工具基本格式);三、实验使用环境(本次实验所使用的平台和相关软件)Windows操作系统Microsoft Visual Studio 2010编程软件四、实验步骤和调试过程(实
2、验步骤、测试数据设计、测试结果分析)画图工具的实现:设计过程主要通过运用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
3、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,
4、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.
5、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.BackColor = Color.White; button13.BackColor = Color.White; (Button)sender).BackColor = Color
6、.Black;/选中的按钮背景颜色为黑色 penWidth = Convert.ToInt32(Button)sender).Tag);/选择宽度按钮的Tag值设为画笔宽度 private void btnColor(object sender, EventArgs e) if (Button)sender).Text = C) if (colorDialog1.ShowDialog() = DialogResult.OK) button14.BackColor = colorDialog1.Color; else button14.BackColor = (Button)sender).Ba
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C# 课程设计 画图 工具

限制150内