示例#1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get the book at the selection
        /// </summary>
        /// <param name="helper"></param>
        /// <returns>a ScrBook that is at the selection</returns>
        /// ------------------------------------------------------------------------------------
        private IScrBook BookAtSelection(SelectionHelper helper)
        {
            if (helper == null)
            {
                return(null);
            }

            if (m_page.Publication == null || !(m_page.Publication is ScripturePublication))
            {
                return(null);
            }

            ScripturePublication scrPub = m_page.Publication as ScripturePublication;

            return(scrPub.GetBook(helper, SelectionHelper.SelLimitType.Anchor));
        }
示例#2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get the book at the selection
        /// </summary>
        /// <param name="helper"></param>
        /// <returns>a ScrBook that is at the selection</returns>
        /// ------------------------------------------------------------------------------------
        private ScrBook BookAtSelection(SelectionHelper helper)
        {
            if (helper == null)
            {
                return(null);
            }

            if (m_page.Publication == null || !(m_page.Publication is ScripturePublication))
            {
                return(null);
            }

            ScripturePublication scrPub = m_page.Publication as ScripturePublication;
            int hvo = scrPub.GetBookHvo(helper, SelectionHelper.SelLimitType.Anchor);

            return(new ScrBook(m_cache, hvo));
        }
示例#3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets Scripture reference for a selection
        /// </summary>
        /// <param name="helper">The selection helper that represents the selection</param>
        /// <param name="fInclusive"><c>true</c> if the reference returned should include the
        /// reference of the text of the verse where the selection is, even if that selection
        /// is not at the start of the verse; <c>false</c> if the reference should be that of
        /// the first full verse at or following the selection</param>
        /// <param name="scriptureRef">returns the scripture reference found</param>
        /// <returns>A TsString representing the reference of the selection, or null if the
        /// selection represents a book title or something weird.</returns>
        /// ------------------------------------------------------------------------------------
        private ITsString GetSelectionReference(SelectionHelper helper, bool fInclusive,
                                                out BCVRef scriptureRef)
        {
            scriptureRef = new BCVRef();
            if (helper != null && m_page.Publication != null && m_page.Publication is ScripturePublication)
            {
                ScripturePublication scrPub = m_page.Publication as ScripturePublication;
                int iParaLevel = helper.GetLevelForTag((int)StText.StTextTags.kflidParagraphs);
                if (iParaLevel >= 0)
                {
                    ScrTxtPara para = new ScrTxtPara(m_cache, helper.LevelInfo[iParaLevel].hvo);
                    // Look through the verses of the paragraph until we pass the location
                    // where the page break occurs. This verse reference will then be the
                    // first one on the page.
                    ScrVerse firstVerseOnPage = null;
                    int      ichPageBreak     = helper.IchAnchor;
                    foreach (ScrVerse verse in para)
                    {
                        if (!fInclusive)
                        {
                            firstVerseOnPage = verse;
                        }
                        if (verse.VerseStartIndex > ichPageBreak ||
                            (verse.VerseStartIndex == ichPageBreak && !fInclusive))
                        {
                            break;
                        }
                        if (fInclusive)
                        {
                            firstVerseOnPage = verse;
                        }
                    }

                    ITsString tssBookName = GetBookName(helper);
                    if (tssBookName != null)
                    {
                        ITsStrBldr bldr = tssBookName.GetBldr();
                        int        cch  = bldr.Length;
                        if (firstVerseOnPage != null)
                        {
                            if (firstVerseOnPage.StartRef.Verse != 0)
                            {
                                bldr.Replace(cch, cch, " " +
                                             ((Scripture)m_scr).ChapterVerseRefAsString(firstVerseOnPage.StartRef, m_wsDefault), null);
                            }
                            scriptureRef = firstVerseOnPage.StartRef;
                        }
                        return(bldr.GetString());
                    }
                    //else
                    //{
                    //    // Probably no verses were found in the paragraph
                    //    IVwSelection sel = FindNextPara(helper);
                    //    helper = SelectionHelper.Create(sel, helper.RootSite);

                    //    return GetSelectionReference(helper, fInclusive, out scriptureRef);
                    //}
                }
            }
            return(null);
        }