Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event
        /// data.</param>
        /// ------------------------------------------------------------------------------------
        private void btnSave_Click(object sender, EventArgs e)
        {
            IScrDraft savedVersion;

            using (SaveVersionDialog dlg = new SaveVersionDialog(m_cache, m_helpTopicProvider))
            {
                dlg.ShowDialog();
                savedVersion = dlg.SavedVersion;
            }

            if (savedVersion == null)
            {
                return;
            }

            // Add the archive as a new root node in the tree
            TreeNode versionNode = new TreeNode(GetSavedVersionLabel(savedVersion));

            versionNode.Tag = savedVersion;
            // Add all of the books in the archive as child nodes.
            foreach (IScrBook book in savedVersion.BooksOS)
            {
                TreeNode bookNode = new TreeNode(((IScrBook)book).BestUIName + " " +
                                                 ImportedBooks.GetBookInfo(book));
                bookNode.Tag = book;
                versionNode.Nodes.Add(bookNode);
            }
            m_treeArchives.Nodes.Insert(0, versionNode);
        }
Example #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:SavedVersionsDialog"/> class.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="styleSheet">The style sheet.</param>
        /// <param name="zoomFactorDraft">The zoom percentage to be used for the "draft" (i.e.,
        /// main Scripture) view</param>
        /// <param name="zoomFactorFootnote">The zoom percentage to be used for the "footnote"
        /// view</param>
        /// <param name="helpTopicProvider">The help topic provider.</param>
        /// <param name="app">The app.</param>
        /// ------------------------------------------------------------------------------------
        public SavedVersionsDialog(FdoCache cache, IVwStylesheet styleSheet,
                                   float zoomFactorDraft, float zoomFactorFootnote, IHelpTopicProvider helpTopicProvider,
                                   FwApp app)
        {
            InitializeComponent();

            m_cache             = cache;
            m_helpTopicProvider = helpTopicProvider;
            m_app          = app;
            m_styleSheet   = styleSheet;
            m_zoomDraft    = zoomFactorDraft;
            m_zoomFootnote = zoomFactorFootnote;
            m_scr          = cache.LangProject.TranslatedScriptureOA;

            // Create a list of all of the nodes to add.  The list will be sorted by date
            // before adding them to the tree.
            List <TreeNode> list = new List <TreeNode>();

            // Add all of the saved version as root nodes in the tree
            foreach (IScrDraft savedVersion in m_scr.ArchivedDraftsOC)
            {
                TreeNode versionNode = new TreeNode(GetSavedVersionLabel(savedVersion));
                versionNode.Tag = savedVersion;
                list.Add(versionNode);

                // Add all of the books in the saved version as child nodes.
                foreach (IScrBook book in savedVersion.BooksOS)
                {
                    TreeNode bookNode = new TreeNode(((IScrBook)book).BestUIName + " " +
                                                     ImportedBooks.GetBookInfo(book));
                    bookNode.Tag = book;
                    versionNode.Nodes.Add(bookNode);
                }
            }

            // Sort the list of root nodes by date in decending order.
            list.Sort(new ArchiveDateComparer(false));

            // Add all of the nodes in the list to the tree view.
            foreach (TreeNode node in list)
            {
                m_treeArchives.Nodes.Add(node);
            }

            // If the list is empty then disable the action buttons.
            if (list.Count == 0)
            {
                m_btnDiff.Enabled       = false;
                m_btnCopyToCurr.Enabled = false;
                m_btnDelete.Enabled     = false;
            }
        }