예제 #1
0
파일: TextBox.cs 프로젝트: wtfcolt/game
        void GetCharacterAtPoint(Vector2 point, out int lineIndex, out int lineCharIndex)
        {
            // Get the line
            if (IsMultiLine)
            {
                lineIndex = LineBufferOffset + (int)Math.Floor(point.Y / Font.GetLineSpacing());
                if (lineIndex >= _lines.Count)
                {
                    lineIndex = _lines.Count - 1;
                }
            }
            else
            {
                lineIndex = 0;
            }

            // Get the character
            if (IsMultiLine)
            {
                lineCharIndex = StyledText.FindLastFittingChar(_lines[lineIndex].LineText, Font, (int)point.X);
            }
            else
            {
                var substr = _lines[lineIndex].LineText.Substring(LineCharBufferOffset);
                lineCharIndex  = StyledText.FindLastFittingChar(substr, Font, (int)point.X);
                lineCharIndex += LineCharBufferOffset;
            }

            if (lineCharIndex > _lines[lineIndex].LineText.Length)
            {
                lineCharIndex = _lines[lineIndex].LineText.Length;
            }
        }
예제 #2
0
파일: TextBoxLine.cs 프로젝트: wtfcolt/game
        public int CountFittingCharactersLeft(Font font, int startChar, int maxLineLength)
        {
            string subStr;

            if (startChar == 0)
            {
                subStr = _lineText;
            }
            else if (startChar >= _lineText.Length)
            {
                return(1);
            }
            else
            {
                subStr = _lineText.Substring(startChar);
            }

            return(StyledText.FindLastFittingChar(subStr, font, maxLineLength));
        }