EndSave(AutoCAD)是什么(.net vb)的成员?

问题描述 投票:0回答:2

EndSave(AutoCAD)是什么(.net vb)的成员?

Application.DocumentManager.MdiActiveDocument

我不知道它在哪里,所以我可以添加一个处理程序来注册它的事件。

.net vb.net autocad addhandler
2个回答
1
投票

首先,您必须声明导入:

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports System.Windows

1)像这样处理他DocumentLockModeChanged事件:

Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
    Try
        subHandler = New DocumentLockModeChangedEventHandler(AddressOf docChange)
        AddHandler Application.DocumentManager.DocumentLockModeChanged, subHandler
    Catch ex As Exception
        Err.Clear()
    End Try
End Sub

2)然后检查command是SAVE还是SAVEAS:

Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
Dim subHandler As [Delegate]
Public Sub docChange(ByVal sender As Object, ByVal e As DocumentLockModeChangedEventArgs)
    If e.GlobalCommandName = "QSAVE" Or e.GlobalCommandName = "SAVE" Or e.GlobalCommandName = "SAVEAS" Then   
        Application.ShowAlertDialog("Save has occurred")
    End If
End Sub

此时如果需要,可以添加terminate事件的句柄,如下所示:

Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate
    RemoveHandler Application.DocumentManager.DocumentLockModeChanged, subHandler
End Sub

1
投票

我致力于使用CommandEnded事件而不是DocumentLockModeChanged。现在只有在保存命令(QSAVe,SAVE,SAVEAS)结束时才会注册。

© www.soinside.com 2019 - 2024. All rights reserved.