Пример #1
0
 public DocView(SwAddin addin, IModelView mv, DocumentEventHandler doc)
 {
     userAddin = addin;
     mView     = (ModelView)mv;
     iSwApp    = (ISldWorks)userAddin.SwApp;
     parent    = doc;
 }
Пример #2
0
        public bool AttachModelDocEventHandler(ModelDoc2 modDoc)
        {
            if (modDoc == null)
            {
                return(false);
            }

            DocumentEventHandler docHandler = null;

            if (!openDocs.Contains(modDoc))
            {
                switch (modDoc.GetType())
                {
                case (int)swDocumentTypes_e.swDocPART:
                {
                    docHandler = new PartEventHandler(modDoc, this);
                    break;
                }

                case (int)swDocumentTypes_e.swDocASSEMBLY:
                {
                    docHandler = new AssemblyEventHandler(modDoc, this);
                    break;
                }

                case (int)swDocumentTypes_e.swDocDRAWING:
                {
                    docHandler = new DrawingEventHandler(modDoc, this);
                    break;
                }

                default:
                {
                    return(false);        //Unsupported document type
                }
                }
                docHandler.AttachEventHandlers();
                openDocs.Add(modDoc, docHandler);
            }
            return(true);
        }
Пример #3
0
        public void AttachEventsToAllDocuments()
        {
            ModelDoc2 modDoc = (ModelDoc2)iSwApp.GetFirstDocument();

            while (modDoc != null)
            {
                if (!openDocs.Contains(modDoc))
                {
                    AttachModelDocEventHandler(modDoc);
                }
                else if (openDocs.Contains(modDoc))
                {
                    bool connected = false;
                    DocumentEventHandler docHandler = (DocumentEventHandler)openDocs[modDoc];
                    if (docHandler != null)
                    {
                        connected = docHandler.ConnectModelViews();
                    }
                }

                modDoc = (ModelDoc2)modDoc.GetNext();
            }
        }