Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            var sf = new ShellForms();

            sf.Run(new Maindialog(sf)
            {
                Title = "Main"
            });
        }
Ejemplo n.º 2
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);
		}
Ejemplo n.º 3
0
		public Nesteddialog(ShellForms sf) {
			base.Add (new Label (5, 5){ Text = "A nested dialog!" });

			var btn = new Button(5, 7, "Close...");
			base.Add(btn);

			btn.OnPressed += _ => {
				sf.Pop ();
				sf.Refresh ();
			};
		}
Ejemplo n.º 4
0
        public Nesteddialog(ShellForms sf)
        {
            base.Add(new Label(5, 5)
            {
                Text = "A nested dialog!"
            });

            var btn = new Button(5, 7, "Close...");

            base.Add(btn);

            btn.OnPressed += _ => {
                sf.Pop();
                sf.Refresh();
            };
        }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            var sf = new ShellForms();

            // build
            var ui    = new MainWindow(sf);
            var clock = new Clock();

            // bind
            clock.OnClockTick += ui.Display_time;

            // run
            using (clock) {
                clock.Start();
                sf.Run(ui);
            };
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            // build
            var dlg       = new MainDlg();
            var cmd       = new CommandlineProvider();
            var txt       = new TextfileProvider();
            var pager     = new Pager();
            var formatter = new Formatter();
            var ep        = new Entrypoints(cmd, txt, pager, formatter);
            var app       = new App(dlg, ep);

            // run
            app.Start();

            var sf = new ShellForms();

            sf.Run(dlg);
        }
Ejemplo n.º 7
0
        public MainWindow(ShellForms parent)
        {
            this.parent = parent;
            this.Title  = "Alarm Clock";

            base.Add(new Label(2, 2)
            {
                Text = "Wake-up time: "
            });

            var txtWakeupTime = new Textbox(16, 2, 5);

            txtWakeupTime.Text = DateTime.Now.AddMinutes(1).ToString("HH:mm");
            base.Add(txtWakeupTime);

            var btnStartStop = new Button(22, 2, "Start");

            base.Add(btnStartStop);

            this.lblTime = new Label(2, 4, 8);
            base.Add(this.lblTime);
        }
Ejemplo n.º 8
0
		public static void Main (string[] args)
		{
			var sf = new ShellForms ();
			sf.Run (new Maindialog (sf) {Title = "Main"});
		}
Ejemplo n.º 9
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);
		}
Ejemplo n.º 10
0
 public Confirmations Show(ShellForms parent)
 {
     owner.Run();
     parent.Refresh();
     return(this.confirmation);
 }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
		public Confirmations Show(ShellForms parent) {
			owner.Run ();
			parent.Refresh ();
			return this.confirmation;
		}
Ejemplo n.º 13
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);
        }