C#课设报告.docx

上传人:b****5 文档编号:6132331 上传时间:2023-01-04 格式:DOCX 页数:15 大小:129.73KB
下载 相关 举报
C#课设报告.docx_第1页
第1页 / 共15页
C#课设报告.docx_第2页
第2页 / 共15页
C#课设报告.docx_第3页
第3页 / 共15页
C#课设报告.docx_第4页
第4页 / 共15页
C#课设报告.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

C#课设报告.docx

《C#课设报告.docx》由会员分享,可在线阅读,更多相关《C#课设报告.docx(15页珍藏版)》请在冰豆网上搜索。

C#课设报告.docx

C#课设报告

一、设计目的:

《面向对象程序设计课程设计》是《面向对象程序设计》课程的实践环节。

通过课程设计实践,使学生进一步加深理解和掌握面向对象的基本概念、面向对象程序开发的基本思路和方法、windowsForm设计原则和方法以及它们在软件开发过程中的使用方法,达到提高学生C#语言编程和调试动手能力,培养学生使用面向对象程序设计、数据结构、数据库原理和软件工程等相关课程知识解决实际问题的能力的目的。

二、设计内容:

(1)根据课题要求设计数据结构和WindowsUI界面,并且编写完成了程序;

(2)画图程序具有的功能:

在菜单栏中,“文件”的下拉菜单能实现打开、保存、打印、退出等功能;“编辑”下拉菜单能实现移动、删除等功能;“绘制”下拉菜单能实现绘制点、直线、矩形、多边形、圆形、圆弧、椭圆等功能;“颜色”下拉菜单能实现编辑颜色的功能;“帮助”实现帮助主题功能。

在工具栏中设计了相关的绘制图形的按钮快捷方式,方便用户操作;同时还增添了实现了调整线条宽度的功能。

状态栏显示鼠标当前位置。

三、所设计应用系统运行所需要的软件、硬件环境:

Visualstudio2005环境

四、关键功能算法和函数流程图:

1)绘制点的相关算法:

[Serializable()]

publicclassPoint:

IGraphics///////////////////////点类

{

boolbedraw=false;

PointFPoiP=newPointF();//用于记录点的位置

ColorpenColor;//画笔颜色

floatpenWdith;//画笔宽度

publicvoidMouseDown(objectsender,MouseEventArgse)

{

this.bedraw=true;

this.PoiP=e.Location;//记录要绘制点的位置

}

publicvoidMouseMove(objectsender,MouseEventArgse)

{

this.bedraw=true;

}

publicvoidMouseUp(objectsender,MouseEventArgse)

{

this.bedraw=false;

}

publicvoiddpen(Colorcolor,floatwidth)//为画笔属性赋值

{

this.penColor=color;

this.penWdith=width;

}

publicvoidDraw(Graphicsg)//绘制点

{

Brushbrush=newSolidBrush(this.penColor);

g.FillEllipse(brush,this.PoiP.X-4,this.PoiP.Y-4,8,8);//绘制点

}

publicboolJudge(MouseEventArgse)

{

returnfalse;

}

publicvoidCircum(booljudge)

{

MessageBox.Show("不能计算周长!

","警告",MessageBoxButtons.OK);

}

publicvoidArea(booljudge)

{

MessageBox.Show("不能计算面积!

","警告",MessageBoxButtons.OK);

}

}

2)绘制直线的算法:

[Serializable()]

publicclassLine:

IGraphics///////////////////////////直线类

{

boolbedraw=false;//标记是否开始和停止绘制

PointFLinP1=newPointF();

PointFLinP2=newPointF();//记录线段的起点和终点

ColorpenColor;//画笔颜色

floatpenWdith;//画笔宽度

publicvoidMouseDown(objectsender,MouseEventArgse)

{

this.bedraw=true;

this.LinP1=e.Location;

}

publicvoidMouseMove(objectsender,MouseEventArgse)

{

if(this.bedraw)

this.LinP2=e.Location;

}

publicvoidMouseUp(objectsender,MouseEventArgse)

{

this.LinP2=e.Location;

this.bedraw=false;

}

publicvoiddpen(Colorcolor,floatwidth)//为画笔属性赋值

{

this.penColor=color;

this.penWdith=width;

}

publicvoidDraw(Graphicsg)

{

Penpen=newPen(this.penColor,this.penWdith);

g.DrawLine(pen,this.LinP1,this.LinP2);//绘制直线

}

publicboolJudge(MouseEventArgse)//判断点是否在线段上或在其延长线上

{

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)))

returntrue;

else

returnfalse;

}

publicvoidCircum(booljudge)

{

floatSegCir=(float)Math.Sqrt((this.LinP1.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);

}

publicvoidArea(booljudge)

{

MessageBox.Show("不能计算面积!

","警告",MessageBoxButtons.OK);

}

}

3)绘制矩形的算法:

[Serializable()]

publicclassRectangle:

IGraphics/////////////////////矩形类

{

boolbedraw=false;

PointFRecP1=newPointF();

PointFRecP2=newPointF();//记录矩形的两个顶点

ColorpenColor;//画笔颜色

floatpenWdith;//画笔宽度

publicvoidMouseDown(objectsender,MouseEventArgse)

{

this.bedraw=true;

this.RecP1=e.Location;

}

publicvoidMouseMove(objectsender,MouseEventArgse)

{

if(this.bedraw)

this.RecP2=e.Location;

}

publicvoidMouseUp(objectsender,MouseEventArgse)

{

this.bedraw=false;

}

publicvoiddpen(Colorcolor,floatwidth)//为画笔属性赋值

{

this.penColor=color;

this.penWdith=width;

}

publicvoidDraw(Graphicsg)

{

Penpen=newPen(this.penColor,this.penWdith);

g.DrawRectangle(pen,this.RecP1.X,this.RecP1.Y,this.RecP2.X-this.RecP1.X,this.RecP2.Y-this.RecP1.Y);//绘制矩形

}

publicboolJudge(MouseEventArgse)//判断点是否在矩形内

{

if(e.Location.X>=this.RecP1.X&&e.Location.X<=this.RecP2.X&&e.Location.Y>=this.RecP1.Y&&e.Location.Y<=this.RecP2.Y)//判断鼠标是否在矩形内

returntrue;

else

returnfalse;

}

publicvoidCircum(booljudge)

{

floatRecCir=2*(this.RecP2.X-this.RecP1.X)+2*(this.RecP2.Y-this.RecP1.Y);

MessageBox.Show("矩形周长为:

"+RecCir,"消息",MessageBoxButtons.OK);

}

publicvoidArea(booljudge)

{

floatRecArea=(this.RecP2.X-this.RecP1.X)*(this.RecP2.Y-this.RecP1.Y);

MessageBox.Show("矩形面积为:

"+RecArea,"消息",MessageBoxButtons.OK);

}

}

4)绘制多边形的算法:

[Serializable()]

publicclassPolygon:

IGraphics//////////////////多边形类

{

PointF[]Pol=newPointF[1];//用于记录顶点的位置

boolbedraw=false;

ColorpenColor;//画笔颜色

floatpenWdith;//画笔宽度

publicvoidMouseDown(objectsender,MouseEventArgse)

{

this.bedraw=true;

this.Pol[this.Pol.Length-1]=e.Location;//记录要绘制点的位置

}

publicvoidMouseMove(objectsender,MouseEventArgse)

{

}

publicvoidMouseUp(objectsender,MouseEventArgse)

{

}

publicvoiddpen(Colorcolor,floatwidth)//为画笔属性赋值

{

this.penColor=color;

this.penWdith=width;

}

publicvoidDraw(Graphicsg)

{

Penpen=newPen(this.penColor,this.penWdith);

g.DrawPolygon(pen,this.Pol);//绘制多边形

}

publicboolJudge(MouseEventArgse)

{

returnfalse;

}

publicvoidCircum(booljudge)

{

MessageBox.Show("不能计算周长!

","警告",MessageBoxButtons.OK);

}

publicvoidArea(booljudge)

{

MessageBox.Show("不能计算面积!

","警告",MessageBoxButtons.OK);

}

}

5)绘制圆的算法:

[Serializable()]

publicclassCircle:

IGraphics/////////////////////////圆类

{

boolbedraw=false;

PointFpoint1=newPointF();

PointFpoint2=newPointF();//分别记录圆的圆心和圆上任意一点的坐标

ColorpenColor;//画笔颜色

floatpenWdith;//画笔宽度

publicvoidMouseDown(objectsender,MouseEventArgse)

{

this.bedraw=true;

this.point1=e.Location;

}

publicvoidMouseMove(objectsender,MouseEventArgse)

{

if(this.bedraw==true)

this.point2=e.Location;

}

publicvoidMouseUp(objectsender,MouseEventArgse)

{

this.bedraw=false;

}

publicvoiddpen(Colorcolor,floatwidth)//为画笔属性赋值

{

this.penColor=color;

this.penWdith=width;

}

publicvoidDraw(Graphicsg)

{

Penpen=newPen(this.penColor,this.penWdith);

floatr=(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);//绘制圆

}

publicboolJudge(MouseEventArgse)

{

floatr=(float)Math.Sqrt((point2.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)//判断鼠标是否在圆内

returntrue;

else

returnfalse;

}

publicvoidCircum(booljudge)//计算圆周长

{

floatr=(float)Math.Sqrt((point2.X-point1.X)*(point2.X-point1.X)+(point2.Y-point1.Y)*(point2.Y-point1.Y));

floatCirC=(float)(2*Math.PI*r);

MessageBox.Show("圆形周长为:

"+CirC,"消息",MessageBoxButtons.OK);

}

publicvoidArea(booljudge)//计算圆面积

{

floatr=(float)Math.Sqrt((point2.X-point1.X)*(point2.X-point1.X)+(point2.Y-point1.Y)*(point2.Y-point1.Y));

floatCirA=(float)Math.PI*r*r;

MessageBox.Show("圆形面积为:

"+CirA,"消息",MessageBoxButtons.OK);

}

}

6)绘制弧形的算法:

[Serializable()]

publicclassArc:

IGraphics//////////////////////弧形类

{

boolbedraw=false;

PointFpoint1=newPointF();

PointFpoint2=newPointF();//记录矩形的左上角和右下角坐标

ColorpenColor;//画笔颜色

floatpenWdith;//画笔宽度

publicvoidMouseDown(objectsender,MouseEventArgse)

{

this.bedraw=true;

this.point1=e.Location;

}

publicvoidMouseMove(objectsender,MouseEventArgse)

{

if(this.bedraw==true)

this.point2=e.Location;

}

publicvoidMouseUp(objectsender,MouseEventArgse)

{

this.bedraw=false;

}

publicvoiddpen(Colorcolor,floatwidth)//为画笔属性赋值

{

this.penColor=color;

this.penWdith=width;

}

publicvoidDraw(Graphicsg)//绘制弧形

{

Penpen=newPen(this.penColor,this.penWdith);

g.DrawRectangle(pen,point1.X,point1.Y,Math.Abs(point2.X-point1.X),Math.Abs(point2.Y-point1.Y));

}

publicboolJudge(MouseEventArgse)//计算前先判断鼠标是否在线段上

{

returnfalse;

}

publicvoidCircum(booljudge)

{

MessageBox.Show("不能计算长度","警告",MessageBoxButtons.OK);

}

publicvoidArea(booljudge)

{

MessageBox.Show("不能计算面积!

","警告",MessageBoxButtons.OK);

}

}

7)绘制椭圆的算法:

[Serializable()]

publicclassEllipse:

IGraphics/////////////////////椭圆类

{

boolbedraw=false;

PointFpoint1=newPointF();

PointFpoint2=newPointF();//记录矩形的左上角和右下角坐标

ColorpenColor;//画笔颜色

floatpenWdith;//画笔宽度

publicvoidMouseDown(objectsender,MouseEventArgse)

{

this.bedraw=true;

this.point1=e.Location;

}

publicvoidMouseMove(objectsender,MouseEventArgse)

{

if(this.bedraw==true)

this.point2=e.Location;

}

publicvoidMouseUp(objectsender,MouseEventArgse)

{

this.bedraw=false;

}

publicvoiddpen(Colorcolor,floatwidth)//为画笔属性赋值

{

this.penColor=color;

this.penWdith=width;

}

publicvoidDraw(Graphicsg)//绘制椭圆

{

Penpen=newPen(this.penColor,this.penWdith);

g.DrawEllipse(pen,point1.X,point1.Y,point2.X-point1.X,point2.Y-point1.Y);

}

publicboolJudge(MouseEventArgse)//计算前先判断鼠标是否在线段上

{

floata=((point1.X-point2.X)/2)*((point1.X-point2.X)/2);

floatb=((point1.Y-point2.Y)/2)*((point1.Y-point2.Y)/2);

floatc=(point1.X+point2.X)/2;

floatd=(point1.Y+point2.Y)/2;

if((((e.X-c)*(e.X-c))/a+((e.Y-d)*(e.Y-d))/b)<=1)

returntrue;

else

returnfalse;

}

publicvoidCircum(booljudge)

{

floatEllCir=(float)Math.PI*(Math.Abs(this.point1.X-this.point2.X)+Math.Abs(this.point1.Y-thi

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 简历

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

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