Beispiel #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Deletes a footnote
        /// </summary>
        /// <param name="args"></param>
        /// <returns><c>true</c> if we handle this</returns>
        /// ------------------------------------------------------------------------------------
        protected bool OnDeleteFootnote(object args)
        {
            if (DataUpdateMonitor.IsUpdateInProgress(DataAccess))
            {
                return(true);                //discard this event
            }
            if (!ValidFootnoteSelection)
            {
                return(true);
            }

            string undo;
            string redo;

            TeResourceHelper.MakeUndoRedoLabels("kstidUndoDelFootnote", out undo, out redo);
            using (new UndoTaskHelper(this, undo, redo, false))
                using (new DataUpdateMonitor(this, RootBox.DataAccess, this, "DeleteFootnote"))
                {
                    SelectionHelper helper  = SelectionHelper.Create(this);
                    int             fnLevel = helper.GetLevelForTag((int)ScrBook.ScrBookTags.kflidFootnotes);

                    if (helper.Selection.IsRange)
                    {
                        DeleteFootnoteRange(helper);
                    }
                    else
                    {
                        // There's no range selection, so delete only one footnote
                        ScrFootnote footnote = new ScrFootnote(m_fdoCache, helper.LevelInfo[fnLevel].hvo);
                        ScrFootnote.DeleteFootnoteAndMarker(footnote);
                    }

                    if (RootBox.Height <= 0)
                    {
                        DraftView.Focus();
                    }
                    else
                    {
                        int     iBook     = helper.LevelInfo[fnLevel + 1].ihvo;
                        ScrBook book      = m_bookFilter.GetBook(iBook);
                        int     iFootnote = helper.LevelInfo[fnLevel].ihvo;

                        // If the last footnote in the book was deleted find a footnote to move to
                        if (iFootnote >= book.FootnotesOS.Count)
                        {
                            FindNearestFootnote(ref iBook, ref iFootnote);
                        }

                        FootnoteEditingHelper.ScrollToFootnote(iBook, iFootnote, 0);
                    }
                }

            return(true);
        }
Beispiel #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Export all of scripture
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void ExportScripture()
        {
            int sectionCount = 0;

            for (int i = 0; i < m_bookFilter.BookCount; i++)
            {
                sectionCount += m_bookFilter.GetBook(i).SectionsOS.Count;
            }
            using (ProgressDialogWithTask progressDlg = new ProgressDialogWithTask(Form.ActiveForm))
            {
                progressDlg.SetRange(0, sectionCount);
                progressDlg.Title = DlgResources.ResourceString("kstidExportXmlProgress");
                progressDlg.CancelButtonVisible = true;
                progressDlg.Cancel += new CancelHandler(OnExportCancel);

                progressDlg.RunTask(true, new BackgroundTaskInvoker(ExportScripture));
            }
        }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Obtain one book from the book filter.
 /// </summary>
 /// <param name="hvo"></param>
 /// <param name="tag"></param>
 /// <param name="index">Indicates the item of interest. &lt;b&gt;Zero based&lt;/b&gt;.</param>
 /// <returns></returns>
 /// ------------------------------------------------------------------------------------
 public override int get_VecItem(int hvo, int tag, int index)
 {
     if (tag != ScriptureTags.kflidScriptureBooks)
     {
         return(base.get_VecItem(hvo, tag, index));
     }
     Debug.Assert(index >= 0 && index < m_filter.BookHvos.Count);
     return(m_filter.GetBook(index).Hvo);
 }
Beispiel #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Insert a bar to separate this book from the following book (unless this is the last
        /// book being displayed).
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected virtual void InsertBookSeparator(int hvoScrBook, IVwEnv vwenv)
        {
            FilteredScrBooks filter = m_cache.ServiceLocator.GetInstance <IFilteredScrBookRepository>().GetFilterInstance(m_filterInstance);
            int hvoLastScrBook      = filter.GetBook(filter.BookCount - 1).Hvo;

            if (hvoLastScrBook != hvoScrBook)
            {
                vwenv.AddSimpleRect((int)FwTextColor.kclrTransparent, -1, 20000, 0);
                vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(ColorUtil.LightInverse(m_BackColor)), -1, 10000, 0);
                vwenv.AddSimpleRect((int)FwTextColor.kclrTransparent, -1, 5000, 0);
            }
        }
Beispiel #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create a string of book names in the filter.
        /// </summary>
        /// <param name="filter">book filter</param>
        /// <returns>string with comma-delimited list of books in the filter</returns>
        /// ------------------------------------------------------------------------------------
        private string GetExportedBooksStr(FilteredScrBooks filter)
        {
            StringBuilder filteredBooks = new StringBuilder();

            if (filter.BookCount > 3)
            {
                return(string.Empty);
            }

            // Append all scripture books in filter to string
            for (int bookIndex = 0; bookIndex < filter.BookCount; bookIndex++)
            {
                if (bookIndex > 0)
                {
                    filteredBooks.Append(", ");
                }
                filteredBooks.Append(((ScrBookRef)filter.GetBook(bookIndex).BookIdRA).UIBookName);
            }

            return(string.Format(TeResourceHelper.GetResourceString("kstidExportDlgMultipleBooks"),
                                 filteredBooks.ToString()));
        }
        public void UnfilteredBooksTest()
        {
            int filteredCount = m_filter.BookCount;

            Assert.AreEqual(m_scr.ScriptureBooksOS.Count, filteredCount);
            for (int i = 0; i < m_scr.ScriptureBooksOS.Count; i++)
            {
                int bookHvo = m_filter.GetBook(i).Hvo;
                Assert.AreEqual(bookHvo, m_scr.ScriptureBooksOS[i].Hvo, "Mismatch on book " + i);
            }
        }