public ModelViewHelper(SwAddin addin, IModelView mv, DocumentEventHandler doc) { userAddin = addin; modelView = (ModelView)mv; iSwApp = (ISldWorks)userAddin.SwApp; parent = doc; }
/// <summary> /// removes the values of the <param name="modDoc">modDoc</param> from the documentsEventHandlers hashtable and sets them to null /// </summary> /// <param name="modDoc"></param> /// <returns></returns> public bool RemoveModelFromDocEventRepo(ModelDoc2 modDoc) { DocumentEventHandler docHandler = (DocumentEventHandler)documentsEventsRepo[modDoc]; documentsEventsRepo.Remove(modDoc); modDoc = null; docHandler = null; return(true); }
/// <summary> /// Get the first open document from the addin, iterates through the documents and then /// if they don't have event handlers, attaches it to them based on the document type /// </summary> public void AttachEventsToAllDocuments() { ModelDoc2 ThisDocument = (ModelDoc2)solidworks.GetFirstDocument(); while (ThisDocument != null) { if (!documentsEventsRepo.Contains(ThisDocument)) { AttachEventHandlersToDocument(ThisDocument); } else if (documentsEventsRepo.Contains(ThisDocument)) { DocumentEventHandler documentEventHandler = (DocumentEventHandler)documentsEventsRepo[ThisDocument]; if (documentEventHandler != null) { documentEventHandler.ConnectModelViews(); } } ThisDocument = (ModelDoc2)ThisDocument.GetNext(); } }