//Method for drawing a box with ASCII characters, from the two character sets defined earlier static void DrawBox(PageElement pageElement, string[] characterSet) { //Sets specified startposition Console.SetCursorPosition(pageElement.StartX, pageElement.StartY); //Upper left corner piece Console.Write(characterSet[2]); //for-loop for horizontal lines for (int i = 0; i < pageElement.Width / 2; i++) { Console.Write(characterSet[0]); Console.SetCursorPosition(Console.CursorLeft - 2, Console.CursorTop + (pageElement.Height + 1)); Console.Write(characterSet[0]); Console.SetCursorPosition(Console.CursorLeft, Console.CursorTop - (pageElement.Height + 1)); } //Upper right corner piece Console.Write(characterSet[3]); //Setting starting position to draw vertical lines Console.SetCursorPosition(pageElement.StartX, pageElement.StartY + 1); //for-loop for vertical lines for (int i = 0; i < pageElement.Height; i++) { Console.Write(characterSet[1]); Console.SetCursorPosition(Console.CursorLeft + pageElement.Width, Console.CursorTop); Console.Write(characterSet[1]); Console.SetCursorPosition(Console.CursorLeft - (pageElement.Width + 2), Console.CursorTop + 1); } //Lower left corner piece Console.Write(characterSet[4]); //Position for lower right corner piece Console.SetCursorPosition(pageElement.StartX + 1 + pageElement.Width, pageElement.StartY + 1 + pageElement.Height); //Lower right corner piece Console.Write(characterSet[5]); //Drawing menu text Console.SetCursorPosition(pageElement.StartX + 1, pageElement.StartY + 1); Console.WriteLine(pageElement.Text); Console.SetCursorPosition(pageElement.StartX + 1, pageElement.StartY + 2); }
//Method for adding PageElements to a Page objects pageElementList void AddPageElement(int function, int width, int height, int startX, int startY, string text) { PageElement Element = new PageElement(function, width, height, startX, startY, text); pageElementList.Add(Element); }