public static void Initialize(Type type) { try { if (!(DocumentDataObject.instanceType != null)) { if (type == null) { throw new InvalidOperationException("null instance type"); } DocumentDataObject.instanceType = type; foreach (Document doc in Application.DocumentManager) { DocumentDataObject.AddDocument(doc); } if (!DocumentDataObject.ReactorsStarted) { Application.DocumentManager.DocumentCreated += (new DocumentCollectionEventHandler(DocumentDataObject.DocumentCreated)); Application.DocumentManager.DocumentBecameCurrent += (new DocumentCollectionEventHandler(DocumentDataObject.DocumentBecameCurrent)); Application.DocumentManager.DocumentActivated += (new DocumentCollectionEventHandler(DocumentDataObject.DocumentActivated)); Application.DocumentManager.DocumentToBeDestroyed += (new DocumentCollectionEventHandler(DocumentDataObject.DocumentToBeDestroyed)); DocumentDataObject.ReactorsStarted = true; } } } catch { } }
private static void DocumentCreated(object sender, DocumentCollectionEventArgs e) { if (e.Document != null) { DocumentDataObject.AddDocument(e.Document); } }