Created
March 31, 2010 23:45
-
-
Save pzurek/351107 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Initialize() | |
{ | |
DocumentCollection dm = Application.DocumentManager; | |
dm.DocumentActivated += delegate(object s, DocumentCollectionEventArgs d){ | |
Document doc = d.Document; | |
doc.CommandWillStart += delegate(object sender, CommandEventArgs e){ | |
if ((e.GlobalCommandName == "PUBLISH") || | |
(e.GlobalCommandName == "EXPORT") || | |
(e.GlobalCommandName == "3DDWF")){ | |
// Register for publishing events | |
Publisher pb = Application.Publisher; | |
pb.AboutToBeginBackgroundPublishing += new AboutToBeginBackgroundPublishingEventHandler(pb_AboutToBeginBackgroundPublishing); | |
pb.AboutToBeginPublishing += new AboutToBeginPublishingEventHandler(pb_AboutToBeginPublishing); | |
pb.BeginEntity += new BeginEntityEventHandler(pb_BeginEntity); | |
pb.BeginSheet += new BeginSheetEventHandler(pb_BeginSheet); | |
} | |
}; | |
doc.CommandEnded += new CommandEventHandler(doc_CommandEnded); | |
doc.CommandFailed += new CommandEventHandler(doc_CommandEnded); | |
doc.CommandCancelled += new CommandEventHandler(doc_CommandEnded); | |
}; | |
} | |
void doc_CommandEnded(object sender, CommandEventArgs e){ | |
if ((e.GlobalCommandName == "PUBLISH") || | |
(e.GlobalCommandName == "EXPORT") || | |
(e.GlobalCommandName == "3DDWF")){ | |
// Unregister from publishing events | |
Publisher pb = Application.Publisher; | |
pb.AboutToBeginBackgroundPublishing -= new AboutToBeginBackgroundPublishingEventHandler(pb_AboutToBeginBackgroundPublishing); | |
pb.AboutToBeginPublishing -= new AboutToBeginPublishingEventHandler(pb_AboutToBeginPublishing); | |
pb.BeginEntity -= new BeginEntityEventHandler(pb_BeginEntity); | |
pb.BeginSheet -= new BeginSheetEventHandler(pb_BeginSheet); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment