private static void Main(string[] args) { //// each test shall be run on separate run - colors conflicts and handles conflicts //var tests = new InternalTests(); ////tests.PrintDefaultColors(); //tests.PrintCustomColors(); //return; ConsoleManager helper = new ConsoleManager(); //helper.ReplaceConsoleColor(ConsoleColor.DarkCyan, Color.Salmon); helper.ReplaceConsoleColors( new Tuple <ConsoleColor, Color>(ConsoleColor.DarkCyan, Color.Chocolate), new Tuple <ConsoleColor, Color>(ConsoleColor.Blue, Color.DodgerBlue), new Tuple <ConsoleColor, Color>(ConsoleColor.Yellow, Color.Gold), new Tuple <ConsoleColor, Color>(ConsoleColor.DarkBlue, Color.MidnightBlue)); IConsole console = new SystemConsole(helper, isFullScreen: false); ConsoleOperations ops = new ConsoleOperations(console); TestCommands test = new TestCommands(console); //PrintColorsMessages(console); //PrintAllNamedColors(helper, console); //PrintFrames(ops, console); //PrintTables(ops); console.ReadLine(); }
private void ReadLineTest() { var console = new SystemConsole(); using (var s = new StringReader("Testing")) { System.Console.SetIn(s); console.ReadLine().Should().Be("Testing"); } }
private void Run(Arguments arguments) { try { if (arguments.IsHelpOptionFound()) { Help(); return; } string signatureFile = arguments.IsOptionPresent("sign") ? arguments.Options["sign"].Value : null; bool testLoad = arguments.IsOptionPresent("test"); bool debug = arguments.IsOptionPresent("debug"); string obfuscator = arguments.IsOptionPresent("obfuscator") ? arguments.Options["obfuscator"].Value : "obfuscar"; if (arguments.IsOptionPresent("config")) { string config = arguments.Options["config"].Value; if (config.ToUpper() != "RELEASE") { SystemConsole.WriteLine("No obfuscation at configuration <cyan>{0}", config); return; } } foreach (string file in arguments.Parameters) { if (!File.Exists(file)) { throw new FileNotFoundException(); } Obfuscate(obfuscator, file, signatureFile, testLoad: testLoad, debug: debug); } } catch (Exception ex) { if (Debugger.IsAttached) { throw; } SystemConsole.WriteLine(ex.ToXT()); } finally { if (Debugger.IsAttached || arguments.IsOptionPresent("wait")) { SystemConsole.WriteLine("--- press <yellow>enter<default> to exit ---"); SystemConsole.ReadLine(); } } }
static string ShowSelector(List <string> files) { SystemConsole.WriteLine("Please select the program to use:"); string selectors = ASCII.Strings.Digits + ASCII.Strings.UppercaseLetters; int i = 0; foreach (string file in files) { string selector = ""; //get selector { int n = ++i; while (n > 0) { selector += selectors[n % selectors.Length]; n /= selectors.Length; } } SystemConsole.WriteLine(" <cyan>{0}<default> {1}", selector, file); } while (true) { string selector = SystemConsole.ReadLine(); SystemConsole.WriteLine(); i = 0; //get number foreach (char c in selector) { int x = selectors.IndexOf(c); if (x < 0) { i = -1; break; } i = i * selectors.Length + x; } if (i < 1 || i > files.Count) { SystemConsole.WriteLine(string.Format("Selection <red>{0}<default> is invalid!", selector)); continue; } return(files[i - 1]); } }
/// <summary> /// Starts the service as service process or user interactive commandline program. In user interactive mode a logconsole is created to receive messages. /// In service mode an eventlog is used. /// </summary> public void Run() { try { Init(); if (IsWindowsService) { Run(this); return; } if (SystemConsole.IsConsoleAvailable && SystemConsole.CanReadKey) { SystemConsole.SetKeyPressedEvent(OnKeyPressed); } // run commandline CommandLineRun(); } catch (Exception ex) { log.LogEmergency(ex, "Unhandled exception:\n" + ex.ToXT()); } finally { // force stop if not already stopped / set stopped flag at service if (IsWindowsService) { Stop(); } Logger.Flush(); Logger.Close(); SystemConsole.RemoveKeyPressedEvent(); if (Debugger.IsAttached) { Thread.Sleep(1000); SystemConsole.WriteLine("--- Press <yellow>enter<default> to exit ---"); SystemConsole.ReadLine(); } } }
private void Run(string[] args) { bool waitOnExit = Debugger.IsAttached; try { Arguments arguments = Arguments.FromArray(args); waitOnExit |= arguments.IsOptionPresent("wait"); if (arguments.IsHelpOptionFound()) { Help(); return; } if (arguments.IsOptionPresent("increment") || arguments.IsOptionPresent("stable")) { AutoUpdate(arguments); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); List <Project> projects = LoadSolution(arguments); Application.Run(new FormMain(this, projects)); } catch (Exception ex) { if (!IsConsoleMode) { MessageBox.Show(ex.ToString()); } if (Debugger.IsAttached) { throw; } } finally { if (waitOnExit) { SystemConsole.WriteLine("--- press <yellow>enter<default> to exit ---"); SystemConsole.ReadLine(); } } }