/// ------------------------------------------------------------------------------------
        /// <summary>
        /// Makes a selection in the specified annotation (without scrolling the annotation in
        /// the view).
        /// </summary>
        /// <param name="vc">The notes view constructor</param>
        /// <param name="fScrollNearTop">if set to <c>true</c> scrolls the specified note to a
        /// position near the top of the view.</param>
        /// <param name="bookIndex">Index of the book.</param>
        /// <param name="iAnnotation">Index of the annotation.</param>
        /// <param name="iResponse">Index of the response (0 if setting the selection in one of
        /// the StJournalText fields rather than in a response.</param>
        /// <param name="noteTag">The tag indicating the field of the annotation where the
        /// selection is to be made.</param>
        /// <param name="rootSite">The root site.</param>
        /// <param name="fNoteIsExpanded">if <c>true</c> make a selection at the start and end so
        /// that the whole annotation can be scrolled into view. if set to <c>false</c> only
        /// make a selection at the start of the annotation.</param>
        /// ------------------------------------------------------------------------------------
        internal void MakeSelectionInNote(TeNotesVc vc, bool fScrollNearTop, int bookIndex,
                                          int iAnnotation, int iResponse, ScrScriptureNote.ScrScriptureNoteTags noteTag,
                                          IVwRootSite rootSite, bool fNoteIsExpanded)
        {
            if (vc == null || vc.NotesSequenceHandler == null)
            {
                return;
            }

            SelectionHelper selHelper;

            if (fScrollNearTop)
            {
                // Make an un-installed selection at the top of the annotation in order to scroll the
                // annotation to the top of the view.
                selHelper = new SelectionHelper();
                selHelper.NumberOfLevels             = 2;
                selHelper.LevelInfo[0].cpropPrevious = 0;
                selHelper.LevelInfo[0].ich           = -1;
                selHelper.LevelInfo[0].ihvo          = iAnnotation;
                selHelper.LevelInfo[0].tag           = vc.NotesSequenceHandler.Tag;
                selHelper.LevelInfo[0].ws            = 0;
                selHelper.LevelInfo[1].cpropPrevious = 0;
                selHelper.LevelInfo[1].ich           = -1;
                selHelper.LevelInfo[1].ihvo          = bookIndex;
                selHelper.LevelInfo[1].tag           = (int)Scripture.ScriptureTags.kflidBookAnnotations;
                selHelper.LevelInfo[1].ws            = 0;
                selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, -2);
                selHelper.IchAnchor             = 0;
                selHelper.AssocPrev             = false;
                selHelper.NumberOfPreviousProps = 2;
                if (fNoteIsExpanded)
                {
                    selHelper.SetSelection(rootSite, true, true, VwScrollSelOpts.kssoNearTop);
                }
                else
                {
                    // Annotation is collapsed. Only attempt a selection at the start of it.
                    selHelper.SetSelection(rootSite, true, true);
                    return;
                }
            }
            else
            {
                EnsureNoteIsVisible(vc, bookIndex, iAnnotation, rootSite);
            }

            // Now make the real (installed) selection in the desired field of the annotation.
            bool fIsResponse = (noteTag == ScrScriptureNote.ScrScriptureNoteTags.kflidResponses);

            selHelper = new SelectionHelper();
            selHelper.NumberOfLevels             = 4;
            selHelper.LevelInfo[0].tag           = (int)StText.StTextTags.kflidParagraphs;
            selHelper.LevelInfo[0].ihvo          = 0;
            selHelper.LevelInfo[1].tag           = (int)noteTag;
            selHelper.LevelInfo[1].ihvo          = iResponse;
            selHelper.LevelInfo[1].cpropPrevious = (fIsResponse ? 0 : 1);
            selHelper.LevelInfo[2].tag           = vc.NotesSequenceHandler.Tag;
            selHelper.LevelInfo[2].ihvo          = iAnnotation;
            selHelper.LevelInfo[3].tag           = (int)Scripture.ScriptureTags.kflidBookAnnotations;
            selHelper.LevelInfo[3].ihvo          = bookIndex;
            selHelper.IchAnchor = 0;
            selHelper.AssocPrev = false;
            selHelper.SetSelection(rootSite, true, true);
        }
Exemple #2
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Call MouseUp on the rootbox
        /// </summary>
        /// -----------------------------------------------------------------------------------
        protected override void CallMouseUp(Point pt, Rectangle rcSrcRoot, Rectangle rcDstRoot)
        {
            IVwSelection     sel = m_rootb.MakeSelAt(pt.X, pt.Y, rcSrcRoot, rcDstRoot, false);
            ScrScriptureNote ann = CurrentAnnotation;

            ScrScriptureNote.ScrScriptureNoteTags noteTagToSelect =
                ScrScriptureNote.ScrScriptureNoteTags.kflidDiscussion;

            bool fMakeSelInFirstResponse = false;

            if (sel != null && sel.SelType == VwSelType.kstPicture)
            {
                SelectionHelper selHelper = SelectionHelper.Create(sel, this);
                SelLevInfo[]    info      = selHelper.LevelInfo;

                if (info.Length >= 1 &&
                    info[0].tag == (int)ScrScriptureNote.ScrScriptureNoteTags.kflidDiscussion ||
                    info[0].tag == (int)ScrScriptureNote.ScrScriptureNoteTags.kflidRecommendation ||
                    m_fdoCache.GetClassOfObject(info[0].hvo) == StJournalText.kClassId)
                {
                    bool fExpanding = m_vc.ToggleItemExpansion(info[0].hvo, m_rootb);
                    if (fExpanding)
                    {
                        // If  the tag is not a valid tag, the assumption
                        // is we're expanding the responses.
                        fMakeSelInFirstResponse = (info[0].tag < 0);
                        noteTagToSelect         = (ScrScriptureNote.ScrScriptureNoteTags)info[0].tag;
                    }
                }
                else if (selHelper.GetTextPropId(SelectionHelper.SelLimitType.Anchor) ==
                         -(int)NotesFrags.kfrConnotCategory)                // This is not a real flid, just a unique number to match on.
                {
                    SetAnnotationCategory(ann);
                }
                else if (info.Length >= 2 && info[1].tag == m_currentNotesTag)
                {
                    m_ignoreSelChanged = !m_vc.ToggleItemExpansion(info[1].hvo, m_rootb);
                }
            }

            base.CallMouseUp(pt, rcSrcRoot, rcDstRoot);
            m_ignoreSelChanged = false;

            if (!m_pictureSelected)
            {
                return;
            }

            m_pictureSelected = false;

            if (ann == null || m_vc.NotesSequenceHandler == null)
            {
                return;
            }

            // Make a selection in the proper place in the annotation.
            int book = BCVRef.GetBookFromBcv(ann.BeginRef) - 1;
            ScrBookAnnotations annotations = (ScrBookAnnotations)m_scr.BookAnnotationsOS[book];
            int index = m_vc.NotesSequenceHandler.GetVirtualIndex(annotations.Hvo, ann.IndexInOwner);

            if (fMakeSelInFirstResponse)
            {
                NotesEditingHelper.MakeSelectionInNote(book, index, 0,
                                                       ScrScriptureNote.ScrScriptureNoteTags.kflidResponses);
            }
            else if (m_vc.IsExpanded(ann.Hvo) &&
                     m_vc.IsExpanded(Cache.GetObjProperty(ann.Hvo, (int)noteTagToSelect)))
            {
                NotesEditingHelper.MakeSelectionInNote(m_vc, false, book,
                                                       index, 0, noteTagToSelect, this, true);
            }
            else
            {
                NotesEditingHelper.MakeSelectionInNoteRef(m_vc, book, index, this);
            }
        }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Makes a selection in the specified annotation (without scrolling the annotation in
 /// the view).
 /// </summary>
 /// <param name="bookIndex">Index of the book.</param>
 /// <param name="iAnnotation">Index of the annotation.</param>
 /// <param name="iResponse">Index of the response (0 if setting the selection in one of
 /// the StJournalText fields rather than in a response.</param>
 /// <param name="noteTag">The tag indicating the field of the annotation where the
 /// selection is to be made.</param>
 /// ------------------------------------------------------------------------------------
 internal void MakeSelectionInNote(int bookIndex, int iAnnotation, int iResponse,
                                   ScrScriptureNote.ScrScriptureNoteTags noteTag)
 {
     MakeSelectionInNote(CurrentNotesVc, true, bookIndex, iAnnotation, iResponse,
                         noteTag, Control as IVwRootSite, true);
 }