Exemple #1
0
 public void Write(ConsoleColor foreground, ConsoleColor background, string format, params object[] args)
 {
     SafeConsoleColorSetter.SetColor(foreground, background);
     try
     {
         string currentText = String.Format(format, args);
         tw.Write(currentText);
         s_currentLine.Append(currentText);
     }
     finally
     {
         SafeConsoleColorSetter.ResetColor();
     }
 }
Exemple #2
0
        public static int Main(string[] args)
        {
            Application.EnableVisualStyles();

            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);

            try
            {
                // Load defaults from app.config.
                s_options = new Options();

                // If args were spec'd on cmd line, use them; else show the GUI prompt.
                if (args.Length > 0)
                {
                    return(MainImplCmd(args));
                }
                else
                {
                    return(MainImplGui());
                }
            }
            catch (ApplicationException ex)
            {
                ConsoleWriter.Error.WriteLine(Global.Options.ErrorForeground, ex.Message);

                return(CommandLine.ShowUsage());
            }
            catch (Exception ex)
            {
                ConsoleWriter.Error.WriteLine(Global.Options.ErrorForeground, ex.ToString());

                return(1);
            }
            finally
            {
                SafeConsoleColorSetter.ResetColor();
            }
        }
Exemple #3
0
            public void WriteLine(ConsoleColor foreground, ConsoleColor background, string format, params object[] args)
            {
                SafeConsoleColorSetter.SetColor(foreground, background);
                try
                {
                    string currentText = String.Format(format, args);
                    tw.WriteLine(currentText);
                    s_currentLine.Append(currentText).Append("\n");
                    if (Global.Options.Pause)
                    {
                        s_linesWritten += (int)Math.Ceiling((double)Math.Max(s_currentLine.Length, 1) / (double)Console.BufferWidth);
                        if (s_linesWritten > (Console.WindowHeight - 2))
                        {
                            SafeConsoleColorSetter.SetColor(Global.Options.PausePromptForeground, Global.Options.PausePromptBackground);
                            Console.Write("<space> next page, (q)uit, (c)ontinue... ");
                            SafeConsoleColorSetter.ResetColor();
                            ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                            Console.WriteLine();
                            s_linesWritten = 0;
                            switch (keyInfo.KeyChar.ToString().ToLower())
                            {
                            case "c":                             // continue to the end without pausing
                                Global.Options.Pause = false;
                                break;

                            case "q":                             // quit
                                System.Environment.Exit(1);
                                break;
                            }
                        }
                    }
                    s_currentLine.Length = 0;
                }
                finally
                {
                    SafeConsoleColorSetter.ResetColor();
                }
            }