Example #1
0
		public Messagebox(string title, IEnumerable<string> message, 
						  ConfirmationButtons confirmationbuttons = ConfirmationButtons.Ok) {
			this.owner = new ShellForms ();

			this.Title = title;

			message = message.SelectMany (l => l.Split (new[]{'\n'}));

			var messageWidth = message.Max (l => l.Length);
			var width = messageWidth + 4;
			var height = message.Count() + 4;
			var left = Console.WindowWidth / 2 - width / 2;
			var top = Console.WindowHeight / 2 - height / 2;

			var lblFrame = new Label (left, top);
			lblFrame.Text = "+" + new string('-', width-2) + "+";
			for (var i = 1; i < height; i++)
				lblFrame.Text += "\n" + "|" + new string(' ', width-2) + "|";
			lblFrame.Text += "\n" + "+" + new string('-', width-2) + "+";
			base.Add (lblFrame);

			var lblMsg = new Label (left + 2, top + 2);
			lblMsg.Text = string.Join ("\n", message);
			base.Add (lblMsg);


			if (confirmationbuttons == ConfirmationButtons.Ok) {
				var btnOk = new Button (left + width / 2 - 2, top + height - 1, "Ok");
				base.Add (btnOk);

				btnOk.OnPressed += _ => {
					this.confirmation = Confirmations.Ok;
					this.owner.Stop ();
				};
			} else {
				var btnOk = new Button (left + width / 2 - 7, top + height - 1, "Ok");
				base.Add (btnOk);

				btnOk.OnPressed += _ => {
					this.confirmation = Confirmations.Ok;
					this.owner.Stop ();
				};

				var btnCancel = new Button (left + width / 2 - 2, top + height - 1, "Cancel");
				base.Add (btnCancel);

				btnCancel.OnPressed += _ => {
					this.confirmation = Confirmations.Cancel;
					this.owner.Stop ();
				};
			}

			owner.Push (this);
		}
Example #2
0
		public Maindialog(ShellForms sf) {
			var tb = new Textbox (2, 4, 15);
			tb.Text = "Hello, world!";
			base.Add (tb);

			var btn = new Button (2, 6, "Display");
			base.Add (btn);

			var lbl = new Label (15, 6, 15);
			lbl.Text = "Overwrite";
			base.Add (lbl);

			btn.OnPressed += _ => lbl.Text = tb.Text;

			var lst = new Listbox (2, 8, 20, 3);
			lst.Items = new[]{ "multi", "selection", "listbox", "with", "scrolling" };
			lst.MultipleSelect = true;
			base.Add (lst);

			base.Add (new Label (2, 12){ Text = "No mammal?" });

			var rbg = new Radiobuttongroup (15, 12);
			rbg.Choices = new[]{ "dog", "cat", "mouse", "ant" };
			base.Add (rbg);

			var btn2 = new Button (2, 17, "Open new Dlg...");
			base.Add (btn2);

			btn2.OnPressed += _ => {
				sf.Push (new Nesteddialog (sf){Title = "Nested"});
				sf.Refresh ();
			};

			base.Add (new Label (2, 19){ Text = "Type command, hit Enter: " });

			var cmd = new Command (26, 19, 10);
			base.Add (cmd);

			cmd.OnOrdered += sender => new Messagebox ("Command entered", sender.Text).Show (sf);

			var mb = new Menubar (2, 21);
			mb.Menuitems = new[]{ "Show message box", "Reset command", "Exit"};
			base.Add (mb);

			mb.OnSelected += (sender, i) => {
				switch(i) {
				case 0:
					if (new Messagebox ("Test", "A msg\nbox with a\nmulti-line message.", Messagebox.ConfirmationButtons.OkCancel).Show (sf) == Messagebox.Confirmations.Cancel)
						new Messagebox("Test", "Oh, cancellation?").Show(sf);
					break;
				case 1:
					cmd.Text = "";
					break;
				case 2:
					Environment.Exit(0);
					break;
				}
			};


			var cb = new Checkbox (2, 23, "The red pill?");
			cb.Checked = true;
			base.Add (cb);


			base.Add (new Label (2, 25){ Text = "Password: "******"geheim";
			txtPwd.IsPassword = true;
			base.Add (txtPwd);

			btn = new Button (21, 25, "Show Password...");
			base.Add (btn);

			btn.OnPressed += sender => new Messagebox ("Password", txtPwd.Text).Show (sf);


			base.Add (new Label (2, 27){ Text = "Progress percent (0..100): " });

			var cmdPercent = new Command (29, 27, 5) { Text = "30" };
			cmdPercent.Name = "tbPercent";
			base.Add (cmdPercent);

			var pb = new Progressbar (35, 27, 12);
			base.Add (pb);

			cmdPercent.OnOrdered += _ => pb.Percent = Single.Parse(cmdPercent.Text);
		}
Example #3
0
        public Messagebox(string title, IEnumerable <string> message,
                          ConfirmationButtons confirmationbuttons = ConfirmationButtons.Ok)
        {
            this.owner = new ShellForms();

            this.Title = title;

            message = message.SelectMany(l => l.Split(new[] { '\n' }));

            var messageWidth = message.Max(l => l.Length);
            var width        = messageWidth + 4;
            var height       = message.Count() + 4;
            var left         = Console.WindowWidth / 2 - width / 2;
            var top          = Console.WindowHeight / 2 - height / 2;

            var lblFrame = new Label(left, top);

            lblFrame.Text = "+" + new string('-', width - 2) + "+";
            for (var i = 1; i < height; i++)
            {
                lblFrame.Text += "\n" + "|" + new string(' ', width - 2) + "|";
            }
            lblFrame.Text += "\n" + "+" + new string('-', width - 2) + "+";
            base.Add(lblFrame);

            var lblMsg = new Label(left + 2, top + 2);

            lblMsg.Text = string.Join("\n", message);
            base.Add(lblMsg);


            if (confirmationbuttons == ConfirmationButtons.Ok)
            {
                var btnOk = new Button(left + width / 2 - 2, top + height - 1, "Ok");
                base.Add(btnOk);

                btnOk.OnPressed += _ => {
                    this.confirmation = Confirmations.Ok;
                    this.owner.Stop();
                };
            }
            else
            {
                var btnOk = new Button(left + width / 2 - 7, top + height - 1, "Ok");
                base.Add(btnOk);

                btnOk.OnPressed += _ => {
                    this.confirmation = Confirmations.Ok;
                    this.owner.Stop();
                };

                var btnCancel = new Button(left + width / 2 - 2, top + height - 1, "Cancel");
                base.Add(btnCancel);

                btnCancel.OnPressed += _ => {
                    this.confirmation = Confirmations.Cancel;
                    this.owner.Stop();
                };
            }

            owner.Push(this);
        }
Example #4
0
        public Maindialog(ShellForms sf)
        {
            var tb = new Textbox(2, 4, 15);

            tb.Text = "Hello, world!";
            base.Add(tb);

            var btn = new Button(2, 6, "Display");

            base.Add(btn);

            var lbl = new Label(15, 6, 15);

            lbl.Text = "Overwrite";
            base.Add(lbl);

            btn.OnPressed += _ => lbl.Text = tb.Text;

            var lst = new Listbox(2, 8, 20, 3);

            lst.Items          = new[] { "multi", "selection", "listbox", "with", "scrolling" };
            lst.MultipleSelect = true;
            base.Add(lst);

            base.Add(new Label(2, 12)
            {
                Text = "No mammal?"
            });

            var rbg = new Radiobuttongroup(15, 12);

            rbg.Choices = new[] { "dog", "cat", "mouse", "ant" };
            base.Add(rbg);

            var btn2 = new Button(2, 17, "Open new Dlg...");

            base.Add(btn2);

            btn2.OnPressed += _ => {
                sf.Push(new Nesteddialog(sf)
                {
                    Title = "Nested"
                });
                sf.Refresh();
            };

            base.Add(new Label(2, 19)
            {
                Text = "Type command, hit Enter: "
            });

            var cmd = new Command(26, 19, 10);

            base.Add(cmd);

            cmd.OnOrdered += sender => new Messagebox("Command entered", sender.Text).Show(sf);

            var mb = new Menubar(2, 21);

            mb.Menuitems = new[] { "Show message box", "Reset command", "Exit" };
            base.Add(mb);

            mb.OnSelected += (sender, i) => {
                switch (i)
                {
                case 0:
                    if (new Messagebox("Test", "A msg\nbox with a\nmulti-line message.", Messagebox.ConfirmationButtons.OkCancel).Show(sf) == Messagebox.Confirmations.Cancel)
                    {
                        new Messagebox("Test", "Oh, cancellation?").Show(sf);
                    }
                    break;

                case 1:
                    cmd.Text = "";
                    break;

                case 2:
                    Environment.Exit(0);
                    break;
                }
            };


            var cb = new Checkbox(2, 23, "The red pill?");

            cb.Checked = true;
            base.Add(cb);


            base.Add(new Label(2, 25)
            {
                Text = "Password: "******"geheim";
            txtPwd.IsPassword = true;
            base.Add(txtPwd);

            btn = new Button(21, 25, "Show Password...");
            base.Add(btn);

            btn.OnPressed += sender => new Messagebox("Password", txtPwd.Text).Show(sf);


            base.Add(new Label(2, 27)
            {
                Text = "Progress percent (0..100): "
            });

            var cmdPercent = new Command(29, 27, 5)
            {
                Text = "30"
            };

            cmdPercent.Name = "tbPercent";
            base.Add(cmdPercent);

            var pb = new Progressbar(35, 27, 12);

            base.Add(pb);

            cmdPercent.OnOrdered += _ => pb.Percent = Single.Parse(cmdPercent.Text);
        }