コード例 #1
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);
            }
        }
コード例 #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets all the questions/phrases from each section, including any customized or added
        /// ones. Any additions are actually added to the collection of questions for the
        /// appropriate section & category.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private IEnumerable <Question> GetQuestions()
        {
            //HashSet<string> processedCategories = new HashSet<string>();
            int currBook = -1;
            SortedDictionary <QuestionKey, Customizations> currBookCustomizations = null;
            Category category           = null;
            Question lastQuestionInBook = null;
            int      iQuestion          = -1;

            foreach (Section section in m_sections.Items)
            {
                if (m_customizations != null && BCVRef.GetBookFromBcv(section.StartRef) != currBook)
                {
                    foreach (var question in GetTrailingCustomizations(currBook, currBookCustomizations, lastQuestionInBook, category, iQuestion))
                    {
                        yield return(question);
                    }

                    currBook = BCVRef.GetBookFromBcv(section.StartRef);
                    m_customizations.TryGetValue(currBook, out currBookCustomizations);
                }
                for (int iCat = 0; iCat < section.Categories.Length; iCat++)
                {
                    category = section.Categories[iCat];

                    for (iQuestion = 0; iQuestion < category.Questions.Count;)
                    {
                        Question q = category.Questions[iQuestion];

                        if (string.IsNullOrEmpty(q.Text))
                        {
                            category.Questions.RemoveAt(iQuestion);
                            continue;
                        }

                        if (q.ScriptureReference == null)
                        {
                            q.ScriptureReference = section.ScriptureReference;
                            q.StartRef           = section.StartRef;
                            q.EndRef             = section.EndRef;
                        }
                        if (currBookCustomizations != null)
                        {
                            foreach (var question in GetCustomizations(q, category, iQuestion, currBookCustomizations))
                            {
                                lastQuestionInBook = question;
                                yield return(question);

                                iQuestion++;
                            }
                        }
                        else
                        {
                            yield return(q);

                            iQuestion++;
                        }
                    }
                }
            }
            foreach (var question in GetTrailingCustomizations(currBook, currBookCustomizations, lastQuestionInBook, category, iQuestion))
            {
                yield return(question);
            }
            m_customizations = null;             // Allow this to be garbage collected (and prevent accidental future use)
        }
コード例 #3
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);
            IScrScriptureNote ann = CurrentAnnotation;

            int  noteTagToSelect         = 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 == ScrScriptureNoteTags.kflidDiscussion ||
                    info[0].tag == ScrScriptureNoteTags.kflidRecommendation ||
                    m_fdoCache.ServiceLocator.ObjectRepository.GetClsid(info[0].hvo) == StJournalTextTags.kClassId)
                {
                    if (m_vc.ToggleItemExpansion(info[0].hvo, m_rootb))
                    {
                        // If the tag is not a valid tag, the assumption
                        // is we're expanding the responses.
                        fMakeSelInFirstResponse = (info[0].tag < 0);
                        noteTagToSelect         = 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 == kCurrentNotesTag)
                {
                    m_vc.ToggleItemExpansion(info[1].hvo, m_rootb);
                    m_ignoreSelChanged = true;
                }
            }

            m_suspendHighlightChange = true;
            try
            {
                base.CallMouseUp(pt, rcSrcRoot, rcDstRoot);
            }
            finally
            {
                m_ignoreSelChanged       = false;
                m_suspendHighlightChange = false;
            }

            UpdateNoteHighlight(ann);

            if (!m_pictureSelected)
            {
                return;
            }

            m_pictureSelected = false;

            if (ann == null)
            {
                return;
            }

            // Make a selection in the proper place in the annotation.
            int book = BCVRef.GetBookFromBcv(ann.BeginRef) - 1;
            IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[book];
            int index = m_rootb.DataAccess.GetObjIndex(annotations.Hvo, ScrBookAnnotationsTags.kflidNotes, ann.Hvo);

            if (fMakeSelInFirstResponse)
            {
                NotesEditingHelper.MakeSelectionInNote(book, index, 0, ScrScriptureNoteTags.kflidResponses);
            }
            else if (m_vc.IsExpanded(ann.Hvo) &&
                     m_vc.IsExpanded(m_rootb.DataAccess.get_ObjectProp(ann.Hvo, noteTagToSelect)))
            {
                NotesEditingHelper.MakeSelectionInNote(m_vc, false, book,
                                                       index, 0, noteTagToSelect, this, true);
            }
            else
            {
                NotesEditingHelper.MakeSelectionInNoteRef(m_vc, book, index, this);
            }
        }