Inheritance: Widget
コード例 #1
0
ファイル: util.cs プロジェクト: txdv/mc
        public static Result Query(Result flags, string errormsg, string condition, string file)
        {
            var s = String.Format (condition, file);
            int len = Math.Min (s.Length, Application.Cols-8);

            var d = new Dialog (len, 8, "Error");
            d.ErrorColors ();
            d.Add (new Label (1, 1, errormsg));
            d.Add (new Label (1, 2, String.Format (condition, file.Ellipsize (len-condition.Length))));

            Result result = Result.Ignore;
            Button b;
            if ((flags & Result.Retry) == Result.Retry) {
                b = new Button (0, 0, "Retry", true);
                b.Clicked += delegate {
                    result = Result.Retry;
                    d.Running = false;
                };
                d.Add (b);
            }
            if ((flags & Result.Ignore) == Result.Ignore) {
                b = new Button (0, 0, "Ignore", true);
                b.Clicked += delegate {
                    result = Result.Ignore;
                    d.Running = false;
                };
                d.Add (b);
            }
            if ((flags & Result.Cancel) == Result.Cancel) {
                b = new Button (0, 0, "Cancel", true);
                b.Clicked += delegate {
                    result = Result.Cancel;
                    d.Running = false;
                };
                d.Add (b);
            }
            Application.Run (d);
            return result;
        }
コード例 #2
0
ファイル: gui.cs プロジェクト: mono/mono-curses
        /// <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>
        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);
        }
コード例 #3
0
ファイル: gui.cs プロジェクト: mono/mono-curses
        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);
            }

            Application.Run (d);
            return clicked;
        }
コード例 #4
0
ファイル: gui.cs プロジェクト: mono/mono-curses
        /// <summary>
        ///   Adds a button to the dialog
        /// </summary>
        /// <remarks>
        /// </remarks>
        public void AddButton(Button b)
        {
            if (buttons == null)
                buttons = new List<Button> ();

            buttons.Add (b);
            button_len += b.w + button_space;

            Add (b);
        }
コード例 #5
0
ファイル: MainWindow.cs プロジェクト: RoninBG/smuxi
        public MainWindow()
            : base(0, 0, Application.Cols, Application.Lines)
        {
            //Frame layout = new Frame(0,0, Application.Cols, Application.Lines, "smuxi");
            //Add(layout);

            // menu
            Button fileButton = new Button(0, 0, "File");
            fileButton.Clicked += delegate {
                Dialog dialog = new Dialog(40, 6, "File Menu");

                Button quitButton = new Button(0, 0, "Quit");
                quitButton.Clicked += delegate {
                    Frontend.Quit();
                };
                dialog.AddButton(quitButton);

                Button closeButton = new Button(0, 0, "Close");
                closeButton.Clicked += delegate {
                    dialog.Running = false;
                    dialog.Clear();
                };
                dialog.AddButton(closeButton);

                Application.Run(dialog);
            };
            Add(fileButton);

            Button helpButton = new Button(10, 0, "Help");
            helpButton.Clicked += delegate {
                Dialog dialog = new Dialog(30, 6, "Help Menu");

                Button aboutButton = new Button(0, 0, "About");
                aboutButton.Clicked += delegate {
                    Dialog aboutDialog = new Dialog(70, 10, "About smuxi");

                    aboutDialog.Add(new Label(0, 0, "smuxi"));
                    aboutDialog.Add(new Label(0, 1, "Frontend: " + Frontend.UIName + " " + Frontend.Version));
                    aboutDialog.Add(new Label(0, 2, "Engine: " + Frontend.EngineVersion));
                    aboutDialog.Add(new Label(0, 4, "Copyright(C) 2005-2007 (C) Mirco Bauer <*****@*****.**>"));

                    Button closeButton = new Button("Close");
                    closeButton.Clicked += delegate {
                        aboutDialog.Running = false;
                        aboutDialog.Clear();
                    };
                    aboutDialog.AddButton(closeButton);

                    Application.Run(aboutDialog);
                };
                dialog.AddButton(aboutButton);

                Button helpCloseButton = new Button(0, 0, "Close");
                helpCloseButton.Clicked += delegate {
                    dialog.Running = false;
                    dialog.Clear();
                };
                dialog.AddButton(helpCloseButton);

                Application.Run(dialog);
            };
            Add(helpButton);

            // output
            /*
            TextView textView = new TextView(0, 1, Application.Cols, Application.Lines -2);
            textView.Add("Hello World!");
            textView.Add("Foo bar me!");
            Add(textView);
            */
            LogWidget log = new LogWidget(0, 1, Application.Cols, Application.Lines -2);
            Add(log);

            _UI = new CursesUI(log);

            // input
            Entry entry = new Entry(0, Application.Lines - 1, Application.Cols, String.Empty);
            Add(entry);
            _Entry = entry;

            // status
        }
コード例 #6
0
ファイル: util.cs プロジェクト: arg/mc
 public static void Error(string msg)
 {
     var d = new Dialog (Math.Min (Application.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);
     Application.Run (d);
 }
コード例 #7
0
ファイル: util.cs プロジェクト: arg/mc
 void MakeButton(Dialog d, int x, int y, string text, System.Action action)
 {
     Button b = new Button (x, y, text);
     b.Clicked += delegate {
         action ();
         d.Running = false;
     };
     d.Add (b);
 }