private void DisplayCurrentRoot() { if (m_currentRoot > 0) { m_xrev.DatTree.Visible = true; ICmObjectRepository repo = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>(); ICmObject root; // JohnT: I don't know why this is done at all. Therefore I made a minimal change rather than removing it // altogether. If someone knows why it sometimes needs doing, please comment. Or if you know why it once did // and it no longer applies, please remove it. I added the test that the Clerk is not aleady looking // at this object to suppress switching back to the raw text pane when clicking on the Info pane of an empty text. // (FWR-3180) if (repo.TryGetObject(m_currentRoot, out root) && root is IStText && m_xrev.Clerk.CurrentObjectHvo != m_currentRoot) { m_xrev.Clerk.JumpToRecord(m_currentRoot); } } else if (m_currentRoot == 0) { m_xrev.DatTree.Visible = false; } }
protected AnalysisOccurrence GetAnalysisFromSelection(IVwSelection sel) { AnalysisOccurrence result = null; var cvsli = sel.CLevels(false); cvsli--; // CLevels includes the string property itself, but AllTextSelInfo doesn't need it. // Out variables for AllTextSelInfo. int ihvoRoot; int tagTextProp; int cpropPrevious; int ichAnchor; int ichEnd; int ws; bool fAssocPrev; int ihvoEnd; ITsTextProps ttpBogus; // Main array of information retrieved from sel. var rgvsli = SelLevInfo.AllTextSelInfo(sel, cvsli, out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd, out ws, out fAssocPrev, out ihvoEnd, out ttpBogus); if (rgvsli.Length > 1) { // Need to loop backwards until we get down to index 1 or index produces a valid Segment. var i = rgvsli.Length - 1; ISegment seg = null; for (; i > 0; i--) { // get the container for whatever is selected at this level. ICmObject container; if (!m_objRepo.TryGetObject(rgvsli[i].hvo, out container)) { return(null); // may fail, e.g., trying to get bookmark for text just deleted. } seg = container as ISegment; if (seg != null) { break; } } if (seg != null && i > 0) // This checks the case where there is no Segment in the selection at all { // Make a new AnalysisOccurrence var selObject = m_objRepo.GetObject(rgvsli[i - 1].hvo); if (selObject is IAnalysis) { var indexInContainer = rgvsli[i - 1].ihvo; result = new AnalysisOccurrence(seg, indexInContainer); } if (result == null || !result.IsValid) { result = new AnalysisOccurrence(seg, 0); } } else { // TODO: other possibilities?! Debug.Assert(false, "Reached 'other' situation in OccurrenceContainingSelection()."); } } return(result); }