Пример #1
0
        /// <summary>
        /// Renders text string starting from start and ending with end indexes.
        /// </summary>
        /// <param name="render">graphics to render to.</param>
        /// <param name="X">X position to render to.</param>
        /// <param name="Y">Y position to render to.</param>
        /// <param name="text">text to render.</param>
        /// <param name="start">text starting index.</param>
        /// <param name="stop">text ending index.</param>
        public override void DrawText(Graphics render, int x, int y, String text, int start, int stop)
        {
            if (false == this.loaded)
            {
                return;
            }

            if ((null == text) || (text.Length == 0))
            {
                return;
            }

            int renderX = x;

            if (stop < 0)
            {
                stop = (int)(text.Length);
            }

            if (stop > text.Length)
            {
                stop = text.Length;
            }

            if (start < 0)
            {
                start = 0;
            }

            for (int i = start; i < stop; i++)
            {
                WinLetterCached letter = this.letters[text[i]];

                if (null != letter)
                {
                    renderX += letter.Render(render, renderX, y);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Measures text length.
        /// </summary>
        /// <param name="text">text to measure.</param>
        /// <param name="start">text starting index.</param>
        /// <param name="stop">text ending index.</param>
        /// <returns>rendered text length.</returns>
        public override int TextLength(String text, int start, int stop)
        {
            if ((null == text) || (text.Length == 0))
            {
                return(0);
            }

            if (false == this.loaded)
            {
                return(0);
            }

            int length = 0;

            if ((stop < 0) || (stop > text.Length))
            {
                stop = (int)(text.Length);
            }

            if (start < 0)
            {
                start = 0;
            }

            for (int i = start; i < stop; i++)
            {
                WinLetterCached letter = this.letters[text[i]];

                if (null != letter)
                {
                    length += letter.Width;
                }
            }

            return(length);
        }