static void PrintCopyr(ConsoleDeviceContract.Imp !imp) { ClearConsole(imp); Console.WriteLine("Copyright (c) 1994-2013 Antoni Sawicki <*****@*****.**>"); Console.WriteLine("Copyright (c) 2016-2017 Natalia Portillo <*****@*****.**>"); Console.WriteLine("Version 2.4 (singularity); Canary Islands, January 2017"); }
static void DrawCircle(ConsoleDeviceContract.Imp !imp, int handMax, int sYcen, int sXcen) { int x, y, r; char c; for (r = 0; r < 60; r++) { x = (int)(Math.Cos(r * Math.PI / 180 * 6) * handMax * FontWH_Ratio + sXcen); y = (int)(Math.Sin(r * Math.PI / 180 * 6) * handMax + sYcen); switch (r) { case 0: case 5: case 10: case 15: case 20: case 25: case 30: case 35: case 40: case 45: case 50: case 55: c = 'o'; break; default: c = '.'; break; } SetCursorPosition(imp, x, y); Console.Write(c); } }
public static void RunAclock(ConsoleDeviceContract.Imp !imp) { PrintCopyr(imp); Thread.Sleep(2000); int sXmax, sYmax, smax, handMax, sXcen, sYcen; DateTime ltime; sXmax = sYmax = handMax = sXcen = sYcen = 0; ClearConsole(imp); HideCursor(imp); while (true) { if (!KeepRunning) { break; } ltime = DateTime.Now; GetConsoleDimensions(imp, out sXmax, out sYmax); if (sXmax / FontWH_Ratio <= sYmax) { smax = sXmax / FontWH_Ratio; } else { smax = sYmax; } handMax = (smax / 2) - 1; sXcen = sXmax / 2; sYcen = sYmax / 2; ClearConsole(imp); DrawCircle(imp, handMax, sYcen, sXcen); DrawHand(imp, (ltime.Hour * 5) + (ltime.Minute / 10), 2 * handMax / 3, 'h', sXcen, sYcen); DrawHand(imp, ltime.Minute, handMax - 2, 'm', sXcen, sYcen); DrawHand(imp, ltime.Second, handMax - 1, '.', sXcen, sYcen); SetCursorPosition(imp, sXcen - 5, sYcen - (3 * handMax / 5)); Console.Write(".:ACLOCK:."); SetCursorPosition(imp, sXcen - 5, sYcen + (3 * handMax / 5)); Console.Write("{0:D2}:{1:D2}:{2:D2}", ltime.Hour, ltime.Minute, ltime.Second); Thread.Sleep(1000); } PrintCopyr(imp); ShowCursor(imp); }
static void DrawHand(ConsoleDeviceContract.Imp !imp, int minute, int hlength, char c, int sXcen, int sYcen) { int x, y, n; double r = (minute - 15) * (Math.PI / 180) * 6; for (n = 1; n < hlength; n++) { x = (int)(Math.Cos(r) * n * FontWH_Ratio + sXcen); y = (int)(Math.Sin(r) * n + sYcen); SetCursorPosition(imp, x, y); Console.Write(c); } }
public static void Main() { bool itRun = false; foreach (string s in new string[] { "/dev/video-text", "/dev/conout" }) { ConsoleDeviceContract.Imp imp = OpenConsole((!)s); if (imp != null) { itRun = true; RunAclock(imp); delete imp; break; } } if (!itRun) { Console.WriteLine("Cannot open console"); return; } }