Example #1
0
        protected void RenderWord2(int index, int item, int longestName)
        {
            Console.BackgroundColor = conf.BackColor;
            string word = ColorInfo.GetColorName(index);

            if (index == item)
            {
                Console.ForegroundColor = conf.PromptColor;
                Console.Write("[");
                Console.ForegroundColor = conf.HelpColor;
                Console.Write(word);
                Console.ForegroundColor = conf.PromptColor;
                Console.Write("]");
            }
            else
            {
                Console.ForegroundColor = conf.HelpColor;
                Console.Write($" {word} ");
            }
            string arrow = "";

            arrow  = arrow.PadRight(longestName - word.Length, '-');
            arrow += "->";
            Console.Write(arrow);
            Console.BackgroundColor = ColorInfo.GetColor(index);
            Console.ForegroundColor = ColorInfo.IsDarkColor(index) ? ConsoleColor.White : ConsoleColor.Black;
            Console.WriteLine("  (color looks like this)  ");
        }
Example #2
0
        protected void RenderList2(int item)
        {
            Console.BackgroundColor = conf.BackColor;
            Console.Clear();
            int longest = 0;

            for (int i = 0; i < ColorInfo.NumColors; ++i)
            {
                longest = Math.Max(longest, ColorInfo.GetColorName(i).Length);
            }
            for (int i = 0; i < ColorInfo.NumColors; ++i)
            {
                RenderWord2(i, item, longest);
            }
        }
Example #3
0
        //user selects one of 16 colors - escape with [ESC] key
        protected ConsoleColor UserEntersColor(Item item, T target)
        {
            ConsoleColor originalColor = GetColor(item, target);

            int          item2 = -1;
            ConsoleColor aColor;

            do
            {
                item2++;
                aColor = ColorInfo.GetColor(item2);
            }while (!aColor.Equals(originalColor));

            ConsoleKeyInfo key;

            do
            {
                Thread.Sleep(conf.DelayMilliSeconds);
                RenderList2(item2);
                key = Console.ReadKey();
                if (key.Key == ConsoleKey.UpArrow || key.Key == ConsoleKey.PageUp || key.Key == ConsoleKey.LeftArrow)
                {
                    item2 = item2 == 0 ? ColorInfo.NumColors - 1 : item2 - 1;
                }
                else
                if (key.Key == ConsoleKey.DownArrow || key.Key == ConsoleKey.PageDown || key.Key == ConsoleKey.RightArrow)
                {
                    item2 = (item2 + 1) % ColorInfo.NumColors;
                }
                else
                if (key.Key == ConsoleKey.Enter)
                {
                    return(ColorInfo.GetColor(item2));
                }
                else
                if (key.Key == ConsoleKey.Escape)
                {
                    return(originalColor);
                }
            }while (true);
        }