Mono.Terminal.Application.Msg C# (CSharp) Method

Msg() public static method

Displays a message on a modal dialog box.
The error boolean indicates whether this is an error message box or not.
public static Msg ( bool error, string caption, string t ) : void
error bool
caption string
t string
return void
        public static 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; };

            Application.Run (d);
        }