Example #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Find the difference in both views and bring it into view.
		/// </summary>
		/// <param name="diff">difference to seek</param>
		/// ------------------------------------------------------------------------------------
		internal void ScrollToDiff(Difference diff)
		{
			CheckDisposed();

			// Things aren't yet fully initialized, so quit and we'll get back here later.
			if (diff == null ||
				m_diffViewWrapper.CurrentDiffView == null ||
				m_diffViewWrapper.RevisionDiffView == null)
				return;

			if (diff.DiffType == DifferenceType.SectionAddedToCurrent ||
				diff.DiffType == DifferenceType.SectionHeadAddedToCurrent)
			{
				// For Section*AddedToCurrent diff, the Current pane will highlight the
				// entire section (or head), the Revision pane will show a paragraph location.
				ScrSection sectionCurr = new ScrSection(m_cache, diff.GetHvoOfFirstSection(false));
				m_diffViewWrapper.CurrentDiffView.ScrollToSectionDiff(sectionCurr.IndexInBook);
				m_diffViewWrapper.RevisionDiffView.ScrollToParaDiff(diff.HvoRev, diff.IchMinRev);
			}
			else if (diff.DiffType == DifferenceType.SectionMissingInCurrent ||
				diff.DiffType == DifferenceType.SectionHeadMissingInCurrent)
			{
				// For Section*MissingInCurrent diff, the Revsion pane will highlight the
				//  entire section.
				ScrSection sectionRev = new ScrSection(m_cache, diff.GetHvoOfFirstSection(true));
				m_diffViewWrapper.RevisionDiffView.ScrollToSectionDiff(sectionRev.IndexInBook);
				if (diff.DiffType == DifferenceType.SectionMissingInCurrent)
				{
					// Since the para hvo for the current may have been changed by deleting
					//  sections, we will find a new insert index every time, and scroll to that section
					m_diffViewWrapper.CurrentDiffView.ScrollToSectionDiff(
						m_bookMerger.GetCurrSectionInsertIndex(diff.RefEnd));
				}
				else if (diff.DiffType == DifferenceType.SectionHeadMissingInCurrent)
				{
					// the Current pane will show a paragraph location.
					m_diffViewWrapper.CurrentDiffView.ScrollToParaDiff(diff.HvoCurr, diff.IchMinCurr);
				}
			}
			else
			{
				// Paragraph Diff case.
				// TODO: For ParagraphMissingInCurrent differences: Someday when we can
				// show a paragraph insertion point, we will need to call the book merger to get
				// the correct insertion point because it's possible that the hvoCurr paragraph
				// may have been deleted, e.g. m_bookMerger.GetCurrParaInsertIndex(diff)
				m_diffViewWrapper.CurrentDiffView.ScrollToParaDiff(diff.HvoCurr, diff.IchMinCurr);
				m_diffViewWrapper.RevisionDiffView.ScrollToParaDiff(diff.HvoRev, diff.IchMinRev);
			}
		}