Esempio n. 1
0
 public static void TrySetConsoleColor(ConsoleColorFlags colorFlags)
 {
     // SetConsoleTextAttribute may fail if stdout is redirected to a sink other
     // than the cmd window (eg: VS's output window).
     try
     { SetConsoleColor(colorFlags); }
     catch (Win32Exception)
     { }
 }
Esempio n. 2
0
 public static void TrySetConsoleColor(ConsoleColorFlags colorFlags)
 {
     // SetConsoleTextAttribute may fail if stdout is redirected to a sink other
     // than the cmd window (eg: VS's output window).
     try
     { SetConsoleColor(colorFlags); }
     catch (Win32Exception)
     { }
 }
Esempio n. 3
0
        //
        // Interface
        public static void SetConsoleColor(ConsoleColorFlags colorFlags)
        {
            // Set the color on the current stdout stream.
            const int stdout = -11;

            IntPtr hStdOut = Kernel32.GetStdHandle(stdout);
            if (hStdOut == IntPtr.Zero || hStdOut == new IntPtr(-1))
                throw new Win32Exception();

            if (!Kernel32.SetConsoleTextAttribute(hStdOut, colorFlags))
                throw new Win32Exception();
        }
Esempio n. 4
0
    public static void TrySetConsoleColor(ConsoleColorFlags colorFlags)
    {
        // don't do anything if 'black on black'
        if ( 0 == (Int32)colorFlags ) { return; }

        // SetConsoleTextAttribute may fail if stdout is redirected to a sink other
        // than the cmd window (eg: VS's output window).
        try
        { SetConsoleColor(colorFlags); }
        catch (Win32Exception)
        { }
    }
Esempio n. 5
0
    public static void TrySetConsoleColor(ConsoleColorFlags colorFlags)
    {
        // don't do anything if 'black on black'
        if (0 == (Int32)colorFlags)
        {
            return;
        }

        // SetConsoleTextAttribute may fail if stdout is redirected to a sink other
        // than the cmd window (eg: VS's output window).
        try
        { SetConsoleColor(colorFlags); }
        catch (Win32Exception)
        { }
    }
Esempio n. 6
0
        //
        // Interface

        public static void SetConsoleColor(ConsoleColorFlags colorFlags)
        {
            // Set the color on the current stdout stream.
            const int stdout = -11;

            IntPtr hStdOut = Kernel32.GetStdHandle(stdout);

            if (hStdOut == IntPtr.Zero || hStdOut == new IntPtr(-1))
            {
                throw new Win32Exception();
            }

            if (!Kernel32.SetConsoleTextAttribute(hStdOut, colorFlags))
            {
                throw new Win32Exception();
            }
        }
Esempio n. 7
0
 public static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput, ConsoleColorFlags wAttributes);
Esempio n. 8
0
 public static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput, ConsoleColorFlags wAttributes);