From 8d9dde4845dc400f670c8360043aac248acd37c6 Mon Sep 17 00:00:00 2001
From: DYH <1742647821@qq.com>
Date: Mon, 20 Jun 2022 05:37:28 +0000
Subject: [PATCH 1/2] =?UTF-8?q?add=20src/IFoxCAD.Cad/Runtime/CommandTool.c?=
=?UTF-8?q?s.=20=E5=A2=9E=E5=8A=A0sendcommand=E5=87=BD=E6=95=B0=20CommandT?=
=?UTF-8?q?ool.SendCommand()?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/IFoxCAD.Cad/Runtime/CommandTool.cs | 31 ++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 src/IFoxCAD.Cad/Runtime/CommandTool.cs
diff --git a/src/IFoxCAD.Cad/Runtime/CommandTool.cs b/src/IFoxCAD.Cad/Runtime/CommandTool.cs
new file mode 100644
index 0000000..8e604a4
--- /dev/null
+++ b/src/IFoxCAD.Cad/Runtime/CommandTool.cs
@@ -0,0 +1,31 @@
+public static class CommandTool
+{
+ ///
+ /// 发送cmd指令
+ ///
+ /// 命令内容
+ /// 指示发送的字符串是否在命令行上回显
+ internal static void SendCommand(string CommandParameter, bool echoCommand = false)
+ {
+ Document mdiActiveDocument = Application.DocumentManager.MdiActiveDocument;
+ SetFocus(mdiActiveDocument.Window.Handle);
+ if (mdiActiveDocument == null)
+ return;
+ if (CommandParameter.StartsWith("'"))
+ {
+ mdiActiveDocument.SendStringToExecute(CommandParameter + "\n", true, false, echoCommand);
+ }
+ else
+ {
+ string Left = Application.GetSystemVariable("cmdnames").ToString();
+ if (Left == "")
+ mdiActiveDocument.SendStringToExecute("_" + CommandParameter + "\n", true, false, echoCommand);
+ else if (Left.Length >= 4 && Left.Substring(0, 4).ToUpper() == "GRIP")
+ mdiActiveDocument.SendStringToExecute("_" + CommandParameter + "\n", true, false, echoCommand);
+ else
+ mdiActiveDocument.SendStringToExecute("\u0003\u0003_" + CommandParameter + "\n", true, false, echoCommand);
+ }
+ }
+ [System.Runtime.InteropServices.DllImport("user32.dll")]
+ private static extern IntPtr SetFocus(IntPtr hwnd);
+}
\ No newline at end of file
--
Gitee
From cd629a9c4775946c7c8fa91b6ef6c5f58d34f7f0 Mon Sep 17 00:00:00 2001
From: DYH <1742647821@qq.com>
Date: Mon, 20 Jun 2022 05:39:23 +0000
Subject: [PATCH 2/2] update src/IFoxCAD.Cad/Runtime/CommandTool.cs.
---
src/IFoxCAD.Cad/Runtime/CommandTool.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/IFoxCAD.Cad/Runtime/CommandTool.cs b/src/IFoxCAD.Cad/Runtime/CommandTool.cs
index 8e604a4..bb157c3 100644
--- a/src/IFoxCAD.Cad/Runtime/CommandTool.cs
+++ b/src/IFoxCAD.Cad/Runtime/CommandTool.cs
@@ -4,7 +4,7 @@ public static class CommandTool
/// 发送cmd指令
///
/// 命令内容
- /// 指示发送的字符串是否在命令行上回显
+ /// 指示发送的字符串是否在命令行上回显
internal static void SendCommand(string CommandParameter, bool echoCommand = false)
{
Document mdiActiveDocument = Application.DocumentManager.MdiActiveDocument;
--
Gitee