Esempio n. 1
0
        private static void EditColor(ConhicsColor conhicsColorToEdit, byte r, byte g, byte b, string colorName)
        {
            ConsoleColor consoleColorToEdit = conhicsColorToEdit.ConsoleColor;

            conhicsColorToEdit.SetColor(r, g, b, colorName);
            string consoleColorToEditName       = Enum.GetName(typeof(ConsoleColor), consoleColorToEdit);
            object consoleScreenBufferInfoBoxed = consoleScreenBufferInfo;

            typeof(Integration.CONSOLE_SCREEN_BUFFER_INFO_EX)
            .GetField(name: consoleColorToEditName)
            .SetValue(obj: consoleScreenBufferInfoBoxed, value: conhicsColorToEdit.ColorRef);
            consoleScreenBufferInfo = (Integration.CONSOLE_SCREEN_BUFFER_INFO_EX)consoleScreenBufferInfoBoxed;
            Integration.SetConsoleScreenBufferInfoEx(Screen.s_handle, ref consoleScreenBufferInfo);
        }
Esempio n. 2
0
 static ColorManager()
 {
     colorDictionary                = new Dictionary <string, ConhicsColor>();
     consoleScreenBufferInfo        = default(Integration.CONSOLE_SCREEN_BUFFER_INFO_EX);
     consoleScreenBufferInfo.cbSize = Marshal.SizeOf(consoleScreenBufferInfo);
     Integration.GetConsoleScreenBufferInfoEx(Screen.s_handle, ref consoleScreenBufferInfo);
     foreach (ConsoleColor color in Enum.GetValues(typeof(ConsoleColor)))
     {
         string colorName = Enum.GetName(typeof(ConsoleColor), color);
         colorDictionary.Add(
             key: colorName,
             value: new ConhicsColor(color, colorName));
     }
 }