/// <summary> /// Write a string array to the buffer, breaking it up into groups. /// The user will need to cycle through the list. /// </summary> /// <param name="outputs"> /// An array of strings to output as groups to the screen frame. /// </param> /// <param name="groupSize"> /// The number of strings to print on each screen frame. /// </param> public void WriteList(string[] outputs, int groupSize = 10) { if (outputs == null) { // Throw exception. throw new NullReferenceException("String array 's' was null"); } // Do this after exception cases. if (isFake) { outputs.ToList().ForEach(x => Debug.WriteLine(x)); } // Correct any bad group sizes. if (groupSize <= 0) { // Auto-correct the stupid user. groupSize = 2; } int numerator = outputs.Length; int denominator = groupSize; // n things at a time. int quotient = numerator / denominator; int remainder = numerator % denominator; // Loop through and display all groups. for (int i = 0; i < quotient; ++i) { for (int j = 0; j < denominator; ++j) { this.WriteLine(outputs[i * denominator + j]); } this.WriteLine("Please type 'any' key for next grouping.", TextUIJustify.CENTER); this.Render(); if (!isFake) { InputController.PressAnyKey(); } this.ClearBuffer(); } // Display the last group. if (remainder > 0) { for (int i = 0; i < remainder; ++i) { this.WriteLine(outputs[denominator * quotient + i]); } this.Render(); } if (!isFake) { InputController.PressAnyKey(); } return; }
/// <summary> /// Attemps to read input from the user to fill out details in an date range packet. /// </summary> /// <param name="tui"> /// The text ui reference for outout to the screen space. /// </param> /// <param name="action"> /// The action the packet will perform. /// </param> /// <param name="sessionID"> /// The sessionID of the current user. /// <returns> /// A newly created date range packet from user input. /// </returns> private DateRangePacket ReadDateRangePacket(TextUI tui, string action, string sessionID) { // A nice message at the top. tui.WriteLine("Please enter custom report details \n ", TextUI.TextUIJustify.CENTER); tui.Refresh(); // Get the 9 digit, positive ID for this packet. The context of the ID will is based // on the option the user chose. Either member or provider, the state will be displayed // at the top header. string id = InputController.ReadInteger(9, 9, true, "ID").ToString(); // Show the id. tui.WriteLine("\tID: " + id); tui.Refresh(); // Get the end date and start date range from the current date. string endDate = DateTime.Now.ToString("MM-dd-yyyy"); DateTime.TryParse(endDate, out DateTime result); string startDate = result.AddDays(-5.0).ToString("MM-dd-yyyy"); // Show start date. tui.WriteLine("\tStartDate: " + startDate.ToString()); tui.Refresh(); // Show end date. tui.WriteLine("\tEndDate: " + endDate); tui.Refresh(); tui.WriteLine("\nPress any key to confirm.", TextUI.TextUIJustify.CENTER); tui.Refresh(); // Press any key to continue. InputController.PressAnyKey(); // Create and return a new date range packet. return(new DateRangePacket(action, sessionID, startDate.ToString(), endDate, id)); }