雪山飞狐_lzh 发表于 2009-5-30 13:53
C#代码和VB.Net的代码相差不大的,网上有代码转换器可以试下,不过大体应该看的懂
完整的代码: - Class TlsApplication
- Implements IExtensionApplication
- Private Sub IExtensionApplication_Initialize() Implements IExtensionApplication.Initialize
- TTest.Start()
- End Sub
- Private Sub IExtensionApplication_Terminate() Implements IExtensionApplication.Terminate
- End Sub
- End Class
- Class TTest
- Shared m_Veto As Boolean = False
- Public Shared Sub Start()
- Application.DocumentManager.DocumentLockModeChanged += New DocumentLockModeChangedEventHandler(AddressOf vetoCommand)
- Application.BeginDoubleClick += New BeginDoubleClickEventHandler(AddressOf beginDoubleClick)
- End Sub
- Private Shared Sub beginDoubleClick(sender As Object, e As BeginDoubleClickEventArgs)
- Dim doc As Document = Application.DocumentManager.MdiActiveDocument
- Dim ed As Editor = doc.Editor
- Dim res As PromptSelectionResult = ed.SelectImplied()
- Dim ss As SelectionSet = res.Value
- If ss IsNot Nothing Then
- If ss.Count = 1 Then
- Using tr As Transaction = doc.TransactionManager.StartTransaction()
- Dim line As Line = TryCast(tr.GetObject(ss(0).ObjectId, OpenMode.ForRead), Line)
- If line IsNot Nothing Then
- Dim rb As ResultBuffer = line.GetXDataForApplication("MyApp")
- If rb IsNot Nothing Then
- m_Veto = True
- End If
- End If
- End Using
- End If
- End If
- End Sub
- Private Shared Sub vetoCommand(sender As Object, e As DocumentLockModeChangedEventArgs)
- If e.GlobalCommandName.ToLower() = "properties" Then
- If m_Veto Then
- e.Veto()
- Application.ShowAlertDialog("hello")
- m_Veto = False
- End If
- End If
- End Sub
- End Class
|