Exemplo 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);
        }
Exemplo n.º 2
0
        internal static void SetupMenu(ScreenCollection screens)
        {
            var screen = new Screen("Menus");
            MenuBar menuBar = SetupMenuBar(screen);

            screen.Controls.Add(menuBar);

            screens.Add(screen);
        }
Exemplo n.º 3
0
        private static void DoubleBorderListBoxScreen(ScreenCollection screens)
        {
            var screen = new Screen("Double Border List Boxes");

            var control1 = new ListBox();

            control1.Left = 0;
            control1.Top = 0;
            control1.Width = 20;
            control1.Height = 10;
            control1.BorderStyle = BorderStyle.Double;
            control1.HasShadow = true;

            for (int i = 0; i < 20; i++)
            {
                control1.Items.Add(string.Format("Item {0}", i + 1));
            }

            var control2 = new ListBox();

            control2.Left = 30;
            control2.Top = 0;
            control2.Width = 30;
            control2.Height = 15;
            control2.BorderStyle = BorderStyle.Double;
            control2.HasShadow = true;

            for (int i = 0; i < 40; i++)
            {
                control2.Items.Add(string.Format("Item {0}", i + 1));
            }

            var control3 = new ListBox();

            control3.Left = 0;
            control3.Top = 11;
            control3.Width = 25;
            control3.Height = 10;
            control3.BorderStyle = BorderStyle.Double;
            control3.HasShadow = true;

            for (int i = 0; i < 5; i++)
            {
                control3.Items.Add(string.Format("Item {0}", i + 1));
            }

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

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

            screens.Add(screen);
        }
Exemplo n.º 4
0
        private static void SetupEditMenu(Screen screen, MenuBar menuBar)
        {
            var menu = new Menu(screen);
            menu.Text = "Edit";

            AddMenuItem(menu, "Cut");
            AddMenuItem(menu, "Copy");
            menu.AddSeparator();
            AddMenuItem(menu, "Paste");

            menuBar.Menus.Add(menu);
        }
Exemplo n.º 5
0
        internal static MenuBar SetupMenuBar(Screen screen)
        {
            var menuBar = new MenuBar(screen);
            menuBar.Left = 0;
            menuBar.Top = 0;
            menuBar.Width = screen.Width;

            SetupFileMenu(screen, menuBar);
            SetupEditMenu(screen, menuBar);
            SetupViewMenu(screen, menuBar);

            return menuBar;
        }
Exemplo n.º 6
0
        private static void SetupFileMenu(Screen screen, MenuBar menuBar)
        {
            var menu = new Menu(screen);
            menu.Text = "File";

            AddMenuItem(menu, "New");
            AddMenuItem(menu, "Open");
            menu.AddSeparator();
            AddMenuItem(menu, "Save");
            menu.AddSeparator();
            AddMenuItem(menu, "Close");

            menuBar.Menus.Add(menu);
        }
Exemplo n.º 7
0
        private static void SetupViewMenu(Screen screen, MenuBar menuBar)
        {
            var menu = new Menu(screen);
            menu.Text = "Animals";

            AddMenuItem(menu, "Dog");
            AddMenuItem(menu, "Cat");
            menu.AddSeparator();
            AddMenuItem(menu, "Mouse");
            menu.AddSeparator();
            AddMenuItem(menu, "Monkey");
            menu.AddSeparator();
            AddMenuItem(menu, "Horse");
            menu.AddSeparator();
            AddMenuItem(menu, "Hummingbird hawk-moth");

            menuBar.Menus.Add(menu);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        private static void DoubleBorderLabelScreen(ScreenCollection screens)
        {
            var screen = new Screen("Double Border Labels");

            var control1 = new Label("This is a left aligned label (full width, double border).");

            control1.Left = 0;
            control1.Top = 0;
            control1.Width = screen.Width;
            control1.BorderStyle = BorderStyle.Double;

            var control2 = new Label("This is a centered label (full width, double border).");

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

            var control3 = new Label("This is a right aligned label (full width, double border).");

            control3.Left = 0;
            control3.Top = control2.Top + control2.Height;
            control3.Width = screen.Width;
            control3.TextAlign = TextAlign.Right;
            control3.BorderStyle = BorderStyle.Double;

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

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

            screens.Add(screen);

            screen.AfterPaint += (s, e) =>
            {
                Console.ReadKey(true);
            };
        }
Exemplo n.º 10
0
        private static void ShadowLabelScreen(ScreenCollection screens)
        {
            var screen = new Screen("Basic Labels");

            var control1 = new Label("This is a left aligned label (shadow, no border).");

            control1.Left = 0;
            control1.Top = 0;
            control1.Width = screen.Width - 2;

            var control2 = new Label("This is a centered label (shadow, no border).");

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

            var control3 = new Label("This is a right aligned label (shadow, full width, no border).");

            control3.Left = 0;
            control3.Top = control2.Top + control2.Height + 2;
            control3.Width = screen.Width;
            control3.TextAlign = TextAlign.Right;

            control1.HasShadow = true;
            control2.HasShadow = true;
            control3.HasShadow = true;

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

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

            screens.Add(screen);

            screen.AfterPaint += (s, e) =>
            {
                Console.ReadKey(true);
            };
        }
Exemplo n.º 11
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;
            };
        }
Exemplo n.º 12
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);
                }
            };
        }
Exemplo n.º 13
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);
        }