/// <summary> /// Write using a Figlet font /// </summary> /// <param name="text"></param> /// <param name="font"></param> public void Write(StringBuilder text, FigletFont font) => Write(text.ToString(), font);
static void Main(string[] args) { var desc = "FFmpeg batch"; var fontArr = System.Text.Encoding.Default.GetBytes(ContessaFont.CONTESSA); FigletFont font = FigletFont.Load(fontArr); Figlet figlet = new Figlet(font); Console.WriteLine(figlet.ToAscii(desc), Color.Blue); ValueArgument <string> source = new ValueArgument <string>( 's', "source", "Specify the path and search pattern of source files"); source.Optional = false; ValueArgument <string> output = new ValueArgument <string>( 'o', "output", "Specify the output format extension"); output.Optional = false; var parser = new CommandLineParser.CommandLineParser(); parser.Arguments.Add(source); parser.Arguments.Add(output); Console.WriteFormatted("Convert multiple audio and video files using ", Color.White); Console.WriteLineFormatted("FFmpeg", Color.Green); try { parser.ParseCommandLine(args); Run(source.Value, output.Value).Wait(); Environment.Exit(0); } catch (CommandLineException e) { parser.ShowUsage(); Console.WriteLine("Examples:"); Console.WriteLine(string.Empty); Console.WriteLine($@" > To convert all wav files in currenty folder (and sub-directories recursivelly) and convert to mp3 format"); Console.WriteLineFormatted($@" ffmpeg-batch -s /**/*.wav -o mp3", Color.Green); Console.WriteLine(string.Empty); Console.WriteLine($@" > To convert all wma files in c:\music and convert to mp3 format"); Console.WriteLineFormatted($@" ffmpeg-batch -s c:\music\*.wma -o mp3", Color.Green); Console.WriteLine(Environment.NewLine); Console.WriteLine("Install/Uninstall tool:"); Console.WriteLine(string.Empty); Console.WriteLine($@" > To install tool from system"); Console.WriteLineFormatted($@" dotnet tool install -g ffmpeg-batch", Color.Green); Console.WriteLine(string.Empty); Console.WriteLine($@" > To uninstall tool from system"); Console.WriteLineFormatted($@" dotnet tool uninstall -g ffmpeg-batch", Color.Green); Environment.Exit(1); } catch (Exception e) { Console.WriteLine("Error executing utility"); Console.WriteLine(e.ToString()); Environment.Exit(2); } }
private void Run() { /*Size consoleSize = Size.Min(ConsoleRenderer.ConsoleLargestWindowSize, new Size((25 + 1) * 7 + 1, 60)); * try { * ConsoleRenderer.ConsoleWindowRect = new Rect(consoleSize); * Console.BufferWidth = consoleSize.Width; * } * catch (Exception e) { * var consoleRect = new Rect(Console.WindowLeft, Console.WindowTop, Console.WindowWidth, Console.WindowHeight); * Console.WriteLine(consoleRect); * var bufferRect = new Size(Console.BufferWidth, Console.BufferHeight); * Console.WriteLine(bufferRect); * Console.WriteLine(e.Message); * }*/ Console.WindowWidth = 80; Console.BufferWidth = 80; Console.OutputEncoding = Encoding.UTF8; Console.Title = Path.GetFileNameWithoutExtension(Console.Title); var data = new Data { Title = "Header Title", SubTitle = "Header SubTitle", Formatted = "Aaaa\nBbbb\nCccc", LoremIpsum = "Lo|rem ip|sum do|lor sit amet, con|sec|te|tur adi|pis|cing elit, sed do eius|mod tem|por in|ci|di|dunt ut la|bo|re et do|lo|re mag|na ali|qua. Ut enim ad mi|nim ve|ni|am, qu|is nos|trud exer|ci|ta|tion ul|lam|co la|bo|ris ni|si ut ali|quip ex ea com|mo|do con|se|quat. Du|is au|te iru|re do|lor in rep|re|hen|de|rit in vo|lup|ta|te ve|lit es|se cil|lum do|lo|re eu fu|gi|at nul|la pa|ri|a|tur. Ex|cep|te|ur sint oc|ca|e|cat cu|pi|da|tat non pro|i|dent, sunt in cul|pa qui of|fi|cia de|se|runt mol|lit anim id est la|bo|rum.", LoremIpsumShort = "Lo|rem ip|sum do|lor sit amet, con|sec|te|tur adi|pis|cing elit, sed do eius|mod tem|por in|ci|di|dunt ut la|bo|re et do|lo|re mag|na ali|qua. Ut enim ad mi|nim ve|ni|am, qu|is nos|trud exer|ci|ta|tion ul|lam|co la|bo|ris ni|si ut ali|quip ex ea com|mo|do con|se|quat.", Unicode = "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽž", Guid = Guid.NewGuid(), Date = DateTime.Now, Items = new List <DataItem> { new DataItem { Id = 1, Name = "Name 1", Value = "Value 1", SubItems = new List <DataItem> { new DataItem { Id = 11, Name = "Name 1.1", Value = "Value 1.1" }, new DataItem { Id = 12, Name = "Name 1.2", Value = "Value 1.2" }, } }, new DataItem { Id = 2, Name = "Name 2", Value = "Value 2", SubItems = new List <DataItem> { new DataItem { Id = 21, Name = "Name 2.1", Value = "Value 2.1" }, new DataItem { Id = 22, Name = "Name 2.2", Value = "Value 2.2" }, } }, }, Roman = FigletFont.Load(GetType().Assembly.GetManifestResourceStream(GetType(), "Resources.Roman.flf")), }; /*if (MemoryProfiler.IsActive) { * MemoryProfiler.EnableAllocations(); * MemoryProfiler.Dump(); * } * new ConsoleRenderer().RenderDocument(ReadXaml<Document>(data)); * if (MemoryProfiler.IsActive) * MemoryProfiler.Dump();*/ /*for (int i = 0; i < 100; i++) * new ConsoleRenderer().RenderDocument(ReadXaml<Document>(data));*/ /*if (MemoryProfiler.IsActive) * MemoryProfiler.Dump();*/ Document xamlDoc = ConsoleRenderer.ReadDocumentFromResource(GetType(), "Markup.xaml", data, new XamlElementReaderSettings { ReferenceAssemblies = { typeof(FigletDiv).Assembly } }); //Document xamlDoc = ConsoleRenderer.ReadDocumentFromResource(GetType().Assembly, "Alba.CsConsoleFormat.ConsoleTest.Markup.xaml", data); Console.WriteLine("\nXAML\n"); ConsoleRenderer.RenderDocument(xamlDoc); ConsoleRenderer.RenderDocument(xamlDoc, new HtmlRenderTarget(File.Create("../Tmp/0.html"), new UTF8Encoding(false))); Document builtDoc = new ViewBuilder().CreateDocument(data); Console.WriteLine("\nBUILDER\n"); ConsoleRenderer.RenderDocument(builtDoc); ConsoleRenderer.RenderDocument(builtDoc, new HtmlRenderTarget(File.Create("../Tmp/0a.html"), new UTF8Encoding(false))); Console.WriteLine("\nBUILDER FLUENT\n"); ConsoleRenderer.RenderDocument(new ViewBuilder().CreateDocumentFluent(data)); var buffer = new ConsoleBuffer(80) { LineCharRenderer = LineCharRenderer.BoxExtended, //Clip = new Rect(1, 1, 78, 30), }; var rainbow = new[] { Black, DarkRed, DarkYellow, DarkGreen, DarkCyan, DarkBlue, DarkMagenta, DarkRed, Black, Red, Yellow, Green, Cyan, Blue, Magenta, Red, }; /*for (int i = 0; i < 16; i++) * buffer.FillRectangle((ConsoleColor)i, i, i, 80 - i * 2, 31 - i * 2);*/ const LineWidth Thick = LineWidth.Heavy; for (int i = 0; i < rainbow.Length; i++) { buffer.FillBackgroundRectangle(i, i, 80 - i * 2, (rainbow.Length - i) * 2, rainbow[i]); } buffer.DrawHorizontalLine(1, 0, 78, White); buffer.DrawHorizontalLine(1, 1, 78, White, Thick); buffer.DrawHorizontalLine(3, 3, 7, White); buffer.DrawVerticalLine(1, 1, 9, White); buffer.DrawVerticalLine(2, 2, 4, White); buffer.DrawVerticalLine(5, 0, 6, White, Thick); buffer.DrawVerticalLine(5, 0, 6, White); buffer.DrawVerticalLine(6, 0, 6, White); buffer.DrawVerticalLine(3, 0, 12, White, Thick); buffer.DrawRectangle(0, 0, 80, 32, White, Thick); buffer.FillBackgroundVerticalLine(40, 0, 32, Yellow); buffer.FillForegroundVerticalLine(41, 0, 32, White, FullBlock); buffer.FillForegroundVerticalLine(42, 0, 32, White, DarkShade); buffer.FillForegroundVerticalLine(43, 0, 32, White, MediumShade); buffer.FillForegroundVerticalLine(44, 0, 32, White, LightShade); buffer.DrawString(15, 15, Black, "Hello world!"); buffer.DrawString(15, 16, White, "Hello world! Hello world! Hello world! Hello world! Hello world! Hello world!"); //buffer.ApplyBackgroundColorMap(0, 0, buffer.Width, buffer.Height, ColorMaps.Invert); //buffer.ApplyForegroundColorMap(0, 0, buffer.Width, buffer.Height, ColorMaps.Invert); new ConsoleRenderTarget().Render(buffer); //new ConsoleRenderTarget { ColorOverride = White, BackgroundOverride = Black }.Render(buffer); Colors.WriteLine("Console without colors is boring..."); Colors.WriteLine("Colors".Red(), " are".Green(), " fun!".Blue()); Colors.WriteLine( "Background".Red().OnDarkRed(), "colors".Green().OnDarkGreen(), "are".Blue().OnDarkBlue(), "even".DarkRed().OnRed(), "more".DarkGreen().OnGreen(), "fun!".DarkBlue().OnBlue()); Colors.WriteLine(new Border { Shadow = new Thickness(-1, -1, 1, 1), ShadowColor = DarkGray, Align = Align.Left, Children = { "Borders yay!".Yellow().OnGray() } }); using (var file = File.Create("../Tmp/1.html")) new HtmlRenderTarget(file, new UTF8Encoding(false)).Render(buffer); using (var file = new StreamWriter(File.Create("../Tmp/1.ans"), Encoding.GetEncoding("ibm437")) { NewLine = "" }) new AnsiRenderTarget(file).Render(buffer); using (var file = File.Create("../Tmp/1.txt")) new TextRenderTarget(file).Render(buffer); using (var file = File.Create("../Tmp/1.asc")) new TextRenderTarget(file, Encoding.GetEncoding("ibm437")).Render(buffer); /*var text = new TextRenderTarget(); * text.Render(buffer); * Console.Write(text.OutputText);*/ /*Console.WriteLine(Console.OutputEncoding); * Console.OutputEncoding = Encoding.UTF8; * Console.WriteLine("■▬▲►▼◄"); * Console.WriteLine("▀▄█▌▐"); * Console.WriteLine("♠♣♥♦"); * Console.WriteLine("☺☻☼♀♂♫"); * Console.WriteLine("«»‘’‚‛“”„‟‹›");*/ /*const string TestString1 = "«»‘’‚‛“”„‟‹›", TestString2 = "─═│║┼╪╫╬"; * foreach (EncodingInfo encodingInfo in Encoding.GetEncodings()) { * try { * Encoding encoding = encodingInfo.GetEncoding(); * bool matched1 = encoding.GetString(encoding.GetBytes(TestString1)) == TestString1; * bool matched2 = encoding.GetString(encoding.GetBytes(TestString2)) == TestString2; * Console.OutputEncoding = encoding; * Console.WriteLine("{0,-10}{1,-20}{2}{3} {4} {5}", * encodingInfo.CodePage, encodingInfo.Name, matched1 ? "+" : "-", matched2 ? "+" : "-", TestString1, TestString2); * } * catch { * Console.WriteLine("{0,-10}{1,-20}xx FAILED", * encodingInfo.CodePage, encodingInfo.Name); * } * }*/ /*for (int i = 1; i < 10000; i += 10) { * var sb = new StringBuilder(); * for (int j = 0; j < 10; j++) * sb.AppendFormat("{0,-6}{1} ", (i + j), (char)(i + j)); * Console.Write(sb); * }*/ }
/// <summary> /// Write using a Figlet font /// </summary> /// <param name="text"></param> /// <param name="font"></param> public void Write(string text, FigletFont font) { Console.Write(ConsoleLogEntry.DisableProcessingCode); Console.WriteAscii(text, font); Console.Write(ConsoleLogEntry.DisableProcessingCode); }
public FigletCommand() { FigletFont = FigletFont.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream("kuvuBot.Assets.big.flf")); }
static void Main(string[] args) { // NOTE: Running all of the following examples at once will result in unexpected // coloring behavior, as more than 16 different colors are used! // Uses default ASCII Figlet font. Console.WriteAscii("Hello World"); Console.WriteAsciiAlternating("Hello World", new FrequencyBasedColorAlternator(2, Color.Green, Color.White)); // Print out Hello World in all example fonts. var assembly = Assembly.GetExecutingAssembly(); foreach (var resourceName in assembly.GetManifestResourceNames()) { foreach (DictionaryEntry resource in new ResourceReader(assembly.GetManifestResourceStream(resourceName))) { var font = FigletFont.Load((Stream)resource.Value); Figlet figlet = new Figlet(font); string asciiArt = figlet.ToAscii("Hello World").ConcreteValue; Console.WriteLine(asciiArt); Console.WriteLine(); } } //string[] storyFragments = new string[] //{ // "John went to the store.", // "He wanted to buy fruit.", // "The security guard wouldn't let him buy fruit.", // "John didn't like being harrassed about buying fruit.", // "He went to another fruit store.", // "At the other fruit store, he selected a ripe piece of fruit.", // "A security guard came by and deselected the piece of fruit.", // "John selected it again.", // "He was determined to buy fruit.", // "Until 7 PM, when the store closed." //}; //int r = 225; //int g = 255; //int b = 250; //for (int i = 0; i < 10; i++) //{ // Console.WriteLine(storyFragments[i], Color.FromArgb(r, g, b)); // r -= 18; // b -= 9; //} //string dream = " a dream of {0} and {1} and {2} and {3} and {4} and {5} and {6} and {7} and {8} and {9}..."; //string[] fruits = new string[] //{ // "bananas", // "strawberries", // "mangoes", // "pineapples", // "cherries", // "oranges", // "apples", // "peaches", // "plums", // "melons" //}; //Formatter[] fruits = new Formatter[] //{ // new Formatter("bananas", Color.LightGoldenrodYellow), // new Formatter("strawberries", Color.Pink), // new Formatter("mangoes", Color.PeachPuff), // new Formatter("pineapples", Color.Yellow), // new Formatter("cherries", Color.Red), // new Formatter("oranges", Color.Orange), // new Formatter("apples", Color.LawnGreen), // new Formatter("peaches", Color.MistyRose), // new Formatter("plums", Color.Indigo), // new Formatter("melons", Color.LightGreen), //}; //Console.WriteLineFormatted(dream, Color.LightGoldenrodYellow, Color.Gray, fruits); //Console.WriteLineFormatted(dream, Color.Gray, fruits); //int meowCounter = 0; //string[] meowVariant = new string[] //{ // " merrrowwww", // " meow", // " mew", // " meeeowww", // " meow" //}; //ColorAlternatorFactory alternatorFactory = new ColorAlternatorFactory(); //ColorAlternator alternator = alternatorFactory.GetAlternator(new[] { "hiss", "m[a-z]+w" }, Color.Plum, Color.PaleVioletRed); //for (int i = 0; i < 15; i++) //{ // string catMessage = " cats"; // if (i % 3 == 0) // { // catMessage = meowVariant[meowCounter++]; // } // else if (i % 10 == 0) // { // catMessage = " hiss"; // } // Console.WriteLineAlternating(catMessage, alternator); //} //ColorAlternatorFactory alternatorFactory = new ColorAlternatorFactory(); //ColorAlternator alternator = alternatorFactory.GetAlternator(2, Color.Plum, Color.PaleVioletRed); //for (int i = 0; i < 15; i++) //{ // Console.WriteLineAlternating(" cats", alternator); //} //string storyAboutRain = " i like rain. it is nice when it rains, because it means that things get wet."; //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); //ColorAlternatorFactory alternatorFactory = new ColorAlternatorFactory(); //ColorAlternator alternator = alternatorFactory.GetAlternator(2, Color.PaleTurquoise, Color.PaleGreen); ////alternator = alternatorFactory.GetAlternator(new[] { "[0-9]", "a" }, Color.LightYellow, Color.PaleGreen); //StyleSheet styleSheet = new StyleSheet(Color.White); //styleSheet.AddStyle("h", Color.Red); //styleSheet.AddStyle("y", Color.Orange); //styleSheet.AddStyle("b", Color.Yellow); //styleSheet.AddStyle("[0-9]", Color.Lime); //Console.WriteFormatted("hi {0} and {1}", Color.DeepSkyBlue, new Formatter("billy", Color.MediumAquamarine), new Formatter("steve", Color.MediumPurple)); //Console.WriteFormatted("hi {0}", new Formatter("mike", Color.MediumOrchid), Color.White); //Console.WriteFormatted("hi {0} and {1}", Color.OrangeRed, Color.Orange, "john", "gary"); //Console.WriteFormatted("hi {0} and {1}", new Formatter("billy", Color.MediumAquamarine), new Formatter("steve", Color.MediumPurple), Color.OldLace); //Console.WriteFormatted("hi {0}", "mike", Color.MediumOrchid, Color.White); //Console.WriteFormatted("hi {0}, {1}, and {2}", new Formatter("billy", Color.MediumAquamarine), new Formatter("steve", Color.MediumPurple), new Formatter("brian", Color.MediumBlue), Color.WhiteSmoke); //Console.WriteFormatted("hi {0} and {1}", "jerry", "larry", Color.Orange, Color.White); //Console.WriteFormatted("hi {0}, {1}, {2}, and {3}", new Formatter("billy", Color.MediumAquamarine), new Formatter("steve", Color.MediumPurple), new Formatter("brian", Color.MediumBlue), new Formatter("jones", Color.DeepSkyBlue), Color.WhiteSmoke); //Console.WriteFormatted("hi {0}, {1}, and {2}", "jerry", "larry", "bob smith", Color.Orange, Color.White); //Console.WriteFormatted("hi {0}, {1}, {2}, and {3}", "jerry", "larry", "bob smith", "david", Color.MediumOrchid, Color.White); //Console.WriteAlternating(true, alternator); //Console.WriteAlternating('c', alternator); //Console.WriteAlternating(new[] { 'c', 'a', 't' }, alternator); //Console.WriteAlternating(5m, alternator); //Console.WriteAlternating(5d, alternator); //Console.WriteAlternating(5f, alternator); //Console.WriteAlternating(5, alternator); //Console.WriteAlternating(5L, alternator); //Console.WriteAlternating((object)5, alternator); //Console.WriteAlternating("cats stalk you" , alternator); //Console.WriteAlternating(5U, alternator); //Console.WriteAlternating(5UL, alternator); //Console.WriteAlternating("hi {0}", alternator, "bill"); //Console.WriteAlternating("hi {0}", "bill", alternator); //Console.WriteAlternating(new[] { 'c', 'a', 't' }, 1, 2, alternator); //Console.WriteAlternating("hi {0} and {1}", "bill", "mitch", alternator); //Console.WriteAlternating("hi {0}, {1}, and {2}", "bill", "mitch", "gary", alternator); //Console.WriteAlternating("hi {0}, {1}, {2}, and {3}", "bill", "mitch", "gary", "gladys", alternator); //Console.WriteStyled(true, styleSheet); //Console.WriteStyled('c', styleSheet); //Console.WriteStyled(new[] { 'c', 'a', 't' }, styleSheet); //Console.WriteStyled(5m, styleSheet); //Console.WriteStyled(5d, styleSheet); //Console.WriteStyled(5f, styleSheet); //Console.WriteStyled(5, styleSheet); //Console.WriteStyled(5L, styleSheet); //Console.WriteStyled((object)5, styleSheet); //Console.WriteStyled("cats stalk you", styleSheet); //Console.WriteStyled(5U, styleSheet); //Console.WriteStyled(5UL, styleSheet); //Console.WriteStyled("hi {0}", "bill", styleSheet); //Console.WriteStyled("hi {0}", "bill", styleSheet); //Console.WriteStyled(new[] { 'c', 'a', 't' }, 1, 2, styleSheet); //Console.WriteStyled("hi {0} and {1}", "bill", "mitch", styleSheet); //Console.WriteStyled("hi {0}, {1}, and {2}", "bill", "mitch", "gary", styleSheet); //Console.WriteStyled("hi {0}, {1}, {2}, and {3}", "bill", "mitch", "gary", "gladys", styleSheet); //Console.WriteLineFormatted("hi {0} and {1}", Color.DeepSkyBlue, new Formatter("billy", Color.MediumAquamarine), new Formatter("steve", Color.MediumPurple)); //Console.WriteLineFormatted("hi {0}", new Formatter("mike", Color.MediumOrchid), Color.White); //Console.WriteLineFormatted("hi {0} and {1}", Color.OrangeRed, Color.Orange, "john", "gary"); //Console.WriteLineFormatted("hi {0} and {1}", new Formatter("billy", Color.MediumAquamarine), new Formatter("steve", Color.MediumPurple), Color.OldLace); //Console.WriteLineFormatted("hi {0}", "mike", Color.MediumOrchid, Color.White); //Console.WriteLineFormatted("hi {0}, {1}, and {2}", new Formatter("billy", Color.MediumAquamarine), new Formatter("steve", Color.MediumPurple), new Formatter("brian", Color.MediumBlue), Color.WhiteSmoke); //Console.WriteLineFormatted("hi {0} and {1}", "jerry", "larry", Color.Orange, Color.White); //Console.WriteLineFormatted("hi {0}, {1}, {2}, and {3}", new Formatter("billy", Color.MediumAquamarine), new Formatter("steve", Color.MediumPurple), new Formatter("brian", Color.MediumBlue), new Formatter("jones", Color.DeepSkyBlue), Color.WhiteSmoke); //Console.WriteLineFormatted("hi {0}, {1}, and {2}", "jerry", "larry", "bob smith", Color.Orange, Color.White); //Console.WriteLineFormatted("hi {0}, {1}, {2}, and {3}", "jerry", "larry", "bob smith", "david", Color.MediumOrchid, Color.White); //Console.WriteLineAlternating(true, alternator); //Console.WriteLineAlternating('c', alternator); //Console.WriteLineAlternating(new[] { 'c', 'a', 't' }, alternator); //Console.WriteLineAlternating(5m, alternator); //Console.WriteLineAlternating(5d, alternator); //Console.WriteLineAlternating(5f, alternator); //Console.WriteLineAlternating(5, alternator); //Console.WriteLineAlternating(5L, alternator); //Console.WriteLineAlternating((object)5, alternator); //Console.WriteLineAlternating("cats stalk you", alternator); //Console.WriteLineAlternating(5U, alternator); //Console.WriteLineAlternating(5UL, alternator); //Console.WriteLineAlternating("hi {0}", alternator, "bill"); //Console.WriteLineAlternating("hi {0}", "bill", alternator); //Console.WriteLineAlternating(new[] { 'c', 'a', 't' }, 1, 2, alternator); //Console.WriteLineAlternating("hi {0} and {1}", "bill", "mitch", alternator); //Console.WriteLineAlternating("hi {0}, {1}, and {2}", "bill", "mitch", "gary", alternator); //Console.WriteLineAlternating("hi {0}, {1}, {2}, and {3}", "bill", "mitch", "gary", "gladys", alternator); //Console.WriteLineStyled(true, styleSheet); //Console.WriteLineStyled('c', styleSheet); //Console.WriteLineStyled(new[] { 'c', 'a', 't' }, styleSheet); //Console.WriteLineStyled(5m, styleSheet); //Console.WriteLineStyled(5d, styleSheet); //Console.WriteLineStyled(5f, styleSheet); //Console.WriteLineStyled(5, styleSheet); //Console.WriteLineStyled(5L, styleSheet); //Console.WriteLineStyled((object)5, styleSheet); //Console.WriteLineStyled("cats stalk you", styleSheet); //Console.WriteLineStyled(5U, styleSheet); //Console.WriteLineStyled(5UL, styleSheet); //Console.WriteLineStyled("hi {0}", "bill", styleSheet); //Console.WriteLineStyled("hi {0}", "bill", styleSheet); //Console.WriteLineStyled(new[] { 'c', 'a', 't' }, 1, 2, styleSheet); //Console.WriteLineStyled("hi {0} and {1}", "bill", "mitch", styleSheet); //Console.WriteLineStyled("hi {0}, {1}, and {2}", "bill", "mitch", "gary", styleSheet); //Console.WriteLineStyled("hi {0}, {1}, {2}, and {3}", "bill", "mitch", "gary", "gladys", styleSheet); Console.ReadKey(); }
public RowContent(Component component, string label, string componentName, ColumnLocation location, int offset, object componentParameter, Color?foreColor, Color?backColor, FigletFont font) { ContentType = ContentTypes.Component; Label = label; Component = component; ComponentParameter = componentParameter; ComponentName = componentName; Location = location; Offset = offset; ForegroundColor = foreColor; BackgroundColor = backColor; Font = font; }
public RowContent(string staticContent, ColumnLocation location, int offset, Enum foreColor, Enum backColor, FigletFont font) { ContentType = ContentTypes.Static; Component = Component.StaticContent; StaticContent = staticContent; Location = location; Offset = offset; ForegroundColorPalette = foreColor; BackgroundColorPalette = backColor; Font = font; }
static void Main(string[] args) { bool showHelp = false; bool showPreview = false; string font = "standard"; string fileOutput = null; bool wroteToFile = false; var options = new OptionSet() { { "h|help|?", v => { showHelp = true; } }, { "f|font=", v => { font = v; } }, { "o|output=", filename => { if (filename == null || (filename.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)) { Console.WriteLine("Invalid output file name"); Environment.Exit(0); } fileOutput = filename; } }, { "p|preview", v => { showPreview = true; } } }; var parsed = options.Parse(args); if (showHelp) { _showHelp(); Environment.Exit(0); } if (showPreview) { _showPreview(); Environment.Exit(0); } #if DEBUG Console.WriteLine($"[Loading font]: dotnet_figlet.Console.Fonts.{font}.flf"); #endif var assembly = typeof(Program).GetTypeInfo().Assembly; Stream resource = assembly.GetManifestResourceStream($"dotnet_figlet.Console.Fonts.{font}.flf"); if (resource == null) { Console.WriteLine($"Unknow font: {font}"); Console.WriteLine("To see a list of available fonts use figlet -p"); Environment.Exit(0); } FigletFont figletFont = FigletFont.Load(resource); Figlet figlet = new Figlet(figletFont); #if DEBUG Console.WriteLine($"[Figlet font]: MaxLength={figletFont.MaxLength}, Height={figletFont.Height}, FullLayout={figletFont.FullLayout}, BaseLine={figletFont.BaseLine}"); #endif List <string> extraparams; try { extraparams = options.Parse(args); } catch (OptionException e) { Console.Write("Invalid option(s): "); Console.WriteLine(e.Message); return; } string message = ""; if (extraparams.Count > 0) { message = String.Join(" ", extraparams.ToArray()); List <string> tokens = new List <string>(); foreach (string extraparam in extraparams) { tokens.AddRange(extraparam.Split(' ').ToList()); } #if DEBUG Console.WriteLine($"[Input]: {message}"); Console.WriteLine($"Console.WindowWidth: {Console.WindowWidth} Console.LargestWindowWidth: {Console.LargestWindowWidth}"); #endif int start = 0; int take = tokens.Count; bool needsToBeSplitted = true; List <string> lines = new List <string>(); while (needsToBeSplitted) { if (take <= 0) { needsToBeSplitted = false; if (start < tokens.Count) { lines.Add(String.Join(" ", tokens.ToArray())); } } else { string[] subSentence = tokens.Skip(start).Take(take).ToArray(); string line = String.Join(" ", subSentence); bool subsentenceLengthOk = figlet.ToAscii(line).CharacterGeometry.GetLength(1) <= (Console.WindowWidth - 1); if (subSentence.Length == 0) { needsToBeSplitted = false; } else if (subsentenceLengthOk) { lines.Add(line); start = start + subSentence.Length; take = tokens.Count - start; } else { take--; } } } TextWriter defaultOutput = Console.Out; FileStream stream = null; StreamWriter writer = null; if (fileOutput != null) { try { stream = new FileStream(fileOutput, FileMode.OpenOrCreate, FileAccess.Write); writer = new StreamWriter(stream); wroteToFile = true; } catch (Exception e) { Console.WriteLine(e.Message); Environment.Exit(0); } Console.SetOut(writer); } foreach (string line in lines) { Console.WriteLine(figlet.ToAscii(String.Join(" ", line)).ToString()); } if (wroteToFile) { Console.SetOut(defaultOutput); writer.Close(); stream.Close(); } } Environment.Exit(0); }