diff --git a/CADSecondDevelop/CADSDTemplate.png b/CADSecondDevelop/CADSDTemplate.png new file mode 100644 index 0000000000000000000000000000000000000000..a504da16f5cd9a414ff98f3a5955bba83c73edc7 Binary files /dev/null and b/CADSecondDevelop/CADSDTemplate.png differ diff --git a/CADSecondDevelop/CADSecondDevelop.csproj b/CADSecondDevelop/CADSecondDevelop.csproj new file mode 100644 index 0000000000000000000000000000000000000000..6cafeb85e25548915c9a1da5296815accb2152d6 --- /dev/null +++ b/CADSecondDevelop/CADSecondDevelop.csproj @@ -0,0 +1,40 @@ + + + Template + 0.0.1 + CAD.SecondDevelop.Template + CAD SecondDevelop Template + InspireFunction + vicwjb + InspireFunction + Templates to use when creating an library with IFoxCAD. + dotnet-new;templates;library;ifox;SecondDevelop + MIT + true + https://gitee.com/inspirefunction/ifoxcadtemplate + https://gitee.com/inspirefunction/ifoxcadtemplate.git + git + netstandard2.0 + true + false + content + $(NoWarn);NU5128 + true + readme.md + CADSDTemplate.png + + + + + + + + + + + True + \ + + + + diff --git a/CADSecondDevelop/CADSecondDevelop.sln b/CADSecondDevelop/CADSecondDevelop.sln new file mode 100644 index 0000000000000000000000000000000000000000..fc95a7ed40a1a3fbef0af4f0d74608750e3ed0d8 --- /dev/null +++ b/CADSecondDevelop/CADSecondDevelop.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35431.28 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CADSecondDevelop", "CADSecondDevelop.csproj", "{CB286D0F-AF94-420F-AFE8-665A4DF72A5F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CB286D0F-AF94-420F-AFE8-665A4DF72A5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CB286D0F-AF94-420F-AFE8-665A4DF72A5F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB286D0F-AF94-420F-AFE8-665A4DF72A5F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CB286D0F-AF94-420F-AFE8-665A4DF72A5F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7B4D18FB-59CF-4666-9AAB-8D5E2DC7E5F4} + EndGlobalSection +EndGlobal diff --git a/CADSecondDevelop/readme.md b/CADSecondDevelop/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..084fa57cbb152f631560f7f315bdb550d3e37cf7 --- /dev/null +++ b/CADSecondDevelop/readme.md @@ -0,0 +1,55 @@ +适用于CAD二次开发的项目模板。 + +安装准备: + +- Visual Studio: + + - 打开==开发者 PowerShell==,打开方式: + 1. 视图 => 终端 + 2. 快捷键:==Ctrl + \`==(\`是Esc下面的按键) + + - 在窗口定位到==CAD.SecondDevelop.Template.1.0.0.nupkg==文件所在的目录 + + ``` + PS D:\CADSecondDevelop> + ``` + + 输入:==CD .\bin\Debug== + + ``` + PS D:\CADSecondDevelop> CD .\bin\Debug + ``` + 回车 + ``` + PS D:\CADSecondDevelop\bin\Debug> + ``` + +- 命令提示符: + + - 打开==CAD.SecondDevelop.Template.1.0.0.nupkg==文件所在的目录 + - 在路径框内点击选中全部路径后,输入CMD,回车。 + - 确保显示路径为==CAD.SecondDevelop.Template.1.0.0.nupkg==文件所在目录,具体设置参考Visual Studio所述 + +使用==dotnet==工具安装: + +- ``` + dotnet new install CAD.SecondDevelop.Template.CSharp.0.1 + ``` + +- `如果提示:'dotnet' 不是内部或外部命令,也不是可运行的程序或批处理文件。` + +- 将`dotnet.exe`所在路径添加到系统环境变量`Path`中 + +此模板支持创建`AutoCAD`,`ZWCAD`,`GstarCAD`的项目。 + +1. 可以在vs里直接选择项目的类型。也可以用命令行创建。 + +- `dotnet new CADSD.0.1 -C acad -n acadtest` // 创建AutoCAD项目,并将项目命名为acadtest + +- `dotnet new CADSD.0.1 -C zcad -n zcadtest` // 创建ZWCAD项目,并将项目命名为zcadtest + +- `dotnet new CADSD.0.1 -C gcad -n gcadtest` // 创建GstarCAD项目,并将项目命名为gcadtest + +2. 卸载模版 + +- `dotnet new uninstall`,后命令行会显示你所有安装的可卸载模版,每个模版下部都有卸载命令,按命令执行即可 diff --git a/CADSecondDevelop/templates/CADSecondDevelopTemplate/.template.config/CADSDTemplate.png b/CADSecondDevelop/templates/CADSecondDevelopTemplate/.template.config/CADSDTemplate.png new file mode 100644 index 0000000000000000000000000000000000000000..a504da16f5cd9a414ff98f3a5955bba83c73edc7 Binary files /dev/null and b/CADSecondDevelop/templates/CADSecondDevelopTemplate/.template.config/CADSDTemplate.png differ diff --git a/CADSecondDevelop/templates/CADSecondDevelopTemplate/.template.config/template.json b/CADSecondDevelop/templates/CADSecondDevelopTemplate/.template.config/template.json new file mode 100644 index 0000000000000000000000000000000000000000..84894791ec33b23602a94904eab0190f75b7a69a --- /dev/null +++ b/CADSecondDevelop/templates/CADSecondDevelopTemplate/.template.config/template.json @@ -0,0 +1,52 @@ +{ + "$schema": "http://json.schemastore.org/template", + "icon": "CADSDTemplate.png", + "author": "vicwjb", + "classifications": [ + "Library" + ], + "name": "CADSecondDevelopTemplate.0.1", + "identity": "CAD.SecondDevelop.Template.CSharp.0.1", + "shortName": "CADSD.0.1", + "tags": { + "language": "C#", + "type": "project" + }, + "sourceName": "CADSecondDevelopTemplate", + "preferNameDirectory": true, + "symbols": { + "CAD": { + "type": "parameter", + "description": "The CAD for the project.", + "datatype": "choice", + "enableQuotelessLiterals": true, + "choices": [ + { + "choice": "acad", + "description": "AutoCAD" + }, + { + "choice": "zcad", + "description": "ZWCAD" + }, + { + "choice": "gcad", + "description": "GstarCAD" + } + ], + "defaultValue": "acad" + }, + "acad": { + "type": "computed", + "value": "(CAD == \"acad\")" + }, + "zcad": { + "type": "computed", + "value": "(CAD == \"zcad\")" + }, + "gcad": { + "type": "computed", + "value": "(CAD == \"gcad\")" + } + } +} \ No newline at end of file diff --git a/CADSecondDevelop/templates/CADSecondDevelopTemplate/CADSecondDevelopTemplate.csproj b/CADSecondDevelop/templates/CADSecondDevelopTemplate/CADSecondDevelopTemplate.csproj new file mode 100644 index 0000000000000000000000000000000000000000..d4d542dd5018db222af23ac50f8df92fee76aaec --- /dev/null +++ b/CADSecondDevelop/templates/CADSecondDevelopTemplate/CADSecondDevelopTemplate.csproj @@ -0,0 +1,56 @@ + + + + net48 + + enable + + preview + + true + + true + + True + + True + + true + + False + + 1.0.0.* + + 1.0.0.0 + + MSB3270;CS1591;CS3021 + + + + acad + gcad + zcad + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CADSecondDevelop/templates/CADSecondDevelopTemplate/CadCmds.cs b/CADSecondDevelop/templates/CADSecondDevelopTemplate/CadCmds.cs new file mode 100644 index 0000000000000000000000000000000000000000..81e0258283a4291f437e51c226e03ccbe3f224f9 --- /dev/null +++ b/CADSecondDevelop/templates/CADSecondDevelopTemplate/CadCmds.cs @@ -0,0 +1,27 @@ +[assembly: CommandClass(typeof(CADSecondDevelopTemplate.CadCmds))] + +namespace CADSecondDevelopTemplate; + +public partial class CadCmds +{ + private PaletteSet? MainSet { get; set; } = null; + + [CommandMethod(nameof(HelloCAD), CommandFlags.Session | CommandFlags.UsePickSet)] + public void HelloCAD() + { + if (MainSet == null || MainSet.Visible == false) + { + MainSet = new PaletteSet("ToolBox"); + ElementHost host = new() + { + AutoSize = true, + Dock = DockStyle.Fill, + Child = new Main() + }; + MainSet.Add("Add ElementHost", host); + MainSet.Visible = true; + MainSet.Size = new System.Drawing.Size(254, 645); + MainSet.Dock = DockSides.Left; + } + } +} diff --git a/CADSecondDevelop/templates/CADSecondDevelopTemplate/GlobalUsing.cs b/CADSecondDevelop/templates/CADSecondDevelopTemplate/GlobalUsing.cs new file mode 100644 index 0000000000000000000000000000000000000000..93bf39f136ece4ad86f398538a8647a79e2ed7e2 --- /dev/null +++ b/CADSecondDevelop/templates/CADSecondDevelopTemplate/GlobalUsing.cs @@ -0,0 +1,213 @@ +#if (acad) +global using System; +global using System.Collections; +global using System.Collections.Generic; +global using System.IO; +global using System.Linq; +global using System.Text; +global using System.Reflection; +global using System.Text.RegularExpressions; +global using System.Linq.Expressions; + +global using Microsoft.Win32; + +global using System.ComponentModel; +global using System.Runtime.InteropServices; +global using System.Collections.Specialized; +global using System.Windows.Forms; +global using System.Windows.Forms.Integration; +global using System.Diagnostics; +global using System.Drawing; +global using System.Runtime.CompilerServices; +global using System.Threading; +global using System.Diagnostics.CodeAnalysis; + +global using Exception = System.Exception; +global using Registry = Microsoft.Win32.Registry; +global using RegistryKey = Microsoft.Win32.RegistryKey; + +global using System.Collections.ObjectModel; + +global using Microsoft.CSharp.RuntimeBinder; + +global using System.Web.Script.Serialization; + +global using Autodesk.AutoCAD.ApplicationServices; +global using Autodesk.AutoCAD.EditorInput; +global using Autodesk.AutoCAD.Colors; +global using Autodesk.AutoCAD.DatabaseServices; +global using Autodesk.AutoCAD.Geometry; +global using Autodesk.AutoCAD.Runtime; +global using Autodesk.AutoCAD.Windows; + +global using Acap = Autodesk.AutoCAD.ApplicationServices.Application; +global using Acaop = Autodesk.AutoCAD.ApplicationServices.Core.Application; +global using Acgi = Autodesk.AutoCAD.GraphicsInterface; + +global using Autodesk.AutoCAD.DatabaseServices.Filters; +global using Autodesk.AutoCAD; + +global using Autodesk.AutoCAD.GraphicsInterface; + +global using WorldDraw = Autodesk.AutoCAD.GraphicsInterface.WorldDraw; +global using Manager = Autodesk.AutoCAD.GraphicsSystem.Manager; +global using Group = Autodesk.AutoCAD.DatabaseServices.Group; +global using Viewport = Autodesk.AutoCAD.DatabaseServices.Viewport; +global using Polyline = Autodesk.AutoCAD.DatabaseServices.Polyline; +global using Cad_DwgFiler = Autodesk.AutoCAD.DatabaseServices.DwgFiler; +global using Cad_DxfFiler = Autodesk.AutoCAD.DatabaseServices.DxfFiler; +global using Cad_ErrorStatus = Autodesk.AutoCAD.Runtime.ErrorStatus; +global using Color = Autodesk.AutoCAD.Colors.Color; +global using AcException = Autodesk.AutoCAD.Runtime.Exception; + +global using IFoxCAD.Basal; +global using IFoxCAD.Cad; + +#region Project Using +global using CADSecondDevelopTemplate.Models; +global using CADSecondDevelopTemplate.ViewModels; +global using CADSecondDevelopTemplate.Views; +#endregion + +#region Nuget Using +global using CommunityToolkit.Mvvm.ComponentModel; +global using CommunityToolkit.Mvvm.Input; +global using Microsoft.Xaml.Behaviors; +global using Newtonsoft.Json; +#endregion +#elif (zcad) + +global using System; +global using System.Collections; +global using System.Collections.Generic; +global using System.Collections.ObjectModel; +global using System.Collections.Specialized; +global using System.ComponentModel; +global using System.Diagnostics; +global using System.Drawing; +global using System.IO; +global using System.Linq; +global using System.Linq.Expressions; +global using System.Reflection; +global using System.Runtime.CompilerServices; +global using System.Runtime.InteropServices; +global using System.Text; +global using System.Text.RegularExpressions; +global using System.Threading; +global using System.Web.Script.Serialization; +global using System.Windows.Forms; +global using System.Windows.Forms.Integration; +global using Microsoft.CSharp.RuntimeBinder; +global using Microsoft.Win32; +global using System.Diagnostics.CodeAnalysis; + +global using ZwSoft.ZwCAD; +global using ZwSoft.ZwCAD.ApplicationServices; +global using ZwSoft.ZwCAD.Colors; +global using ZwSoft.ZwCAD.DatabaseServices; +global using ZwSoft.ZwCAD.DatabaseServices.Filters; +global using ZwSoft.ZwCAD.EditorInput; +global using ZwSoft.ZwCAD.Geometry; + +global using ZwSoft.ZwCAD.GraphicsInterface; +global using ZwSoft.ZwCAD.Runtime; +global using ZwSoft.ZwCAD.Windows; +global using Registry = Microsoft.Win32.Registry; +global using RegistryKey = Microsoft.Win32.RegistryKey; +global using Exception = System.Exception; +global using Acap = ZwSoft.ZwCAD.ApplicationServices.Application; +global using Acaop = ZwSoft.ZwCAD.ApplicationServices.Application; +global using Cad_DwgFiler = ZwSoft.ZwCAD.DatabaseServices.DwgFiler; +global using Cad_DxfFiler = ZwSoft.ZwCAD.DatabaseServices.DxfFiler; +global using Group = ZwSoft.ZwCAD.DatabaseServices.Group; +global using Polyline = ZwSoft.ZwCAD.DatabaseServices.Polyline; +global using Viewport = ZwSoft.ZwCAD.DatabaseServices.Viewport; +global using WorldDraw = ZwSoft.ZwCAD.GraphicsInterface.WorldDraw; +global using Manager = ZwSoft.ZwCAD.GraphicsSystem.Manager; +global using Cad_ErrorStatus = ZwSoft.ZwCAD.Runtime.ErrorStatus; +global using Color = ZwSoft.ZwCAD.Colors.Color; +global using AcException = ZwSoft.ZwCAD.Runtime.Exception; + +#region Project Using +global using CADSecondDevelopTemplate.Models; +global using CADSecondDevelopTemplate.ViewModels; +global using CADSecondDevelopTemplate.Views; +#endregion + +#region Nuget Using +global using CommunityToolkit.Mvvm.ComponentModel; +global using CommunityToolkit.Mvvm.Input; +global using Microsoft.Xaml.Behaviors; +global using Newtonsoft.Json; +#endregion +#elif (gcad) + +global using GrxCAD; + +global using GrxCAD.ApplicationServices; +global using GrxCAD.Colors; +global using GrxCAD.DatabaseServices; +global using GrxCAD.DatabaseServices.Filters; +global using GrxCAD.EditorInput; +global using GrxCAD.Geometry; + +global using GrxCAD.GraphicsInterface; +global using GrxCAD.Internal; +global using GrxCAD.Runtime; +global using GrxCAD.Windows; + +global using System; +global using System.Collections; +global using System.Collections.Generic; +global using System.Collections.ObjectModel; +global using System.Collections.Specialized; +global using System.ComponentModel; +global using System.Diagnostics; +global using System.Drawing; +global using System.IO; +global using System.Linq; +global using System.Linq.Expressions; +global using System.Reflection; +global using System.Runtime.CompilerServices; +global using System.Runtime.InteropServices; +global using System.Text; +global using System.Text.RegularExpressions; +global using System.Threading; +global using System.Web.Script.Serialization; +global using System.Windows.Forms; +global using System.Windows.Forms.Integration; +global using Microsoft.CSharp.RuntimeBinder; +global using Microsoft.Win32; +global using System.Diagnostics.CodeAnalysis; + +global using Acap = GrxCAD.ApplicationServices.Application; +global using Acaop = GrxCAD.ApplicationServices.Application; +global using Cad_DwgFiler = GrxCAD.DatabaseServices.DwgFiler; +global using Cad_DxfFiler = GrxCAD.DatabaseServices.DxfFiler; +global using Group = GrxCAD.DatabaseServices.Group; +global using Polyline = GrxCAD.DatabaseServices.Polyline; +global using Viewport = GrxCAD.DatabaseServices.Viewport; +global using Acgi = GrxCAD.GraphicsInterface; +global using WorldDraw = GrxCAD.GraphicsInterface.WorldDraw; +global using Manager = GrxCAD.GraphicsSystem.Manager; +global using Cad_ErrorStatus = GrxCAD.Runtime.ErrorStatus; +global using Registry = Microsoft.Win32.Registry; +global using RegistryKey = Microsoft.Win32.RegistryKey; +global using Exception = System.Exception; +global using Color = GrxCAD.Colors.Color; +global using AcException = GrxCAD.Runtime.Exception; + +#region Project Using +global using CADSecondDevelopTemplate.Models; +global using CADSecondDevelopTemplate.ViewModels; +global using CADSecondDevelopTemplate.Views; +#endregion + +#region Nuget Using +global using CommunityToolkit.Mvvm.ComponentModel; +global using CommunityToolkit.Mvvm.Input; +global using Microsoft.Xaml.Behaviors; +global using Newtonsoft.Json; +#endregion +#endif + diff --git a/CADSecondDevelop/templates/CADSecondDevelopTemplate/Models/MainModel.cs b/CADSecondDevelop/templates/CADSecondDevelopTemplate/Models/MainModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..c81d4e832133cf00cbe274aaf572817a418cb38f --- /dev/null +++ b/CADSecondDevelop/templates/CADSecondDevelopTemplate/Models/MainModel.cs @@ -0,0 +1,6 @@ +namespace CADSecondDevelopTemplate.Models; +public partial class MainModel : ObservableObject +{ + [ObservableProperty] + private string textBoxText = ""; +} diff --git a/CADSecondDevelop/templates/CADSecondDevelopTemplate/PlugInApplication.cs b/CADSecondDevelop/templates/CADSecondDevelopTemplate/PlugInApplication.cs new file mode 100644 index 0000000000000000000000000000000000000000..4d26e01393e234764238e54d1d8b5f540b8b53ce --- /dev/null +++ b/CADSecondDevelop/templates/CADSecondDevelopTemplate/PlugInApplication.cs @@ -0,0 +1,18 @@ +[assembly: ExtensionApplication(typeof(CADSecondDevelopTemplate.PlugInApplication))] +namespace CADSecondDevelopTemplate; +public class PlugInApplication : IExtensionApplication +{ + public void Initialize() + { + Acap.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nloading...\n"); + + // 如果需要将程序的目录加入信任路径,将下行代码取消注释 + // AppendSupportPath(CurrentDirectory.FullName); + } + + public void Terminate() + { + // 这里不能调用输出函数,因为这个函数执行的时候,已经没有editor对象了。 + // 所以如果不是想要在cad关闭的时候清理某些东西,这里不用写任何的代码。 + } +} diff --git a/CADSecondDevelop/templates/CADSecondDevelopTemplate/ViewModels/MainViewModel.cs b/CADSecondDevelop/templates/CADSecondDevelopTemplate/ViewModels/MainViewModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..99dce31373ecbaa57ff049042b7e0eca6f050c5f --- /dev/null +++ b/CADSecondDevelop/templates/CADSecondDevelopTemplate/ViewModels/MainViewModel.cs @@ -0,0 +1,15 @@ +namespace CADSecondDevelopTemplate.ViewModels; + +public partial class MainViewModel : ObservableObject +{ + public static MainViewModel Default => new(); + + [ObservableProperty] + private MainModel mModel = new(); + + [RelayCommand] + private void ButtonClick(string name) + { + MModel.TextBoxText = name; + } +} diff --git a/CADSecondDevelop/templates/CADSecondDevelopTemplate/Views/Main.xaml b/CADSecondDevelop/templates/CADSecondDevelopTemplate/Views/Main.xaml new file mode 100644 index 0000000000000000000000000000000000000000..17fd576abc23584e078d6d6f6a1a3c40b44651ad --- /dev/null +++ b/CADSecondDevelop/templates/CADSecondDevelopTemplate/Views/Main.xaml @@ -0,0 +1,47 @@ + + + + + + + + + + + diff --git a/CADSecondDevelop/templates/CADSecondDevelopTemplate/Views/Main.xaml.cs b/CADSecondDevelop/templates/CADSecondDevelopTemplate/Views/Main.xaml.cs new file mode 100644 index 0000000000000000000000000000000000000000..3e8bcda187966d5280a53da75d9a189c37a5f2b4 --- /dev/null +++ b/CADSecondDevelop/templates/CADSecondDevelopTemplate/Views/Main.xaml.cs @@ -0,0 +1,13 @@ +namespace CADSecondDevelopTemplate.Views; + +/// +/// Main.xaml 的交互逻辑 +/// +public partial class Main : System.Windows.Controls.UserControl +{ + public Main() + { + InitializeComponent(); + this.DataContext = MainViewModel.Default; + } +}