private int ParsePage(List <Item> results, Application app, Document doc, int p, int lastPageEnd) { ColorConsole.Write(p.ToString().Green()); Range pageBreakRange = null; try { pageBreakRange = app.Selection.GoToNext(WdGoToItem.wdGoToPage); var links = doc.Range(lastPageEnd, pageBreakRange.End).Hyperlinks; if (links.Count > 0) { ParseLinks(results, p, links.Cast <Hyperlink>()?.Select(link => { var text = link.Type == MsoHyperlinkType.msoHyperlinkRange ? link.TextToDisplay?.Trim() : string.Empty; var item = new Item(string.Empty, text, link.Address); link.NAR(); return(item); })?.ToList()); links.NAR(); } lastPageEnd = pageBreakRange.End; } catch (Exception ex) { ColorConsole.WriteLine(ex.Message.White().OnRed()); lastPageEnd++; // TODO: Check } finally { pageBreakRange.NAR(); } return(lastPageEnd); }
static void Main(string[] args) { Options options = new Options(); CommandLine.Parser.Default.ParseArguments(args, options); if (options.DataBase == null || (options.GetEncoding() == null)) { Console.Write(options.GetUsage()); } else { var t = new LocaleHelper(); //Console.WriteLine(CultureInfo.CurrentUICulture.Name); ColorConsole.WriteLine(strings.copyDataBase.Green()); ColorConsole.WriteLine(strings.main_msg.Red()); ColorConsole.Write(options.DataBase.Yellow(), $" {strings.main_msg_continue} {strings.yes}: ".Red()); var answer = Console.ReadLine(); if (answer.ToUpper() == strings.yes) { var parser = new Parser(options, new LogScreenWriter()); parser.Execute(); } } Console.WriteLine(strings.hit_close); Console.ReadKey(); }
static int Render(IList <XElement> files, int index, int level, string path) { var normalizedLevelPath = path == "" ? Path.DirectorySeparatorChar.ToString() : (Path.DirectorySeparatorChar + path + Path.DirectorySeparatorChar); while (index < files.Count) { var element = files[index]; var file = element.Element("PackagePath").Value; var dir = Path.GetDirectoryName(file); var paths = dir.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); var normalizeCurrentPath = Path.DirectorySeparatorChar + string.Join(Path.DirectorySeparatorChar, paths) + Path.DirectorySeparatorChar; if (!normalizeCurrentPath.StartsWith(normalizedLevelPath) || paths.Length < level) { return(index); } if (paths.Length > level) { ColorConsole.Write(new string(' ', (level + 1) * 2 + 2)); if (level == 0) { ColorConsole.Write("/".Gray()); } ColorConsole.WriteLine(paths[level].Green(), "/".Gray()); index = Render(files, index, level + 1, string.Join(Path.DirectorySeparatorChar, paths[..(level + 1)]));
private bool ProcessResult(CommandResult result) { switch (result.Type) { case ResultType.Exit: return(true); case ResultType.Invalid: ColorConsole.WriteLine("^14:00Command '{0}' not recognized. Type 'help' to see list of valid commands.", result.Command); return(false); case ResultType.Error: ColorConsole.WriteLine("\n^04:00A problem was encountered when trying to execute '{0}'", result.Command); ColorConsole.Write("^08:00{0}", new string('-', Console.BufferWidth)); ColorConsole.WriteLine("^12:00{0}", result.ErrorMessage); ColorConsole.WriteLine("^08:00{0}", new string('-', Console.BufferWidth)); ProcessCommand("printresult errors"); ColorConsole.WriteLine("^08:00{0}", new string('-', Console.BufferWidth)); return(false); case ResultType.Success: if (!String.IsNullOrEmpty(result.SuccessMessage)) { ColorConsole.Write("\n^03:00{0}", new string('-', Console.BufferWidth)); ColorConsole.WriteLine("^11:00{0}", result.SuccessMessage); ColorConsole.Write("^03:00{0}\n", new string('-', Console.BufferWidth)); } return(false); } return(false); }
private static void PrintNextFigure(Figure nextFig) { for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { Console.SetCursorPosition(15 + col, 3 + row); Console.Write(" "); } } for (int row = 0; row < nextFig.Form.GetLength(0); row++) { for (int col = 0; col < nextFig.Form.GetLength(1); col++) { Console.SetCursorPosition(15 + col, 3 + row); if (nextFig.Form[row, col] != 0) { ColorConsole.Write("█", GetColor(nextFig.Form[row, col])); } else { ColorConsole.Write(" "); } } } }
public async Task UpdateWorkItems(Account account, CancellationToken cancellationToken) { var workItems = await this.GetWorkItems(account, cancellationToken); foreach (var workItem in workItems) { try { var html = HttpUtility.HtmlDecode(workItem.Fields.DescriptionHtml); if (!string.IsNullOrWhiteSpace(html)) { var content = new[] { new Op { op = AddOperation, path = DescriptionField, value = html } }.ToJson(); using (var stringContent = new CapturedStringContent(content, JsonPatchMediaType)) { var pat = account.IsPat ? this.GetBase64Token(account.Token) : (BearerAuthHeaderPrefix + account.Token); await $"https://dev.azure.com/{account.Org}/{account.Project}/_apis/wit/workitems/{workItem.Id}?api-version=6.0" .WithHeader(AuthHeader, pat) .PatchAsync(stringContent); ColorConsole.Write(workItem.Id.ToString(), ".".Blue()); } } } catch (Exception ex) { await this.LogError(ex, workItem.Id.ToString()); } } ColorConsole.WriteLine(); }
public override void Draw() { Width = Text.Length; IsDirty = false; base.Draw(); ColorConsole.Write(Text); }
public static async Task <string> GetAuthTokenByUserCredentialsInteractiveAsync(Settings input) { var resource = GetResourceUrl(input); if (string.IsNullOrWhiteSpace(input.Tenant) || string.IsNullOrWhiteSpace(input.ClientId) || string.IsNullOrWhiteSpace(resource) || string.IsNullOrWhiteSpace(input.ReplyUrl)) { throw new ArgumentException($"To use the User-credentials interactive-flow, please provide valid Tenant, ClientId, ResourceUrl, ReplyUrl in '{input.AppSettingsFile}'"); } var accessToken = await AuthTokens.GetOrAdd(input.Tenant ?? string.Empty, k => { return(new Lazy <Task <string> >(async() => { var ctx = GetAuthenticationContext(input.Tenant); Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult result = null; var promptBehavior = new PlatformParameters(PromptBehavior.SelectAccount, new CustomWebUi()); ColorConsole.Write("Authenticating...\n"); try { result = await ctx.AcquireTokenAsync(resource, input.ClientId, new Uri(input.ReplyUrl), promptBehavior); } catch (UnauthorizedAccessException) { // If the token has expired, prompt the user with a login prompt result = await ctx.AcquireTokenAsync(resource, input.ClientId, new Uri(input.ReplyUrl), promptBehavior); } return result?.AccessToken; })); }).Value; return(accessToken); }
public static async Task <string> GetAuthToken(string tenantId) { var accessToken = await AuthTokens.GetOrAdd(tenantId ?? string.Empty, k => { return(new Lazy <Task <string> >(async() => { var ctx = GetAuthenticationContext(tenantId); AuthenticationResult result = null; var promptBehavior = new PlatformParameters(PromptBehavior.SelectAccount, new CustomWebUi()); ColorConsole.Write("Authenticating...\n"); try { result = await ctx.AcquireTokenAsync(AzureDevOpsResourceId, ClientId, new Uri(ReplyUri), promptBehavior); } catch (UnauthorizedAccessException) { // If the token has expired, prompt the user with a login prompt result = await ctx.AcquireTokenAsync(AzureDevOpsResourceId, ClientId, new Uri(ReplyUri), promptBehavior); } return result?.AccessToken; })); }).Value; return(accessToken); }
public static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; string[] inputs = null; var outputs = new List <string>(); var format = OutputFormat.md; if (args?.Length > 0) { inputs = ProcessInputs(ref format, args); } else { ColorConsole.Write("Provide the files to parse links and the format to save", " (e.g. c:\\deckWithLinks.pptx;c:\\docWithLinks.docx;c:\\folderWithDocs --md)".DarkGray(), ": ".Green()); var param = Console.ReadLine().Split("--", StringSplitOptions.RemoveEmptyEntries); inputs = ProcessInputs(ref format, param); } InputBase.Exclusions = (Environment.GetEnvironmentVariable(ExclusionsKey, EnvironmentVariableTarget.User) ?? Environment.GetEnvironmentVariable(ExclusionsKey, EnvironmentVariableTarget.Machine))?.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)?.Select(x => x.Trim()).ToList(); foreach (var input in inputs) { if (File.Exists(input)) { ProcessFile(format, outputs, input.Trim()); } else { if (Directory.Exists(input)) { var files = new[] { "*.pptx", "*.docx" }.SelectMany(x => Directory.EnumerateFiles(input.Trim(), x, SearchOption.AllDirectories)); foreach (var file in files) { ProcessFile(format, outputs, file.Trim()); } } } } ColorConsole.WriteLine("outputs", ": ".Green(), outputs.Count.ToString().DarkGray()); if (outputs?.Count > 0) { if (outputs.Count > 1) { ColorConsole.Write("\n", "> ".Green(), "Merge outputs? ", "(y/n) ".Green()); var yesno = Console.ReadKey(); ColorConsole.WriteLine(); if (yesno.Key == ConsoleKey.Y) { OutputBase.GetInstance(format).Merge(outputs); } } outputs.ForEach(o => ColorConsole.WriteLine(o.DarkGray())); } ColorConsole.Write("\nPress any key to continue", "...".Green()); Console.ReadLine(); }
public static void Information(int score, Figure nextFig) { Console.SetCursorPosition(15, 0); ColorConsole.Write("SCORE: " + score, ConsoleColor.Green); Console.SetCursorPosition(15, 1); ColorConsole.Write("NEXT FIGURE: ", ConsoleColor.Green); PrintNextFigure(nextFig); Console.WriteLine(); }
public override void Run() { // Affichage des proprietes de l'objet ObjectDisplay <T> .displayObject(value); Console.WriteLine($""); ColorConsole.WriteLine("─────────── COMMANDES ───────────", ConsoleColor.White); ColorConsole.Write("SPACEBAR ", ConsoleColor.Yellow); ColorConsole.WriteLine($"Retourner sur le menu {lastMenu.Title}", ConsoleColor.White); }
public static void Run(string file = null) { Console.Clear(); lolfile : string curDir = Reference.CurrentDir; if (file == null) { ColorConsole.Write(ConsoleColor.Yellow, "File to read => "); string ftr = Console.ReadLine(); if (!ftr.Contains(Reference.RootPath)) { curDir += @"\" + ftr; } else { curDir = ftr; } } else { if (!file.Contains(Reference.RootPath)) { curDir += @"\" + file; } else { curDir = file; } } if (!File.Exists(curDir)) { ColorConsole.WriteLine(ConsoleColor.Red, "File doesn't exist."); if (file == null) { goto lolfile; } else { goto end; } } string[] lines = File.ReadAllLines(curDir); Console.Clear(); for (int i = 0; i < lines.Length; i++) { ColorConsole.WriteLine(ConsoleColor.Cyan, lines[i]); } end :; }
public static bool Init() { Console.Clear(); dosetup : ColorConsole.Write(ConsoleColor.Yellow, "Install Sartox OS? (y/n) "); string answer = Console.ReadLine(); bool setup; if (answer == "y") { setup = true; doformat : ColorConsole.WriteLine(ConsoleColor.Yellow, "Sartox OS will now format your hard drive. Agree? (y/n)"); string format = Console.ReadLine(); if (format == "y") { Reference.FAT.Format(Reference.RootPath.Replace(@":\", string.Empty), "FAT32", true); } else { ColorConsole.WriteLine(ConsoleColor.Red, "Invalid answer."); goto doformat; } ColorConsole.WriteLine(ConsoleColor.Yellow, "Create your user account."); ColorConsole.Write(ConsoleColor.White, "User"); ColorConsole.Write(ConsoleColor.Yellow, " => "); string user = Console.ReadLine(); ColorConsole.Write(ConsoleColor.White, "Password"); ColorConsole.Write(ConsoleColor.Yellow, " => "); string pass = Console.ReadLine(); ColorConsole.WriteLine(ConsoleColor.Yellow, "=> Creating user account..."); Reference.UserAccount = new Acc(user, pass); Reference.UserAccount.Create(); ColorConsole.WriteLine(ConsoleColor.Green, "=> Created user account."); ColorConsole.WriteLine(ConsoleColor.Yellow, "=> Finishing installation..."); File.WriteAllText(Reference.RootPath + "Installed.txt", "Sartox OS is installed... no, there is no easter egg here.", Encoding.ASCII); Power.Restart(); } else if (answer == "n") { setup = false; } else { ColorConsole.WriteLine(ConsoleColor.Red, "Invalid answer."); goto dosetup; } return(setup); }
public override async Task <int> ExecuteAsync() { if (Files.Count == 0) { ColorConsole.Write("Init requires at least one URI to fetch initial .netconfig from."); return(0); } var configs = new List <string>(); var result = 0; // First download all the temp configs foreach (var spec in Files) { var tempConfig = Path.GetTempFileName(); var tempFile = Path.GetTempFileName(); var command = new AddCommand(Config.Build(tempConfig)); command.Files.Add(new FileSpec(tempFile, spec.Uri)); ColorConsole.WriteLine("Downloading seed config file(s)...".Yellow()); if (await command.ExecuteAsync() != 0) { result = -1; } configs.Add(tempFile); } // Then merge with the current config foreach (var entry in configs.SelectMany(x => Config.Build(x)).Where(x => x.Level == null)) { // Internally, setting a null string is actually valid. Maybe reflect that in the API too? Configuration.SetString(entry.Section, entry.Subsection, entry.Variable, entry.RawValue !); } foreach (var config in configs.Select(x => Config.Build(x))) { // Process each downloaded .netconfig as a source of files var files = new UpdateCommand(config).GetConfiguredFiles(); // And update them against the current dir config. var update = new UpdateCommand(Config.Build()); update.Files.AddRange(files); if (await update.ExecuteAsync() != 0) { result = -1; } } return(result); }
public static string ReadLine(this ColorConsole console, string prompt, ConsoleColor foregroundColor, ConsoleColor backgroundColor = ConsoleColor.Black, bool intercept = false, char echo = '*') { lock (readGate) { console.Write(prompt, foregroundColor, backgroundColor); if (!intercept) { return(System.Console.ReadLine()); } else { int left = System.Console.CursorLeft; StringBuilder sb = new StringBuilder(); ConsoleKeyInfo keyInfo; while ((keyInfo = System.Console.ReadKey(intercept)).Key != ConsoleKey.Enter) { if (ConsoleKey.LeftArrow == keyInfo.Key || ConsoleKey.RightArrow == keyInfo.Key) { continue; } if (ConsoleKey.Backspace == keyInfo.Key) { if (System.Console.CursorLeft > left) { console.Write("\b \b"); if (sb.Length > 0) { sb.Remove(sb.Length - 1, 1); } } continue; } System.Console.Write(echo); sb.Append(keyInfo.KeyChar); } ; console.WriteLineBlank(); return(sb.ToString()); } } }
static void LSColors(ColorConsole trm, InfoWriter iw, string key, string value) { var items = value.Split(':'); trm.Write(string.Format("{0," + EnvVarWidth + "}", key)); iw.Separator(); trm.SetForeground(0xe0, 0xe0, 0xe0); bool first = true; foreach (var item in items) { if (first) { first = false; } else { trm.Write(new string(' ', EnvVarWidth + 2)); } trm.Write($"{item,-20}"); trm.Write(" "); var idx = item.IndexOf('='); if (idx > 0) { var itemKey = item.Substring(0, idx); var itemVal = item.Substring(idx + 1); var parts = itemVal.Split(';'); foreach (var part in parts) { trm.SetCode(part); } trm.Write("(Color)"); trm.SetDefaults(); if (LSKeys.TryGetValue(itemKey, out string desc)) { trm.Write(" "); trm.Write(desc); } } trm.WriteLine(); } trm.SetDefaults(); }
public override CommandResult Execute() { CommandResult result = new CommandResult(Command, Args); if (Shell.Client.ConnectionPool.AnybodyAlive()) { return(CommandResult.CreateError(Command, Args, String.Format("Already connected to {0}", Shell.Config.Host))); } int numWorkers = 5; if (Args != null && Args.Length > 0) { numWorkers = Convert.ToInt32(Args[0]); } Shell.Client.NumberOfWorkers = numWorkers; Shell.Client.Aggregator.ClearLogs(); //ColorConsole.ResetAfterWrite = false; ColorConsole.Write("^03:00Attempting connection to {0}... ", Shell.Config.Host); result.Type = Shell.Client.Start() ? ResultType.Success : ResultType.Error; if (result.Type == ResultType.Success) { //result.SuccessMessage = String.Format("Successfully connected to {0}", Shell.Config.Host); ColorConsole.WriteLine("^11:00Connected"); ColorConsole.Write("^03:00Getting folder list... "); Shell.Client.RequestManager.SubmitAndWait(new FolderTreeRequest("\"\"", FolderTreeCallback), false); ColorConsole.Write("^03:00Populating folder data... "); Shell.Client.MailboxManager.PopulateFolderData(null, FolderDataCallback); while (!foldersPopulated) { Thread.Sleep(1); } return(result); } else if (result.Type == ResultType.Error) { //ColorConsole.WriteLine("^12:00Failed"); result.ErrorMessage = String.Format( "The was a problem connecting to {0}. Please check your settings and connection and try again.", Shell.Config.Host); } return(result); }
private void ShowMessageGroup(IMessage[] msgList, int startNum) { //*UID(5) From(15) Subject(30) Date ColorConsole.WriteLine("\n^15:00 UID From Subject Date"); ColorConsole.Write("^08:00{0}", new string('-', Console.BufferWidth)); int msgCount = 0; int blockSize = MSGS_PER_BLOCK; for (int i = startNum; i < startNum + MSGS_PER_BLOCK; i++) { if (i == msgList.Length) { int maxGroups = msgList.Length / MSGS_PER_BLOCK; blockSize = msgList.Length - (maxGroups * MSGS_PER_BLOCK); break; } IMessage msg = msgList[i]; if (!msg.HeaderLoaded) { bool headerLoaded = false; Shell.Client.RequestManager.SubmitRequest(new MessageFlagRequest(msg, delegate { Shell.Client.RequestManager.SubmitRequest(new MessageHeaderRequest(msg, delegate(IRequest req) { //headerLoaded = true; MessageHeaderProcessor mhp = req.GetProcessorAsType <MessageHeaderProcessor>(); PrintMessage(mhp.Message); msgCount++; }), false); }), false); } else { PrintMessage(msg); msgCount++; } } while (msgCount < blockSize) { Thread.Sleep(1); } }
public static void HandleSubscription(string inputFile) { if (!File.Exists(inputFile)) { ColorConsole.Write($"{inputFile} does not exist!".White().OnRed()); return; } var distinctItems = new List <DistinctResource>(); var outputFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), $"{nameof(AzResources)} - {Path.GetFileNameWithoutExtension(inputFile)}.xlsx"); var outputFileInfo = new FileInfo(outputFile); if (outputFileInfo.Exists) { ColorConsole.Write($"{outputFile} already exists! Overwrite it? (", "Y/N".Green(), ") ".Yellow()); var input = Console.ReadKey(); if (input.Key != ConsoleKey.Y) { return; } else { Console.WriteLine("\n"); } } using (var pkg = new ExcelPackage(outputFileInfo)) //file.OpenWrite() { HandleResources(pkg, 1, distinctItems, inputFile); PackageHelper.WriteToTarget(distinctItems.Distinct(), -1, "Distinct_Resources", pkg); } ColorConsole.WriteLine($"Output saved to: {outputFile}\nPress 'O' to open the file or any other key to exit...".White().OnGreen()); var open = Console.ReadKey(); if (File.Exists(outputFile) && open.Key == ConsoleKey.O) { Process.Start(new ProcessStartInfo(outputFile) { UseShellExecute = true }); } }
private static void ProcessFile(OutputFormat format, List <string> outputs, string file) { ColorConsole.WriteLine("input", ": ".Green(), file.DarkGray()); ColorConsole.Write("> "); try { var results = InputBase.GetInstance(file).ExtractLinks(file); var outputFile = Path.Combine(Path.GetDirectoryName(file), $"{$"{nameof(Linx)}_{Path.GetFileName(file)}."}{format}"); new ConsoleOut().Save(results, outputFile); if (OutputBase.GetInstance(format).Save(results, outputFile)) { outputs.Add(outputFile); } } catch (Exception ex) { ColorConsole.WriteLine(ex.Message.White().OnRed()); } }
private void ParseSlide(List <Item> results, int s, Slide slide) { ColorConsole.Write(s.ToString().Green()); var links = slide.Hyperlinks; if (links.Count > 0) { ParseLinks(results, s, links.Cast <Hyperlink>()?.Select(link => { var text = link.Type == MsoHyperlinkType.msoHyperlinkRange ? link.TextToDisplay?.Trim() : string.Empty; var item = new Item(string.Empty, text, link.Address); link.NAR(); return(item); })?.ToList()); } if (slide.HasNotesPage == MsoTriState.msoTrue) { var notesPages = slide.NotesPage; foreach (Shape shape in notesPages.Shapes) { if (shape.Type == MsoShapeType.msoPlaceholder && shape.PlaceholderFormat.Type == PpPlaceholderType.ppPlaceholderBody) { var notes = shape.TextFrame.TextRange.Text; var notesLinks = new List <Item>(); // Credit: https://stackoverflow.com/a/10576770 foreach (Match m in NotesLinkParser.Matches(notes)) { notesLinks.Add(new Item(string.Empty, m.Value.Split('/').LastOrDefault().Replace("-", " ").Replace("_", " "), m.Value)); } if (notesLinks.Count > 0) { ParseLinks(results, s, notesLinks); } } } } slide.NAR(); }
private void DeleteMessage(int uid) { ColorConsole.Write("\n^05:00Deleting message {0}... ", uid); IMessage msg = Shell.Client.MailboxManager.GetMessageByUID(uid, Shell.CurrentFolder.ID); DeleteMessageRequest dmr = new DeleteMessageRequest(msg, delegate(IRequest req) { if (req.Result.Response == IMAPResponse.IMAP_SUCCESS_RESPONSE) { if (Shell.Client.MailboxManager.RemoveMessage(uid, Shell.CurrentFolder.ID)) { ColorConsole.WriteLine("^13:00Done\n"); } } }); Shell.Client.Aggregator.ClearLogs(); Shell.Client.RequestManager.SubmitAndWait(dmr, false); }
protected void ParseLink(List <Item> results, int s, int l, string text, string link) { if (!string.IsNullOrWhiteSpace(link)) { var sanitizedLink = link?.SanitizeLink(); if (!(Exclusions?.Any(e => sanitizedLink.Contains(e, StringComparison.OrdinalIgnoreCase)) == true)) { var sanitizedText = text?.SanitizeText(sanitizedLink); if (!results.Any(r => r.Text.Equals(sanitizedText, StringComparison.Ordinal) && r.Link.Equals(sanitizedLink, StringComparison.Ordinal))) { ColorConsole.Write(l.ToString()); results.Add(new Item($"{s}.{l}", sanitizedText, sanitizedLink)); } else { ColorConsole.Write(l.ToString().DarkGray()); } } } }
public async Task ExecuteAppInsights(IList <Result> results, string timeframe = "60m", int retries = 60, CancellationToken stopToken = default) { if (!string.IsNullOrWhiteSpace(settings.AppInsightsAppId) && !string.IsNullOrWhiteSpace(settings.AppInsightsApiKey)) { try { ColorConsole.Write(" App-Insights ".White().OnDarkGreen(), "[", results.Count.ToString().Green(), "]"); var found = false; var i = 0; List <Log> aiLogs = null; do { i++; aiLogs = (await this.GetLogs(results.Select(t => t.op_Id), stopToken, timeframe))?.ToList(); found = aiLogs?.Count >= results.Count; ColorConsole.Write((aiLogs?.Count > 0 ? $"{aiLogs?.Count.ToString()}" : string.Empty), ".".Green()); await Task.Delay(1000); }while (!stopToken.IsCancellationRequested && found == false && i < retries); if (aiLogs?.Count > 0) { aiLogs.ForEach(ai => { var result = results.SingleOrDefault(r => ai.operation_ParentId.Contains(r.op_Id, StringComparison.OrdinalIgnoreCase)); result.ai_ms = ai.duration; result.ai_op_Id = ai.operation_Id; // TODO: Rest of the props }); ColorConsole.WriteLine(); } else { ColorConsole.WriteLine("\nNo logs found!".Yellow()); } } catch (Exception ex) { ColorConsole.WriteLine(ex.Message.White().OnRed()); } } }
public override CommandResult Execute() { CommandResult result = new CommandResult(Command, Args); IFolder cFolder = Shell.CurrentFolder; IFolder[] subFolders = Shell.Client.MailboxManager.GetChildFolders(cFolder); ColorConsole.WriteLine("\n^15:00 {0} {1} {2}^07:00", ("Name").PadRight(30), ("Unseen").PadRight(2), ("Exists").PadRight(5)); ColorConsole.Write("^08:00{0}", new string('-', Console.BufferWidth)); foreach (IFolder f in subFolders) { ColorConsole.WriteLine("^07:00{0}{1} {2} {3}", f.SubFolders.Length > 0 ? "+":" ", f.Name.PadRight(30), f.Unseen.ToString().PadLeft(6), f.Exists.ToString().PadLeft(6)); } Console.WriteLine(); return(result); }
public void Display() { if (IsDisplaying) { return; } IsDisplaying = true; NeedToBeRefreshed = false; Console.Clear(); ColorConsole.Write("[POKE", "DEX] ", ConsoleColor.Red, ConsoleColor.White); ColorConsole.WriteLine(Title, ConsoleColor.Yellow); ColorConsole.WriteLine("─────────────────────────────────", ConsoleColor.White); Console.WriteLine(" "); Run(); IsDisplaying = false; if (NeedToBeRefreshed) { Display(); } }
public static void Draw(GameField field) { Console.SetCursorPosition(0, 0); for (int row = 0; row < field.Field.GetLength(0); row++) { for (int col = 0; col < field.Field.GetLength(1); col++) { if (field.Field[row, col] != 0) { int colorValue = field.Field[row, col]; ColorConsole.Write("█", GetColor(colorValue)); } else { ColorConsole.Write("*"); } } ColorConsole.Write("\n"); } }
static void Main(string[] args) { ColorConsole.Write(); ColorConsole.WriteLine(null); ColorConsole.WriteLine("It's so easy to add some ", "color".Magenta(), " to your console."); ColorConsole.Write(null); ColorConsole.WriteLine(); ColorConsole.WriteLine("You can use all these ", "colors".Color((ConsoleColor) new Random().Next(1, 14)), "."); foreach (var color in Enum.GetValues(typeof(ConsoleColor)).Cast <ConsoleColor>()) { ColorConsole.WriteLine(color.ToString().Color(color), " ", ("On " + color.ToString()).White().On(color)); } ColorConsole.WriteLine(); var colorToken = new ColorToken("I'm a ColorToken, change me when you want :)", ConsoleColor.White, ConsoleColor.Blue); ColorConsole.WriteLine(colorToken); ColorConsole.WriteLine(colorToken.Cyan().OnDarkYellow()); ColorConsole.WriteLine(); ColorConsole.WriteLine(new[] { "You can even use ", "masking".Magenta(), "." }.Mask(ConsoleColor.DarkYellow, null)); ColorConsole.WriteLine(new[] { "You can even use ", "masking".Magenta(), "." }.Mask(ConsoleColor.DarkYellow)); ColorConsole.WriteLine(new[] { "You can even use ", "masking".Magenta(), "." }.Mask(null, null)); ColorConsole.WriteLine(new[] { "You can even use ", "masking".Magenta(), "." }.Mask(null, ConsoleColor.DarkYellow)); ColorConsole.WriteLine(new[] { "You can even use ", "masking".Magenta().OnYellow(), "." }.Mask(null, ConsoleColor.DarkYellow)); ColorConsole.WriteLine(new[] { "You can even use ", "masking".Magenta().OnYellow(), "." }.Mask(ConsoleColor.Black, ConsoleColor.DarkYellow)); ColorToken[] noTokens = null; // watch as I do nothing ColorConsole.WriteLine(new[] { new ColorToken(), null }.Mask(null, null)); ColorConsole.WriteLine(noTokens.Mask(ConsoleColor.Red)); var lines = System.IO.File.ReadAllLines(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "kiwi.txt")); Array.ForEach( lines, line => ColorConsole.Write(line.DarkRed().OnDarkGreen(), " ".PadRight(Console.WindowWidth - line.Length).OnDarkGreen())); }
protected override void Run() { ColorConsole.WriteLine(ConsoleColor.Yellow, "Login to your user account."); login : ColorConsole.Write(ConsoleColor.White, "User"); ColorConsole.Write(ConsoleColor.Yellow, " => "); string user = Console.ReadLine(); ColorConsole.Write(ConsoleColor.White, "Password"); ColorConsole.Write(ConsoleColor.Yellow, " => "); string pass = Console.ReadLine(); if (AccMan.Exist(user) && AccMan.GetPassword(user, true) == pass) { Reference.UserAccount = new Acc(user, pass); CmdMan.Init(); } else { ColorConsole.WriteLine(ConsoleColor.Red, "Incorrect credentials."); goto login; } }