Example #1
0
        /// <summary>
        /// Get the default console palette from the registery
        /// </summary>
        /// <param name="colors"></param>
        /// <remarks>Note that Windows stores colors in ConsoleColor enum order and in BGR byte order <see cref="ColorReference"/></remarks>
        public static ConsolePalette GetDefaultConsolePalette(bool addScreenAndPopup = false)
        {
            ConsolePalette colors = new ConsolePalette(false);

            using (RegistryKey consoleKey = Registry.CurrentUser.OpenSubKey("Console", true))
            {
                for (int i = 0; i < colors.Count; i++)
                {
                    string valueName = "ColorTable" + (i < 10 ? "0" : "") + i;
                    colors[i].BGR = (int)consoleKey.GetValue(valueName, colors[i].BGR);
                }
                if (addScreenAndPopup)
                {
                    var color = (int)consoleKey.GetValue("ScreenColors", colors[0].BGR);
                    // the default colors, foreground first
                    colors.Add(colors[color >> 4 & color]);
                    colors.Add(colors[color >> 4]);

                    color = (int)consoleKey.GetValue("PopupColors", colors[7].BGR);
                    // the popup colors, foreground first
                    colors.Add(colors[color >> 4 & color]);
                    colors.Add(colors[color >> 4]);
                }
            }

            return(colors);
        }
Example #2
0
        public static ConsolePalette GetCurrentConsolePalette(bool addScreenAndPopup = false)
        {
            var palette = new ConsolePalette();

            LoadCurrentColorset(palette, addScreenAndPopup);
            return(palette);
        }
Example #3
0
 private void SetPalette(FormatToken token, ConsolePalette palette)
 {
     if (token is PropertyToken)
     {
         _console.BackgroundColor = palette.ArgumentBackground;
         _console.ForegroundColor = palette.ArgumentForeground;
     }
     else
     {
         _console.BackgroundColor = palette.Background;
         _console.ForegroundColor = palette.Foreground;
     }
 }
Example #4
0
        private void SetPalette(FormatToken token, ConsolePalette palette)
        {
            var property = token as PropertyToken;

            if (property != null)
            {
                _console.BackgroundColor = palette.ArgumentBackground;
                _console.ForegroundColor = palette.ArgumentForeground;
            }
            else
            {
                _console.BackgroundColor = palette.Background;
                _console.ForegroundColor = palette.Foreground;
            }
        }
Example #5
0
 public static void ResetConsolePalette(bool DefaultColors = false)
 {
     _consolePalette = new ConsolePalette(DefaultColors);
 }
Example #6
0
 public static void ResetConsolePalette()
 {
     _consolePalette = new ConsolePalette();
 }