/// <summary> /// Fill screen /// </summary> static void ClearScreen() { ConsoleHelpers.FillRect(0, Console.WindowHeight, 0, Console.WindowWidth, ConsoleHelpers.Convert(background)); mesh.Draw(); if (toggleHelp) { help.Draw(); } if (toggleAbout) { about.Draw(); } info(step); }
/// <summary> /// Draw! /// </summary> /// <param name="args">The command-line arguments.</param> public static void Main(string[] args) { Console.CursorVisible = false; Console.BackgroundColor = ConsoleHelpers.Convert(background); new Thread(() => { var height = Console.WindowHeight; var width = Console.WindowWidth; while (true) { if (height != Console.WindowHeight || width != Console.WindowWidth) { height = Console.WindowHeight; width = Console.WindowWidth; ConsoleResizeEvent(height, width); } Thread.Sleep(100); } }) { IsBackground = true }.Start(); mesh = CreateMesh(); about = CreateAbout(Console.WindowWidth); help = CreateHelp(); ClearScreen(); mesh.InvalidateEvent += Update; while (true) { info(step); if (toggleHelp) { help.Draw(); } if (toggleAbout) { about.Draw(); } var key = Console.ReadKey(false).Key; ConsoleHelpers.FillRect(Console.BackgroundColor); if (key == ConsoleKey.F1 || key == ConsoleKey.F) { toggleAbout = !toggleAbout; // about.Clear(); mesh.Draw(); } if (key == ConsoleKey.H) { toggleHelp = !toggleHelp; // help.Clear(); mesh.Draw(); } if (key == ConsoleKey.Escape) { break; } else if (key == ConsoleKey.LeftArrow) { mesh.Move(-step, 0); } else if (key == ConsoleKey.RightArrow) { mesh.Move(step, 0); } else if (key == ConsoleKey.UpArrow) { mesh.Move(0, step); } else if (key == ConsoleKey.DownArrow) { mesh.Move(0, -step); } else if (key == ConsoleKey.E) { mesh.Rotate(Math.PI / 12); } else if (key == ConsoleKey.W) { mesh.Rotate(-Math.PI / 12); } else if (key == ConsoleKey.S) { ang = 0; step = 2; mesh = CreateMesh(); about = CreateAbout(Console.WindowWidth); help = CreateHelp(); ClearScreen(); } else if (key == ConsoleKey.Subtract && step > 1) { step--; mesh.Draw(); } else if (key == ConsoleKey.Add) { step++; mesh.Draw(); } else { mesh.Draw(); } } Console.SetCursorPosition(0, 0); }