資源簡介
可實現(xiàn)動態(tài)縮放功能以及對象捕捉功能,仿AutoCAD的簡易交互式CAD系統(tǒng)。由于代碼沒寫詳細注釋,歡迎來私信或郵件詢問。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?NCEditor.AffineTransform;
using?NCEditor.Mouse;
using?System.Drawing.Drawing2D;
using?NCEditor.Tools;
using?NCEditor.CanvasCtrl;
using?NCEditor.SnapPoint;
namespace?NCEditor
{
????public?partial?class?FormDoc?:?Form
????{
????????public?static?baseTool?currentTool;//當前命令
????????public?static?DictionaryseTool>?registerTool?=?new?DictionaryseTool>();
????????//初始化繪圖工具
????????public?const?string?CREATELINETOOL?=?“CREATELINETOOL“;
????????public?const?string?CREATERECTANGLETOOL?=?“CREATERECTANGLETOOL“;
????????public?const?string?CREATECIRCLETOOL?=?“CREATECIRCLETOOL“;
????????//初始化編輯工具
????????public?const?string?NOTOOLLOAD?=?“NOTOOLLOAD“;
????????public?const?string?EDITDELETETOOL?=?“EDITDELETETOOL“;
????????public?const?string?EDITMOVETOOL?=?“EDITMOVETOOL“;
????????//記錄上一個命令
????????public?static?string?LASTTOOL?=?“NOTOOLLOAD“;
????????public?FormDoc()
????????{
????????????InitializeComponent();
????????????//注冊繪圖工具
????????????registerTool.Add(CREATELINETOOL?new?CreateLineTool());
????????????registerTool.Add(CREATERECTANGLETOOL?new?CreateRectangleTool());
????????????registerTool.Add(CREATECIRCLETOOL?new?CreateCircleTool());
????????????//注冊編輯工具
????????????registerTool.Add(NOTOOLLOAD?new?NoToolLoad());
????????????registerTool.Add(EDITDELETETOOL?new?EditDeleteTool());
????????????currentTool?=?registerTool[NOTOOLLOAD];
????????}
????????public?void?UseTool(string?registerName)//加載工具
????????{
????????????currentTool.UnLoadTool();
????????????currentTool?=?registerTool[registerName];
????????????currentTool.LoadTool();
????????????//baseTool?setTool?=?registerTool[registerName];
????????????//if?(setTool?!=?null)
????????????//{
????????????//????setTool.LoadTool();
????????????//????currentTool?=?setTool;
????????????//}
????????}
????????private?void?FormDoc_Load(object?sender?EventArgs?e)
????????{
????????????canvasDraw.Cursor?=?new?Cursor(“CursorBlank.cur“);//載入自定義空鼠標。
????????????MouseShape.Mstyle?=?Mousestyle.None;//程序啟動無MouseMove事件時繪圖窗口無鼠標。
????????}
????????private?void?canvasDraw_MouseMove(object?sender?MouseEventArgs?e)
????????{
????????????currentTool.MouseMove(e);
????????????StatusX.Text?=?MouseShape.MousePoint.X.ToString();
????????????StatusY.Text?=?MouseShape.MousePoint.Y.ToString();
????????}
????????private?void?canvasDraw_MouseDown(object?sender?MouseEventArgs?e)
????????{
????????????currentTool.MouseDown(e);
????????}
????????private?void?canvasDraw_KeyDown(object?sender?KeyEventArgs?e)
????????{
????????????currentTool.KeyDown(e);
????????????if?(e.KeyCode?==?Keys.Space?||?e.KeyCode?==?Keys.Enter)
????????????{
????????????????if?(baseTool.count?==?1)
????????????????{
????????????????????curren
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4807??2013-01-06?11:48??CAD\NCEditor\AffineTransform\CoordinateShape.cs
?????文件???????1869??2012-09-09?16:01??CAD\NCEditor\AffineTransform\NCMatrix.cs
?????文件????????326??2012-08-14?10:26??CAD\NCEditor\bin\Debug\CursorBlank.cur
?????文件??????54784??2013-02-19?21:52??CAD\NCEditor\bin\Debug\NCEditor.exe
?????文件?????146944??2013-02-19?21:52??CAD\NCEditor\bin\Debug\NCEditor.pdb
?????文件??????11600??2013-02-20?21:53??CAD\NCEditor\bin\Debug\NCEditor.vshost.exe
?????文件????????490??2012-06-02?22:34??CAD\NCEditor\bin\Debug\NCEditor.vshost.exe.manifest
?????文件???????5926??2013-01-06?11:56??CAD\NCEditor\CanvasCtrl\Canvas.cs
?????文件???????1124??2012-08-13?21:47??CAD\NCEditor\CanvasCtrl\Canvas.Designer.cs
?????文件???????7028??2013-02-19?15:48??CAD\NCEditor\ClassDiagram1.cd
?????文件???????7307??2013-02-19?15:49??CAD\NCEditor\ClassDiagram2.cd
?????文件???????7580??2013-02-19?18:19??CAD\NCEditor\ClassDiagram3.cd
?????文件????????326??2012-08-14?10:26??CAD\NCEditor\CursorBlank.cur
?????文件???????4164??2012-10-01?10:35??CAD\NCEditor\FormDoc.cs
?????文件???????9510??2012-10-01?10:34??CAD\NCEditor\FormDoc.Designer.cs
?????文件??????12149??2012-10-01?10:34??CAD\NCEditor\FormDoc.resx
?????文件???????2249??2013-01-06?11:56??CAD\NCEditor\Mouse\MouseShape.cs
?????文件????????233??2012-08-13?22:15??CAD\NCEditor\Mouse\Mousest
?????文件???????5546??2013-02-19?18:19??CAD\NCEditor\NCEditor.csproj
?????文件??????13224??2013-01-06?11:56??CAD\NCEditor\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????6815??2013-02-19?21:52??CAD\NCEditor\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????812??2012-10-01?10:50??CAD\NCEditor\obj\x86\Debug\GenerateResource.read.1.tlog
?????文件???????1108??2012-10-01?10:50??CAD\NCEditor\obj\x86\Debug\GenerateResource.write.1.tlog
?????文件???????6542??2013-02-20?21:53??CAD\NCEditor\obj\x86\Debug\NCEditor.csproj.FileListAbsolute.txt
?????文件???????1052??2013-02-19?16:15??CAD\NCEditor\obj\x86\Debug\NCEditor.csproj.GenerateResource.Cache
?????文件???????9174??2013-02-19?21:42??CAD\NCEditor\obj\x86\Debug\NCEditor.csprojResolveAssemblyReference.cache
?????文件??????54784??2013-02-19?21:52??CAD\NCEditor\obj\x86\Debug\NCEditor.exe
?????文件???????4361??2013-02-19?21:42??CAD\NCEditor\obj\x86\Debug\NCEditor.FormDoc.resources
?????文件?????146944??2013-02-19?21:52??CAD\NCEditor\obj\x86\Debug\NCEditor.pdb
?????文件????????180??2013-02-19?21:42??CAD\NCEditor\obj\x86\Debug\NCEditor.Properties.Resources.resources
............此處省略52個文件信息
評論
共有 條評論