Пример #1
0
        private System.String ResizeLine(TextPaint textPaint, string line, int availableWidth)
        {
            var texteWidth = MeasureTextWidth (textPaint, line);
            var lastDeletePos = -1;

            var builder = new StringBuilder (line);
            while (texteWidth > availableWidth && builder.Length () > 0) {
                lastDeletePos = builder.Length () / 2;
                builder.DeleteCharAt (builder.Length () / 2);
                var textToMeasure = builder.ToString () + Ellipsis;
                texteWidth = MeasureTextWidth (textPaint, textToMeasure);
            }

            if (lastDeletePos > -1)
                builder.Insert (lastDeletePos, Ellipsis);
            return builder.ToString ();
        }