private void SetForegroundColor(ConsoleColor color) { if (!UseColors) { return; } // this.CheckFile(ref ResultLine); this.foregroundColor = color; if (FileStreamWriter != null) { String SetColorCommand = "\0foreground color=" + foregroundColor.ToString(); FileStreamWriter.WriteLine(SetColorCommand); } else if (ResultLines != null) { String SetColorCommand = "\0foreground color=" + foregroundColor.ToString(); ResultLines.Add(SetColorCommand); } else { Console.ForegroundColor = foregroundColor; } }
/// <summary> /// Log a specific message by LogLevel. Won't log if the LogLevel is greater than the maxLogLevel set. /// </summary> /// <param name="message">The message to log. The current time will be prepended.</param> /// <param name="level">Optional. Default <see cref="LogLevel.Info" />.</param> /// <param name="color">Optional. Default is auotmatic</param> public void Write(string message, LogLevel level = LogLevel.Info, ConsoleColor color = ConsoleColor.Black) { // Remember to change to a font that supports your language, otherwise it'll still show as ???. Console.OutputEncoding = Encoding.UTF8; if (level > _maxLogLevel) { return; } var finalMessage = Logger.GetFinalMessage(message.Replace("NecroBot", "RocketBot"), level, color); Console.WriteLine(finalMessage); // Fire log write event. OnLogWrite?.Invoke(this, new LogWriteEventArgs { Message = finalMessage, Level = level, Color = color }); // ReSharper disable once SwitchStatementMissingSomeCases Color _color = new Color(); Dictionary <LogLevel, Color> colors = new Dictionary <LogLevel, Color>() { { LogLevel.Error, Color.Red }, { LogLevel.Caught, Color.Green }, { LogLevel.Info, Color.DarkCyan }, { LogLevel.Warning, Color.FromArgb(255, 128, 128, 0) }, { LogLevel.Pokestop, Color.Cyan }, { LogLevel.Farming, Color.Magenta }, { LogLevel.Sniper, Color.White }, { LogLevel.Recycling, Color.DarkMagenta }, { LogLevel.Flee, Color.FromArgb(255, 128, 128, 0) }, { LogLevel.Transfer, Color.DarkGreen }, { LogLevel.Evolve, Color.DarkGreen }, { LogLevel.Berry, Color.FromArgb(255, 128, 128, 0) }, { LogLevel.Egg, Color.FromArgb(255, 128, 128, 0) }, { LogLevel.Debug, Color.Gray }, { LogLevel.Update, Color.White }, { LogLevel.New, Color.Green }, { LogLevel.SoftBan, Color.Red }, { LogLevel.LevelUp, Color.Magenta }, { LogLevel.BotStats, Color.Magenta }, { LogLevel.Gym, Color.Magenta }, { LogLevel.GymDisk, Color.Cyan }, { LogLevel.Service, Color.White } }; _color = colors[level]; if (string.IsNullOrEmpty(color.ToString()) || color.ToString() != "Black") { _color = FromColor(color); } if (string.IsNullOrEmpty(_color.ToString())) { _color = Color.White; } MainForm.ColoredConsoleWrite(_color, finalMessage); }
private static ConsoleColor ChooseColor() { var colors = Enum.GetNames(typeof(ConsoleColor)); Console.WriteLine("Pick your color: "); foreach (var c in colors.Where(c => c != "Black")) { Console.WriteLine(c); } ConsoleColor color = ConsoleColor.Black; while (color == ConsoleColor.Black) { try { color = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), Console.ReadLine()); if (!colors.Contains(color.ToString()) || color == ConsoleColor.Black) { throw new Exception(); } } catch { Console.WriteLine("INVALID SELECTION STUPID!"); color = ConsoleColor.Black; } } Console.ForegroundColor = color; Console.WriteLine("Your chats will all be {0}", color.ToString()); return(color); }
/// <summary> /// Convert ConsoleColor to Color /// </summary> /// <param name="consoleColor"></param> /// <returns></returns> public static Color ToColor(this ConsoleColor consoleColor) { Color c = Color.FromName(consoleColor.ToString()); if (c.IsNamedColor) { return(c); } throw new ArgumentException("Unknown color: " + consoleColor.ToString(), paramName: nameof(consoleColor)); }
private static void ListEnum2() { //Loop never terminates, but should! ConsoleColor current = (ConsoleColor)0; for (int i = 0; (current.ToString() != i.ToString()); i++) { current = (ConsoleColor)i; Console.WriteLine("enum:" + current + ", i:" + i + ", condition:" + (current.ToString() != i.ToString())); Console.ReadLine(); } }
private static void ListEnum1() { //Loop terminates, and should. ConsoleColor current = (ConsoleColor)0; bool end = current.ToString() == 0.ToString(); for (int i = 0; !end; i++) { current = (ConsoleColor)i; end = current.ToString() == i.ToString(); Console.WriteLine("enum:" + current + ", i:" + i + ", condition:" + !end); Console.ReadLine(); } }
private StatementAst CreateProcessedMessage(IScriptPosition position, ConsoleColor dashColor, Type astType) { ExpressionAst traceInvocation = InvokeMember( isStatic: true, Type(typeof(SequencePointTracer)), nameof(SequencePointTracer.TraceExpression), Variable("Host"), Member(Type(typeof(ConsoleColor)), dashColor.ToString(), isStatic: true), Type(astType), Variable(StackVariable), Constant(position.LineNumber), Constant(position.ColumnNumber), Index( Array( Pipeline( CommandExpression( ArrayLiteral(Variable(TempVariable))))), Constant(0)), Variable("false")); return(Pipeline(CommandExpression(traceInvocation))); // var prefix = Add(CreateDashString(), String("< {0}")); // var message = Format(prefix, Variable(TempVariable)); // return Pipeline( // Command( // WriteHost, // message, // CommandParameter("ForegroundColor"), // String(dashColor.ToString()))); }
private string GetHexColor(ConsoleColor clr) { var c = Color.FromName(clr.ToString()); var result = string.Format("#{0:x6}", c.ToArgb() & 0xFFFFFF); return(result); }
public void ConvertConsoleColorTest() { KnownColor form = KnownColor.DarkRed; ConsoleColor consoleColor = ConsoleColor.DarkRed; var l = (int)consoleColor; var m = (int)form; //foreach (FieldInfo fi in typeof(ConsoleColor).GetFields(BindingFlags.Public | BindingFlags.Static)) //{ foreach (FieldInfo fc in typeof(KnownColor).GetFields(BindingFlags.Public | BindingFlags.Static)) { if (fc.Name == consoleColor.ToString()) { foreach (FieldInfo fi in typeof(ConsoleColor).GetFields(BindingFlags.Public | BindingFlags.Static)) { //if (fi.n) } form = (KnownColor)consoleColor; } } //} }
static void WriteThemeData(ConsoleColor foreground, ConsoleColor background) { string dataPath = @"Data/Theme.txt"; File.WriteAllText(dataPath, foreground.ToString() + "\n"); File.WriteAllText(dataPath, background.ToString()); }
public void SetDoorColor(ConsoleColor newColor) { color = newColor; // rename door according to color name = "The " + color.ToString() + " Door"; }
} // end of ConvertColor method public void SaveScreen(string fileName) { FileStream stream; StreamWriter textOut = null; try { stream = new FileStream(fileName, FileMode.Create, FileAccess.Write); textOut = new StreamWriter(stream); textOut.WriteLine(backgroundColor.ToString()); textOut.WriteLine(foregroundColor.ToString()); for (int i = 0; i < screenText.Length; i++) { textOut.WriteLine(screenText[i]); } textOut.Close(); } catch (Exception ex) { Console.WriteLine("Error Creating file: "); Console.WriteLine(ex.ToString()); return; } finally { if (textOut != null) { textOut.Close(); } } } // of of SaveScreen method
private static void EinstellungenMenuAktion(string iniVariable, string iniSchluessel, string aufforderungText, string aufforderungTitel, Typ eingabenTyp, int[] limitTypZahl = null) { bool einstellungFertigBearbeitet = false; string rueckgabeAenderung = ""; Program.WriteAt(0, 0, " "); do { try { if (eingabenTyp == Typ.Zahl && limitTypZahl != null && limitTypZahl.Length == 2 && limitTypZahl[0] < limitTypZahl[1]) { rueckgabeAenderung = Microsoft.VisualBasic.Interaction.InputBox($"{aufforderungText} (Min: {limitTypZahl[0]}, Max: {limitTypZahl[1]})", aufforderungTitel, Einstellungen.ini.Read(iniVariable, iniSchluessel)); } else { rueckgabeAenderung = Microsoft.VisualBasic.Interaction.InputBox(aufforderungText, aufforderungTitel, Einstellungen.ini.Read(iniVariable, iniSchluessel)); } switch (eingabenTyp) { case Typ.Farbe: ConsoleColor neueFarbe = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), rueckgabeAenderung); Einstellungen.ini.Write(iniVariable, neueFarbe.ToString(), iniSchluessel); einstellungFertigBearbeitet = true; break; case Typ.Zahl: int neueZahl = int.Parse(rueckgabeAenderung); if (limitTypZahl != null && limitTypZahl.Length == 2 && limitTypZahl[0] < limitTypZahl[1]) { if (neueZahl >= limitTypZahl[0] && neueZahl <= limitTypZahl[1]) { Einstellungen.ini.Write(iniVariable, neueZahl.ToString(), iniSchluessel); einstellungFertigBearbeitet = true; } else { einstellungFertigBearbeitet = false; } } else { Einstellungen.ini.Write(iniVariable, neueZahl.ToString(), iniSchluessel); einstellungFertigBearbeitet = true; } break; case Typ.Text: Einstellungen.ini.Write(iniVariable, rueckgabeAenderung, iniSchluessel); einstellungFertigBearbeitet = true; break; default: break; } } catch (Exception) { einstellungFertigBearbeitet = false; } } while (!einstellungFertigBearbeitet); }
public void WriteLine(string message, ConsoleColor textColor, bool isError) { outputMessages.Add(new OutputMessage(message, textColor, isError)); // Dump to the console to assist debugging Console.WriteLine("IsError: {0}, TextColor: {1}, Message: {2}", isError, textColor.ToString(), message); }
/// <summary> /// Prints list of all colours on the screen. /// </summary> /// <param name="message"></param> /// <returns>What the user has written. It's supposed to be the number of the colour in the given list. You can cast it to 'ConsoleColor'</returns> private string SelectColour(string message) { Console.Clear(); Console.WriteLine("Please write the number of the colour you want to use and press 'Enter'"); Console.WriteLine(message); ConsoleColor BackgroundColor = Console.BackgroundColor; ConsoleColor TextColor = Console.ForegroundColor; for (int i = 0; i < Enum.GetNames(typeof(ConsoleColor)).Length; i++) { try { ConsoleColor c = (ConsoleColor)i; Console.ForegroundColor = c; Console.WriteLine((i + 1) + "." + c.ToString()); } catch (System.ArgumentException) { i++; } } Console.BackgroundColor = BackgroundColor; Console.ForegroundColor = TextColor; string result = Console.ReadLine(); return(result); }
public static ANSI_COLOR Color_Console_To_ANSI(ConsoleColor Color) { switch (Color) { case ConsoleColor.DarkYellow: return(ANSI_COLOR.YELLOW); case ConsoleColor.Yellow: return(ANSI_COLOR.YELLOW_BRIGHT); case ConsoleColor.DarkRed: return(ANSI_COLOR.RED); case ConsoleColor.Red: return(ANSI_COLOR.RED_BRIGHT); case ConsoleColor.DarkMagenta: return(ANSI_COLOR.MAGENTA_BRIGHT); case ConsoleColor.Magenta: return(ANSI_COLOR.MAGENTA_BRIGHT); case ConsoleColor.DarkGreen: return(ANSI_COLOR.GREEN_BRIGHT); case ConsoleColor.Green: return(ANSI_COLOR.GREEN_BRIGHT); case ConsoleColor.DarkCyan: return(ANSI_COLOR.CYAN); case ConsoleColor.Cyan: return(ANSI_COLOR.CYAN_BRIGHT); case ConsoleColor.DarkBlue: return(ANSI_COLOR.BLUE); case ConsoleColor.Blue: return(ANSI_COLOR.BLUE_BRIGHT); case ConsoleColor.White: return(ANSI_COLOR.WHITE_BRIGHT); case ConsoleColor.Gray: return(ANSI_COLOR.WHITE); case ConsoleColor.DarkGray: return(ANSI_COLOR.BLACK_BRIGHT); case ConsoleColor.Black: return(ANSI_COLOR.BLACK); default: { System.Diagnostics.Debugger.Break(); throw new ArgumentOutOfRangeException($"{nameof(Color)}({Color.ToString()})"); } } }
public static void Echo( this ConsoleColor obj, EchoEvaluationContext ctx) { var(@out, context, _) = ctx; if (context.EchoMap.MappedCall(obj, ctx)) { return; } var smbcol = context.ShellEnv.Colors.HighlightSymbol; var str = $" {smbcol}{GetCmd(EchoDirectives.b + "", obj.ToString().ToLower())} {context.ShellEnv.Colors.Default}"; @out.Echo(smbcol + "{"); @out.Echo(context.ShellEnv.Colors.Default + obj.ToString() + " " + context.ShellEnv.Colors.Name + str); @out.Echo(smbcol + "}"); }
public static void WriteLine(ConsoleColor c, string value, params object[] prms) { for (int i = 0; i < prms.Length; i++) { prms[i] = "<f=" + c.ToString().ToLower() + ">" + prms[i]; } Write(String.Format(value, prms) + Environment.NewLine); }
public void Write(string message, LogLevel level = LogLevel.Info, ConsoleColor color = ConsoleColor.Black) { if (LogToUI != null && level != LogLevel.Debug) { message = Logger.GetFinalMessage(message, level, color); LogToUI(message, level, color.ToString()); } }
public override string ToString() { return($"Figure {GetType().Name}\n" + $"Location at ({_x},{_y})\n" + $"Color: {Color.ToString()}\n" + $"IsVisible: {_isVisible}\n" + $"Has area: {Area}"); }
/// <summary> /// Devuelve los datos del Automovil /// </summary> /// <returns></returns> public override string ConsultarDatos() { StringBuilder sb = new StringBuilder(); sb.AppendLine(base.ToString()); sb.AppendFormat("Color {0}\n", color.ToString()); return(sb.ToString()); }
/// <summary> /// Gets the rgb color of a console color /// </summary> /// <returns>RGB color</returns> public static Color ToColor(this ConsoleColor color) { var c = Color.FromName(Enum.Parse(typeof(ConsoleColor), color.ToString() !).ToString() !); return(c.IsKnownColor switch { false => Color.FromArgb(255, 128, 128, 0), _ => c, });
public void SwitchStatementOfEnum_WithNoCases_ReturnsEnumsStringRepresentatio() { ConsoleColor consoleColor = ConsoleColor.DarkCyan; Func <ConsoleColor, string> @delegate = GetColorWithNoCases; var func = ExecuteLambda <Func <ConsoleColor, string> >(@delegate); string color = func(consoleColor); Assert.AreEqual(color, consoleColor.ToString()); }
public void SwitchStatementOfEnum_GivenASpecificValueOfTheEnum_ReturnsEnumsStringRepresentation() { ConsoleColor consoleColor = ConsoleColor.DarkCyan; Func <ConsoleColor, string> @delegate = GetColor; var func = ExecuteLambda <Func <ConsoleColor, string> >(@delegate); string color = func(consoleColor); Assert.AreEqual(color, consoleColor.ToString()); }
public ColoredCharacter Get(char character, ConsoleColor color) { string key = character + color.ToString(); if (!usedCharacters.ContainsKey(key)) { usedCharacters.Add(key, new ColoredCharacter(character, color)); } return(usedCharacters[key]); }
public Key(int x, int y, ConsoleColor keyColor) { X = x; Y = y; sprite = Constants.KEY; color = keyColor; // name key according to color Name = "The " + color.ToString() + " Key"; }
/// <summary> /// Publica todos los datos del Producto. /// </summary> /// <returns>Devuelve un string con los datos del Producto</returns> public virtual string Mostrar() { StringBuilder str = new StringBuilder(); str.AppendFormat("CODIGO DE BARRAS: {0}\r\n", codigoDeBarras); str.AppendFormat("MARCA : {0}\r\n", marca.ToString()); str.AppendFormat("COLOR EMPAQUE : {0}\r\n", colorPrimarioEmpaque.ToString()); str.AppendLine("---------------------"); return(str.ToString()); }
protected override string UtilesToString() { StringBuilder sb = new StringBuilder(); sb.AppendLine(base.UtilesToString()); sb.AppendLine("Color: " + _color.ToString()); sb.AppendLine("Trazo: " + _trazo + "\n"); return(sb.ToString()); }
/// <summary> /// Writes Xml articulating the current state of the <see cref="StdConsoleObject">StdConsoleObject</see>.</summary> /// <param name="writer">The stream to which this object will /// be serialized.</param> public void WriteXml(System.Xml.XmlWriter writer) { writer.WriteAttributeString(string.Empty, "Name", string.Empty, _name); writer.WriteAttributeString(string.Empty, "Text", string.Empty, _text); writer.WriteAttributeString(string.Empty, "Length", string.Empty, _length.ToString()); writer.WriteAttributeString(string.Empty, "ForeColour", string.Empty, _foreground.ToString()); writer.WriteAttributeString(string.Empty, "BackColour", string.Empty, _background.ToString()); ((IXmlSerializable)_location).WriteXml(writer); }
public static Color FromColor(ConsoleColor c) { switch (c) { case ConsoleColor.DarkYellow: return(Color.FromArgb(255, 128, 128, 0)); default: return(Color.FromName(c.ToString())); } }
public static Color ProcessTerminalColor(ConsoleColor color) { switch (color) { case (ConsoleColor.DarkBlue): return Color.FromArgb(1, 0x24, 0x56); case (ConsoleColor.Green): return Color.LimeGreen; default: return Color.FromName(color.ToString()); } }
public static string ProcessHtmlColor(ConsoleColor color) { switch (color) { case (ConsoleColor.DarkBlue): return "#012456"; case (ConsoleColor.Green): return "Lime"; default: return color.ToString(); } }
public CrayonColor(ConsoleColor color) { this.OriginalName = color.ToString(); this._consoleColor = color; }
/// <summary> /// Get color mapping xml element without background color /// </summary> /// <returns> /// The color mapping. /// </returns> /// <param name="doc"> /// Document. /// </param> /// <param name="level"> /// Level. /// </param> /// <param name="foregroundColor"> /// Foreground color. /// </param> private XmlElement GetColorMapping(XmlDocument doc, string level, ConsoleColor foregroundColor) { return this.GetColorMapping(doc, level, foregroundColor.ToString(), String.Empty); }
public static string ToString(ConsoleColor color) { return color.ToString(); }
static Brush consoleColorToBrush(ConsoleColor consoleColor) { // Recognize default system color. if (consoleColor == Config.DefaultConsoleColor) return Config.SystemFontBrush; // Handle 'DarkYellow' which does not have a brush with a matching // name. if (consoleColor == ConsoleColor.DarkYellow) return Brushes.DarkGoldenrod; var colorStr = consoleColor.ToString(); return new BrushConverter().ConvertFromString(colorStr) as Brush; }
public int Run() { normalForeColor = Console.ForegroundColor; normalBackColor = Console.BackgroundColor; highlightForeColor = ConsoleColor.Cyan; highlightBackColor = Console.BackgroundColor; errorForeColor = ConsoleColor.Red; errorBackColor = Console.BackgroundColor; if (args.Length == 0 || (args.Length > 0 && args[0].EqualsOneOf(StringComparison.InvariantCultureIgnoreCase, "/?", "/h", "/help"))) { DisplayUsage(args.Length > 1 ? args[1] : null); return 0; } if (args[0].EqualsOneOf(StringComparison.InvariantCultureIgnoreCase, "/hidden")) { DisplayUsage(null, true); return 0; } string cmdline; StringBuilder cmdlineBuilder; int result; // TODO change this project to use the Config settings. bool translateCR = false; bool translateLF = false; bool translateTab = false; bool wrapOutput = false; cmdlineBuilder = new StringBuilder(); try { if (args.Length == 2 && (args[0].Equals("-s", StringComparison.CurrentCultureIgnoreCase) || args[0].Equals("-set", StringComparison.CurrentCultureIgnoreCase))) { ConsoleColor tmpColor; string arg; arg = args[1]; if (arg.StartsWith("{") && arg.EndsWith("}")) { arg = arg.Substring(1, arg.Length - 2); } // Convert old DOS colors to .net ConsoleColor arg = ConvertDOSColors(arg); // TODO support bg if (int.TryParse(arg, out result) && result >= (int)ConsoleColor.Black && result <= (int)ConsoleColor.White) { tmpColor = (ConsoleColor)result; } else if (ConsoleColorNames.Contains(arg, StringComparison.InvariantCultureIgnoreCase)) { tmpColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), arg, true); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("error in -s argument: invalid color specified"); Console.ForegroundColor = normalForeColor; return 10; } try { Console.ForegroundColor = tmpColor; } catch (Exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("error in -s argument: invalid color specified"); Console.ForegroundColor = normalForeColor; return 10; } return 0; } if (ConsoleEx.IsInputRedirected) { // When piping text to pcolor, I'm assuming that there is only // one argument for pcolor and that is a color. cmdlineBuilder.Append(args[0]); cmdlineBuilder.Append(Console.In.ReadToEnd()); } else { // Read all the content from the arguments. for (int argsi = 0; argsi < args.Length; argsi++) { string a = args[argsi]; string al = a.ToLowerInvariant(); if (al.Equals("-f") || al.Equals("-file")) { if (argsi <= args.Length - 2) { StringBuilder contents; argsi++; contents = new StringBuilder(); if (!File.Exists(args[argsi])) { Console.ForegroundColor = errorForeColor; WriteLine(ConsoleColor.Red, "-f the file was not found"); DisplayUsage("-f"); Console.ForegroundColor = normalForeColor; return 4; } if (contents.LoadFromFile(args[argsi])) { cmdlineBuilder.Append(contents.ToString()); } } else { Console.ForegroundColor = errorForeColor; WriteLine(ConsoleColor.Red, "-f is missing its file name"); DisplayUsage("-f"); Console.ForegroundColor = normalForeColor; return 4; } } else if (al.EndsWith("-escape") || al.EndsWith("-crlf") || al.EndsWith("-cr-lf") || al.EndsWith("-cr-lf-tab")) { translateCR = true; translateLF = true; translateTab = true; } else if (al.EndsWith("!escape") || al.EndsWith("!crlf") || al.EndsWith("!cr-lf") || al.EndsWith("!cr-lf-tab")) { translateCR = false; translateLF = false; translateTab = false; } else if (al.EndsWith("-cr")) { translateCR = true; } else if (al.EndsWith("!cr")) { translateCR = false; } else if (al.EndsWith("-lf")) { translateLF = true; } else if (al.EndsWith("!lf")) { translateLF = false; } else if (al.EndsWith("-tab")) { translateTab = true; } else if (al.EndsWith("!tab")) { translateTab = false; } else if (al.EndsWith("-wrap")) { wrapOutput = true; } else if (al.EndsWith("!wrap")) { wrapOutput = false; } else { // Convert hand-typed/specific linefeeds and tabs if (translateCR) { a = a.Replace("\\r\\n", "\r\n"); } if (translateLF) { a = a.Replace("\\n", "\n"); } if (translateTab) { a = a.Replace("\\t", "\t"); } if (wrapOutput) { cmdlineBuilder.Append(Text.Wrap(a)); } else { cmdlineBuilder.Append(a); } if (argsi < args.Length - 1 && !a.EndsWith("\n")) { cmdlineBuilder.Append(" "); } } } } cmdline = cmdlineBuilder.ToString(); // Convert old DOS colors to .net ConsoleColor cmdline = ConvertDOSColors(cmdline); // Provide a default color. if (!cmdline.StartsWith("{")) { cmdline = "{" + normalForeColor.ToString() + "/" + normalBackColor.ToString() + "}" + cmdline; } WriteColoredString(cmdline); } catch (Exception ex) { // do nothing Console.Write(ex.Message); return 1; } Console.ForegroundColor = normalForeColor; return 0; }
private static Color ConsoleColorToColor(ConsoleColor console) { return Color.FromName(console.ToString()); }
private TerminalColor ConvertColor(ConsoleColor color, TerminalColor defaultColor) { TerminalColor result; if(Enum.TryParse<TerminalColor>(color.ToString(), out result)) return result; else return defaultColor; }
/// <summary> /// Sets the console color to use for the specified event type. /// </summary> /// <param name="eventType">The TraceEventType to set the color for.</param> /// <param name="color">The ConsoleColor to use for outputing trace messages of the specified type.</param> /// <remarks> /// <para> /// When selecting colors note that PowerShell redefines DarkYellow and DarkMagenta and uses them /// as default colors, so best to to avoid those two colors because result is not consistent. /// </para> /// </remarks> public void SetConsoleColor(TraceEventType eventType, ConsoleColor color) { lock (_consoleLock) { if (!Enum.IsDefined(typeof (ConsoleColor), color)) { throw new ArgumentOutOfRangeException("color", Resource.InvalidConsoleColor); } var key = eventType.ToString() + "Color"; Attributes[key] = color.ToString(); } }
private string GetColorWithNoCases(ConsoleColor consoleColor) { string color = string.Empty; switch (consoleColor) { default: color = consoleColor.ToString(); break; } return color; }
private string GetColor(ConsoleColor consoleColor) { string color = string.Empty; switch (consoleColor) { case ConsoleColor.DarkCyan: color = consoleColor.ToString(); break; default: throw new NotImplementedException(); } return color; }