diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ApplicationExt.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ApplicationExt.cs new file mode 100644 index 0000000..5f29bde --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ApplicationExt.cs @@ -0,0 +1,35 @@ +using System; +using System.Windows; + +namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils +{ + public static class ApplicationExt + { + public static void SetMainWindow(this Application application, Window window) + { + if (application == null) + { + throw new ArgumentNullException(nameof(application)); + } + if (window == null) + { + throw new ArgumentNullException(nameof(window)); + } + application.MainWindow = window; + } + public static void InitApplication() + { + if (Application.Current == null) + { + new System.Windows.Application + { + ShutdownMode = ShutdownMode.OnExplicitShutdown, + Resources = new ResourceDictionary + { + Source = new Uri("pack://application:,,,/Sinvo.EplanHpD.Plugin.WPFUI;component/Themes/Theme.xaml") + } + }; + } + } + } +} diff --git a/Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs b/Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs index 740898f..abbf52e 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 Sinvo.EplanHpD.Plugin.WPFUI; +using Sinvo.EplanHpD.Plugin.WPFUI.Utils; using System; using System.Drawing; using System.IO; @@ -9,7 +10,11 @@ using System.Windows.Forms.Integration; namespace Sinvo.EplanHpD.Plugin { +#if DEBUG public class DesignPluginEntry : EPLAN.Harness.API.Plugins.IHpDPlugin +#else + public class DesignPluginEntry +#endif { public string Name => "兴禾ProD插件-3D"; @@ -55,6 +60,8 @@ namespace Sinvo.EplanHpD.Plugin public void Initialize() { AppDomainDllLoader.SetLaoder(); + ApplicationExt.InitApplication(); + } diff --git a/Sinvo.EplanHpD.Plugin/PluginEntry.cs b/Sinvo.EplanHpD.Plugin/PluginEntry.cs index a9bd831..65f4c35 100644 --- a/Sinvo.EplanHpD.Plugin/PluginEntry.cs +++ b/Sinvo.EplanHpD.Plugin/PluginEntry.cs @@ -4,6 +4,7 @@ using EPLAN.Harness.API.Plugins.Core; using EPLAN.Harness.Core.Controls; using EPLAN.Harness.ProjectCore; using Sinvo.EplanHpD.Plugin.WPFUI; +using Sinvo.EplanHpD.Plugin.WPFUI.Utils; using System; using System.Drawing; using System.IO; @@ -142,7 +143,7 @@ namespace Sinvo.EplanHpD.Plugin { //throw new NotImplementedException(); AppDomainDllLoader.SetLaoder(); - + ApplicationExt.InitApplication(); } public void Terminate()