From 7c26e343a6df8736e8a60f7c32fe8b8b4ffbcb5d Mon Sep 17 00:00:00 2001 From: lihanbo Date: Mon, 23 Dec 2024 11:55:20 +0800 Subject: [PATCH] =?UTF-8?q?105040=20Update=20=E5=A2=9E=E5=8A=A0=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E5=BC=80=E5=90=AF=E9=80=BB=E8=BE=91=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E5=90=8C=E6=97=B6=E5=BC=80=E5=90=AF=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs | 31 +++++++++++++++---- Sinvo.EplanHpD.Plugin/PluginEntry.cs | 3 +- Sinvo.EplanHpD.Plugin/ScanPluginEntry.cs | 26 +++++++++++----- .../Sinvo.EplanHpD.Plugin.csproj | 11 +++++++ 4 files changed, 57 insertions(+), 14 deletions(-) diff --git a/Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs b/Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs index 11a2f48..589ef77 100644 --- a/Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs +++ b/Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs @@ -1,6 +1,7 @@ using EPLAN.Harness.API; using EPLAN.Harness.API.Plugins.Core; using EPLAN.Harness.AppCore; +using Sinvo.EplanHpD.Plugin.Service; using Sinvo.EplanHpD.Plugin.WPFUI; using Sinvo.EplanHpD.Plugin.WPFUI.Extension; using Sinvo.EplanHpD.Plugin.WPFUI.Utils; @@ -8,6 +9,7 @@ using System; using System.Drawing; using System.IO; using System.Reflection; +using System.Runtime.Remoting; using System.Windows.Forms.Integration; namespace Sinvo.EplanHpD.Plugin @@ -51,15 +53,32 @@ namespace Sinvo.EplanHpD.Plugin public string ToolbarTooltip => "伺服电机线缆抓取"; + LectotypeWindow window; + public void Execute(HpdApi api) { + new DBHelper().CodeFirst(); + var doc = api.CurrentProject.GetActiveDocument(); - var window = new LectotypeWindow(doc.ID); - ElementHost.EnableModelessKeyboardInterop(window); - var mainApp = BaseApp.ActiveApplication; - var helper = new System.Windows.Interop.WindowInteropHelper(window); - helper.Owner = mainApp.Handle; - window.Show(); + if(window == null) + { + window = new LectotypeWindow(doc.ID); + ElementHost.EnableModelessKeyboardInterop(window); + var mainApp = BaseApp.ActiveApplication; + var helper = new System.Windows.Interop.WindowInteropHelper(window); + helper.Owner = mainApp.Handle; + window.Closed += delegate + { + window = null; + }; + window.Show(); + } + else + { + window.WindowState = System.Windows.WindowState.Normal; + window.Activate(); + } + } public void Initialize() diff --git a/Sinvo.EplanHpD.Plugin/PluginEntry.cs b/Sinvo.EplanHpD.Plugin/PluginEntry.cs index 57eb31b..3b6f434 100644 --- a/Sinvo.EplanHpD.Plugin/PluginEntry.cs +++ b/Sinvo.EplanHpD.Plugin/PluginEntry.cs @@ -116,10 +116,11 @@ namespace Sinvo.EplanHpD.Plugin catch (Exception) { window = new MainWindow(flexReport); + // 解决WPF窗体在WinForm中无法输入的问题 ElementHost.EnableModelessKeyboardInterop(window); window.Show(); } - // 解决WPF窗体在WinForm中无法输入的问题 + } } diff --git a/Sinvo.EplanHpD.Plugin/ScanPluginEntry.cs b/Sinvo.EplanHpD.Plugin/ScanPluginEntry.cs index d104291..84088da 100644 --- a/Sinvo.EplanHpD.Plugin/ScanPluginEntry.cs +++ b/Sinvo.EplanHpD.Plugin/ScanPluginEntry.cs @@ -50,16 +50,28 @@ namespace Sinvo.EplanHpD.Plugin public HpDModule Module => HpDModule.WorkSpace; public string ToolbarTooltip => "扫描器"; - + ScannerWindow window; public void Execute(HpdApi api) { //var doc = api.CurrentProject.GetActiveDocument(); - var window = new ScannerWindow(); - ElementHost.EnableModelessKeyboardInterop(window); - var mainApp = BaseApp.ActiveApplication; - var helper = new System.Windows.Interop.WindowInteropHelper(window); - helper.Owner = mainApp.Handle; - window.Show(); + if (window == null) + { + window = new ScannerWindow(); + ElementHost.EnableModelessKeyboardInterop(window); + var mainApp = BaseApp.ActiveApplication; + var helper = new System.Windows.Interop.WindowInteropHelper(window); + helper.Owner = mainApp.Handle; + window.Closed += delegate + { + window = null; + }; + window.Show(); + } + else + { + window.WindowState = System.Windows.WindowState.Normal; + window.Activate(); + } } public void Initialize() diff --git a/Sinvo.EplanHpD.Plugin/Sinvo.EplanHpD.Plugin.csproj b/Sinvo.EplanHpD.Plugin/Sinvo.EplanHpD.Plugin.csproj index a8d00b3..401ddf2 100644 --- a/Sinvo.EplanHpD.Plugin/Sinvo.EplanHpD.Plugin.csproj +++ b/Sinvo.EplanHpD.Plugin/Sinvo.EplanHpD.Plugin.csproj @@ -70,27 +70,34 @@ RefDLL\EPLAN.Harness.API.dll + False RefDLL\EPLAN.Harness.API.Plugins.dll + False RefDLL\EPLAN.Harness.API.Plugins.Core.dll + False False RefDLL\EPLAN.Harness.AppCore.dll + False RefDLL\EPLAN.Harness.Common.dll + False False RefDLL\EPLAN.Harness.Core.dll + False False RefDLL\EPLAN.Harness.ProjectCore.dll + False ..\packages\HandyControl.3.5.1\lib\net481\HandyControl.dll @@ -129,6 +136,10 @@ + + {AD1AA2BC-9289-46AE-BDC0-30AE13F51B3F} + Sinvo.EplanHpD.Plugin.Service + {2DBCD22A-650D-4797-9908-9C4D5D6665FE} Sinvo.EplanHpD.Plugin.WPFUI