public static void Error(string msg) { var d = new Dialog(Math.Min(Terminal.Cols - 8, msg.Length + 6), 8, "Error"); d.ErrorColors(); d.Add(new Label(1, 1, msg)); var b = new Button(0, 0, "Ok"); b.Clicked += delegate { d.Running = false; }; d.AddButton(b); Terminal.Run(d); }
/// <summary> /// Displays a message on a modal dialog box. /// </summary> /// <remarks> /// The error boolean indicates whether this is an /// error message box or not. /// </remarks> static public void Msg(bool error, string caption, string t) { var lines = new List <string> (); int last = 0; int max_w = 0; string x; for (int i = 0; i < t.Length; i++) { if (t [i] == '\n') { x = t.Substring(last, i - last); lines.Add(x); last = i + 1; if (x.Length > max_w) { max_w = x.Length; } } } x = t.Substring(last); if (x.Length > max_w) { max_w = x.Length; } lines.Add(x); Dialog d = new Dialog(System.Math.Max(caption.Length + 8, max_w + 8), lines.Count + 7, caption); if (error) { d.ErrorColors(); } for (int i = 0; i < lines.Count; i++) { d.Add(new Label(1, i + 1, (string)lines [i])); } Button b = new Button(0, 0, "Ok", true); d.AddButton(b); b.Clicked += delegate { b.Container.Running = false; }; Terminal.Run(d); }
public static int Query(int width, int height, string title, string message, params string [] buttons) { var d = new Dialog(width, height, title); int clicked = -1, count = 0; foreach (var s in buttons) { int n = count++; var b = new Button(s); b.Clicked += delegate { clicked = n; d.Running = false; }; d.AddButton(b); } if (message != null) { var l = new Label((width - 4 - message.Length) / 2, 0, message); d.Add(l); } Terminal.Run(d); return(clicked); }
static public void Show(Stream source) { var full = new FullView(source); Terminal.Run(full); }