We introduced AutoCAD .NET Database Events before and demonstrated how the Database Events Handler of AutoCAD .NET Addin Wizard (AcadNetAddinWizard) can help us generate database event handlers automatically and nicely.
Most of AutoCAD .NET database events are local, meaning they apply to each different database instance. However, two are global, meaning they will and can only apply to the whole Database type instead of individual instances. They are DatabaseConstructed and XrefAttachAborted.
The following does not make the compiler happy:
db.DatabaseConstructed += DbEvent_DatabaseConstructed_Handler;
db.XrefAttachAborted += DbEvent_XrefAttachAborted_Handler;
AutoCAD .NET API likes this:
Database.DatabaseConstructed += DbEvent_DatabaseConstructed_Handler;
Database.XrefAttachAborted += DbEvent_XrefAttachAborted_Handler;
Readers may wonder why only the two database events are different. The real reason is not clear. Make a bold guess? Negligence!
The two do not really look different at all from others. Here are all of them for the comparison purposes:
public static void SubscribeToDb(Database db)
{
db.AbortDxfIn += DbEvent_AbortDxfIn_Handler;
db.AbortDxfOut += DbEvent_AbortDxfOut_Handler;
db.AbortSave += DbEvent_AbortSave_Handler;
db.BeginDeepClone += DbEvent_BeginDeepClone_Handler;
db.BeginDeepCloneTranslation += DbEvent_BeginDeepCloneTranslation_Handler;
db.BeginDxfIn += DbEvent_BeginDxfIn_Handler;
db.BeginDxfOut += DbEvent_BeginDxfOut_Handler;
db.BeginInsert += DbEvent_BeginInsert_Handler;
db.BeginSave += DbEvent_BeginSave_Handler;
db.BeginWblockBlock += DbEvent_BeginWblockBlock_Handler;
db.BeginWblockEntireDatabase += DbEvent_BeginWblockEntireDatabase_Handler;
db.BeginWblockObjects += DbEvent_BeginWblockObjects_Handler;
db.BeginWblockSelectedObjects += DbEvent_BeginWblockSelectedObjects_Handler;
//db.DatabaseConstructed += DbEvent_DatabaseConstructed_Handler;
Database.DatabaseConstructed += DbEvent_DatabaseConstructed_Handler;
db.DatabaseToBeDestroyed += DbEvent_DatabaseToBeDestroyed_Handler;
db.DeepCloneAborted += DbEvent_DeepCloneAborted_Handler;
db.DeepCloneEnded += DbEvent_DeepCloneEnded_Handler;
db.Disposed += DbEvent_Disposed_Handler;
db.DwgFileOpened += DbEvent_DwgFileOpened_Handler;
db.DxfInComplete += DbEvent_DxfInComplete_Handler;
db.DxfOutComplete += DbEvent_DxfOutComplete_Handler;
db.InitialDwgFileOpenComplete += DbEvent_InitialDwgFileOpenComplete_Handler;
db.InsertAborted += DbEvent_InsertAborted_Handler;
db.InsertEnded += DbEvent_InsertEnded_Handler;
db.InsertMappingAvailable += DbEvent_InsertMappingAvailable_Handler;
db.ObjectAppended += DbEvent_ObjectAppended_Handler;
db.ObjectErased += DbEvent_ObjectErased_Handler;
db.ObjectModified += DbEvent_ObjectModified_Handler;
db.ObjectOpenedForModify += DbEvent_ObjectOpenedForModify_Handler;
db.ObjectReappended += DbEvent_ObjectReappended_Handler;
db.ObjectUnappended += DbEvent_ObjectUnappended_Handler;
db.PartialOpenNotice += DbEvent_PartialOpenNotice_Handler;
db.ProxyResurrectionCompleted += DbEvent_ProxyResurrectionCompleted_Handler;
db.SaveComplete += DbEvent_SaveComplete_Handler;
db.SystemVariableChanged += DbEvent_SystemVariableChanged_Handler;
db.SystemVariableWillChange += DbEvent_SystemVariableWillChange_Handler;
db.WblockAborted += DbEvent_WblockAborted_Handler;
db.WblockEnded += DbEvent_WblockEnded_Handler;
db.WblockMappingAvailable += DbEvent_WblockMappingAvailable_Handler;
db.WblockNotice += DbEvent_WblockNotice_Handler;
//db.XrefAttachAborted += DbEvent_XrefAttachAborted_Handler;
Database.XrefAttachAborted += DbEvent_XrefAttachAborted_Handler;
db.XrefAttachEnded += DbEvent_XrefAttachEnded_Handler;
db.XrefBeginAttached += DbEvent_XrefBeginAttached_Handler;
db.XrefBeginOtherAttached += DbEvent_XrefBeginOtherAttached_Handler;
db.XrefBeginRestore += DbEvent_XrefBeginRestore_Handler;
db.XrefComandeered += DbEvent_XrefComandeered_Handler;
db.XrefPreXrefLockFile += DbEvent_XrefPreXrefLockFile_Handler;
db.XrefRedirected += DbEvent_XrefRedirected_Handler;
db.XrefRestoreAborted += DbEvent_XrefRestoreAborted_Handler;
db.XrefRestoreEnded += DbEvent_XrefRestoreEnded_Handler;
db.XrefSubCommandAborted += DbEvent_XrefSubCommandAborted_Handler;
db.XrefSubCommandStart += DbEvent_XrefSubCommandStart_Handler;
}
The situation is still not changed in the AutoCAD .NET 2012.
The Database Events Hander of the leading edge AutoCAD .NET Addin Wizard (AcadNetAddinWizard) does not treat the two differently, so please manually make the adjustments when they are needed.
Recent Comments