示例#1
0
        internal void RecalculateBoundingAndDisplayedText()
        {
            BoundingIgnoredSizeAndFlags = TextHandle.MeasureText(SpriteHandle, TextValue, FontDrawFlags.NoClip);
            DisplayedText = TextValue;
            Bounding      = BoundingIgnoredSizeAndFlags;
            if (Bounding.Width - 4 > Width)
            {
                while (Bounding.Width - 4 > Width && DisplayedText.Length > 3)
                {
                    DisplayedText = string.Concat(DisplayedText.Substring(0, DisplayedText.Length - 4), "...");
                    Bounding      = TextHandle.MeasureText(SpriteHandle, DisplayedText, DrawFlags);
                }
            }

            // Recalculate the position rectangle
            RecalculatePositionRectangle();

            // Preload the text
            TextHandle.PreloadText(DisplayedText);
        }