112 lines
3.4 KiB
C#
112 lines
3.4 KiB
C#
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 Sinvo.EplanHpD.Plugin.WPFUI.View;
|
|
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)
|
|
{
|
|
bool isLogin = PluginServices.IsLogin;
|
|
if (!isLogin)
|
|
{
|
|
var LoginWindow = new LoginWindow();
|
|
if (LoginWindow.ShowDialog() == true)
|
|
{
|
|
isLogin = PluginServices.IsLogin;
|
|
}
|
|
}
|
|
if (isLogin)
|
|
{
|
|
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();
|
|
}
|
|
}
|
|
public void Terminate()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|