Exemplo n.º 1
0
        private void SetupControls()
        {
            label = new Label();
            progressBar = new ProgressBar();
            rectangle = new Rectangle();

            rectangle.BorderStyle = BorderStyle.Double;
            rectangle.Height = 8;
            rectangle.Width = Width - 6;
            rectangle.Top = Height / 2 - rectangle.Height / 2;
            rectangle.Left = Width / 2 - rectangle.Width / 2;
            rectangle.HasShadow = true;

            label.Width = rectangle.Width - 4;
            label.Top = rectangle.Top + 2;
            label.Left = rectangle.Left + 2;
            label.TextAlign = TextAlign.Center;

            progressBar.Width = label.Width / 2;
            progressBar.ProgressBarStyle = ProgressBarStyle.Marquee;
            progressBar.Left = Width / 2 - progressBar.Width / 2;
            progressBar.Top = label.Top + 2;
            progressBar.BorderStyle = BorderStyle.Single;
            progressBar.BlockColor = ConsoleColor.Green;

            Controls.Add(rectangle, label, progressBar);
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        private static void TestProgressBars(ScreenCollection screens)
        {
            var screen = new Screen("Progress Bars - No Border");

            var control1 = new ProgressBar();

            control1.Left = 0;
            control1.Top = 0;
            control1.Width = 20;
            control1.BlockColor = ConsoleColor.Yellow;

            screen.Controls.Add(control1);

            var control2 = new ProgressBar();

            control2.Left = 20;
            control2.Top = 10;
            control2.Width = 5;
            control2.BorderStyle = BorderStyle.Single;

            screen.Controls.Add(control2);

            var control3 = new ProgressBar();

            control3.Left = 35;
            control3.Top = 20;
            control3.Width = 30;
            control3.BorderStyle = BorderStyle.Double;
            control3.BlockColor = ConsoleColor.Red;
            control3.HasShadow = true;

            screen.Controls.Add(control3);

            var control4 = new ProgressBar();

            control4.Left = 0;
            control4.Top = 15;
            control4.Width = 30;
            control4.BorderStyle = BorderStyle.Double;
            control4.BlockColor = ConsoleColor.Green;
            control4.HasShadow = true;
            control4.ProgressBarStyle = ProgressBarStyle.Marquee;

            screen.Controls.Add(control4);

            screen.Footer.Text = screen.Name + ". Press any key.";

            screens.Add(screen);

            screen.Shown += (s, e) =>
            {
                while (control1.Value < control1.Maximum)
                {
                    Console.ReadKey(true);

                    control1.Increment(10);
                    control2.Increment(10);
                    control3.Increment(10);

                    screen.Footer.Text = string.Format("Value: {0}", control1.Value);
                }
            };
        }