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

资源简介

对编写画图软件有帮助哦!全部代码都是用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 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 newPiont);
        public abstract baseShape copySelf();

        public bool catchHitPoint(Point hitPoint Point testPoint)
        {
            return this.getHitPointRectangle(hitPoint).Contains(testPoint);
        }

        public int catchShapePoint(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(baseShape.getPen() this.getHitPointRectangle(hitPoint));
        }

        public void drawAllHitPoinit(Graphics g)
        {
            Point[] allHitPoint = this.getAllHitPoint();
            for (int i = 0; i < allHitPoint.Length; i++)
            {
                this.drawHitPoint(allHitPoint[i] g);
            }
        }

        public Rectangle getHitPointRectangle(Point hitPoint)
        {
            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)
        {
            this.draw(g);
            if (this.isSelected) this.drawAllHitPoinit(g);
        }

        public static Pen getPen()
        {
            return new Pen(Color.Black);
        }
    }
}

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

     文件       2756  2008-08-27 15:08  CAD\CAD\baseShape.cs

     文件       4147  2008-08-28 16:13  CAD\CAD\baseTool.cs

     文件      28672  2008-08-28 16:55  CAD\CAD\bin\Debug\CAD.exe

     文件      65024  2008-08-28 16:55  CAD\CAD\bin\Debug\CAD.pdb

     文件       5632  2005-12-08 14:51  CAD\CAD\bin\Debug\CAD.vshost.exe

     文件       3425  2008-08-27 16:06  CAD\CAD\CAD.csproj

     文件       7910  2008-08-28 16:50  CAD\CAD\CADframe.cs

     文件       7751  2008-08-28 16:27  CAD\CAD\CADframe.Designer.cs

     文件       6221  2008-08-28 16:27  CAD\CAD\CADframe.resx

     文件       3195  2008-08-27 16:36  CAD\CAD\HandTool.cs

     文件       2639  2008-08-28 16:55  CAD\CAD\LineShape.cs

     文件       1051  2008-08-28 15:29  CAD\CAD\LineTool.cs

     文件        419  2008-08-28 16:56  CAD\CAD\obj\CAD.csproj.FileListAbsolute.txt

     文件        180  2008-08-28 16:27  CAD\CAD\obj\Debug\CAD.CADframe.resources

     文件        845  2008-08-28 16:27  CAD\CAD\obj\Debug\CAD.csproj.GenerateResource.Cache

     文件      28672  2008-08-28 16:55  CAD\CAD\obj\Debug\CAD.exe

     文件      65024  2008-08-28 16:55  CAD\CAD\obj\Debug\CAD.pdb

     文件        180  2008-08-28 16:07  CAD\CAD\obj\Debug\CAD.Properties.Resources.resources

     文件        465  2008-08-27 14:43  CAD\CAD\Program.cs

     文件       1162  2008-08-27 14:24  CAD\CAD\Properties\AssemblyInfo.cs

     文件       2862  2008-08-27 14:24  CAD\CAD\Properties\Resources.Designer.cs

     文件       5612  2008-08-27 14:24  CAD\CAD\Properties\Resources.resx

     文件       1088  2008-08-27 14:24  CAD\CAD\Properties\Settings.Designer.cs

     文件        249  2008-08-27 14:24  CAD\CAD\Properties\Settings.settings

     文件        898  2008-08-27 14:24  CAD\CAD.sln

    ..A..H.     15872  2008-08-28 15:04  CAD\CAD.suo

     目录          0  2008-08-27 14:43  CAD\CAD\obj\Debug\Refactor

     目录          0  2008-08-27 14:24  CAD\CAD\obj\Debug\TempPE

     目录          0  2008-08-28 16:13  CAD\CAD\bin\Debug

     目录          0  2008-08-28 16:55  CAD\CAD\obj\Debug

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

评论

共有 条评论