本文整理汇总了C#中ConsoleColor类的典型用法代码示例。如果您正苦于以下问题:C# ConsoleColor类的具体用法?C# ConsoleColor怎么用?C# ConsoleColor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConsoleColor类属于命名空间,在下文中一共展示了ConsoleColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintCharOnPos
public static void PrintCharOnPos(char ch, int y, int x, ConsoleColor color)
{
Console.ForegroundColor = color;
Console.SetCursorPosition(x, y);
Console.Write(ch);
}
示例2: Write
private void Write(string s, ConsoleColor c)
{
ConsoleColor temp = Console.ForegroundColor;
Console.ForegroundColor = c;
Write(s);
Console.ForegroundColor = temp;
}
示例3: Print
static void Print(ConsoleColor color, string format, params object[] args)
{
var old = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(format, args);
Console.ForegroundColor = old;
}
示例4: Initialize
public static void Initialize(ConsoleColor defaultColor = ConsoleColor.Gray)
{
switches = new List<List<Switch>>();
DefaultColor = defaultColor;
_lock = new object();
isInitialized = true;
}
示例5: WriteLine
public static void WriteLine(ConsoleColor color, object value)
{
var previousColor = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(value);
Console.ForegroundColor = previousColor;
}
示例6: CPrint
public static void CPrint(string Text, ConsoleColor Color)
{
//Set The Colour Of The Font, Then Set It Back To White
Console.ForegroundColor = Color;
Console.Write(Text);
Console.ForegroundColor = ConsoleColor.White;
}
示例7: VerboseWriteLine
public static void VerboseWriteLine(ConsoleColor color, string output)
{
if (WriteVerboseOutput)
{
WriteLine(color, output);
}
}
示例8: Log
private static void Log(string message, ConsoleColor color)
{
var keepColor = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(message);
Console.ForegroundColor = keepColor;
}
示例9: Write
public static void Write(ConsoleColor color, string content)
{
Console.ForegroundColor = color;
BreakIntoLines(content)
.Each(l=>Console.WriteLine(l));
Console.ResetColor();
}
示例10: WriteLine
static void WriteLine(ConsoleColor color, string text, params object[] args)
{
var oldColor = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(text, args);
Console.ForegroundColor = oldColor;
}
示例11: ConsoleWriteLine
private void ConsoleWriteLine(string text, ConsoleColor color)
{
ConsoleColor before = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(text);
Console.ForegroundColor = before;
}
示例12: ProgressBar
/// <summary>
/// Creates progress bar.
/// </summary>
/// <param name="name">Name of the widget.</param>
/// <param name="pos">Position of the progress bar.</param>
/// <param name="width">Width of the progress bar</param>
/// <param name="maxValue">Maximum value.</param>
/// <param name="value">Current value (default: 0).</param>
/// <param name="fc">Foreground color (default gray).</param>
/// <param name="bc">Background color (default black).</param>
public ProgressBar(string name, Position pos, int width, int maxValue, float value = 0.0f,
ConsoleColor fc = ConsoleColor.Gray, ConsoleColor bc = ConsoleColor.Black)
: base(name, pos, width, 1, false, fc, bc)
{
this.Value = value;
this.MaxValue = maxValue;
}
示例13: ColoredConsoleWrite
public static void ColoredConsoleWrite(ConsoleColor color, string text)
{
ConsoleColor originalColor = System.Console.ForegroundColor;
System.Console.ForegroundColor = color;
System.Console.WriteLine($"[{DateTime.Now.ToString("HH:mm:ss")}] " + text);
System.Console.ForegroundColor = originalColor;
}
示例14: WriteColor
public static void WriteColor(ConsoleColor ForeGround, string var)
{
if (ForegroundColor != ForeGround)
ForegroundColor = ForeGround;
WriteLine(var.PadRight(var.Length % WindowWidth, ' '));
LowerBoundOutput();
}
示例15: UseTextColour
public static void UseTextColour(ConsoleColor colour, Action action)
{
var prevForegroundColor = Console.ForegroundColor;
Console.ForegroundColor = colour;
action();
Console.ForegroundColor = prevForegroundColor;
}