// Public interface /// <summary> /// This needs to be run before starting up the manager. /// </summary> /// <param name="serviceProvider"></param> /// <param name="config"></param> public static void Configure(IServiceProvider serviceProvider, IConfigurationRoot config) { Settings = new ToolsGlobalSettings(); if (File.Exists("documentation.json")) { var json = File.ReadAllText("documentation.json"); Documentation = JsonConvert.DeserializeObject <Dictionary <string, List <Documentation> > >(json)["help"]; } _tools ??= new List <ITool>(); _tools.AddRange(serviceProvider.GetServices <ITool>()); SetConfiguration(config); }
public static void DrawTop(ToolsGlobalSettings settings) { var pos = new Point(1, 1); Console.ForegroundColor = ConsoleColor.Yellow; Console.SetCursorPosition(pos.X + 1, pos.Y); Console.Write("╔═╗ +"); Console.SetCursorPosition(pos.X + 1, pos.Y + 1); Console.Write("╚═╬═╗"); Console.SetCursorPosition(pos.X + 1, pos.Y + 2); Console.Write("+ ╚═╝"); Console.SetCursorPosition(pos.X + Width - 8, pos.Y); Console.Write("+ ╔═╗"); Console.SetCursorPosition(pos.X + Width - 8, pos.Y + 1); Console.Write("╔═╬═╝"); Console.SetCursorPosition(pos.X + Width - 8, pos.Y + 2); Console.Write("╚═╝ +"); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(pos.X + 8, pos.Y); Console.Write(settings.Title); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(pos.X + 8, pos.Y + 1); Console.Write(settings.Description); Console.ForegroundColor = ConsoleColor.Gray; Console.SetCursorPosition(pos.X + 8, pos.Y + 2); Console.Write("Version " + settings.Version); if (settings.Info != null && settings.Info.Any()) { var count = 0; foreach (var info in settings.Info) { Console.SetCursorPosition(pos.X + Width - (info.Key.Length + info.Value.Length) - 13, pos.Y + count); Console.ForegroundColor = ConsoleColor.White; Console.Write($"{info.Key}"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.Write($" [{info.Value}]"); if (count > TopHeight - 3) { break; } count++; } } }