Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets the current book, particularly picking the right set of annotations
        /// to add new ones to. Also (and more conspicuously) ends the current Undo task
        /// and makes a new one for importing the new book. Should therefore be called
        /// BEFORE setting up the Undo action for the creation of the book.
        /// </summary>
        /// <param name="nCanonicalBookNumber">The canonical book number.</param>
        /// <returns>The action handler</returns>
        /// ------------------------------------------------------------------------------------
        private IActionHandler SetCurrentBookInternal(int nCanonicalBookNumber)
        {
            // We temporarily un-suppress our action handler long enough to get it so we can
            // grab a local copy.
            m_suppressor.Dispose();
            m_suppressor = null;
            IActionHandler actionHandler = m_cache.ActionHandlerAccessor;

            m_suppressor = new SuppressSubTasks(m_cache);

            if ((m_importedSavedVersion != null && m_importedSavedVersion.BooksOS.Count > 0) ||
                (m_savedVersion != null && m_savedVersion.BooksOS.Count > 0))
            {
                // We want a new undo task for each new book, except the first one
                actionHandler.EndOuterUndoTask();
            }

            // No need to use localizable string from resources because the user will never
            // see these labels because we collapse to a single undo task when the import
            // completes.
            actionHandler.BeginUndoTask("Undo Import Book " + nCanonicalBookNumber,
                                        "Redo Import Book " + nCanonicalBookNumber);

            m_annotations = (ScrBookAnnotations)m_scr.BookAnnotationsOS[nCanonicalBookNumber - 1];

            return(actionHandler);
        }