/// ------------------------------------------------------------------------------------ /// <summary> /// Removes the specified IFwMainWnd from the list of windows. /// </summary> /// <param name="fwMainWindow">The IFwMainWnd to remove</param> /// ------------------------------------------------------------------------------------ public override void RemoveWindow(IFwMainWnd fwMainWindow) { base.RemoveWindow(fwMainWindow); Debug.Assert(!IsDisposed, "Shuting down the app should have happened asynchronously after we get called"); if (MainWindows.Count == 1 && MainWindows[0] is NotesMainWnd) NotesWindow = null; // Notes window is the only window left }
/// ------------------------------------------------------------------------------------ /// <summary> /// Makes sure a closing notes window gets removed from the table of notes windows. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void HandleNotesWindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { Debug.Assert(sender != null || sender == m_notesWindow); m_notesWindow.Closing -= HandleNotesWindowClosing; m_notesWindow = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds a notes window for a specified cache to the list of notes windows stored for /// this application. /// </summary> /// <param name="cache"></param> /// <param name="wnd"></param> /// ------------------------------------------------------------------------------------ public static void AddNotesWndForCache(FdoCache cache, NotesMainWnd wnd) { if (s_notesWindoes.ContainsKey(cache)) { NotesMainWnd oldValue = s_notesWindoes[cache]; oldValue.Close(); } s_notesWindoes[cache] = wnd; wnd.Closing += new System.ComponentModel.CancelEventHandler(HandleNotesWindowClosing); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Toggles the visibility of the notes view. /// </summary> /// <param name="arg">The menu or toolbar item</param> /// <returns><c>true</c> because we handled the message.</returns> /// ------------------------------------------------------------------------------------ protected bool OnViewNotes(object arg) { NotesMainWnd notesWnd = ((TeApp)m_app).NotesWindow; if (notesWnd == null) { try { // Make sure the user can't close the main window when bringing up the // notes window (TE-8561) m_app.EnableMainWindows(false); m_syncHandler.IgnoreAnySyncMessages = true; notesWnd = new NotesMainWnd(m_app, m_StyleSheet, DraftViewZoomPercent); m_app.InitAndShowMainWindow(notesWnd, null); if (!notesWnd.OnFinishedInit()) Debug.Fail("Notes window did not initialize properly"); } finally { m_app.EnableMainWindows(true); m_syncHandler.IgnoreAnySyncMessages = false; } ((TeApp)m_app).NotesWindow = notesWnd; RespondToSyncScrollingMsgs(true); notesWnd.SyncHandler = m_syncHandler; if (ActiveEditingHelper != null) notesWnd.ScrollToScrEditingLocation(this, ActiveEditingHelper); } else if (arg != null) { // The user chose the View/Notes menu option, which is a toggle, // so we close the existing window. notesWnd.Close(); } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Toggles the visibility of the notes view. /// </summary> /// <param name="arg">The menu or toolbar item</param> /// <returns><c>true</c> because we handled the message.</returns> /// ------------------------------------------------------------------------------------ protected bool OnViewNotes(object arg) { NotesMainWnd notesWnd = TeApp.GetNotesWndForCache(m_cache); if (notesWnd == null) { try { // Make sure the user can't close the main window when bringing up the // notes window (TE-8561) FwApp.App.EnableSameProjectWindows(m_cache, false); ActiveEditingHelper.SyncHandler.IgnoreAnySyncMessages = true; notesWnd = new NotesMainWnd(m_cache, m_StyleSheet, DraftViewZoomPercent); FwApp.App.InitAndShowMainWindow(notesWnd, null); notesWnd.OnFinishedInit(); } finally { FwApp.App.EnableSameProjectWindows(m_cache, true); ActiveEditingHelper.SyncHandler.IgnoreAnySyncMessages = false; } TeApp.AddNotesWndForCache(m_cache, notesWnd); EnableSynchronizedScrolling(true); if (ActiveEditingHelper != null) notesWnd.ScrollToScrEditingLocation(this, ActiveEditingHelper); } else if (arg != null) { // The user chose the View/Notes menu option, which is a toggle, // so we close the existing window. notesWnd.Close(); } return true; }