GetConsoleColor() public method

Gets the ConsoleColor mapped to the System.Drawing.Color provided as an argument.
public GetConsoleColor ( Color color ) : ConsoleColor
color Color The System.Drawing.Color whose ConsoleColor alias should be retrieved.
return ConsoleColor
Ejemplo n.º 1
0
        private static void MapToScreen(IEnumerable<KeyValuePair<string, Color>> styleMap, string trailer)
        {
#if !NET40
            Queue.Enqueue(() => Task.Factory.StartNew(() =>
            {
#endif
                var oldSystemColor = System.Console.ForegroundColor;
                int writeCount = 1;
                foreach (KeyValuePair<string, Color> textChunk in styleMap)
                {
                    System.Console.ForegroundColor = colorManager.GetConsoleColor(textChunk.Value);

                    if (writeCount == styleMap.Count())
                    {
                        System.Console.Write(textChunk.Key + trailer);
                    }
                    else
                    {
                        System.Console.Write(textChunk.Key);
                    }

                    writeCount++;
                }

                System.Console.ForegroundColor = oldSystemColor;
#if !NET40
            })).Wait();
#endif
        }
Ejemplo n.º 2
0
        private static void MapToScreen(IEnumerable<KeyValuePair<string, Color>> styleMap, string trailer)
        {
            int writeCount = 1;
            foreach (KeyValuePair<string, Color> textChunk in styleMap)
            {
                System.Console.BackgroundColor = colorManager.GetConsoleColor(textChunk.Value);

                if (writeCount == styleMap.Count())
                {
                    System.Console.Write(textChunk.Key + trailer);
                }
                else
                {
                    System.Console.Write(textChunk.Key);
                }

                writeCount++;
            }

            System.Console.ResetColor();
        }