using SolidWorks.Interop.sldworks;
|
|
namespace PdmSwPlugin.Main.EventHandler
|
{
|
public class PartDocEventHandler : BaseEventHandler
|
{
|
PartDoc doc;
|
BaseAttacher swPlugin;
|
|
public PartDocEventHandler(ModelDoc2 modDoc, BaseAttacher addin) : base(modDoc, addin)
|
{
|
doc = (PartDoc)document;
|
swPlugin = addin;
|
}
|
|
override public bool AttachEventHandlers()
|
{
|
doc.DestroyNotify += new DPartDocEvents_DestroyNotifyEventHandler(OnDestroy);
|
doc.NewSelectionNotify += new DPartDocEvents_NewSelectionNotifyEventHandler(OnNewSelection);
|
// 自定义属性变更事件
|
doc.ChangeCustomPropertyNotify += new DPartDocEvents_ChangeCustomPropertyNotifyEventHandler(swPlugin.OnActiveDocCustomPropertyChanged);
|
ConnectModelViews();
|
return true;
|
}
|
|
override public bool DetachEventHandlers()
|
{
|
doc.DestroyNotify -= new DPartDocEvents_DestroyNotifyEventHandler(OnDestroy);
|
doc.NewSelectionNotify -= new DPartDocEvents_NewSelectionNotifyEventHandler(OnNewSelection);
|
|
doc.ChangeCustomPropertyNotify -= new DPartDocEvents_ChangeCustomPropertyNotifyEventHandler(swPlugin.OnActiveDocCustomPropertyChanged);
|
|
DisconnectModelViews();
|
|
userAddIn.DetachModelEventHandler(document);
|
return true;
|
}
|
|
//Event Handlers
|
public int OnDestroy()
|
{
|
swPlugin.OnDocDestory((ModelDoc2)doc);
|
DetachEventHandlers();
|
return 0;
|
}
|
|
public int OnNewSelection()
|
{
|
return 0;
|
}
|
}
|
}
|