Esempio n. 1
0
        private static void DoubleBorderTextBoxScreen(ScreenCollection screens)
        {
            var screen = new Screen("Double Border Text Boxes");

            var control1 = new TextBox();

            control1.Left = 10;
            control1.Top = 0;
            control1.MaxLength = 6;
            control1.Width = control1.MaxLength + 2;
            control1.BorderStyle = BorderStyle.Double;

            var control2 = new TextBox();

            control2.Left = 0;
            control2.Top = control1.Top + control1.Height;
            control2.Width = screen.Width;
            control2.BorderStyle = BorderStyle.Double;

            var control3 = new TextBox();

            control3.Left = 0;
            control3.Top = control2.Top + control2.Height;
            control3.MaxLength = 20;
            control3.Width = control3.MaxLength;
            control3.BorderStyle = BorderStyle.Double;

            screen.Controls.Add(control1);
            screen.Controls.Add(control2);
            screen.Controls.Add(control3);

            screen.Footer.Text = screen.Name + ". Press escape.";

            screens.Add(screen);
        }
Esempio n. 2
0
        private static void BasicTextBoxScreen(ScreenCollection screens)
        {
            var screen = new Screen("Basic Text Boxes");

            var control1 = new TextBox();

            control1.Left = 10;
            control1.Top = 0;
            control1.MaxLength = 5;
            control1.Width = control1.MaxLength;
            control1.TreatEnterKeyAsTab = false;

            var control2 = new TextBox();

            control2.Left = 0;
            control2.Top = control1.Top + control1.Height;
            control2.Width = screen.Width;
            control2.TextAlign = TextAlign.Center;

            var control3 = new TextBox();

            control3.Left = 0;
            control3.Top = control2.Top + control2.Height;
            control3.MaxLength = 20;
            control3.Width = control3.MaxLength;
            control3.TextBoxType = TextBoxType.Password;

            var control4 = new TextBox();

            control4.Left = 0;
            control4.Top = control3.Top + control3.Height;
            control4.MaxLength = 20;
            control4.TextAlign = TextAlign.Right;

            screen.Controls.Add(control1);
            screen.Controls.Add(control2);
            screen.Controls.Add(control3);
            screen.Controls.Add(control4);

            screen.Footer.Text = screen.Name + ". Press escape.";

            screens.Add(screen);
        }
Esempio n. 3
0
        public LoginScreen(string name)
            : base(name)
        {
            usernameLabel = new Label();
            passwordLabel = new Label();
            usernameTextBox = new TextBox();
            passwordTextBox = new TextBox();
            rectangle = new Rectangle();
            loginButton = new Button();
            cancelButton = new Button();
            failureLabel = new Label();
            progressBar = new ProgressBar();

            SetupControls();

            loginButton.Click += LoginButton_Click;
            cancelButton.Click += CancelButton_Click;
            cancelButton.EscPressed += CancelButton_Click;
            loginButton.EscPressed += CancelButton_Click;
            usernameTextBox.EscPressed += CancelButton_Click;
            passwordTextBox.EscPressed += CancelButton_Click;
            passwordTextBox.KeyPressed += PasswordTextBox_KeyPressed;
        }
Esempio n. 4
0
        private static void ListBoxPopup(ScreenCollection screens)
        {
            var screen = new Screen("List Box Pop Up");

            MenuBar menuBar = Menus.SetupMenuBar(screen);

            var control1 = new ListBox();

            control1.Left = 0;
            control1.Top = 1;
            control1.Width = screen.Width;
            control1.Height = screen.Height - 2;
            control1.BorderStyle = BorderStyle.Double;

            for (int i = 0; i < 150; i++)
            {
                control1.Items.Add(string.Format("Item {0} - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua", i + 1));
            }

            screen.Controls.Add(control1);

            var textBox = new TextBox();
            textBox.BorderStyle = BorderStyle.Double;
            textBox.Width = 8;
            textBox.Left = (screen.Width / 2) - (textBox.Width / 2);
            textBox.Top = (screen.Height / 2) - (textBox.Height / 2);
            textBox.MaxLength = 6;
            textBox.BackgroundColor = System.ConsoleColor.DarkGreen;
            textBox.FocusBackgroundColor = System.ConsoleColor.DarkGreen;
            textBox.Visible = false;
            textBox.TreatEnterKeyAsTab = false;
            textBox.HasShadow = true;

            screen.Controls.Add(textBox);

            screen.Footer.Text = screen.Name + ". Press C to popup a text box, enter or escape.";

            screen.Controls.Add(menuBar);

            screens.Add(screen);

            control1.KeyPressed += (s, e) =>
            {
                if (e.Info.Key == System.ConsoleKey.C)
                {
                    textBox.Visible = true;
                    textBox.Focus();
                    e.Handled = true;
                }
            };

            control1.Selected += (s, e) =>
            {
                screen.Footer.Text = control1.SelectedItem;
            };

            textBox.TextChanged += (s, e) =>
            {
                screen.Footer.Text = string.Format("{0} => {1}", e.OrignalText ?? string.Empty, e.NewText);
            };

            textBox.Leave += (s, e) =>
            {
                //textBox.Visible = false;
            };

            control1.Enter += (s, e) =>
            {
                textBox.Visible = false;
            };
        }
Esempio n. 5
0
        private static void MultilineBasicTextBoxScreen(ScreenCollection screens)
        {
            var screen = new Screen("Multiline Basic Text Boxes");

            var control1 = new TextBox();

            control1.Left = 35;
            control1.Top = 0;
            control1.Width = control1.MaxLength;
            control1.TreatEnterKeyAsTab = false;
            control1.Height = 15;
            control1.Width = 50;
            control1.TextBoxType = TextBoxType.Multiline;
            control1.Text = "So if on advanced addition absolute received replying throwing he." + Environment.NewLine + Environment.NewLine + "Delighted consisted newspaper of unfeeling as neglected so." + Environment.NewLine + "Tell size come hard mrs and four fond are. Of in commanded earnestly resources it. At quitting in strictly up wandered of relation answered felicity. Side need at in what dear ever upon if. Same down want joy neat ask pain help she. Alone three stuff use law walls fat asked. Near do that he help.";
            control1.BorderStyle = BorderStyle.Double;

            var control2 = new TextBox();

            control2.Left = 0;
            control2.Top = control1.Top + control1.Height + 1;
            control2.Width = screen.Width;
            control2.TextAlign = TextAlign.Center;
            control2.Height = 5;
            control2.Width = 20;
            control2.TextBoxType = TextBoxType.Multiline;
            control2.MaxLength = 150;

            var control3 = new TextBox();

            control3.Left = 35;
            control3.Top = control2.Top ;
            control3.Height = 20;
            control3.Width = 50;
            control3.TextBoxType = TextBoxType.Multiline;
            control3.Text = Properties.Resources.LongText;
            control3.BorderStyle = BorderStyle.Double;

            screen.Controls.Add(control1);
            screen.Controls.Add(control2);
            screen.Controls.Add(control3);

            screen.Footer.Text = screen.Name + ". Press escape.";

            screens.Add(screen);
        }