public static string FormatText(LEDDisplaysDictionary dictionary, Align align, Trim trim, Append append, string appendString, int characters, string text, out int start) { if (text == null || text.Length == 0) { text = ""; } int dotsCount = 0; for (int i = 0; i < text.Length; i++) { if (dictionary.IsDotChar(text[i])) { dotsCount++; } } int textLength = text.Length - dotsCount; if (append != Append.None) { while (appendString.Length < characters) { appendString += appendString; } } start = 0; if (textLength > characters) { if (trim == Trim.Right) { text = text.Substring(0, characters); } else { text = text.Substring(textLength - characters, characters); } } else { if (textLength < characters) { int dif = characters - textLength; if (append == Append.Left) { text = appendString.Substring(0, dif) + text; } else if (append == Append.Right) { text = text + appendString.Substring(appendString.Length - dif, dif); } else if (align != Align.Left) { if (align == Align.Center) { start = characters / 2 - textLength / 2; } else if (align == Align.Right) { start = characters - textLength; } } } } return(text); }