ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:129.73KB ,
资源ID:6132331      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6132331.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C#课设报告.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C#课设报告.docx

1、C#课设报告一、设计目的:面向对象程序设计课程设计是面向对象程序设计课程的实践环节。通过课程设计实践,使学生进一步加深理解和掌握面向对象的基本概念、面向对象程序开发的基本思路和方法、windows Form设计原则和方法以及它们在软件开发过程中的使用方法,达到提高学生C#语言编程和调试动手能力,培养学生使用面向对象程序设计、数据结构、数据库原理和软件工程等相关课程知识解决实际问题的能力的目的。二、设计内容:(1) 根据课题要求设计数据结构和Windows UI界面,并且编写完成了程序;(2) 画图程序具有的功能:在菜单栏中,“文件”的下拉菜单能实现打开、保存、打印、退出等功能;“编辑”下拉菜单

2、能实现移动、删除等功能;“绘制”下拉菜单能实现绘制点、直线、矩形、多边形、圆形、圆弧、椭圆等功能;“颜色”下拉菜单能实现编辑颜色的功能;“帮助”实现帮助主题功能。在工具栏中设计了相关的绘制图形的按钮快捷方式,方便用户操作;同时还增添了实现了调整线条宽度的功能。状态栏显示鼠标当前位置。三、所设计应用系统运行所需要的软件、硬件环境:Visual studio 2005环境 四、关键功能算法和函数流程图:1) 绘制点的相关算法: Serializable () public class Point : IGraphics /点类 bool bedraw = false; PointF PoiP =

3、new PointF(); /用于记录点的位置 Color penColor; /画笔颜色 float penWdith; /画笔宽度 public void MouseDown(object sender, MouseEventArgs e) this.bedraw = true; this.PoiP = e.Location; /记录要绘制点的位置 public void MouseMove(object sender, MouseEventArgs e) this.bedraw = true; public void MouseUp(object sender,MouseEventArg

4、s e) this.bedraw = false; public void dpen(Color color, float width) /为画笔属性赋值 this.penColor = color; this.penWdith = width; public void Draw(Graphics g) /绘制点 Brush brush = new SolidBrush(this.penColor); g.FillEllipse(brush, this.PoiP.X - 4, this.PoiP.Y - 4, 8, 8); /绘制点 public bool Judge(MouseEventAr

5、gs e) return false; public void Circum(bool judge) MessageBox.Show(不能计算周长!, 警告, MessageBoxButtons.OK); public void Area(bool judge) MessageBox.Show(不能计算面积!, 警告, MessageBoxButtons.OK); 2) 绘制直线的算法: Serializable() public class Line : IGraphics /直线类 bool bedraw = false; /标记是否开始和停止绘制 PointF LinP1 = new P

6、ointF(); PointF LinP2 = new PointF(); /记录线段的起点和终点 Color penColor; /画笔颜色 float penWdith; /画笔宽度 public void MouseDown(object sender, MouseEventArgs e) this.bedraw = true; this.LinP1 = e.Location; public void MouseMove(object sender, MouseEventArgs e) if (this.bedraw) this.LinP2 = e.Location; public vo

7、id MouseUp(object sender, MouseEventArgs e) this.LinP2 = e.Location; this.bedraw = false; public void dpen(Color color, float width) /为画笔属性赋值 this.penColor = color; this.penWdith = width; public void Draw(Graphics g) Pen pen = new Pen(this.penColor, this.penWdith); g.DrawLine(pen, this.LinP1, this.L

8、inP2); /绘制直线 public bool Judge(MouseEventArgs e) /判断点是否在线段上或在其延长线上 if (Math.Abs(e.X - this.LinP1.X) / (this.LinP2.X - this.LinP1.X) = Math.Abs(e.Y - this.LinP1.Y) / (this.LinP2.Y - this.LinP1.Y) return true; else return false; public void Circum(bool judge) float SegCir = (float )Math.Sqrt(this.LinP

9、1.X - this.LinP2.X) * (this.LinP1.X - this.LinP2.X) + (this.LinP1.Y - this.LinP2.Y) * (this.LinP1.Y - this.LinP2.Y); MessageBox.Show(线段长度为: + SegCir, 消息, MessageBoxButtons.OK); public void Area(bool judge) MessageBox.Show(不能计算面积!, 警告, MessageBoxButtons.OK); 3) 绘制矩形的算法: Serializable() public class Re

10、ctangle : IGraphics /矩形类 bool bedraw = false; PointF RecP1 = new PointF(); PointF RecP2 = new PointF(); /记录矩形的两个顶点 Color penColor; /画笔颜色 float penWdith; /画笔宽度 public void MouseDown(object sender, MouseEventArgs e) this.bedraw = true; this.RecP1 = e.Location; public void MouseMove(object sender, Mous

11、eEventArgs e) if (this.bedraw) this.RecP2 = e.Location; public void MouseUp(object sender, MouseEventArgs e) this.bedraw = false; public void dpen(Color color, float width) /为画笔属性赋值 this.penColor = color; this.penWdith = width; public void Draw(Graphics g) Pen pen = new Pen(this.penColor, this.penWd

12、ith); g.DrawRectangle(pen, this.RecP1.X, this.RecP1.Y, this.RecP2.X - this.RecP1.X, this.RecP2.Y - this.RecP1.Y); /绘制矩形 public bool Judge(MouseEventArgs e) /判断点是否在矩形内 if (e.Location.X = this.RecP1.X & e.Location.X = this.RecP1.Y & e.Location.Y = this.RecP2.Y) /判断鼠标是否在矩形内 return true; else return fal

13、se; public void Circum(bool judge) float RecCir = 2 * (this.RecP2.X - this.RecP1.X) + 2 * (this.RecP2.Y - this.RecP1.Y); MessageBox.Show(矩形周长为: + RecCir, 消息, MessageBoxButtons.OK); public void Area(bool judge) float RecArea = (this.RecP2.X - this.RecP1.X)*(this.RecP2.Y - this.RecP1.Y); MessageBox.Sh

14、ow(矩形面积为:+RecArea , 消息, MessageBoxButtons.OK); 4) 绘制多边形的算法:Serializable() public class Polygon : IGraphics /多边形类 PointF Pol = new PointF1; /用于记录顶点的位置 bool bedraw = false; Color penColor; /画笔颜色 float penWdith; /画笔宽度 public void MouseDown(object sender, MouseEventArgs e) this.bedraw = true; this.Polth

15、is.Pol.Length - 1 = e.Location; /记录要绘制点的位置 public void MouseMove(object sender, MouseEventArgs e) public void MouseUp(object sender, MouseEventArgs e) public void dpen(Color color, float width) /为画笔属性赋值 this.penColor = color; this.penWdith = width; public void Draw(Graphics g) Pen pen = new Pen(this

16、.penColor, this.penWdith); g.DrawPolygon(pen, this.Pol); /绘制多边形 public bool Judge(MouseEventArgs e) return false; public void Circum(bool judge) MessageBox.Show(不能计算周长!, 警告, MessageBoxButtons.OK); public void Area(bool judge) MessageBox.Show(不能计算面积!, 警告, MessageBoxButtons.OK); 5) 绘制圆的算法:Serializable

17、() public class Circle : IGraphics /圆类 bool bedraw = false; PointF point1 = new PointF(); PointF point2 = new PointF(); / 分别记录圆的圆心和圆上任意一点的坐标 Color penColor; /画笔颜色 float penWdith; /画笔宽度 public void MouseDown(object sender, MouseEventArgs e) this.bedraw = true; this.point1 = e.Location; public void Mo

18、useMove(object sender, MouseEventArgs e) if (this.bedraw = true) this.point2 = e.Location; public void MouseUp(object sender, MouseEventArgs e) this.bedraw = false; public void dpen(Color color, float width) /为画笔属性赋值 this.penColor = color; this.penWdith = width; public void Draw(Graphics g) Pen pen

19、= new Pen(this.penColor, this.penWdith); float r =(float ) Math.Sqrt(point2.X - point1.X) * (point2.X - point1.X) + (point2.Y - point1.Y) * (point2.Y - point1.Y); g.DrawEllipse(pen, (point1.X - r), (point1.Y - r), 2 * r, 2 * r); /绘制圆 public bool Judge(MouseEventArgs e) float r = (float )Math.Sqrt(po

20、int2.X - point1.X) * (point2.X - point1.X) + (point2.Y - point1.Y) * (point2.Y - point1.Y); if (Math.Sqrt(e.Location.X - point1.X) * (e.Location.X - point1.X) + (e.Location.Y - point1.Y) * (e.Location.Y - point1.Y) = r) /判断鼠标是否在圆内 return true; else return false; public void Circum(bool judge) /计算圆周长

21、 float r = (float )Math.Sqrt(point2.X - point1.X) * (point2.X - point1.X) + (point2.Y - point1.Y) * (point2.Y - point1.Y); float CirC = (float )(2 * Math.PI * r); MessageBox.Show(圆形周长为: + CirC, 消息, MessageBoxButtons.OK); public void Area(bool judge) /计算圆面积 float r =(float ) Math.Sqrt(point2.X - poin

22、t1.X) * (point2.X - point1.X) + (point2.Y - point1.Y) * (point2.Y - point1.Y); float CirA = (float)Math.PI * r * r; MessageBox.Show(圆形面积为: + CirA, 消息, MessageBoxButtons.OK); 6) 绘制弧形的算法:Serializable() public class Arc : IGraphics /弧形类 bool bedraw = false; PointF point1 = new PointF(); PointF point2 =

23、 new PointF(); /记录矩形的左上角和右下角坐标 Color penColor; /画笔颜色 float penWdith; /画笔宽度 public void MouseDown(object sender, MouseEventArgs e) this.bedraw = true; this.point1 = e.Location; public void MouseMove(object sender, MouseEventArgs e) if (this.bedraw = true) this.point2 = e.Location; public void MouseUp

24、(object sender, MouseEventArgs e) this.bedraw = false; public void dpen(Color color, float width) /为画笔属性赋值 this.penColor = color; this.penWdith = width; public void Draw(Graphics g) /绘制弧形 Pen pen = new Pen(this.penColor, this.penWdith); g.DrawRectangle(pen, point1.X, point1.Y, Math.Abs(point2.X - po

25、int1.X), Math.Abs(point2.Y - point1.Y); public bool Judge(MouseEventArgs e) /计算前先判断鼠标是否在线段上 return false; public void Circum(bool judge) MessageBox.Show(不能计算长度 , 警告, MessageBoxButtons.OK); public void Area(bool judge) MessageBox.Show(不能计算面积!, 警告, MessageBoxButtons.OK); 7) 绘制椭圆的算法:Serializable() publ

26、ic class Ellipse : IGraphics /椭圆类 bool bedraw = false; PointF point1 = new PointF(); PointF point2 = new PointF(); /记录矩形的左上角和右下角坐标 Color penColor; /画笔颜色 float penWdith; /画笔宽度 public void MouseDown(object sender, MouseEventArgs e) this.bedraw = true; this.point1 = e.Location; public void MouseMove(ob

27、ject sender, MouseEventArgs e) if (this.bedraw = true) this.point2 = e.Location; public void MouseUp(object sender, MouseEventArgs e) this.bedraw = false; public void dpen(Color color, float width) /为画笔属性赋值 this.penColor = color; this.penWdith = width; public void Draw(Graphics g) /绘制椭圆 Pen pen = ne

28、w Pen(this.penColor, this.penWdith); g.DrawEllipse(pen, point1.X, point1.Y, point2.X - point1.X, point2.Y - point1.Y); public bool Judge(MouseEventArgs e) /计算前先判断鼠标是否在线段上 float a = (point1.X - point2.X) / 2) * (point1.X - point2.X) / 2); float b = (point1.Y - point2.Y) / 2) * (point1.Y - point2.Y) /

29、 2); float c = (point1 .X + point2.X ) / 2; float d = (point1 .Y + point2 .Y ) / 2; if (e.X - c) * (e.X - c) / a + (e.Y - d) * (e.Y - d) / b) = 1) return true; else return false; public void Circum(bool judge) float EllCir = (float )Math .PI *(Math .Abs (this.point1 .X - this .point2 .X )+Math .Abs (this .point1 .Y -thi

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1