using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; using System.IO; using System.Windows.Forms; using static System.Console; using static System.Threading.Thread; namespace cce { class Utils { static internal Random rng = new Random(); static internal void VarSleep(int adj, int low = 0, int high = 300, int step = 10, decimal chance = 0.25m) { var del = rng.Next(Math.Abs(adj)); if (del <= (int)(adj * chance)) del = low; else if (del >= adj - (int)(adj * chance)) del = high; else del = del * step; Sleep(del); } static internal void Clip(string clip) { WriteLine(); LagWrite("Do you want to copy the result to the Clipboard? [Y/n]: "); var cki = ReadKey().KeyChar; WriteLine(); if (Char.ToLower(cki) == 'y') { Clipboard.SetText(clip); WriteLine("Writing to Clipboard: Done!"); } else WriteLine("Writing to Clipboard: Canceled by User"); } static internal void LagWrite(string input, bool newline = false) { if (AppSettings.Lgwrite == 0) { if (newline) WriteLine(input); else Write(input); return; } var phrases = new List>(); var lines = input.Split(new char[] { '\n' }); for (int i = 0; i < lines.Length; i++) { var line = new List(); var split = lines[i].Split(' '); int min = 4; int selector = rng.Next(min, split.Length > min + 1 ? split.Length : min + 1); var selected = new List(); for (int j = 0; j < split.Length; j++) { selected.Add(split[j]); if (j != 0 && j % selector == 0) { line.Add(String.Join(" ", selected)); selected.Clear(); } } if (selected.Count > 0) line.Add(String.Join(" ", selected)); phrases.Add(line); } for (int i = 0; i < phrases.Count; i++) { for (int j = 0; j < phrases[i].Count; j++) { Write(j != phrases[i].Count - 1 ? phrases[i][j] + " " : phrases[i][j]); VarSleep(22); } if (newline || i < phrases.Count - 1) WriteLine(); } } static internal List Entry() { var list = new List(); ConsoleKeyInfo input = new ConsoleKeyInfo(); bool exit = false; do { List chars = new List(); exit = false; for (int i = 0; i < 30; i++) { input = ReadKey(); if (chars.Count > 0 && input.Key == ConsoleKey.Enter && input.Modifiers == ConsoleModifiers.Control) { list.Add(String.Join("", chars)); break; } else if (i > 20 && input.Key == ConsoleKey.Spacebar || i > 29) { list.Add(String.Join("", chars)); WriteLine(); break; } else if (chars.Count > 0 && input.Key == ConsoleKey.Enter && input.Modifiers == 0) { list.Add(String.Join("", chars)); exit = true; break; } else if (input.Key == ConsoleKey.Backspace) { chars.RemoveAt(chars.Count-1); if (CursorLeft >0) { Write(" "); CursorLeft--; } } else chars.Add(input.KeyChar); } } while (!exit); return list; } } }