diff --git a/NDSD-Screwdriver.sln b/NDSD-Screwdriver.sln new file mode 100644 index 0000000..df2526f --- /dev/null +++ b/NDSD-Screwdriver.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.35122.118 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDSD-Screwdriver", "NDSD-Screwdriver\NDSD-Screwdriver.csproj", "{2448106D-4FBA-4E8F-83B7-3C727C4A4ECE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDSD-TouchSocket", "NDSD-TouchSocket\NDSD-TouchSocket.csproj", "{B2580256-9ED8-4985-BE38-3F771B13E9FD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2448106D-4FBA-4E8F-83B7-3C727C4A4ECE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2448106D-4FBA-4E8F-83B7-3C727C4A4ECE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2448106D-4FBA-4E8F-83B7-3C727C4A4ECE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2448106D-4FBA-4E8F-83B7-3C727C4A4ECE}.Release|Any CPU.Build.0 = Release|Any CPU + {B2580256-9ED8-4985-BE38-3F771B13E9FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2580256-9ED8-4985-BE38-3F771B13E9FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2580256-9ED8-4985-BE38-3F771B13E9FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2580256-9ED8-4985-BE38-3F771B13E9FD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {68FA4DBD-E55A-4D47-B660-0E598271CF8F} + EndGlobalSection +EndGlobal diff --git a/NDSD-Screwdriver/.gitattributes b/NDSD-Screwdriver/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/NDSD-Screwdriver/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/NDSD-Screwdriver/.gitignore b/NDSD-Screwdriver/.gitignore new file mode 100644 index 0000000..9491a2f --- /dev/null +++ b/NDSD-Screwdriver/.gitignore @@ -0,0 +1,363 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/NDSD-Screwdriver/App.config b/NDSD-Screwdriver/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/NDSD-Screwdriver/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/NDSD-Screwdriver/Form1.Designer.cs b/NDSD-Screwdriver/Form1.Designer.cs new file mode 100644 index 0000000..a05d7b7 --- /dev/null +++ b/NDSD-Screwdriver/Form1.Designer.cs @@ -0,0 +1,40 @@ +namespace NDSD_Screwdriver +{ + partial class Form1 + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/NDSD-Screwdriver/Form1.cs b/NDSD-Screwdriver/Form1.cs new file mode 100644 index 0000000..7e21f37 --- /dev/null +++ b/NDSD-Screwdriver/Form1.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace NDSD_Screwdriver +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} diff --git a/NDSD-Screwdriver/NDSD-Screwdriver.csproj b/NDSD-Screwdriver/NDSD-Screwdriver.csproj new file mode 100644 index 0000000..23a5c02 --- /dev/null +++ b/NDSD-Screwdriver/NDSD-Screwdriver.csproj @@ -0,0 +1,80 @@ + + + + + Debug + AnyCPU + {2448106D-4FBA-4E8F-83B7-3C727C4A4ECE} + WinExe + NDSD_Screwdriver + NDSD-Screwdriver + v4.8 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/NDSD-Screwdriver/NDSD-Screwdriver.sln b/NDSD-Screwdriver/NDSD-Screwdriver.sln new file mode 100644 index 0000000..7afd2a1 --- /dev/null +++ b/NDSD-Screwdriver/NDSD-Screwdriver.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.35122.118 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDSD-Screwdriver", "NDSD-Screwdriver.csproj", "{2448106D-4FBA-4E8F-83B7-3C727C4A4ECE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDSD-TouchSocket", "..\NDSD-TouchSocket\NDSD-TouchSocket.csproj", "{B2580256-9ED8-4985-BE38-3F771B13E9FD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2448106D-4FBA-4E8F-83B7-3C727C4A4ECE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2448106D-4FBA-4E8F-83B7-3C727C4A4ECE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2448106D-4FBA-4E8F-83B7-3C727C4A4ECE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2448106D-4FBA-4E8F-83B7-3C727C4A4ECE}.Release|Any CPU.Build.0 = Release|Any CPU + {B2580256-9ED8-4985-BE38-3F771B13E9FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2580256-9ED8-4985-BE38-3F771B13E9FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2580256-9ED8-4985-BE38-3F771B13E9FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2580256-9ED8-4985-BE38-3F771B13E9FD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {68FA4DBD-E55A-4D47-B660-0E598271CF8F} + EndGlobalSection +EndGlobal diff --git a/NDSD-Screwdriver/Program.cs b/NDSD-Screwdriver/Program.cs new file mode 100644 index 0000000..0ca9a55 --- /dev/null +++ b/NDSD-Screwdriver/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace NDSD_Screwdriver +{ + internal static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/NDSD-Screwdriver/Properties/AssemblyInfo.cs b/NDSD-Screwdriver/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..51fad9c --- /dev/null +++ b/NDSD-Screwdriver/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("NDSD-Screwdriver")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("NDSD-Screwdriver")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("2448106d-4fba-4e8f-83b7-3c727c4a4ece")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/NDSD-Screwdriver/Properties/Resources.Designer.cs b/NDSD-Screwdriver/Properties/Resources.Designer.cs new file mode 100644 index 0000000..4b1cf71 --- /dev/null +++ b/NDSD-Screwdriver/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace NDSD_Screwdriver.Properties +{ + + + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NDSD_Screwdriver.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/NDSD-Screwdriver/Properties/Resources.resx b/NDSD-Screwdriver/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/NDSD-Screwdriver/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/NDSD-Screwdriver/Properties/Settings.Designer.cs b/NDSD-Screwdriver/Properties/Settings.Designer.cs new file mode 100644 index 0000000..5532fad --- /dev/null +++ b/NDSD-Screwdriver/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace NDSD_Screwdriver.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/NDSD-Screwdriver/Properties/Settings.settings b/NDSD-Screwdriver/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/NDSD-Screwdriver/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/NDSD-TouchSocket/BufferAnalysis.cs b/NDSD-TouchSocket/BufferAnalysis.cs new file mode 100644 index 0000000..57fc757 --- /dev/null +++ b/NDSD-TouchSocket/BufferAnalysis.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NDSD_TouchSocket +{ + internal class BufferAnalysis + { + private static bool LastState; + public static int CountNumber = 0; + + public static void JudgeSingle(bool state) + { + if (state == true) + { + LastState = state; + CountNumber++; + } + else if (state == false && LastState == false) + { + LastState = state; + CountNumber++; + } + } + + + /// + /// 将一个数组拆成另外一个数组 + /// + /// 原始数组,被拆分的数组 + /// 从原始数组第几个元素开始 + /// 目标数组的长度 + /// 目标数组开始的元素序号,默认为0 + /// + public static byte[] SplitByteArray(byte[] originbyte, int oringinstartindex, int destbytelength, int destbytestartindex = 0) + { + byte[] result = new byte[destbytelength]; + System.Array.Copy(originbyte, oringinstartindex, result, destbytestartindex, destbytelength); + return result; + } + } +} diff --git a/NDSD-TouchSocket/DOperate.cs b/NDSD-TouchSocket/DOperate.cs new file mode 100644 index 0000000..4af5833 --- /dev/null +++ b/NDSD-TouchSocket/DOperate.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NDSD_TouchSocket +{ + public class DOperate + { + SendAnalysis sendAnalysis; + + public DOperate() + { + sendAnalysis = new SendAnalysis(); + } + + public byte[] DOpen(Port port) + { + return sendAnalysis.DOpenDataAnalysis((byte)port); + } + + public byte[] DClose(Port port) + { + return sendAnalysis.DCloseDataAnlysis((byte)port); + } + } + + public enum Port + { + D1 = 0x05, + D2, + D3, + D4, + D5, + D6, + D7, + D8, + D9, + D10, + D11, + D12, + D13, + D14, + D15, + D16, + } + +} diff --git a/NDSD-TouchSocket/NDSD-TouchSocket.csproj b/NDSD-TouchSocket/NDSD-TouchSocket.csproj new file mode 100644 index 0000000..23c28e7 --- /dev/null +++ b/NDSD-TouchSocket/NDSD-TouchSocket.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {B2580256-9ED8-4985-BE38-3F771B13E9FD} + Library + Properties + NDSD_TouchSocket + NDSD-TouchSocket + v4.8 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\NDSD-Screwdriver\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + + ..\NDSD-Screwdriver\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + ..\NDSD-Screwdriver\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\NDSD-Screwdriver\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\NDSD-Screwdriver\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\NDSD-Screwdriver\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + + + + + + + ..\NDSD-Screwdriver\packages\TouchSocket.2.1.0-rc.9\lib\net472\TouchSocket.dll + + + ..\NDSD-Screwdriver\packages\TouchSocket.Core.2.1.0-rc.9\lib\net472\TouchSocket.Core.dll + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/NDSD-TouchSocket/Properties/AssemblyInfo.cs b/NDSD-TouchSocket/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0921020 --- /dev/null +++ b/NDSD-TouchSocket/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("NDSD-TouchSocket")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("NDSD-TouchSocket")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("b2580256-9ed8-4985-be38-3f771b13e9fd")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/NDSD-TouchSocket/SendAnalysis.cs b/NDSD-TouchSocket/SendAnalysis.cs new file mode 100644 index 0000000..e67b6bc --- /dev/null +++ b/NDSD-TouchSocket/SendAnalysis.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NDSD_TouchSocket +{ + public class SendAnalysis + { + private string DOperateHead = "01 05 00 "; + private string DOpenData = " FF 00"; + private string DCloseData = " 00 00"; + + //开启 + public byte[] DOpenDataAnalysis(byte port) + { + string CrcData = DOperateHead + port.ToString("X2") + DOpenData; //结合 + return CrcCombine(CrcData); + } + + //关闭 + public byte[] DCloseDataAnlysis(byte port) + { + string CrcData = DOperateHead + port.ToString("X2") + DCloseData; //结合 + return CrcCombine(CrcData); + } + + //结合CRC + public byte[] CrcCombine(string CrcData) + { + byte[] body = CrcData.ToBytesFromHexString(); //byte的校验体 + int crc = CRC16.CalculateCRC(body, body.Length); //int32CRC值 + byte highByte = (byte)(crc >> 8); // 获取高字节 + byte lowByte = (byte)(crc & 0xFF); // 获取低字节 + byte[] crcBytes = { lowByte, highByte }; + return body.Concat(crcBytes).ToArray(); + } + + } + + +} diff --git a/NDSD-TouchSocket/TcpServer.cs b/NDSD-TouchSocket/TcpServer.cs new file mode 100644 index 0000000..6c0e129 --- /dev/null +++ b/NDSD-TouchSocket/TcpServer.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TouchSocket.Core; +using TouchSocket.Sockets; + +namespace NDSD_TouchSocket +{ + public class TcpServer + { + private static readonly Lazy lazy = new Lazy(() => new TcpServer()); + + public static TcpServer Instance => lazy.Value; + + TcpService service = new TcpService(); + + public bool ServerOpen(string ip, string port) + { + try + { + service.Connecting = (client, e) => + { + Console.WriteLine(client.IP + " 正在连接"); + return EasyTask.CompletedTask; + };//有客户端正在连接 + service.Connected = (client, e) => + { + Console.WriteLine(client.IP + " 成功连接"); + service.ResetIdAsync(client.Id, client.IP); + return EasyTask.CompletedTask; + };//有客户端成功连接 + service.Closing = (client, e) => + { + Console.WriteLine(client.IP + " 正在断开连接"); + return EasyTask.CompletedTask; + };//有客户端正在断开连接,只有当主动断开时才有效。 + service.Closed = (client, e) => + { + Console.WriteLine(client.IP + " 断开连接"); + return EasyTask.CompletedTask; + };//有客户端断开连接 + service.Received = (client, e) => + { + ////从客户端收到信息 + //var mes = Encoding.ASCII.GetString(e.ByteBlock.Buffer, 0, e.ByteBlock.Len);//注意:数据长度是byteBlock.Len + //logHelper.Info($"已从{client.IP}:{client.Port}接收到信息:{mes}"); + + BufferMemory(BufferAnalysis.SplitByteArray(e.ByteBlock.Span.ToArray(), 0, e.ByteBlock.Length)); + + return EasyTask.CompletedTask; + }; + + service.Setup(new TouchSocketConfig()//载入配置 + .SetListenOptions(option => + { + option.Add(new TcpListenOption() + { + IpHost = ip + ":" + port, + Name = "Server",//名称用于区分监听 + ServiceSslOption = null,//可以针对当前监听,单独启用ssl加密 + Adapter = () => new NormalDataHandlingAdapter(),//可以单独对当前地址监听,配置适配器 + //还有其他可配置项,都是单独对当前地址有效。 + }); + }) + .ConfigureContainer(a =>//容器的配置顺序应该在最前面 + { + a.AddConsoleLogger();//添加一个控制台日志注入(注意:在maui中控制台日志不可用) + }) + .ConfigurePlugins(a => + { + //a.Add();//此处可以添加插件 + })); + try + { + service.Start(); + return true; + } + catch (Exception ex) + { + return false; + } + } + catch (Exception ex) + { + return false; + } + } + + public bool Isopen() + { + if (service.ServerState == ServerState.None) + { + return false; + } + return true; + } + + public bool Isstart() + { + if (service.ServerState == ServerState.Stopped) + { + return false; + } + return true; + } + + public bool ServerStart() + { + try + { + service.Start(); + return true; + } + catch (Exception ex) + { + return false; + } + } + + public bool ServerStop() + { + try + { + service.Stop(); + return true; + } + catch (Exception ex) + { + return false; + } + } + + public bool ServerDispose() + { + try + { + service.Dispose(); + return true; + } + catch (Exception ex) + { + return false; + } + } + + public async void SendMessage(byte[] bytes) + { + //尝试性获取 + if (service.TryGetClient("192.168.0.178", out var sessionClient)) + { + await sessionClient.SendAsync(bytes); + } + return; + } + + private void BufferMemory(byte[] bytes) + { + if (bytes[4] == 0x00 && bytes[5] == 0xB9) + { + BufferAnalysis.JudgeSingle(false); + } + else if (bytes[4] == 0xFF && bytes[5] == 0xF9) + { + BufferAnalysis.JudgeSingle(true); + } + } + + } +} diff --git a/NDSD-TouchSocket/Utils.cs b/NDSD-TouchSocket/Utils.cs new file mode 100644 index 0000000..efe0755 --- /dev/null +++ b/NDSD-TouchSocket/Utils.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NDSD_TouchSocket +{ + public static class Utils + { + /// + /// 16进制格式字符串转字节数组 + /// + /// + /// + public static byte[] ToBytesFromHexString(this string hexString) + { + //以 ' ' 分割字符串,并去掉空字符 + string[] chars = hexString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + byte[] returnBytes = new byte[chars.Length]; + //逐个字符变为16进制字节数据 + for (int i = 0; i < chars.Length; i++) + { + returnBytes[i] = Convert.ToByte(chars[i], 16); + } + return returnBytes; + } + + /// + /// 用指定编码将给定的字符串转16进制格式字符串 + /// + /// 待转换的字符串 + /// 编码规则 + /// + public static string ToHexString(this string plainString, Encoding encode) + { + byte[] byteDatas = encode.GetBytes(plainString); + return ToHexStrFromByte(byteDatas); + } + + /// + /// 字节数组转16进制字符串:空格分隔 + /// + /// + /// + public static string ToHexStrFromByte(this byte[] byteDatas) + { + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < byteDatas.Length; i++) + { + builder.Append(string.Format("{0:X2} ", byteDatas[i])); + } + return builder.ToString().Trim(); + } + } + + public static class CRC16 + { + private static readonly byte[] auchCRCHi = new byte[] { + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, + 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, + 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, + 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, + 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, + 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, + 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, + 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, + 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, + 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 + }; + + private static readonly byte[] auchCRCLo = new byte[] { + 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, + 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, + 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, + 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, + 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4, + 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, + 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, + 0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, + 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, + 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29, + 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, + 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, + 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, + 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, + 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, + 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, + 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E, + 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, + 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, + 0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, + 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, + 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, + 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, + 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, + 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, + 0x43, 0x83, 0x41, 0x81, 0x80, 0x40 + }; + + public static int CalculateCRC(byte[] puchMsg, int usDataLen) + { + byte uchCRCHi = 0xFF; + byte uchCRCLo = 0xFF; + int uIndex; + + for (int i = 0; i < usDataLen; i++) + { + uIndex = uchCRCLo ^ puchMsg[i]; + uchCRCLo = (byte)(uchCRCHi ^ auchCRCHi[uIndex]); + uchCRCHi = auchCRCLo[uIndex]; + } + + return (uchCRCHi << 8) | uchCRCLo; // 返回校验值 + } + } +} diff --git a/NDSD-TouchSocket/packages.config b/NDSD-TouchSocket/packages.config new file mode 100644 index 0000000..0cf70b2 --- /dev/null +++ b/NDSD-TouchSocket/packages.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file