예제 #1
0
        void UpdateTextRows(string text)
        {
            // Do nothing if text has not changed since last time
            if (text == lastText)
            {
                return;
            }

            // Split into rows based on \r escape character
            textRows = text.Split('\r');

            // Set text we just processed
            lastText = text;

            // Find widest row
            widestRow = 0;
            for (int i = 0; i < textRows.Length; i++)
            {
                float width = font.GetCharacterWidth(textRows[i]);
                if (width > widestRow)
                {
                    widestRow = width;
                }
            }
        }
예제 #2
0
        void UpdateTextRows(string text)
        {
            // Do nothing if text has not changed since last time
            if (text == lastText)
            {
                return;
            }

            // Split into rows based on \r escape character
            // Text read from plain-text files will become \\r so need to replace this first
            text     = text.Replace("\\r", "\r");
            textRows = text.Split('\r');

            // Set text we just processed
            lastText = text;

            // Find widest row
            widestRow = 0;
            for (int i = 0; i < textRows.Length; i++)
            {
                float width = font.GetCharacterWidth(textRows[i]);
                if (width > widestRow)
                {
                    widestRow = width;
                }
            }
        }
예제 #3
0
        float GetCharacterWidthToCursor()
        {
            if (font == null)
            {
                return(0);
            }

            return(font.GetCharacterWidth(text, cursorPosition));
        }