using log4net;
|
using PdmSwPlugin.Common.Setting;
|
using PdmSwPlugin.Common.Util;
|
using PdmSwPlugin.Main;
|
using PdmSwPlugin.Main.EventHandler;
|
using SolidWorks.Interop.sldworks;
|
using System.Runtime.InteropServices;
|
using System.Windows;
|
|
namespace WpfUI
|
{
|
/// <summary>
|
/// Window1.xaml 的交互逻辑
|
/// </summary>
|
public partial class Window1 : Window
|
{
|
private SldWorks SwApp;
|
private PluginSetting GlobalConfig;
|
private BaseAttacher attacher;
|
private MainControl mainControl;
|
public Window1()
|
{
|
InitializeComponent();
|
GlobalConfig = PluginSetting.Instance;
|
}
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
{
|
if (SwApp != null)
|
{
|
return;
|
}
|
else
|
{
|
try
|
{
|
// SwApp = (SldWorks)Marshal.GetActiveObject("SldWorks.Application.28");
|
SwApp = (SldWorks)System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application");
|
mainControl = new MainControl(SwApp);
|
mainControl.Loaded += MainControl_Loaded;
|
stack.Children.Add(mainControl);
|
|
}
|
catch (COMException ex)
|
{
|
MessageBox.Show(ex.Message);
|
}
|
}
|
}
|
|
private void MainControl_Loaded(object sender, RoutedEventArgs e)
|
{
|
attacher = new AsyncAttacher(SwApp, mainControl);
|
attacher.AttachEventHandlers();
|
}
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
{
|
Button_Click(null, null);
|
}
|
}
|
}
|