void Application_DocumentChange() { //Reassign values to the document and wiki page states. lastActiveDocument = ActiveDocumentInstance; lastActiveDocumentFullName = ActiveDocumentFullName; activeDocumentContent = ActiveDocumentContentRange; //if current document is a wiki page. if (EditedPages.ContainsKey(lastActiveDocumentFullName)) { currentPageFullName = EditedPages[lastActiveDocumentFullName]; CurrentPagePublished = false; if (PublishedStatus.ContainsKey(currentPageFullName)) { if (PublishedStatus[currentPageFullName]) { CurrentPagePublished = true; } } } else { currentPageFullName = null; CurrentPagePublished = false; } }
void Application_DocumentBeforeClose(Microsoft.Office.Interop.Word.Document doc, ref bool cancel) { this.Application.StatusBar = statusMessage; string docFullName = doc.FullName; if (EditedPages.ContainsKey(docFullName)) { doc.Saved = true; EditedPages.Remove(doc.FullName); } }
/// <summary> /// Event triggered before closing a document. /// </summary> /// <param name="doc">The instance of the document.</param> /// <param name="cancel">Reference to a variable stating if the operation should be canceled. /// Switch the value to 'true' to cancle the closing. /// </param> void Application_DocumentBeforeClose(Microsoft.Office.Interop.Word.Document doc, ref bool cancel) { string docFullName = doc.FullName; //if is edited wiki page if (EditedPages.ContainsKey(docFullName)) { //Prevent default save dialog from appearing. doc.Saved = true; //TODO: display a custom dialog for saving to the wiki. } RemoveTaskPane(doc); if (EditedPages.ContainsKey(doc.FullName)) { EditedPages.Remove(doc.FullName); } }
/// <summary> /// Event triggered when the active document changes. /// <remarks>This event is triggered every time you switch to a different document window. /// It does NOT refer to content changing.</remarks> /// </summary> void Application_DocumentChange() { //Remove the orphan task panes. RemoveOrphans(); //Reassign values to the document and wiki page states. lastActiveDocument = ActiveDocumentInstance; lastActiveDocumentFullName = ActiveDocumentFullName; activeDocumentContent = ActiveDocumentContentRange; //if current document is a wiki page. if (EditedPages.ContainsKey(lastActiveDocumentFullName)) { currentPageFullName = EditedPages[lastActiveDocumentFullName]; } else { currentPageFullName = null; } //Update the toggle button. UpdateWikiExplorerButtonState(); //Trigger event DocumentChanged(); }