private void ListAllCommands(HelpInput input) { if (!input.CommandTypes.Any()) { Console.WriteLine("There are no known commands!"); return; } var commands = input.CommandTypes.Select(type => new { Name = CommandFactory.CommandNameFor(type), Description = CommandFactory.DescriptionFor(type) }); var longestCommandName = commands .Select(m => m.Name) .Aggregate(string.Empty, (seed, f) => f?.Length > seed.Length ? f : seed); var padRight = longestCommandName.Length + 2; Console2.BreakLine(); commands.OrderBy(m => m.Name).ForEach(m => { Console2.Yellow(m.Name.PadRight(padRight)); Console2.Write(m.Description); Console2.BreakLine(); }); Console2.BreakLine(); Console2.Write("For a command usage, type: "); Console2.White("miru help <command>"); Console2.BreakLine(); Console2.BreakLine(); }
public bool WritePublicText(string value, bool append = false) { float fontSize = (this.GetProperty("FontSize") as ITerminalProperty <float>).GetValue(this); int visibleCount = (int)((33 * 0.8 / fontSize) + 0.0001); // rounding magic ConsoleColor fg = Console2.ForegroundColor; ConsoleColor bg = Console2.BackgroundColor; Console2.ForegroundColor = ConsoleColor.Gray; Console2.WriteLine("LCD:"); string[] lines = value.Split('\n').Select(x => x.Trim('\r')).ToArray(); foreach (string line in lines) { string visiblePart = line.Substring(0, Math.Min(line.Length, visibleCount)); string hiddenPart = line.Substring(Math.Min(line.Length, visibleCount)); Console2.ForegroundColor = ConsoleColor.Cyan; Console2.BackgroundColor = ConsoleColor.Black; Console2.Write(visiblePart); //Console2.ForegroundColor = ConsoleColor.DarkBlue; //Console2.BackgroundColor = ConsoleColor.DarkGray; if (hiddenPart.Length > 0) { Console2.Write(hiddenPart); } else { Console2.CursorLeft = Console2.CursorLeft + visibleCount - visiblePart.Length; Console2.Write(" "); } Console2.BackgroundColor = ConsoleColor.Black; Console2.WriteLine(); } Console2.ForegroundColor = fg; Console2.BackgroundColor = bg; return(true); //throw new NotImplementedException(); }