|
| 1 | +using System; |
| 2 | +using System.Reflection; |
| 3 | +using System.Text.RegularExpressions; |
| 4 | + |
| 5 | +namespace DiscordModNotifiyer.Extensions |
| 6 | +{ |
| 7 | + class ConsoleExtensions |
| 8 | + { |
| 9 | + /// <summary> |
| 10 | + /// Set default welcome messages |
| 11 | + /// </summary> |
| 12 | + public static void ClearConsole() |
| 13 | + { |
| 14 | + Console.Clear(); |
| 15 | + |
| 16 | + //if (string.IsNullOrEmpty(settings.ProxyIp)) |
| 17 | + //{ |
| 18 | + // WriteColor(@"[//--Warning------------------------------------------------------]", ConsoleColor.Yellow); |
| 19 | + // WriteColor($"[// ProxyIp:] Value is not set", ConsoleColor.Yellow); |
| 20 | + // WriteColor(@"[//---------------------------------------------------------------]", ConsoleColor.Yellow); |
| 21 | + //} |
| 22 | + |
| 23 | + Console.WriteLine(Environment.NewLine); |
| 24 | + WriteColor(@"[$$$$$$$$\ $$\ $$\ $$$$$$\ $$\]", ConsoleColor.DarkGreen); |
| 25 | + WriteColor(@"[$$ _____|\__| $$ | $$ __$$\ $$ |]", ConsoleColor.DarkGreen); |
| 26 | + WriteColor(@"[$$ | $$\ $$$$$$\ $$$$$$$\ $$$$$$\ $$ / \__| $$$$$$\ $$$$$$$ | $$$$$$\ $$$$$$\]", ConsoleColor.DarkGreen); |
| 27 | + WriteColor(@"[$$$$$\ $$ |$$ __$$\ $$ _____|\_$$ _|$$$$$$\ $$ | $$ __$$\ $$ __$$ |$$ __$$\ $$ __$$\]", ConsoleColor.DarkGreen); |
| 28 | + WriteColor(@"[$$ __| $$ |$$ | \__|\$$$$$$\ $$ | \______|$$ | $$ / $$ |$$ / $$ |$$$$$$$$ |$$ | \__|]", ConsoleColor.DarkGreen); |
| 29 | + WriteColor(@"[$$ | $$ |$$ | \____$$\ $$ |$$\ $$ | $$\ $$ | $$ |$$ | $$ |$$ ____|$$ |]", ConsoleColor.DarkGreen); |
| 30 | + WriteColor(@"[$$ | $$ |$$ | $$$$$$$ | \$$$$ | \$$$$$$ |\$$$$$$ |\$$$$$$$ |\$$$$$$$\ $$ |]", ConsoleColor.DarkGreen); |
| 31 | + WriteColor(@"[\__| \__|\__| \_______/ \____/ \______/ \______/ \_______| \_______|\__|]", ConsoleColor.DarkGreen); |
| 32 | + Console.WriteLine(Environment.NewLine); |
| 33 | + |
| 34 | + WriteColor(@"[//--Informationen------------------------------------------------]", ConsoleColor.DarkGreen); |
| 35 | + WriteColor($"[// Title:] {Assembly.GetEntryAssembly().GetName().Name}", ConsoleColor.DarkGreen); |
| 36 | + WriteColor($"[// Version:] {Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>().Version}", ConsoleColor.DarkGreen); |
| 37 | + WriteColor($"[// Autor:] {Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright}", ConsoleColor.DarkGreen); |
| 38 | + //WriteColor(@"[//--Exit Codes---------------------------------------------------]", ConsoleColor.DarkGreen); |
| 39 | + //WriteColor($"[// 0:] Application successful exited", ConsoleColor.DarkGreen); |
| 40 | + //WriteColor($"[// 1:] Supported OS is not given", ConsoleColor.DarkGreen); |
| 41 | + //WriteColor($"[// 2:] User has no root permissions", ConsoleColor.DarkGreen); |
| 42 | + //WriteColor($"[// 3:] Networksadapters are not set", ConsoleColor.DarkGreen); |
| 43 | + //WriteColor(@"[//--Settings-----------------------------------------------------]", ConsoleColor.DarkGreen); |
| 44 | + //WriteColor($"[// Call on Networkchange:] {settings.CallOnNetworkchange}", ConsoleColor.DarkGreen); |
| 45 | + //WriteColor($"[// Set proxy on Autostart:] {settings.SetProxyOnStartUp}", ConsoleColor.DarkGreen); |
| 46 | + //WriteColor($"[// Proxy status:] {status}", ConsoleColor.DarkGreen); |
| 47 | + //WriteColor(@"[//--Options------------------------------------------------------]", ConsoleColor.DarkGreen); |
| 48 | + //WriteColor($"[// 1:] Toggle \"Call on Networkchange\"", ConsoleColor.DarkGreen); |
| 49 | + //WriteColor($"[// 2:] Enable proxy", ConsoleColor.DarkGreen); |
| 50 | + //WriteColor($"[// 3:] Disable proxy", ConsoleColor.DarkGreen); |
| 51 | + //WriteColor($"[// ESC:] Close application", ConsoleColor.DarkGreen); |
| 52 | + WriteColor(@"[//---------------------------------------------------------------]", ConsoleColor.DarkGreen); |
| 53 | + Console.WriteLine(Environment.NewLine); |
| 54 | + |
| 55 | + //if (string.IsNullOrEmpty(settings.NetworkChangeAdapters)) |
| 56 | + //{ |
| 57 | + // WriteColor(@"[//--No Networkadapters-------------------------------------------]", ConsoleColor.DarkRed); |
| 58 | + // WriteColor($"[//:] Please insert Networkadapters (\"NetworkChangeAdapters\") in the settings.json", ConsoleColor.DarkRed); |
| 59 | + // WriteColor(@"[//---------------------------------------------------------------]", ConsoleColor.DarkRed); |
| 60 | + // if (!Debugger.IsAttached) |
| 61 | + // { |
| 62 | + // Environment.Exit(3); |
| 63 | + // } |
| 64 | + // else |
| 65 | + // { |
| 66 | + // Console.WriteLine(Environment.NewLine); |
| 67 | + // } |
| 68 | + //} |
| 69 | + } |
| 70 | + |
| 71 | + |
| 72 | + /// <summary> |
| 73 | + /// Write some coloring console messages for the user |
| 74 | + /// https://stackoverflow.com/questions/2743260/is-it-possible-to-write-to-the-console-in-colour-in-net |
| 75 | + /// </summary> |
| 76 | + /// <param name="message">Message to write</param> |
| 77 | + /// <param name="color">ConsoleColor value of the color</param> |
| 78 | + public static void WriteColor(string message, ConsoleColor color) |
| 79 | + { |
| 80 | + var pieces = Regex.Split(message, @"(\[[^\]]*\])"); |
| 81 | + |
| 82 | + for (int i = 0; i < pieces.Length; i++) |
| 83 | + { |
| 84 | + string piece = pieces[i]; |
| 85 | + |
| 86 | + if (piece.StartsWith("[") && piece.EndsWith("]")) |
| 87 | + { |
| 88 | + Console.ForegroundColor = color; |
| 89 | + piece = piece.Substring(1, piece.Length - 2); |
| 90 | + } |
| 91 | + |
| 92 | + Console.Write(piece); |
| 93 | + Console.ResetColor(); |
| 94 | + } |
| 95 | + |
| 96 | + Console.WriteLine(); |
| 97 | + } |
| 98 | + } |
| 99 | +} |
0 commit comments