105040 Update 增加窗口开启逻辑,不允许同时开启多个窗口

This commit is contained in:
lihanbo 2024-12-23 11:55:20 +08:00
parent 8e7e3a4cba
commit 7c26e343a6
4 changed files with 57 additions and 14 deletions

View File

@ -1,6 +1,7 @@
using EPLAN.Harness.API; using EPLAN.Harness.API;
using EPLAN.Harness.API.Plugins.Core; using EPLAN.Harness.API.Plugins.Core;
using EPLAN.Harness.AppCore; using EPLAN.Harness.AppCore;
using Sinvo.EplanHpD.Plugin.Service;
using Sinvo.EplanHpD.Plugin.WPFUI; using Sinvo.EplanHpD.Plugin.WPFUI;
using Sinvo.EplanHpD.Plugin.WPFUI.Extension; using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
using Sinvo.EplanHpD.Plugin.WPFUI.Utils; using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
@ -8,6 +9,7 @@ using System;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Runtime.Remoting;
using System.Windows.Forms.Integration; using System.Windows.Forms.Integration;
namespace Sinvo.EplanHpD.Plugin namespace Sinvo.EplanHpD.Plugin
@ -51,15 +53,32 @@ namespace Sinvo.EplanHpD.Plugin
public string ToolbarTooltip => "伺服电机线缆抓取"; public string ToolbarTooltip => "伺服电机线缆抓取";
LectotypeWindow window;
public void Execute(HpdApi api) public void Execute(HpdApi api)
{ {
new DBHelper().CodeFirst();
var doc = api.CurrentProject.GetActiveDocument(); var doc = api.CurrentProject.GetActiveDocument();
var window = new LectotypeWindow(doc.ID); if(window == null)
ElementHost.EnableModelessKeyboardInterop(window); {
var mainApp = BaseApp.ActiveApplication; window = new LectotypeWindow(doc.ID);
var helper = new System.Windows.Interop.WindowInteropHelper(window); ElementHost.EnableModelessKeyboardInterop(window);
helper.Owner = mainApp.Handle; var mainApp = BaseApp.ActiveApplication;
window.Show(); 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() public void Initialize()

View File

@ -116,10 +116,11 @@ namespace Sinvo.EplanHpD.Plugin
catch (Exception) catch (Exception)
{ {
window = new MainWindow(flexReport); window = new MainWindow(flexReport);
// 解决WPF窗体在WinForm中无法输入的问题
ElementHost.EnableModelessKeyboardInterop(window); ElementHost.EnableModelessKeyboardInterop(window);
window.Show(); window.Show();
} }
// 解决WPF窗体在WinForm中无法输入的问题
} }
} }

View File

@ -50,16 +50,28 @@ namespace Sinvo.EplanHpD.Plugin
public HpDModule Module => HpDModule.WorkSpace; public HpDModule Module => HpDModule.WorkSpace;
public string ToolbarTooltip => "扫描器"; public string ToolbarTooltip => "扫描器";
ScannerWindow window;
public void Execute(HpdApi api) public void Execute(HpdApi api)
{ {
//var doc = api.CurrentProject.GetActiveDocument(); //var doc = api.CurrentProject.GetActiveDocument();
var window = new ScannerWindow(); if (window == null)
ElementHost.EnableModelessKeyboardInterop(window); {
var mainApp = BaseApp.ActiveApplication; window = new ScannerWindow();
var helper = new System.Windows.Interop.WindowInteropHelper(window); ElementHost.EnableModelessKeyboardInterop(window);
helper.Owner = mainApp.Handle; var mainApp = BaseApp.ActiveApplication;
window.Show(); 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() public void Initialize()

View File

@ -70,27 +70,34 @@
<ItemGroup> <ItemGroup>
<Reference Include="EPLAN.Harness.API"> <Reference Include="EPLAN.Harness.API">
<HintPath>RefDLL\EPLAN.Harness.API.dll</HintPath> <HintPath>RefDLL\EPLAN.Harness.API.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="EPLAN.Harness.API.Plugins"> <Reference Include="EPLAN.Harness.API.Plugins">
<HintPath>RefDLL\EPLAN.Harness.API.Plugins.dll</HintPath> <HintPath>RefDLL\EPLAN.Harness.API.Plugins.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="EPLAN.Harness.API.Plugins.Core"> <Reference Include="EPLAN.Harness.API.Plugins.Core">
<HintPath>RefDLL\EPLAN.Harness.API.Plugins.Core.dll</HintPath> <HintPath>RefDLL\EPLAN.Harness.API.Plugins.Core.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="EPLAN.Harness.AppCore, Version=2.9.2.903, Culture=neutral, PublicKeyToken=57aaa27e22f7b107, processorArchitecture=AMD64"> <Reference Include="EPLAN.Harness.AppCore, Version=2.9.2.903, Culture=neutral, PublicKeyToken=57aaa27e22f7b107, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>RefDLL\EPLAN.Harness.AppCore.dll</HintPath> <HintPath>RefDLL\EPLAN.Harness.AppCore.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="EPLAN.Harness.Common"> <Reference Include="EPLAN.Harness.Common">
<HintPath>RefDLL\EPLAN.Harness.Common.dll</HintPath> <HintPath>RefDLL\EPLAN.Harness.Common.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="EPLAN.Harness.Core, Version=2.9.2.903, Culture=neutral, PublicKeyToken=57aaa27e22f7b107, processorArchitecture=AMD64"> <Reference Include="EPLAN.Harness.Core, Version=2.9.2.903, Culture=neutral, PublicKeyToken=57aaa27e22f7b107, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>RefDLL\EPLAN.Harness.Core.dll</HintPath> <HintPath>RefDLL\EPLAN.Harness.Core.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="EPLAN.Harness.ProjectCore, Version=2.9.2.903, Culture=neutral, PublicKeyToken=57aaa27e22f7b107, processorArchitecture=AMD64"> <Reference Include="EPLAN.Harness.ProjectCore, Version=2.9.2.903, Culture=neutral, PublicKeyToken=57aaa27e22f7b107, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>RefDLL\EPLAN.Harness.ProjectCore.dll</HintPath> <HintPath>RefDLL\EPLAN.Harness.ProjectCore.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="HandyControl, Version=3.5.1.0, Culture=neutral, PublicKeyToken=45be8712787a1e5b, processorArchitecture=MSIL"> <Reference Include="HandyControl, Version=3.5.1.0, Culture=neutral, PublicKeyToken=45be8712787a1e5b, processorArchitecture=MSIL">
<HintPath>..\packages\HandyControl.3.5.1\lib\net481\HandyControl.dll</HintPath> <HintPath>..\packages\HandyControl.3.5.1\lib\net481\HandyControl.dll</HintPath>
@ -129,6 +136,10 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Sinvo.EplanHpD.Plugin.Service\Sinvo.EplanHpD.Plugin.Service.csproj">
<Project>{AD1AA2BC-9289-46AE-BDC0-30AE13F51B3F}</Project>
<Name>Sinvo.EplanHpD.Plugin.Service</Name>
</ProjectReference>
<ProjectReference Include="..\Sinvo.EplanHpD.Plugin.WPFUI\Sinvo.EplanHpD.Plugin.WPFUI.csproj"> <ProjectReference Include="..\Sinvo.EplanHpD.Plugin.WPFUI\Sinvo.EplanHpD.Plugin.WPFUI.csproj">
<Project>{2DBCD22A-650D-4797-9908-9C4D5D6665FE}</Project> <Project>{2DBCD22A-650D-4797-9908-9C4D5D6665FE}</Project>
<Name>Sinvo.EplanHpD.Plugin.WPFUI</Name> <Name>Sinvo.EplanHpD.Plugin.WPFUI</Name>