美化 .NET 控制台输出!
Colorful.Console Colorful.Console 是一个 C# 库,它包装了 System.Console 类,暴露了增强的样式功能。如何获取 - 从 NuGet 下载 Colorful.Console - 使用 Git 克隆 git clone https://GitHub.com/tomakita/Colorful.Console.git 基本使用 c# using System; using System.Drawing; using Console = Colorful.Console; ... ... Console.WriteLine("console in pink", Color.Pink); Console.WriteLine("console in default"); 使用完整的 System.Drawing.Color 支持 c# int r = 225; int g = 255; int b = 250; for (int i = 0; i match.ToUpper()); Console.WriteLineStyled(storyAboutRain, styleSheet); 样式化文本的特定区域,根据周围文本执行转换 c# StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle("rain[a-z]", Color.MediumSlateBlue, (unstyledInput, matchLocation, match) = { if (unstyledInput[matchLocation.End] == '.') { return "marshmallows"; } else { return "s'mores"; } }); Console.WriteLineStyled(storyAboutRain, styleSheet); 使用默认字体将文本转换为 ASCII 图像 c# int DA = 244; int V = 212; int ID = 255; for (int i = 0; i chars = new List() { 'r', 'e', 'x', 's', 'z', 'q', 'j', 'w', 't', 'a', 'b', 'c', 'l', 'm', 'r', 'e', 'x', 's', 'z', 'q', 'j', 'w', 't', 'a', 'b', 'c', 'l', 'm', 'r', 'e', 'x', 's', 'z', 'q', 'j', 'w', 't', 'a', 'b', 'c', 'l', 'm' }; Console.WriteWithGradient(chars, Color.Yellow, Color.Fuchsia, 14); 使用说明 Console 颜色可以使用 Colorful.Console.ReplaceAllColorsWithDefaults 函数恢复到其默认值。可以使用 Colorful.Console.ReplaceColor 函数替换控制台颜色表中的单个颜色。Colorful.Console 只能在单个控制台会话中以 16 种不同的颜色(包括默认情况下用作控制台背景的黑色!) 向控制台写入。这是 Windows 控制台本身的限制(参阅 MSDN.aspx)),我们无法克服这个限制。如果您知道有什么方法可以解决这个问题,请告诉我们!
暂无开放 Issues,或尚未同步最近议题。