• 大小: 135KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-23
  • 语言: C#
  • 标签:

资源简介

这是一个用c#面向对象程序设计的画图软件,有很多的备注能是人明白

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace CAD
{
    [Serializable]
    public abstract class baseShape
    {
        private bool isSelected = false;//标识图形是否被选中
        
        private Point p1;//第一个点
        private Point p2;//第二个点

        public  Color penColor;
        public  int penwidth ;

        public void setSelected()//设置为选中状态
        {
            this.isSelected = true;
        }
        public void setUnSelected()//设置为非选中状态
        {
            this.isSelected = false;
        }
        public Point getP1()
        {
            return p1;
        }
        public void setP1(Point p1)
        {
            this.p1 = p1;
        }
        public Point getP2()
        {
            return p2;
        }
        public void setP2(Point p2)
        {
            this.p2 = p2;
        }

        public abstract void draw(Graphics g);//画图形

        public abstract Point[] getAllHitPoint();//得到所有图形
        public abstract void setHitPoint(int hitPointIndex Point newPoint);//设定热点
        public abstract baseShape copySelf();//复制


        public bool catchHitPoint(Point hitPoint Point testPoint)//测试热点捕捉
        {
            return this.getHitPointRectangle(hitPoint).Contains(testPoint);
        }

        public int catchShapPoint(Point testPoint)//捕捉图形
        {
            int hitPointIndex = -1;
            Point[] allHitPoint = this.getAllHitPoint();//的到所有的热点
            for (int i = 0; i < allHitPoint.Length; i++)//循环捕捉判断
            {
                if (this.catchHitPoint(allHitPoint[i] testPoint))
                {
                    return i + 1;//如果捕捉到了热点,返回热点的索引
                }
            }
            if(this.catchShape(testPoint)) return 0;//没有捕捉到热点,捕捉到了图形,返回特别热点
            return hitPointIndex;//返回捕捉到的人点
            }
        public void drawHitPoint(Point hitPoint Graphics g)//画热点
        {
            g.DrawRectangle(new Pen(Color.Red1) this.getHitPointRectangle(hitPoint));
        }

        public void drawAllHitPoint(Graphics g)//画所有热点
        {
            Point[] allHitPoint=this.getAllHitPoint();
            for(int i=0;i<2;i++)
            {
                this.drawHitPoint(allHitPoint[i]g);
            }
        }

        public Rectangle getHitPointRectangle(Point hitPoint)//得到热点矩形,以热点为中心高宽5像素的矩形
        {
            Rectangle rect=new Rectangle();
            rect.X=hitPoint.X-2;
            rect.Y=hitPoint.Y-2;
            rect.Width=5;
            rect.Height=5;
            return rect;
        }

        public abstract bool catchShape(Point testPoint);//图形捕捉

        public void superDraw(Graphics g)//公共画法
        {
            if(this.isSelected) this.drawAllHitPoint(g);
        }

        public static Pen getPen(CADframe objCAD)//得到画笔
        {
            return new Pen(objCAD.clrobjCAD.lineWidth);
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        899  2012-06-21 15:04  CAD\CAD.sln

    ..A..H.     47104  2012-07-04 17:50  CAD\CAD.suo

     文件       6033  2012-06-21 15:04  CAD\UpgradeLog.xml

     文件      27136  2003-01-01 07:40  CAD\实训报告和总结\实训报告.doc

     文件      14848  2003-01-01 07:22  CAD\实训报告和总结\自评表.xls

     文件       3348  2012-06-21 15:04  CAD\_UpgradeReport_Files\UpgradeReport.css

     文件      12505  2010-05-04 01:19  CAD\_UpgradeReport_Files\UpgradeReport.xslt

     文件         69  2012-06-21 15:04  CAD\_UpgradeReport_Files\UpgradeReport_Minus.gif

     文件         71  2012-06-21 15:04  CAD\_UpgradeReport_Files\UpgradeReport_Plus.gif

     文件       3132  2012-07-02 21:15  CAD\CAD\baseShape.cs

     文件       4823  2011-11-27 02:02  CAD\CAD\baseTool.cs

     文件       4119  2012-06-21 15:04  CAD\CAD\CAD.csproj

     文件      16340  2012-07-02 21:44  CAD\CAD\CADframe.cs

     文件      22624  2012-07-02 21:44  CAD\CAD\CADframe.Designer.cs

     文件       6621  2012-07-02 21:44  CAD\CAD\CADframe.resx

     文件       2989  2011-11-27 02:02  CAD\CAD\CircleShape.cs

     文件       1181  2011-11-27 02:02  CAD\CAD\CircleTool.cs

     文件       6674  2011-11-27 02:02  CAD\CAD\EllipseShape.cs

     文件       1184  2011-11-27 02:02  CAD\CAD\EllipseTool.cs

     文件       3822  2011-11-27 02:02  CAD\CAD\HandTool.cs

     文件       3029  2011-11-27 02:02  CAD\CAD\LineShape.cs

     文件       1177  2011-11-27 02:02  CAD\CAD\LineTool.cs

     文件        465  2011-11-27 02:02  CAD\CAD\Program.cs

     文件       7335  2011-11-27 02:02  CAD\CAD\RectangleShape.cs

     文件       1188  2011-11-27 02:02  CAD\CAD\RectangleTool.cs

     文件       1162  2011-11-27 02:02  CAD\CAD\Properties\AssemblyInfo.cs

     文件       2844  2012-06-21 15:04  CAD\CAD\Properties\Resources.Designer.cs

     文件       5612  2011-11-27 02:02  CAD\CAD\Properties\Resources.resx

     文件       1101  2012-06-21 15:04  CAD\CAD\Properties\Settings.Designer.cs

     文件        249  2011-11-27 02:02  CAD\CAD\Properties\Settings.settings

............此处省略56个文件信息

评论

共有 条评论

相关资源