public virtual void Draw() { buffer.ForegroundColor = ForegroundColor; for (int i = 0; i < Items.Length; i++) { buffer.SetCursorPosition(X, Y + i); string item = Items[i]; buffer.ForegroundColor = ForegroundColor; buffer.BackgroundColor = BackgroundColor; if (i == Selected) { buffer.ForegroundColor = SelectedColor; buffer.Write(pretoken); if (fillBackround) { buffer.ForegroundColor = ForegroundColor; buffer.BackgroundColor = SelectedColor; } } else { if (IsValidMenuItem(item)) { buffer.Write("".PadLeft(pretoken.Length)); } else { buffer.SetCursorPosition(X + pretoken.Length, Y + i); } } if (!IsValidMenuItem(item)) { item = (item.Substring(1)); } if (!IsValidMenuItem(item)) { item = (item.Substring(1)); buffer.ForegroundColor = HeadingColor; } buffer.Write(item); buffer.BackgroundColor = BackgroundColor; } buffer.DrawSelf(this.BufferX, this.BufferY); }
public static void Show(string title, ref string result, int width = 35) { ConsoleBuffer buf = new ConsoleBuffer(width, 5); buf.ForegroundColor = ConsoleColor.Yellow; // window borders buf.Write("/".PadRight(width - 1, '-') + "\\"); buf.SetCursorPosition(0, buf.Height - 1); buf.Write("\\".PadRight(width - 1, '-') + "/"); buf.SetCursorPosition(0, 1); buf.WriteVertical("|||"); buf.SetCursorPosition(width - 1, 1); buf.WriteVertical("|||"); // Title buf.SetCursorPosition(4, 0); buf.Write(" " + title + " "); // Textbox frame buf.SetCursorPosition(2, 2); buf.Write(">"); int Xoffset = (80 - width) / 2; int Yoffset = 9; buf.DrawSelf(Xoffset, Yoffset); Console.SetCursorPosition(4 + Xoffset, 2 + Yoffset); bool vis = Console.CursorVisible; Console.ForegroundColor = buf.ForegroundColor; Console.BackgroundColor = buf.BackgroundColor; Console.CursorVisible = true; result = Console.ReadLine(); Console.CursorVisible = vis; }
public void Show(GameClient client, IPEndPoint ep) { buffer.SetCursorPosition(10, 3); buffer.ForegroundColor = ConsoleColor.Gray; buffer.InsertBuffer(headline, 26, 4); string ip = ep.Address.ToString(); buffer.SetCursorPosition((80 - ip.Length) / 2, 8); buffer.Write(ip); buffer.DrawSelf(); Console.SetCursorPosition(26, 12); Console.ForegroundColor = SelectedColor; Console.Write(pretoken); Console.ResetColor(); Console.BackgroundColor = SelectedColor; Console.Write("Cancel"); Console.ResetColor(); client.Connect(ep); long starttime = Program.Time; while (true) { double time = Program.Time / 120.0; ConsoleBuffer slider = new ConsoleBuffer(headline.Width, 1); //slider.BackgroundColor = ConsoleColor.DarkBlue; slider.Clear(); string s = "██████"; slider.DrawText(s, (int)(0.55 * Math.Sin(time) * slider.Width + 0.5 * slider.Width) - s.Length / 2, 0, this.SelectedColor, ConsoleColor.Black); slider.DrawText(" ", 0, 0, ConsoleColor.Black, ConsoleColor.White); slider.DrawText(" ", slider.Width - 1, 0, ConsoleColor.Black, ConsoleColor.White); slider.DrawSelf(26, 10); Thread.Sleep(20); if (Console.KeyAvailable) { if (Console.ReadKey(true).Key == ConsoleKey.Enter) { client.Close(); return; } } if (client.Connected) { break; } if (starttime < Program.Time - 20 * 1000) { client.ErrorMessage = "Connection timed out."; break; } } Console.SetCursorPosition(26, 10); Console.Write("Connected! Logging in..."); //buffer.DrawSelf(); buffer.SetCursorPosition(26, 11); // waits for client to finish stuff client.Sync(); if (client.LoggedIn) { try { client.LobbyMenu.Show(); } catch (Exception e) { client.ErrorMessage = e.Message; } } if (!(client.LoggedIn && client.Connected)) { Items[0] = proitems1[0] + " " + client.ErrorMessage; this.ReadMenu(); } client.Close(); }