public static void PrintFreeStringBundle(FreeStringBundle bundle) { int columnPoint; switch (bundle.GetAlignment()) { case Alignment.Left: columnPoint = bundle.GetPositionX(); break; case Alignment.Right: columnPoint = bundle.GetPositionX() + bundle.GetMaxTextLength() - 1; break; default: columnPoint = (bundle.GetMaxTextLength()) / 2 + bundle.GetPositionX() - 1; break; } int currentRow = bundle.GetPositionY(); foreach (string s in bundle.GetContents()) { FreeString current = new FreeString(s, columnPoint, currentRow, bundle.GetTextColor(), bundle.GetBackgroundColor(), bundle.GetAlignment()); PrintFreeString(current); currentRow++; } CleanUp(); }
// Basic Texts #region FreeString public static void PrintFreeString(FreeString freeString) { SetForeground(freeString.GetForegroundColor()); SetBackground(freeString.GetBackgroundColor()); PrintComponent(freeString.GetText(), freeString.GetPositionActual()); CleanUp(); }
public void MenuDemo() { cHandler.Reset(); Console.Clear(); Menu <int> menu = new Menu <int>(30, 10, 20, Color.Green, Color.Black); menu.AddItem("1", 0); menu.AddItem("2", 1); menu.AddItem("3rd one is longer the the max length", 2); menu.AddItem("4. Different Color", 3, Color.Red, Color.Blue); menu.AddItem("5", 4); menu.AddItem("Exit", 5); menu.LoadInToFocusAction("1", PrintOnePikachu); menu.LoadInToFocusAction(1, PrintTwoPikachu); FreeString guide = new FreeString("Q | LeftAlign, W | CenterAlign, E | RightAlign", 5, 20); bool exit = false; while (!exit) { guide.Print(); menu.Print(); ConsoleKey switcher = Console.ReadKey().Key; switch (switcher) { case ConsoleKey.Enter: if (menu.GetReturn() == 5) { exit = true; } break; case ConsoleKey.UpArrow: if (!menu.AtTop()) { Console.Clear(); menu.Up(); } break; case ConsoleKey.DownArrow: if (!menu.AtBottem()) { Console.Clear(); menu.Down(); } break; case ConsoleKey.Q: menu.LeftAlign(); Console.Clear(); break; case ConsoleKey.W: menu.CenterAlign(); Console.Clear(); break; case ConsoleKey.E: menu.RightAlign(); Console.Clear(); break; } } void PrintOnePikachu() { cHandler.PrintImage("Pikachu", 5, 5); } void PrintTwoPikachu() { cHandler.PrintImage("Pikachu", 5, 5); cHandler.PrintImage("Pikachu", 50, 5); } }