chr
2024-08-07 22beee93f14d042aa184148c53efb79e23416526
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using SolidWorks.Interop.sldworks;
 
namespace PdmSwPlugin.Main.EventHandler
{
    public class DrwDocEventHandler : BaseEventHandler
    {
        DrawingDoc doc;
        BaseAttacher swPlugin;
 
        public DrwDocEventHandler(ModelDoc2 modDoc, BaseAttacher addin) : base(modDoc, addin)
        {
            doc = (DrawingDoc)document;
            swPlugin = addin;
        }
 
        override public bool AttachEventHandlers()
        {
            doc.DestroyNotify += new DDrawingDocEvents_DestroyNotifyEventHandler(OnDestroy);
            doc.NewSelectionNotify += new DDrawingDocEvents_NewSelectionNotifyEventHandler(OnNewSelection);
 
            doc.ChangeCustomPropertyNotify +=
                new DDrawingDocEvents_ChangeCustomPropertyNotifyEventHandler(swPlugin.OnActiveDocCustomPropertyChanged);
 
            ConnectModelViews();
 
            return true;
        }
 
        override public bool DetachEventHandlers()
        {
            doc.DestroyNotify -= new DDrawingDocEvents_DestroyNotifyEventHandler(OnDestroy);
            doc.NewSelectionNotify -= new DDrawingDocEvents_NewSelectionNotifyEventHandler(OnNewSelection);
 
            doc.ChangeCustomPropertyNotify -=
                new DDrawingDocEvents_ChangeCustomPropertyNotifyEventHandler(swPlugin.OnActiveDocCustomPropertyChanged);
 
            DisconnectModelViews();
 
            userAddIn.DetachModelEventHandler(document);
            return true;
        }
 
        //Event Handlers
        public int OnDestroy()
        {
            DetachEventHandlers();
            return 0;
        }
 
        public int OnNewSelection()
        {
            return 0;
        }
    }
}