コード例 #1
0
        private NativeMethods.CONSOLE_SCREEN_BUFFER_INFO_EX GetConsoleScreenBufferInfoEx()
        {
            NativeMethods.CONSOLE_SCREEN_BUFFER_INFO_EX csbe = new NativeMethods.CONSOLE_SCREEN_BUFFER_INFO_EX();
            csbe.cbSize = Marshal.SizeOf(csbe); // 96 = 0x60

            bool brc = NativeMethods.GetConsoleScreenBufferInfoEx(HConsoleOutput, ref csbe);

            if (!brc)
            {
                throw new SystemException("GetConsoleScreenBufferInfoEx->WinError: #" + Marshal.GetLastWin32Error());
            }
            return(csbe);
        }
コード例 #2
0
        private void ApplyColorChanges(NativeMethods.CONSOLE_SCREEN_BUFFER_INFO_EX csbe)
        {
            // strange, needs to be done because window is shrunken somehow
            ++csbe.srWindow.Bottom;
            ++csbe.srWindow.Right;

            bool brc = NativeMethods.SetConsoleScreenBufferInfoEx(HConsoleOutput, ref csbe);

            if (!brc)
            {
                throw new SystemException("SetConsoleScreenBufferInfoEx->WinError: #" + Marshal.GetLastWin32Error());
            }

            // TODO: build scheme

            this._closeColorFinder = new ColorBalancer(ColorScheme.FromDefinition("from system", this.GetCurrentColorset()), new GruchenDefaultColorHeuristic());
        }
コード例 #3
0
        private static void SetNewColorDefinition(ref NativeMethods.CONSOLE_SCREEN_BUFFER_INFO_EX csbe, ConsoleColor color, Color rgbColor)
        {
            // Eh... Ugly code here...

            var r = rgbColor.R;
            var g = rgbColor.G;
            var b = rgbColor.B;

            switch (color)
            {
            case ConsoleColor.Black:
                csbe.black = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.DarkBlue:
                csbe.darkBlue = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.DarkGreen:
                csbe.darkGreen = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.DarkCyan:
                csbe.darkCyan = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.DarkRed:
                csbe.darkRed = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.DarkMagenta:
                csbe.darkMagenta = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.DarkYellow:
                csbe.darkYellow = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.Gray:
                csbe.gray = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.DarkGray:
                csbe.darkGray = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.Blue:
                csbe.blue = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.Green:
                csbe.green = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.Cyan:
                csbe.cyan = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.Red:
                csbe.red = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.Magenta:
                csbe.magenta = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.Yellow:
                csbe.yellow = new NativeMethods.COLORREF(r, g, b);
                break;

            case ConsoleColor.White:
                csbe.white = new NativeMethods.COLORREF(r, g, b);
                break;
            }
        }