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

资源简介

C#窗体应用程序实现点线面等图形元素绘制,实现部分CAD可用的功能

资源截图

代码片段和文件信息

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

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

     文件       3142  2008-08-31 14:24  C#程序实现CAD\CAD\Backup\CAD\baseShape.cs

     文件       4823  2008-08-30 11:35  C#程序实现CAD\CAD\Backup\CAD\baseTool.cs

     文件       3719  2008-08-31 13:33  C#程序实现CAD\CAD\Backup\CAD\CAD.csproj

     文件      16444  2008-08-31 15:17  C#程序实现CAD\CAD\Backup\CAD\CADframe.cs

     文件      22421  2008-08-31 14:30  C#程序实现CAD\CAD\Backup\CAD\CADframe.Designer.cs

     文件       6621  2008-08-31 14:30  C#程序实现CAD\CAD\Backup\CAD\CADframe.resx

     文件       2989  2008-08-31 14:22  C#程序实现CAD\CAD\Backup\CAD\CircleShape.cs

     文件       1181  2008-08-31 13:33  C#程序实现CAD\CAD\Backup\CAD\CircleTool.cs

     文件       6674  2008-09-01 10:12  C#程序实现CAD\CAD\Backup\CAD\EllipseShape.cs

     文件       1184  2008-08-31 10:44  C#程序实现CAD\CAD\Backup\CAD\EllipseTool.cs

     文件       3822  2008-08-31 11:52  C#程序实现CAD\CAD\Backup\CAD\HandTool.cs

     文件       3029  2008-08-31 12:13  C#程序实现CAD\CAD\Backup\CAD\LineShape.cs

     文件       1177  2008-08-30 11:33  C#程序实现CAD\CAD\Backup\CAD\LineTool.cs

     文件        465  2008-08-26 15:08  C#程序实现CAD\CAD\Backup\CAD\Program.cs

     文件       1162  2008-08-26 14:31  C#程序实现CAD\CAD\Backup\CAD\Properties\AssemblyInfo.cs

     文件       2828  2008-08-28 18:44  C#程序实现CAD\CAD\Backup\CAD\Properties\Resources.Designer.cs

     文件       5612  2008-08-26 14:31  C#程序实现CAD\CAD\Backup\CAD\Properties\Resources.resx

     文件       1099  2008-08-28 18:44  C#程序实现CAD\CAD\Backup\CAD\Properties\Settings.Designer.cs

     文件        249  2008-08-26 14:31  C#程序实现CAD\CAD\Backup\CAD\Properties\Settings.settings

     文件       7335  2008-08-31 15:12  C#程序实现CAD\CAD\Backup\CAD\RectangleShape.cs

     文件       1188  2008-08-31 09:37  C#程序实现CAD\CAD\Backup\CAD\RectangleTool.cs

     文件        898  2008-08-26 14:31  C#程序实现CAD\CAD\Backup\CAD.sln

    ..A..H.     35328  2008-09-01 10:13  C#程序实现CAD\CAD\Backup\CAD.suo

     文件       3142  2008-08-31 14:24  C#程序实现CAD\CAD\Backup1\CAD\baseShape.cs

     文件       4823  2011-11-22 19:48  C#程序实现CAD\CAD\Backup1\CAD\baseTool.cs

     文件       3890  2011-10-19 20:48  C#程序实现CAD\CAD\Backup1\CAD\CAD.csproj

     文件      16579  2011-11-23 17:15  C#程序实现CAD\CAD\Backup1\CAD\CADframe.cs

     文件      22553  2011-11-22 16:17  C#程序实现CAD\CAD\Backup1\CAD\CADframe.Designer.cs

     文件       6621  2011-11-22 16:17  C#程序实现CAD\CAD\Backup1\CAD\CADframe.resx

     文件       2989  2008-08-31 14:22  C#程序实现CAD\CAD\Backup1\CAD\CircleShape.cs

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

评论

共有 条评论

相关资源