Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// This is the main interesting method of displaying objects and fragments of them.
        /// A Scripture is displayed by displaying its Books;
        /// and a Book is displayed by displaying its Title and Sections;
        /// and a Section is diplayed by displaying its Heading and Content;
        /// which are displayed by using the standard view constructor for StText.
        ///
        /// This override provides special difference highlighting for a paragraph.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            CheckDisposed();

            switch (frag)
            {
            case (int)StTextFrags.kfrPara:
            {
                // The hvo may refer to m_Differences.CurrentDifference, or to a subdiff,
                //  so find the correct one.
                IScrTxtPara para = Cache.ServiceLocator.GetInstance <IScrTxtParaRepository>().GetObject(hvo);
                Difference  diff = FindDiff(para);

                m_DispPropOverrides.Clear();

                // If the diff represents added sections, and this paragraph belongs to it,
                // we must highlight the whole para
                bool fDisplayMissingParaPlaceholderAfter = false;
                if (diff != null)
                {
                    bool highlightWholePara = diff.IncludesWholePara(para, m_fRev);

                    // If the given paragraph has differences to be highlighted,
                    //  add appropriate properties
                    if ((diff.GetPara(m_fRev) == para || highlightWholePara) && m_fNeedHighlight)
                    {
                        // Need to add override properties for each run in the
                        // range to be highlighted.
                        // Determine the range of the paragraph that we want to highlight.
                        int paraMinHighlight = highlightWholePara ? 0 : diff.GetIchMin(m_fRev);
                        int paraLimHighlight = highlightWholePara ?
                                               para.Contents.Length : diff.GetIchLim(m_fRev);
                        if (paraMinHighlight == paraLimHighlight &&
                            IsParagraphAdditionOrDeletion(diff.DiffType))
                        {
                            if (paraMinHighlight == 0)
                            {
                                InsertMissingContentPara(vwenv);
                            }
                            else
                            {
                                fDisplayMissingParaPlaceholderAfter = true;
                            }
                        }

                        MakeDispPropOverrides(para, paraMinHighlight, paraLimHighlight,
                                              delegate(ref DispPropOverride prop)
                            {
                                prop.chrp.clrBack = kHighlightColor;
                            });
                    }
                }

                // the base Display will do the actual displaying of the Para frag
                base.Display(vwenv, hvo, frag);
                if (fDisplayMissingParaPlaceholderAfter)
                {
                    InsertMissingContentPara(vwenv);
                }
                break;
            }

            default:
                // handle all other frags
                base.Display(vwenv, hvo, frag);
                break;
            }
        }