static void PrintProgressOf(string taskName, float completePercent) { int completePercentI = (int)Math.Ceiling(completePercent); Console.Write(new string('#', completePercentI)); Console.Write(new string(' ', BAR_LENGTH - completePercentI)); Console.WriteLine(string.Format(" {0:0.0}%", completePercent)); MyConsole.ClearLine(); Console.Write(taskName); MyConsole.MoveCursorUp(1); MyConsole.MoveCursorToBeginingOfLine(); }
public static void Load(List <Task> tasks) { float completePercent = 0; foreach (Task task in tasks) { PrintProgressOf(task.name, completePercent); task.action.Invoke(); completePercent += ((float)BAR_LENGTH) / tasks.Count; } PrintProgressOf(FINISHED_TITLE, 100.0f); #if !DEBUG Thread.Sleep(100); #endif // Полоска загрузки как раз занимает 2 линии MyConsole.ClearLine(); // Очищаем линию с текстом о завершении MyConsole.MoveCursorDown(1); MyConsole.ClearLine(); // Очищаем линию с полоской MyConsole.MoveCursorUp(1); }