示例#1
0
        void MoveHighlight(RichTextBoxHighlight highlight, TextPointer startPoint, int length)
        {
            //find the Run
            Run run = null;

            //if (startPoint.Paragraph != null)
            run = GetRun(startPoint, startPoint.Paragraph);
            //else if(startPoint.Parent
            //   run = GetRun(startPoint, startPoint.Parent);

            if (run != null)
            {
                int start = run.ContentStart.GetOffsetToPosition(startPoint);
                highlight.MoveTo(run, start, start + length, adapter.GetIndexOfPointer(run.ContentStart));
            }
            else
            {
                //we seem to have lost the adorner but still tracking the highlight, so lose it too
                RemoveHighlight(highlight);
            }
        }
示例#2
0
        public int Compare(Highlight u1h, Highlight u2h)
        {
            RichTextBoxHighlight u1 = u1h as RichTextBoxHighlight;
            RichTextBoxHighlight u2 = u2h as RichTextBoxHighlight;

            if (u1.AbsoluteStart < u2.AbsoluteStart)
            {
                return(-1);
            }
            if (u1.AbsoluteStart > u2.AbsoluteStart)
            {
                return(1);
            }
            if (u1.AbsoluteStart == u2.AbsoluteStart && u1.AbsoluteEnd == u2.AbsoluteEnd)
            {
                return(0);
            }
            if (u1.AbsoluteStart == u2.AbsoluteStart && u1.AbsoluteEnd < u2.AbsoluteEnd)
            {
                return(-1);
            }
            return(1);
        }