public abstract GetRunWidth ( int charOffset ) : int | ||
charOffset | int | |
return | int |
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 this) { 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); }
bool MoveToNextTextRun() { #if DEBUG if (currentTextRun.IsLineBreak) { throw new NotSupportedException(); } #endif EditableRun nextTextRun = currentTextRun.NextTextRun; if (nextTextRun != null && !nextTextRun.IsLineBreak) { rCharOffset += currentTextRun.CharacterCount; rPixelOffset += currentTextRun.Width; currentTextRun = nextTextRun; caret_char_index = rCharOffset; caretXPos = rPixelOffset + currentTextRun.GetRunWidth(0); return(true); } return(false); }
public void SetCurrentCharIndex(int newCharIndexPointTo) { #if DEBUG if (dbugTextManRecorder != null) { dbugTextManRecorder.WriteInfo("TextLineReader::CharIndex_set=" + newCharIndexPointTo); dbugTextManRecorder.BeginContext(); } #endif if (newCharIndexPointTo < 0 || newCharIndexPointTo > currentLine.CharCount) { throw new NotSupportedException("index out of range"); } if (newCharIndexPointTo == 0) { caret_char_index = 0; caretXPos = 0; rCharOffset = 0; rPixelOffset = 0; currentTextRun = currentLine.FirstRun; } else { int diff = newCharIndexPointTo - caret_char_index; switch (diff) { case 0: { return; } default: { if (diff > 0) { do { if (rCharOffset + currentTextRun.CharacterCount > newCharIndexPointTo) { caret_char_index = newCharIndexPointTo; caretXPos = rPixelOffset + currentTextRun.GetRunWidth(caret_char_index - rCharOffset); #if DEBUG if (dbugTextManRecorder != null) { dbugTextManRecorder.EndContext(); } #endif return; } } while (MoveToNextTextRun()); caret_char_index = rCharOffset + currentTextRun.CharacterCount; caretXPos = rPixelOffset + currentTextRun.Width; return; } else { do { if (rCharOffset - 1 < newCharIndexPointTo) { caret_char_index = newCharIndexPointTo; caretXPos = rPixelOffset + currentTextRun.GetRunWidth(caret_char_index - rCharOffset); #if DEBUG if (dbugTextManRecorder != null) { dbugTextManRecorder.EndContext(); } #endif return; } } while (MoveToPreviousTextRun()); caret_char_index = 0; caretXPos = 0; } } break; } } #if DEBUG if (dbugTextManRecorder != null) { dbugTextManRecorder.EndContext(); } #endif }
bool MoveToNextTextRun() { #if DEBUG if (currentTextRun.IsLineBreak) { throw new NotSupportedException(); } #endif EditableRun nextTextRun = currentTextRun.NextTextRun; if (nextTextRun != null && !nextTextRun.IsLineBreak) { rCharOffset += currentTextRun.CharacterCount; rPixelOffset += currentTextRun.Width; currentTextRun = nextTextRun; charIndex = rCharOffset; caretXPos = rPixelOffset + currentTextRun.GetRunWidth(0); return true; } return false; }