ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magicsld/DocumentEventHandlers.vb
Revision: 40
Committed: Mon Aug 20 21:30:28 2007 UTC (17 years, 8 months ago) by bournival
File size: 1972 byte(s)
Log Message:
Projet de these de Sylvain Bournival. Attention projet VB.

File Contents

# User Rev Content
1 bournival 40 Imports SldWorks
2     Namespace MAGIC
3    
4     'Base class for model event handlers
5     Public Class DocumentEventHandler
6     Protected userAddin As MAGIC
7     Protected iDocument As ModelDoc2
8     Protected iSwApp As SldWorks.SldWorks
9    
10     Overridable Function Init(ByVal sw As SldWorks.SldWorks, ByVal addin As MAGIC, ByVal model As ModelDoc2) As Boolean
11     End Function
12    
13     Overridable Function AttachEventHandlers() As Boolean
14     End Function
15    
16     Overridable Function DetachEventHandlers() As Boolean
17     End Function
18     End Class
19    
20     'Class to listen for Part Events
21     Public Class PartEventHandler
22     Inherits DocumentEventHandler
23    
24     Dim WithEvents iPart As PartDoc
25    
26     Overrides Function Init(ByVal sw As SldWorks.SldWorks, ByVal addin As MAGIC, ByVal model As ModelDoc2) As Boolean
27     userAddin = addin
28     iPart = model
29     iDocument = iPart
30     iswapp = sw
31     End Function
32    
33     Overrides Function AttachEventHandlers() As Boolean
34     AddHandler iPart.DestroyNotify, AddressOf Me.PartDoc_DestroyNotify
35     AddHandler iPart.NewSelectionNotify, AddressOf Me.PartDoc_NewSelectionNotify
36     End Function
37    
38     Overrides Function DetachEventHandlers() As Boolean
39     RemoveHandler iPart.DestroyNotify, AddressOf Me.PartDoc_DestroyNotify
40     RemoveHandler iPart.NewSelectionNotify, AddressOf Me.PartDoc_NewSelectionNotify
41    
42     userAddin.DetachModelEventHandler(iDocument)
43     End Function
44    
45     Function PartDoc_DestroyNotify() As Integer
46     DetachEventHandlers()
47     End Function
48    
49     Function PartDoc_NewSelectionNotify() As Integer
50     ' quand on sélectionne quelquechose (ou désélectionne) cette fonction est appelée.
51     ' ne fonctionne pas si on sélectionne ou désélectionne par code
52     End Function
53     End Class
54     End Namespace