EPLAN_PROD_Plugin/Sinvo.EplanHpD.Plugin/DesignPluginEntry.cs

109 lines
3.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using EPLAN.Harness.API;
using EPLAN.Harness.API.Plugins.Core;
using EPLAN.Harness.AppCore;
using Sinvo.EplanHpD.Plugin.DynaClient;
using Sinvo.EplanHpD.Plugin.Service;
using Sinvo.EplanHpD.Plugin.WPFUI;
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
using System;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.Remoting;
using System.Windows.Forms.Integration;
namespace Sinvo.EplanHpD.Plugin
{
#if Release_WireAndCable || DEBUG
public class DesignPluginEntry : EPLAN.Harness.API.Plugins.IHpDPlugin
#else
public class DesignPluginEntry
#endif
{
public string Name => "兴禾ProD插件-3D";
public string Author => "Sinvo";
public string Description => "兴禾EPLAN Harness proD 2.9 Studio插件,提供伺服电机线缆抓取功能";
/// <summary>
/// 获取DLL版本
/// </summary>
public Version Version => Assembly.GetAssembly(this.GetType()).GetName().Version;
public System.Drawing.Image ToolbarIcon
{
get
{
var imageBytes = Resource.Sinvo;
if (imageBytes != null)
{
using (var ms = new MemoryStream(imageBytes))
{
return Image.FromStream(ms);
}
}
return null;
}
}
public string ToolbarText => "伺服电机线缆抓取";
public HpDModule Module => HpDModule.WorkSpace;
public string ToolbarTooltip => "伺服电机线缆抓取";
LectotypeWindow window;
public void Execute(HpdApi api)
{
new DBHelper().CodeFirst();
var doc = api.CurrentProject.GetActiveDocument();
if(window == null)
{
window = new LectotypeWindow(doc.ID);
// 获取版本号并显示到窗口标题
window.Title += $" V{Version} - {doc.Name}";
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()
{
if (!AppDomainDllLoader.isLoaded)
{
AppDomainDllLoader.SetLaoder();
ApplicationExt.InitApplication();
Consts.InitConfigs();
#if DEBUG
var client = new DynaServerClient();
// PLM 没有EPLAN的许可所以只能使用SOLW的类型登录
client.Login("105040", "blank", "ADMINISTRATOR", "ADMINISTRATOR", "SOLW");
#endif
}
}
public void Terminate()
{
}
}
}