示例#1
0
        public VisualPointInfo GetTextPointInfoFromCaretPoint(int caretX)
        {
            int accTextRunWidth     = 0;
            int accTextRunCharCount = 0;
            Run lastestTextRun      = null;

            foreach (Run t in _runs)
            {
                lastestTextRun = t;
                int thisTextRunWidth = t.Width;
                if (accTextRunWidth + thisTextRunWidth > caretX)
                {
                    CharLocation localPointInfo = t.GetCharacterFromPixelOffset(caretX - thisTextRunWidth);
                    var          pointInfo      = new EditableVisualPointInfo(this, accTextRunCharCount + localPointInfo.RunCharIndex, t);
                    pointInfo.SetAdditionVisualInfo(accTextRunCharCount, caretX, accTextRunWidth);
                    return(pointInfo);
                }
                else
                {
                    accTextRunWidth     += thisTextRunWidth;
                    accTextRunCharCount += t.CharacterCount;
                }
            }
            if (lastestTextRun != null)
            {
                return(null);
            }
            else
            {
                EditableVisualPointInfo pInfo = new EditableVisualPointInfo(this, -1, null);
                pInfo.SetAdditionVisualInfo(accTextRunCharCount, caretX, accTextRunWidth);
                return(pInfo);
            }
        }
示例#2
0
        EditableVisualPointInfo CreateTextPointInfo(int lineId, int lineCharIndex, int caretPixelX,
                                                    EditableRun onTextRun, int textRunCharOffset, int textRunPixelOffset)
        {
            EditableVisualPointInfo textPointInfo = new EditableVisualPointInfo(this, lineCharIndex);

            textPointInfo.SetAdditionVisualInfo(onTextRun, textRunCharOffset, caretPixelX, textRunPixelOffset);
            return(textPointInfo);
        }
示例#3
0
        public EditableVisualPointInfo GetTextPointInfoFromCharIndex(int charIndex)
        {
            int limit = CharCount - 1;

            if (charIndex > limit)
            {
                charIndex = limit;
            }

            EditableVisualPointInfo textPointInfo = new EditableVisualPointInfo(this, charIndex);
            int         rCharOffset  = 0;
            int         rPixelOffset = 0;
            EditableRun lastestRun   = null;

            foreach (EditableRun r in _runs)
            {
                lastestRun = r;
                int thisCharCount = lastestRun.CharacterCount;
                if (thisCharCount + rCharOffset > charIndex)
                {
                    int localCharOffset = charIndex - rCharOffset;
                    int pixelOffset     = lastestRun.GetRunWidth(localCharOffset);
                    textPointInfo.SetAdditionVisualInfo(lastestRun,
                                                        localCharOffset, rPixelOffset + pixelOffset
                                                        , rPixelOffset);
                    return(textPointInfo);
                }
                else
                {
                    rCharOffset  += thisCharCount;
                    rPixelOffset += r.Width;
                }
            }
            textPointInfo.SetAdditionVisualInfo(lastestRun, rCharOffset - lastestRun.CharacterCount, rPixelOffset, rPixelOffset - lastestRun.Width);
            return(textPointInfo);
        }
示例#4
0
        public EditableVisualPointInfo GetCurrentPointInfo()
        {
#if DEBUG
            if (_currentTextRun != null && !_currentTextRun.HasParent)
            {
                throw new NotSupportedException();
            }
            if (_currentTextRun == null)
            {
            }
#endif
            EditableVisualPointInfo textPointInfo =
                new EditableVisualPointInfo(_currentLine, caret_char_index, _currentTextRun);
            textPointInfo.SetAdditionVisualInfo(
                _rCharOffset, _caretXPos, _rPixelOffset);
            return(textPointInfo);
        }