public void Search(ListOfInvoice listOfInvoices, ref int count) { Console.Clear(); EnhancedConsole.WriteAt(0, 10, "What are you looking for?", "white"); string search = EnhancedConsole.GetAt(0, 11, 15); search = search.ToLower(); bool found = false; count = 0; do { if (listOfInvoices.Get(count).GetHeader(). GetCustomer().GetName().ToLower(). Contains(search)) { found = true; Console.Clear(); EnhancedConsole.WriteAt(1, 20, "Found on the record " + (count + 1).ToString("000"), "yellow"); Console.ReadLine(); count--; } count++; }while (!found && count < listOfInvoices.Amount); if (!found) { Console.Clear(); count = 0; SearchByItem(listOfInvoice, ref count, search); } }
public void AdvancedMenu() { bool exit = false; do { Console.BackgroundColor = ConsoleColor.DarkMagenta; EnhancedConsole.DrawWindow(Console.WindowWidth / 4, Console.WindowHeight / 4, "1.- Export To CSV"); Console.BackgroundColor = ConsoleColor.DarkBlue; switch (Console.ReadKey().Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: exit = true; listOfProducts.ConvertToCSV(); Console.Clear(); EnhancedConsole.WriteAt(Console.WindowWidth / 2 - 3, 10, "DONE!", "yellow"); Console.ReadKey(); break; case ConsoleKey.Escape: exit = true; break; } }while (!exit); }
public void Modify(Invoice invoice) { bool exit = false; do { Console.Clear(); EnhancedConsole.WriteAt(0, 10, "Do you want to modify the header or the lines?", "white"); EnhancedConsole.WriteAt(0, 11, "1.-Header 2.-Lines 0.-Cancel", "white"); switch (Console.ReadKey().KeyChar) { case '1': ModifyHeader(invoice.GetHeader()); exit = true; break; case '2': ModifyLines(invoice.GetLines()); exit = true; break; case '0': exit = true; break; } }while (!exit); }
private static void DisplayWelcomeScreen() { DateTime DateOfVersion = new DateTime(2018, 6, 24); EnhancedConsole.DrawWindow(Console.WindowWidth / 3, Console.WindowHeight / 3, 40, 5); EnhancedConsole.WriteAt((Console.WindowWidth / 3) + 1, (Console.WindowHeight / 3) + 1, EnhancedConsole.AUTHOR, "white"); EnhancedConsole.WriteAt((Console.WindowWidth / 3) + 1, (Console.WindowHeight / 3) + 3, EnhancedConsole.VERSION + DateOfVersion.Day.ToString("00") + "/" + DateOfVersion.Month.ToString("00") + "/" + DateOfVersion.Year.ToString("0000"), "white"); bool exit = false; int count = 0; do { Thread.Sleep(50); if (Console.KeyAvailable) { exit = true; } count++; }while (!exit && count < 100); }
private void WriteHeader() { EnhancedConsole.WriteAt(2, 0, "INVOICES " + (currentRecord + 1) + "/" + listOfInvoice.Amount, "white"); EnhancedConsole.WriteAt(68, 0, "J.V. 2018", "white"); EnhancedConsole.WriteAt(0, 1, separator, "gray"); }
private void ShowOtherFooter() { EnhancedConsole.WriteAt(0, Console.WindowHeight - 4, separator, "gray"); EnhancedConsole.WriteAt(2, Console.WindowHeight - 3, "1.-Previous" + " 2.-Next" + " 3.-Search", "white"); EnhancedConsole.WriteAt(2, Console.WindowHeight - 2, "PRESS ENTER TO SELECT THE CUSTOMER", "white"); }
private void ShowHeader() { EnhancedConsole.WriteAt(2, 0, "CUSTOMERS " + (currentRecord + 1) + "/" + listOfCustomers.Amount, "white"); EnhancedConsole.WriteAt(68, 0, "J.V. 2018", "white"); EnhancedConsole.WriteAt(0, 1, separator, "gray"); EnhancedConsole.ShowClock(); }
private static void Close(EnhancedConsole console) { console.Write('e'); console.Write('x'); console.Write('i'); console.Write('t'); console.Write((char)13); }
private void ShowFooter() { EnhancedConsole.WriteAt(0, Console.WindowHeight - 4, separator, "gray"); EnhancedConsole.WriteAt(2, Console.WindowHeight - 3, "1.-Previous" + " 2.-Next" + " 3.-Number" + " 4.-Search" + " 5.-Add", "white"); EnhancedConsole.WriteAt(2, Console.WindowHeight - 2, "0.-Exit " + " 6.-Modify 7.-ConvertPDF F1.-Help", "white"); }
public void ReadAll_Should_Truncate_Empty_Lines() { var console = new EnhancedConsole(); string content = console.ReadAll(); Assert.That(content.Split(new string[] { "\r\n" }, StringSplitOptions.None).Length, Is.EqualTo(5)); Close(console); }
public void ReadAll_Should_Read_The_Last_Line_Without_Empty_Spaces() { var console = new EnhancedConsole(); string content = console.ReadAll(); Assert.That(content.Substring(content.Length - 1, 1), Is.EqualTo(">")); Close(console); }
public Product RunToGetProduct() { bool exit = false; ListOfProducts listOfProducts = new ListOfProducts(); int currentRecord = 0; string separator = new string('_', Console.WindowWidth); do { Console.Clear(); EnhancedConsole.WriteAt(0, 0, "PRODUCTSS " + (currentRecord + 1).ToString("000") + "/" + listOfProducts.Amount.ToString("000"), "white"); EnhancedConsole.WriteAt(0, 1, separator, "gray"); WriteProduct(listOfProducts, currentRecord); EnhancedConsole.WriteAt(0, Console.WindowHeight - 4, separator, "gray"); EnhancedConsole.WriteAt(0, Console.WindowHeight - 3, "1.-Previous Product" + " 2.-Next Product" + " 3.-Search", "white"); EnhancedConsole.WriteAt(0, Console.WindowHeight - 2, "PRESS ENTER TO SELECT THE PRODUCT", "white"); switch (Console.ReadKey().Key) { case ConsoleKey.LeftArrow: case ConsoleKey.NumPad1: case ConsoleKey.D1: //Previus if (currentRecord != 0) { currentRecord--; } break; case ConsoleKey.RightArrow: case ConsoleKey.NumPad2: case ConsoleKey.D2: //Next //I cant allProducts[count+1] != null if (currentRecord != listOfProducts.Amount - 1) { currentRecord++; } break; case ConsoleKey.NumPad3: case ConsoleKey.D3: //Search SearchByText(listOfProducts, ref currentRecord); break; case ConsoleKey.Enter: exit = true; break; } } while (!exit); return(listOfProducts.Get(currentRecord)); }
public void ReadAll_Ignore_NewLine_In_The_Console_Other_ThanNextLine() { var console = new EnhancedConsole(); for (int i = 0; i < 120; i++) { console.Write(i.ToString().ToCharArray()[0]); } string content = console.ReadAll(); }
public void HelpMenuAndControl(ListOfProducts listOfProducts, int countProducts, string separator) { string[] help = { "This text gives help", "This one helps too", "This one its even longer, so we need to check if the " + "string its too long" }; int count = 0; bool exit = false; do { Console.Clear(); EnhancedConsole.WriteAt(0, 0, "productS " + (count + 1).ToString("000") + "/" + listOfProducts.Amount.ToString("000"), "white"); EnhancedConsole.WriteAt(0, 1, separator, "gray"); WriteProduct(listOfProducts, countProducts); EnhancedConsole.WriteAt(0, Console.WindowHeight - 4, separator, "gray"); EnhancedConsole.WriteAt(0, Console.WindowHeight - 3, "1.-Previous Product" + " 2.-Next Product" + " 3.-Search by record" + " 4.-Search" + " 5.-Add Product", "white"); EnhancedConsole.WriteAt(0, Console.WindowHeight - 2, "6.-Edit record" + " 0.-Exit F1.-Help", "white"); Console.BackgroundColor = ConsoleColor.Red; EnhancedConsole.DrawWindow(Console.WindowWidth / 4, Console.WindowHeight / 4, help[count]); Console.BackgroundColor = ConsoleColor.DarkBlue; switch (Console.ReadKey().Key) { case ConsoleKey.LeftArrow: if (count != 0) { count--; } break; case ConsoleKey.RightArrow: if (count != help.Length - 1) { count++; } break; case ConsoleKey.Escape: exit = true; break; } } while (!exit); }
public Customer RunToGetCustomer() { bool exit = false; ListOfCustomers listOfCustomers = new ListOfCustomers(); separator = new string('-', Console.WindowWidth); do { Console.Clear(); ShowHeader(); ShowOtherFooter(); WriteCustomer(listOfCustomers, currentRecord); // Update clock if no key is pressed while (!Console.KeyAvailable) { Thread.Sleep(200); EnhancedConsole.ShowClock(); } switch (Console.ReadKey().Key) { case ConsoleKey.LeftArrow: case ConsoleKey.NumPad1: case ConsoleKey.D1: //Previus if (currentRecord != 0) { currentRecord--; } break; case ConsoleKey.RightArrow: case ConsoleKey.NumPad2: case ConsoleKey.D2: //Next if (currentRecord != listOfCustomers.Amount - 1) { currentRecord++; } break; case ConsoleKey.NumPad3: case ConsoleKey.D3: //Search by number SearchByText(listOfCustomers, ref currentRecord); break; case ConsoleKey.Enter: exit = true; break; } } while (!exit); return(listOfCustomers.Get(currentRecord)); }
public MainWindow() { InitializeComponent(); _offsetColorizer = new OffsetColorizer(); tbxConsole.Focus(); tbxConsole.TextArea.TextView.LineTransformers.Add(_offsetColorizer); _console = new EnhancedConsole(); _keyHandler = new KeyHandler(); SetUpdateTimer(); }
public void Should_Read_Output_To_The_End() { var console = new EnhancedConsole(); Assert.That(console.ReadAll(), Is.Not.Null, "Output is null"); console.Write('d'); console.Write('i'); console.Write('r'); console.Write((char)13); Assert.That(console.ReadAll(), Contains.Substring("dir"), "user command doesn't exist"); Close(console); }
private static void WriteCustomer(ListOfCustomers listOfCustomers, int count) { int y = 5; EnhancedConsole.WriteAt(0, y, "KEY: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfCustomers.Get(count).GetKey(), "white"); y++; EnhancedConsole.WriteAt(0, y, "NAME: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfCustomers.Get(count).GetName(), "white"); y++; EnhancedConsole.WriteAt(0, y, "ID: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfCustomers.Get(count).GetID(), "white"); y++; EnhancedConsole.WriteAt(0, y, "RESIDENCE: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfCustomers.Get(count).GetResidence(), "white"); y++; EnhancedConsole.WriteAt(0, y, "CITY: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfCustomers.Get(count).GetCity(), "white"); y++; EnhancedConsole.WriteAt(0, y, "POSTAL CODE: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfCustomers.Get(count).GetPostalCode(), "white"); y++; EnhancedConsole.WriteAt(0, y, "COUNTRY: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfCustomers.Get(count).GetCountry(), "white"); y++; EnhancedConsole.WriteAt(0, y, "PHONE NUMBER: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfCustomers.Get(count).GetPhoneNumber().ToString(), "white"); y++; EnhancedConsole.WriteAt(0, y, "eMAIL: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfCustomers.Get(count).GetEMail(), "white"); y++; EnhancedConsole.WriteAt(0, y, "CONTACT: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfCustomers.Get(count).GetContact(), "white"); y++; EnhancedConsole.WriteAt(0, y, "COMMENTS: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfCustomers.Get(count).GetComments(), "white"); y++; }
public void Content_Changed_Becomes_True_When_Buffer_Has_New_Content() { var console = new EnhancedConsole(); Assert.That(console.ContentChanged, Is.True); Assert.That(console.ContentChanged, Is.False); console.Write('d'); console.Write('i'); console.Write('r'); console.Write((char)13); Assert.That(console.ContentChanged, Is.True); Close(console); }
public void WriteTotal() { double total = listOfInvoice.Get(currentRecord).CalculateTotal(); double iva = listOfInvoice.Get(currentRecord).CalculateIVA(total); double bas = total - iva; string separator = new string('_', 46); EnhancedConsole.WriteAt(0, Console.WindowHeight - 8, separator, "yellow"); EnhancedConsole.WriteAt(20, Console.WindowHeight - 7, "BASE", "gray"); EnhancedConsole.WriteAt(28, Console.WindowHeight - 7, "IVA", "gray"); EnhancedConsole.WriteAt(36, Console.WindowHeight - 7, "TOTAL", "gray"); EnhancedConsole.WriteAt(20, Console.WindowHeight - 6, bas.ToString(), "white"); EnhancedConsole.WriteAt(28, Console.WindowHeight - 6, iva.ToString(), "white"); EnhancedConsole.WriteAt(36, Console.WindowHeight - 6, total.ToString(), "red"); }
public void SearchByItem(ListOfInvoice list, ref int count, string search) { bool found = false; int count2 = 0; Queue <string> founds = new Queue <string>(); int y = 8; do { Invoice i = list.Get(count); count2 = 0; do { if (i.GetLines().ElementAt(count2). GetProduct().GetDescription(). ToLower().Contains(search.ToLower()) || i.GetLines().ElementAt(count2). GetProduct().GetCode(). ToLower().Contains(search.ToLower()) || i.GetLines().ElementAt(count2). GetProduct().GetCategory(). ToLower().Contains(search.ToLower())) { found = true; founds.Enqueue("Find at " + (count + 1)); } count2++; }while (count2 < i.GetLines().Count); count++; }while (count < list.Amount); if (!found) { EnhancedConsole.WriteAt(30, 16, "Not Found!", "red"); } else { foreach (string s in founds) { EnhancedConsole.WriteAt(2, y, s, "white"); y++; } Console.ReadLine(); } count = 0; }
public void SaveDocument(string fileName) { Console.Clear(); pdf.Save(fileName + ".pdf"); EnhancedConsole.WriteAt(Console.WindowWidth / 2 - 2, 10, "DONE!", "red"); Console.ReadLine(); Console.Clear(); EnhancedConsole.WriteAt(Console.WindowWidth / 2 - 19, 10, "Do you want to see the PDF generated? Y/N", "white"); switch (Console.ReadKey().Key) { case ConsoleKey.Y: Process.Start(fileName + ".pdf"); break; } }
public void HelpMenuAndControl(ListOfCustomers listOfCustomers, int countCustomers, string separator) { string[] help = { "This text gives help", "This one helps too", "This one its even longer, so we need to check if the " + "string its too long" }; int count = 0; bool exit = false; do { Console.BackgroundColor = ConsoleColor.Red; EnhancedConsole.DrawWindow(Console.WindowWidth / 4, Console.WindowHeight / 4, help[count]); Console.BackgroundColor = ConsoleColor.DarkBlue; switch (Console.ReadKey().Key) { case ConsoleKey.LeftArrow: if (count != 0) { count--; } break; case ConsoleKey.RightArrow: if (count != help.Length - 1) { count++; } break; case ConsoleKey.Escape: exit = true; break; } } while (!exit); }
private void WriteInvoicesHeader() { Header h = listOfInvoice.Get(currentRecord).GetHeader(); EnhancedConsole.WriteAt(2, 2, h.GetNumInvoice().ToString("000"), "White"); EnhancedConsole.WriteAt(2, 3, "Customer:", "gray"); EnhancedConsole.WriteAt(12, 3, h.GetCustomer().GetName(), "white"); EnhancedConsole.WriteAt(2, 4, "ID:", "gray"); EnhancedConsole.WriteAt(12, 4, h.GetCustomer().GetID(), "White"); EnhancedConsole.WriteAt(2, 5, h.GetDate().Day.ToString("00") + '/' + h.GetDate().Month.ToString("00") + '/' + h.GetDate().Year.ToString("0000"), "white"); EnhancedConsole.WriteAt(0, 6, separator, "gray"); }
private void WriteInvoicesLines(List <Line> lines) { EnhancedConsole.WriteAt(2, 8, "ITEM", "gray"); EnhancedConsole.WriteAt(20, 8, "AMOUNT", "gray"); EnhancedConsole.WriteAt(28, 8, "PRICE", "gray"); EnhancedConsole.WriteAt(36, 8, "TOTAL", "gray"); int y = 9; foreach (Line l in lines) { EnhancedConsole.WriteAt(2, y, l.GetProduct().GetDescription(), "white"); EnhancedConsole.WriteAt(20, y, l.GetAmount().ToString("000"), "white"); EnhancedConsole.WriteAt(28, y, l.GetPrice().ToString(), "white"); EnhancedConsole.WriteAt(36, y, (l.GetPrice() * (Convert.ToDouble(l.GetAmount()))).ToString(), "white"); y++; } }
private static void Run() { bool exit = false; do { Console.Clear(); EnhancedConsole.WriteAt(Console.WindowWidth / 2 - 13, 10, "1.- INVOICE MANAGEMENT", "white"); EnhancedConsole.WriteAt(Console.WindowWidth / 2 - 13, 11, "2.- CUSTOMERS MANAGEMENT", "white"); EnhancedConsole.WriteAt(Console.WindowWidth / 2 - 13, 12, "3.- PRODUCT MANAGEMENT", "white"); EnhancedConsole.WriteAt(Console.WindowWidth / 2 - 13, 13, "0.- EXIT", "white"); switch (Console.ReadKey().KeyChar) { case '1': InvoiceManager invoiceManager = new InvoiceManager(); invoiceManager.Run(); break; case '2': CustomerManager customerManager = new CustomerManager(); customerManager.Run(); break; case '3': ProductManager productManager = new ProductManager(); productManager.Run(); break; case '0': exit = true; break; } } while (!exit); }
private void CreateInvoice() { bool exit = false; customerManager = new CustomerManager(); productManager = new ProductManager(); Customer c = customerManager.RunToGetCustomer(); Product p; listOfInvoice.Add(c); do { p = productManager.RunToGetProduct(); EnhancedConsole.WriteAt(2, Console.BufferHeight - 5 , "AMOUNT?", "yellow"); string amountSTR; int amount; do { amountSTR = Console.ReadLine(); }while (!Int32.TryParse(amountSTR, out amount)); listOfInvoice.Get(listOfInvoice.Amount - 1).GetLines().Add (new Line(p, amount, p.GetSellPrice())); Console.Clear(); EnhancedConsole.WriteAt(2, Console.BufferHeight - 5 , "DO YOU NEED MORE PRODUCTS? Y/N", "yellow"); if (Console.ReadKey().Key == ConsoleKey.Y) { exit = false; } else { exit = true; } }while (!exit); listOfInvoice.Save(); }
public void ModifyLines(List <Line> list) { string aux; int count; do { do { Console.Clear(); WriteInvoicesLines(list); EnhancedConsole.WriteAt(2, 20, "Wich line do you want to modify?", "white"); aux = EnhancedConsole.GetAt(2, 21, 3); }while (!Int32.TryParse(aux, out count)); }while (!(count > 0 && count <= list.Count)); productManager = new ProductManager(); Product p = productManager.RunToGetProduct(); list.ElementAt(count - 1).SetProduct(p); EnhancedConsole.WriteAt(2, 20 , "AMOUNT?", "yellow"); string amountSTR; int amount; do { amountSTR = Console.ReadLine(); }while (!Int32.TryParse(amountSTR, out amount)); list.ElementAt(count - 1).SetAmount(amount); list.ElementAt(count - 1).SetPrice(p.GetSellPrice()); }
public void SearchByNumber(ListOfInvoice list, ref int count) { string numberSTR; ushort number; do { Console.Clear(); Console.SetCursorPosition(0, 10); EnhancedConsole.WriteAt(0, 10, "Enter the number you are looking for", "white"); numberSTR = EnhancedConsole.GetAt(0, 11, 3); }while (!UInt16.TryParse(numberSTR, out number)); if (number > 0 && number <= list.Amount) { count = number - 1; } else { EnhancedConsole.WriteAt(0, 10, "Wrong Number!", "white"); Console.ReadLine(); } }
private static void WriteProduct(ListOfProducts listOfProducts, int count) { int y = 5; EnhancedConsole.WriteAt(0, y, "CODE: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfProducts.Get(count).GetCode(), "white"); y++; EnhancedConsole.WriteAt(0, y, "DESCRIPTION: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfProducts.Get(count).GetDescription(), "white"); y++; EnhancedConsole.WriteAt(0, y, "CATEGORY: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfProducts.Get(count).GetCategory(), "white"); y++; EnhancedConsole.WriteAt(0, y, "SELL PRICE: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfProducts.Get(count).GetSellPrice() .ToString() + "$", "white"); y++; EnhancedConsole.WriteAt(0, y, "BUY PRICE: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfProducts.Get(count).GetBuyPrice() .ToString() + "$", "white"); y++; EnhancedConsole.WriteAt(0, y, "STOCK: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfProducts.Get(count).GetStock() .ToString(), "white"); y++; EnhancedConsole.WriteAt(0, y, "MINIMUM STOCK: ", "gray"); EnhancedConsole.WriteAt(15, y, listOfProducts.Get(count).GetMinStock() .ToString(), "white"); y++; }