public void Render(ConsoleColor color, bool painAll = false) { if (painAll) { wasPainted = false; } if (!wasPainted) { directory.Show(x, ColumnsWidth.Sum(), color); } Console.BackgroundColor = color; for (int i = 0; i < Math.Min(height, Items.Count); i++) { int elementIndex = i + scroll; if (wasPainted) { if (elementIndex != selectedIndex && elementIndex != selectedPrevIndex) { continue; } } var item = Items[elementIndex]; var saveForeground = Console.ForegroundColor; var saveBackground = Console.BackgroundColor; if (elementIndex == selectedIndex) { Console.ForegroundColor = ConsoleColor.Black; Console.BackgroundColor = ConsoleColor.White; } Console.CursorLeft = x; Console.CursorTop = i + y; item.Render(ColumnsWidth, i, x, y); Console.ForegroundColor = saveForeground; Console.BackgroundColor = saveBackground; } wasPainted = true; }
public void SetColumnsWidth(params double[] widths) { ColumnsWidth.AddRange(widths); }