static void SetupStyle() { PrimaryStyle.AddStyle("(?i)active", Color.ForestGreen); PrimaryStyle.AddStyle("(?i)captured", Color.DarkRed); PrimaryStyle.AddStyle("(?i)locked", Color.Yellow); NumberStyle.AddStyle("[0-9.]*%", Color.Orange); }
public ConsoleColorLogger() { styleSheet = new StyleSheet(Color.BurlyWood); styleSheet.AddStyle("exception", Color.Red); styleSheet.AddStyle("\\s\\d+\\s", Color.Yellow); styleSheet.AddStyle("warn", Color.Gold); styleSheet.AddStyle("offline", Color.Red); styleSheet.AddStyle("online", Color.Green); styleSheet.AddStyle("connect", Color.Green); var slashSeparated = "\\w?\\w?\\w\\w\\w\\/\\w?\\w?\\w\\w\\w"; styleSheet.AddStyle(slashSeparated, Color.HotPink); var timeRegex = "\\d\\d:\\d\\d:\\d\\d"; var dateRegexp = "(\\d+)[-.\\/](\\d+)[-.\\/](\\d+)"; styleSheet.AddStyle(timeRegex, Color.Pink); styleSheet.AddStyle(dateRegexp, Color.DarkTurquoise); styleSheet.AddStyle(RegularExpressions.IpV4AddressPattern, Color.AntiqueWhite); }
private StyleSheet GetDummyOverlappingStyleSheet() { StyleSheet styleSheet = new StyleSheet(dummyDefaultColor); styleSheet.AddStyle(dummyOverlappingPatternOne, dummyStyledColor); styleSheet.AddStyle(dummyOverlappingPatternTwo, dummyStyledColorTwo); return(styleSheet); }
/// <summary> /// Print out what pane is currently open /// </summary> /// <param name="PaneIndex"></param> private static void PrintCurrentPane(int PaneIndex, MouseCords XAndYPos) { // Style mouse output. StyleSheet RunningOutputStyle = new StyleSheet(Color.White); RunningOutputStyle.AddStyle(@"\[|\]|", Color.DarkGray, match => match.ToString()); RunningOutputStyle.AddStyle(@"X:|Y:", Color.Yellow, match => match.ToString()); RunningOutputStyle.AddStyle(@"ZERO", Color.Orange, match => match.ToString()); RunningOutputStyle.AddStyle(@"MAIN", Color.HotPink, match => match.ToString()); // Write seperator line. for (int Count = 0; Count < Console.WindowWidth; Count++) { Console.WriteStyled("-", RunningOutputStyle); } Console.Write(""); // Check for main here if (XAndYPos == null || PaneIndex == -1) { Console.WriteStyled("[X: MAIN][Y: MAIN] | ", RunningOutputStyle); } else { // Write mouse cords. string xPos = "[X: " + XAndYPos.PosX.ToString("D4") + "]"; string yPos = "[Y: " + XAndYPos.PosY.ToString("D4") + "]"; if (XAndYPos.PosY < 0) { yPos = "[Y: ZERO]"; } Console.WriteStyled(xPos + yPos + " | ", RunningOutputStyle); } // Write pane info. Console.ForegroundColor = Color.DarkGray; Console.Write("["); if (PaneIndex >= 0) { Console.ForegroundColor = PaneSizes.ConsolePaneColors[PaneIndex]; Console.Write($"SWITCHING TO OBS PANE NUMBER {PaneIndex + 1}"); } if (PaneIndex < 0) { Console.ForegroundColor = Color.White; Console.Write("SWITCHING TO OBS MAIN PANE"); } Console.ForegroundColor = Color.DarkGray; Console.WriteLine("]"); // Write seperator line. for (int Count = 0; Count < Console.WindowWidth; Count++) { Console.WriteStyled("-", RunningOutputStyle); } Console.Write(""); }
private static StyleSheet CreateStyleSheet() { StyleSheet styleSheet = new StyleSheet(Color.Gray); styleSheet.AddStyle("X", Color.Red); styleSheet.AddStyle("K", Color.White); return(styleSheet); }
public CodeRunner(string sourceCodeFile, IEnumerable <string> inputFiles, CodeRunnerParameters parameters) { _sourceCodeFile = sourceCodeFile; _inputFiles = inputFiles; _parameters = parameters; _styleSheet = new StyleSheet(Color.White); _styleSheet.AddStyle("OK", Color.Green); _styleSheet.AddStyle("KO", Color.Red); }
public void VolgendeStap() { StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle("Je kan de volgende richting uit:", Color.MediumSlateBlue); styleSheet.AddStyle("Je kunt interacteren", Color.Red); Console.WriteLineStyled(_kaart.GetCurrentPosition().ToString(), styleSheet); var interactieKey = Console.ReadKey().Key; Console.WriteLine("═══════════════════════════════════════════════════"); Console.WriteLine(); VerwerkInput(interactieKey, VolgendeStap); }
public void SendWelcomeMessage() { var styleSheet = new StyleSheet(Color.LightGray); styleSheet.AddStyle("C", Color.Red); styleSheet.AddStyle("a", Color.Orange); styleSheet.AddStyle("k", Color.Yellow); styleSheet.AddStyle("e", Color.Lime); var colossal = Properties.Resources.colossal; if (colossal.GetType() == typeof(byte[])) { var font = FigletFont.Load(Properties.Resources.colossal); Console.WriteAsciiStyled("~ Cake ~", font, styleSheet); } }
public static ConsoleKeyInfo ReadKey() { var key = System.Console.ReadKey(); if (key.Key == ConsoleKey.Enter && charBuffer.Count > 0) { lock (locker) { var sentMessage = new string(charBuffer.ToArray()); StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle("Console", Color.Gray); WriteLineStyled($"[{DateTime.Now.ToString("T")}] Console: {sentMessage}", styleSheet, true); charBuffer.Clear(); OnConsoleCommand(null, new ConsoleCommandEventArgs(sentMessage)); } } else if (key.Key == ConsoleKey.Backspace && charBuffer.Count > 0) { charBuffer.RemoveAt(charBuffer.Count - 1); Colorful.Console.Write(" \b"); } else if (char.IsLetterOrDigit(key.KeyChar) || char.IsWhiteSpace(key.KeyChar) || char.IsSymbol(key.KeyChar) || char.IsPunctuation(key.KeyChar)) { charBuffer.Add(key.KeyChar); } return(key); }
void ParseStyles(string file) { if (string.IsNullOrEmpty(file)) { return; } if (!File.Exists(file)) { throw new FileNotFoundException($"Specified CSS file '{file}' was not found.", file); } var css = new ExCSS.Parser().Parse(File.ReadAllText(file)); Console.Write($"Reading CSS styles from '{file}'..."); Console.Write(System.Environment.NewLine); foreach (var rule in css.StyleRules) { var match = ((ExCSS.PrimitiveTerm)rule.Declarations.Properties.Find(p => p.Name == "-match")?.Term)?.Value as string; var color = ((ExCSS.PrimitiveTerm)rule.Declarations.Properties.Find(p => p.Name == "color")?.Term)?.Value as string; if (match != null && color != null) { style.AddStyle(match, GetColor(color)); } } }
public void write(string text) { StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle("SivQuest", Color.MediumSlateBlue); Console.WriteStyled(text, Color.Gray, styleSheet); }
public static void LogMessage(Client client, string message) { StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle(client.Identification, client.ClientColor); Console.WriteLineStyled($"{client.Identification}: {message}", styleSheet); }
private static void PrintLineWithMarker(string marker, string line, Color markerColor) { StyleSheet styleSheet = new StyleSheet(Color.MintCream); styleSheet.AddStyle(@"\[.*\]", markerColor); Console.WriteLineStyled($"[{marker}] {line}", styleSheet); }
public static void LogInitialization(string message) { StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle(InitializationString, Color.LightGreen); Console.WriteLineStyled($"[{InitializationString}] {message}", styleSheet); }
public static void LogModification(string message) { StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle(ModificationString, Color.Orange); Console.WriteLineStyled($"[{ModificationString}] {message}", styleSheet); }
private void OnBotMessageSent(object sender, OnMessageSentArgs e) { StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle(e.SentMessage.DisplayName, ColorTranslator.FromHtml(e.SentMessage.ColorHex)); ConsoleHelper.WriteLineStyled($"[{DateTime.Now.ToString("T")}] {e.SentMessage.DisplayName}: {e.SentMessage.Message}", styleSheet); }
private StyleSheet GetDummyStyleSheet() { StyleSheet styleSheet = new StyleSheet(dummyDefaultColor); styleSheet.AddStyle(dummyPattern, dummyStyledColor); return(styleSheet); }
public static void LogTermination(string message) { StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle(TerminationString, Color.Red); Console.WriteLineStyled($"[{TerminationString}] {message}", styleSheet); }
public static void LogIdentification(string message) { StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle(IdentificationString, Color.LightBlue); Console.WriteLineStyled($"[{IdentificationString}] {message}", styleSheet); }
private void StyleConsole() { // Define o aspeto da aplicação StyleSheet styleSheet = new StyleSheet(Color.White); string target = @"\[(.*?)\]"; styleSheet.AddStyle(target, Color.Gray); styleSheet.AddStyle(@"\[(INFO)\]", Color.Blue); styleSheet.AddStyle(@"\[(WARNING)\]", Color.Yellow); styleSheet.AddStyle(@"\[(CRITICAL)\]", Color.Red); // Define o tamanho da janela da aplicação System.Console.BufferWidth = 150; System.Console.SetWindowSize(System.Console.BufferWidth, 50); // Prepara o Model Program.M_Options.StyleConsole = styleSheet; }
}//FinishTransaction public void MasterPage() { Console.Clear(); Console.WriteLine("Umbrella Corp: Vendo-Matic 7000"); Console.WriteAscii("Snacking Refactored!", FigletFont.Default, Color.Plum); StyleSheet styleSheetMM = new StyleSheet(Color.White); styleSheetMM.AddStyle("MAIN MENU", (Color.LimeGreen)); //StyleSheet styleSheetPM = new StyleSheet(Color.White); //styleSheetPM.AddStyle("PURCHASE MENU", (Color.LimeGreen)); }
//static void NamesRefiller() //{ // var cat = _context.Categories.ToList(); // var names = _context.Names.ToList(); // var list = new List<Name> // { // new Name { Value = "Jedzenie Praca" }, // new Name { Value = "Paliwo" }, // new Name { Value = "ViaTOll" }, // new Name { Value = "Kredyt" }, // new Name { Value = "Internet" }, // new Name { Value = "Allegro Raty" }, // new Name { Value = "Play Abonament" }, // new Name { Value = "Studia Czesne" }, // }; // var listToAdd = new List<Name>(); // foreach (var item in list) // { // if (!names.Any(x => x.Value.ToLower() == item.Value.ToLower())) // { // listToAdd.Add(item); // } // } // if (listToAdd.Count == 0) // return; // _context.Names.AddRange(listToAdd); // _context.SaveChanges(); //} static void LoggerTests() { Logger.Log <Program>($"Starting system ..."); try { var y = 2 - 2; var x = 2 / y; } catch (Exception ex) { Logger.Log(ex); Logger.Log <Program>(ex); Logger.Log(ex, true); Logger.Log <Program>(ex, true); } for (int i = 0; i < 5; i++) { var level = (i % 2 == 0) ? LogLevel.INFO : LogLevel.ERROR; Logger.Log($"Starting system ... {Guid.NewGuid().ToString()}", level); Thread.Sleep(1000); } while (true) { var colors = new List <Color> { Color.Blue, Color.BlueViolet, Color.AliceBlue, Color.CadetBlue, Color.CornflowerBlue, Color.SlateBlue, Color.SteelBlue, Color.RoyalBlue }; var r = new Random(); var styleSheet = new StyleSheet(Color.White); var c = colors[r.Next(0, colors.Count)]; styleSheet.AddStyle("TESTOWA WIDOMOSC", c); Console.WriteLineStyled($"TESTOWA WIDOMOSC - {c.ToString()}", styleSheet); Thread.Sleep(500); } //var logger = new LogTests(); //Log.Information($"App started ... {DateTime.Now.ToShortDateString()}"); //logger.Start(); //var colors = new string[] { "red", "black", "orange", "yellow" }; //Log.Information($"Colors: {colors}"); }
}//RunInterface public bool Menu() { MasterPage(); StyleSheet styleSheetMM = new StyleSheet(Color.White); styleSheetMM.AddStyle("MAIN MENU", (Color.LimeGreen)); Console.WriteLine("MAIN MENU", Color.LimeGreen); Console.WriteLine("\n(1) Display Vending Machine Items\n(2) Make A Purchase\n(3) End Program\n"); string menuInput = Console.ReadLine(); const bool StopMenu = false; const bool ContinueMenu = true; const bool Incomplete = false; bool isPurchaseTransactionComplete = Incomplete; const string DisplaySelction = "1"; const string PurchaseSelection = "2"; const string SecretReport = "9"; const string EndProgram = "3"; if (menuInput == DisplaySelction) { Display(); Console.WriteLineStyled("\n\nPress enter to return to the MAIN MENU...", styleSheetMM); Console.ReadLine(); return StopMenu; } else if (menuInput == PurchaseSelection) { while (isPurchaseTransactionComplete == Incomplete) { isPurchaseTransactionComplete = Purchase(); } return StopMenu; } else if (menuInput == EndProgram) { return ContinueMenu; } else if (menuInput == SecretReport) { Console.WriteLine("Generating sales report...", Color.LimeGreen); InitiateSalesReport(); Console.ReadLine(); Console.Clear(); return StopMenu; } else { ErrorMessage(); Console.WriteLineStyled("SELECTION NOT VALID! Press enter to return to the MAIN MENU.", styleSheetMM); Console.ReadLine(); return StopMenu; } }//Menu
public void Show(List <PlayerModel> players) { var villageShape = GetList(players.Count); StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle("W[0-9]*", Color.DarkRed); styleSheet.AddStyle("V[0-9]*", Color.BlanchedAlmond); styleSheet.AddStyle("H[0-9]*|S[0-9]*", Color.LightBlue); foreach (var row in villageShape) { var output = row; for (var i = 0; i < players.Count; i++) { output = output.Replace("{" + i + "}", GetSymbol(players[i])); } Console.WriteLineStyled(output, styleSheet); } var playersByTeam = players.OrderBy(p => p.Team() != Teams.Evil).ToList(); Console.WriteLine(); Console.WriteLine("Net Aggro for living: "); var stats = playersByTeam.Where(p => p.IsAlive).Select(p => p.Name + ": " + p.NetAggro()).ToList(); Console.WriteLineStyled(string.Join(", ", stats), styleSheet); if (players.Any(p => !p.IsAlive)) { Console.WriteLine(); Console.WriteLine("Net Aggro for dead: "); var deadStats = playersByTeam.Where(p => !p.IsAlive).Select(p => p.Name + ": " + p.NetAggro()).ToList(); Console.WriteLineStyled(string.Join(", ", deadStats), styleSheet); } }
private static void WriteToConsole(string message, LogLevel logLevel, bool coloredConsole = true) { var styleSheet = new StyleSheet(Color.White); var color = Color.White; switch (logLevel) { case LogLevel.INFO: color = Color.Green; break; case LogLevel.ERROR: color = Color.Red; break; default: break; } var datePart = GetDatePart(message); var classPart = GetMessagePart(message, '(', ')'); if (!string.IsNullOrEmpty(classPart)) { styleSheet.AddStyle(classPart, Color.SkyBlue); } styleSheet.AddStyle(logLevel.ToString(), color); styleSheet.AddStyle(datePart, Color.Yellow); styleSheet.AddStyle("->", Color.Yellow); if (coloredConsole) { Console.WriteLineStyled(message, styleSheet); } else { System.Console.WriteLine(message); } }
public static void consoleFormat(StyleSheet styleSheet) { styleSheet.AddStyle("INSERT", Color.Magenta); styleSheet.AddStyle("INTO", Color.Magenta); styleSheet.AddStyle("IGNORE", Color.Magenta); styleSheet.AddStyle("VALUES", Color.Magenta); styleSheet.AddStyle("OK", Color.Green); styleSheet.AddStyle("'.*'", Color.LightCoral); styleSheet.AddStyle("[0-9]", Color.LightCoral); }
public ConsoleColorLogger() { StyleSheet = new StyleSheet(Color.BurlyWood); FillupNumbers(); FillupSuccess(); FillupErrors(); FillupDateTime(); StyleSheet.AddStyle("\\$", Color.LawnGreen); StyleSheet.AddStyle("(?i)\\w*\\.*\\w*service*", Color.LawnGreen); StyleSheet.AddStyle("(?i)\\w*uptime*", Color.CornflowerBlue); StyleSheet.AddStyle("(?i)\\w*version*", Color.CornflowerBlue); StyleSheet.AddStyle("(?i)warn[ing]*", Color.Yellow); FillupCryptoPairs(); StyleSheet.AddStyle(RegularExpressions.IpV4AddressPattern, Color.AntiqueWhite); }
private void OnMessageReceived(object sender, OnMessageReceivedArgs e) { StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle(e.ChatMessage.DisplayName, e.ChatMessage.Color); ConsoleHelper.WriteLineStyled($"[{DateTime.Now.ToString("T")}] {e.ChatMessage.DisplayName}: {e.ChatMessage.Message}", styleSheet); if (e.ChatMessage.Bits > 0) { speechSynthesizer.Speak($"Thanks to {e.ChatMessage.DisplayName} for cheering {e.ChatMessage.Bits} bits!"); } }
}//FeedMoney public void SelectProduct() { MasterPage(); StyleSheet styleSheetPM = new StyleSheet(Color.White); styleSheetPM.AddStyle("PURCHASE MENU", (Color.LimeGreen)); Console.WriteLine("MAKE A PURCHASE\n", Color.LimeGreen); Display(); Console.WriteLine("\nEnter product code to purchase:", Color.LimeGreen); string productSelector = Console.ReadLine(); string transactionResult = vendingMachine.Vend(productSelector); if (transactionResult == "SOLD") { List<VendingMachineItem> products = new List<VendingMachineItem>(vendingMachine.GetInventoryData()); foreach (VendingMachineItem item in products) { if (item.SlotID.ToUpper() == productSelector.ToUpper()) { Console.WriteAscii(item.Message, FigletFont.Default, Color.LawnGreen); } } } else if (transactionResult == "") // Magic Constant test num instead of strng a+ switch case? { ErrorMessage(); Console.WriteLine("OOPS - Nothing was entered! Press enter to return to the PURCHASE MENU.", styleSheetPM); } else if (transactionResult == "DoesNotExist") // Magic Constant test { ErrorMessage(); Console.WriteLine("Item does not exist! Please enter a valid product code! Press enter to return to the PURCHASE MENU.", styleSheetPM); } else if (transactionResult == "OutOfStock") // Magic Constant test { ErrorMessage(); Console.WriteLine("OUT OF STOCK! Please make another selection. Press enter to return to the PURCHASE MENU.", styleSheetPM); } else //cant afford { ErrorMessage(); Console.WriteLineStyled("INSUFFICIENT FUNDS! Please make an alternative selection. Press enter to return to the PURCHASE MENU.", styleSheetPM); } Console.ReadLine(); }//SelectProduct
public static void GreatPrint(string toPrint) { try { System.Console.WriteLine(); System.Console.WriteLine(); int halfTotal = 60; if (Program.using_ansi) { System.Console.WriteLine(LCYAN + " " + new String('=', halfTotal - toPrint.Length) + "(" + NOCOLOR + YELLOW + toPrint + LCYAN + ")" + new String('=', halfTotal - toPrint.Length) + NOCOLOR); } else { StyleSheet styleSheet = new StyleSheet(Color.White); styleSheet.AddStyle("[a-zA-Z]", Color.Yellow); styleSheet.AddStyle("[=()]", Color.LightSkyBlue); Colorful.Console.WriteLineStyled(new String('=', halfTotal - toPrint.Length) + "( " + toPrint + " )" + new String('=', halfTotal - toPrint.Length), styleSheet); } } catch (Exception ex) { GrayPrint(String.Format("{0}", ex)); } }