如何处理EndSave事件(.net vb)?
我不明白:
如果它是DocumentEvent或DocumentCollectionEvent,我也不会得到它。
像该活动的正确名称是什么?我找不到该程序应使用什么名称?
这是我的AutoCAD插件代码,当用户关闭AutoCAD时,该代码已经注册。我希望它也注册EndSave,但我不知道该怎么做。
谢谢。
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.IO
Public Class Class1
<CommandMethod("AddAppEvent")>
Public Sub AddAppEvent()
AddHandler Application.DocumentManager.DocumentActivated, AddressOf AcadDocument_EndSave
AddHandler Application.SystemVariableChanged, AddressOf appSysVarChanged 'adicionado para o save
End Sub
<CommandMethod("RemoveAppEvent")>
Public Sub RemoveAppEvent()
RemoveHandler Application.SystemVariableChanged, AddressOf appSysVarChanged
End Sub
Public Sub AcadDocument_EndSave(ByVal DocumentCollection As Autodesk.AutoCAD.ApplicationServices.
DocumentCollectionEventArgs)
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter("C:\Users\rita.aguiar\Documents\AutoCAD plug-in\Registo de Eventos.txt", True)
file.WriteLine("O documento foi guardado.")
file.Close()
End Sub
Public Sub appSysVarChanged(ByVal senderObj As Object,
ByVal sysVarChEvtArgs As Autodesk.AutoCAD.ApplicationServices.
SystemVariableChangedEventArgs)
Dim oVal As Object = Application.GetSystemVariable(sysVarChEvtArgs.Name)
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter("C:\Users\rita.aguiar\Documents\AutoCAD plug-in\Registo de Eventos.txt", True)
file.WriteLine("O AutoCAD foi encerrado.")
file.Close()
End Sub
End Class
答案 0 :(得分:0)
没有EndSave事件。 我决定改用EndCommand事件,并在用户完成SAVE,SAVEAS和QSAVE命令后进行注册。