Ejemplo n.º 1
0
        private static void addLinebreaks(PrintRule rule, InfoPanelContent content,
                                          Stack <Color> indents, List <int> breakIndices)
        {
            var indentColors = indents.ToList();

            indentColors.Reverse();
            var offset    = 0;
            var oldLength = content.Length;

            for (var i = 0; i < breakIndices.Count; i++)
            {
                if (rule.indent && i == breakIndices.Count - 1)
                {
                    indents.Pop();
                    indentColors.RemoveAt(indentColors.Count - 1);
                }

                // add the actual linebreak
                content.Insert(breakIndices[i] + offset, "\n");
                offset   += content.Length - oldLength;
                oldLength = content.Length;

                // add the indents
                foreach (var color in indentColors)
                {
                    content.Insert(breakIndices[i] + offset, color == Color.Transparent ? " " : PrintConstants.indentDiff, PrintConstants.DefaultFont, color);
                    offset   += content.Length - oldLength;
                    oldLength = content.Length;
                }
            }
        }