Exemple #1
0
        public ControlsTest() : base(80, 23)
        {
            var button1 = new SadConsole.Controls.Button(11);

            button1.Text     = "Click";
            button1.Position = new Point(1, 1);
            button1.Click   += (s, e) => Window.Message("Clicked!", "OK");
            Add(button1);

            var radioButton = new SadConsole.Controls.RadioButton(20, 1);

            radioButton.Text     = "Group 1 Option 1";
            radioButton.Position = new Point(1, 3);
            Add(radioButton);

            radioButton          = new SadConsole.Controls.RadioButton(20, 1);
            radioButton.Text     = "Group 1 Option 2";
            radioButton.Position = new Point(1, 4);
            Add(radioButton);

            radioButton           = new SadConsole.Controls.RadioButton(20, 1);
            radioButton.Text      = "Group 2 Option 1";
            radioButton.Position  = new Point(1, 6);
            radioButton.GroupName = "group2";
            Add(radioButton);

            radioButton           = new SadConsole.Controls.RadioButton(20, 1);
            radioButton.Text      = "Group 2 Option 2";
            radioButton.Position  = new Point(1, 7);
            radioButton.GroupName = "group2";
            Add(radioButton);

            var checkbox = new SadConsole.Controls.CheckBox(13, 1);

            checkbox.Text     = "Check box";
            checkbox.Position = new Point(1, 9);
            Add(checkbox);

            var prog = new SadConsole.Controls.ProgressBar(10, 1, System.Windows.HorizontalAlignment.Left);

            prog.Position = new Point(checkbox.Bounds.Left, checkbox.Bounds.Bottom + 1);
            Add(prog);

            progressTimer = new Timer(0.5, (timer, time) => { prog.Progress = prog.Progress >= 1f ? 0f : prog.Progress + 0.1f; });

            var listbox = new SadConsole.Controls.ListBox(20, 6);

            listbox.Position   = new Point(25, 1);
            listbox.HideBorder = false;
            listbox.Items.Add("item 1");
            listbox.Items.Add("item 2");
            listbox.Items.Add("item 3");
            listbox.Items.Add("item 4");
            listbox.Items.Add("item 5");
            listbox.Items.Add("item 6");
            listbox.Items.Add("item 7");
            listbox.Items.Add("item 8");
            Add(listbox);

            var slider = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Horizontal, 20);

            slider.Position = new Point(25, 7);
            slider.Maximum  = 18;
            Add(slider);

            slider          = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, 8);
            slider.Position = new Point(47, 1);
            slider.Maximum  = 6;
            Add(slider);

            var input = new SadConsole.Controls.InputBox(20);

            input.Position = new Point(25, 9);
            Add(input);

            var selButton = new SadConsole.Controls.SelectionButton(20);

            selButton.Text     = "Selection Button 1";
            selButton.Position = new Point(55, 3);
            Add(selButton);

            var selButton1 = new SadConsole.Controls.SelectionButton(20);

            selButton1.Text     = "Selection Button 2";
            selButton1.Position = new Point(55, 4);
            Add(selButton1);

            var selButton2 = new SadConsole.Controls.SelectionButton(20);

            selButton2.Text     = "Selection Button 3";
            selButton2.Position = new Point(55, 5);
            Add(selButton2);

            var selButton3 = new SadConsole.Controls.SelectionButton(20);

            selButton3.Text     = "Selection Button 4";
            selButton3.Position = new Point(55, 6);
            Add(selButton3);

            var selButton4 = new SadConsole.Controls.SelectionButton(20);

            selButton4.Text     = "Selection Button 5";
            selButton4.Position = new Point(55, 7);
            Add(selButton4);

            selButton.PreviousSelection  = selButton4;
            selButton.NextSelection      = selButton1;
            selButton1.PreviousSelection = selButton;
            selButton1.NextSelection     = selButton2;
            selButton2.PreviousSelection = selButton1;
            selButton2.NextSelection     = selButton3;
            selButton3.PreviousSelection = selButton2;
            selButton3.NextSelection     = selButton4;
            selButton4.PreviousSelection = selButton3;
            selButton4.NextSelection     = selButton;

            FocusedControl = null;
            //DisableControlFocusing = true;

            List <Tuple <Color, string> > colors = new List <Tuple <Color, string> >();

            colors.Add(new Tuple <Color, string>(StarterProject.Theme.Red, "Red"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.RedDark, "DRed"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.Purple, "Prp"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.PurpleDark, "DPrp"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.Blue, "Blu"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.BlueDark, "DBlu"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.Cyan, "Cya"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.CyanDark, "DCya"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.Green, "Gre"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.GreenDark, "DGre"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.Yellow, "Yel"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.YellowDark, "DYel"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.Orange, "Ora"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.OrangeDark, "DOra"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.Brown, "Bro"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.BrownDark, "DBrow"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.Gray, "Gray"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.GrayDark, "DGray"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.White, "White"));
            colors.Add(new Tuple <Color, string>(StarterProject.Theme.Black, "Black"));

            backgroundcycle = colors.Select(i => i.Item1).ToArray();
            backIndex       = 5;


            //int y = 25 - 20;
            //int x = 0;
            //int colorLength = 4;
            //foreach (var color1 in colors)
            //{
            //    foreach (var color2 in colors)
            //    {
            //        _Print(x, y, new ColoredString(color2.Item2.PadRight(colorLength).Substring(0, colorLength), color2.Item1, color1.Item1, null));
            //        y++;
            //    }

            //    y = 25 -20;
            //    x += colorLength;
            //}
        }
Exemple #2
0
        public ControlsTest() : base(80, 23)
        {
            //ThemeColors = SadConsole.Themes.Colors.CreateFromAnsi();

            var prog1 = new ProgressBar(10, 1, HorizontalAlignment.Left)
            {
                Position = new Point(16, 5)
            };

            Add(prog1);

            var prog2 = new ProgressBar(1, 6, VerticalAlignment.Bottom)
            {
                Position = new Point(18, 7)
            };

            Add(prog2);

            var slider = new ScrollBar(Orientation.Horizontal, 10)
            {
                Position = new Point(16, 3),
                Maximum  = 18
            };

            Add(slider);

            slider = new ScrollBar(Orientation.Vertical, 6)
            {
                Position = new Point(16, 7),
                Maximum  = 6
            };
            Add(slider);

            progressTimer = new Timer(TimeSpan.FromSeconds(0.5));
            progressTimer.TimerElapsed += (timer, e) => { prog1.Progress = prog1.Progress >= 1f ? 0f : prog1.Progress + 0.1f; prog2.Progress = prog2.Progress >= 1f ? 0f : prog2.Progress + 0.1f; };

            Components.Add(progressTimer);

            var listbox = new SadConsole.Controls.ListBox(20, 6)
            {
                Position = new Point(28, 3)
            };

            listbox.Items.Add("item 1");
            listbox.Items.Add("item 2");
            listbox.Items.Add("item 3");
            listbox.Items.Add("item 4");
            listbox.Items.Add("item 5");
            listbox.Items.Add("item 6");
            listbox.Items.Add("item 7");
            listbox.Items.Add("item 8");
            Add(listbox);

            var radioButton = new RadioButton(20, 1)
            {
                Text     = "Group 1 Option 1",
                Position = new Point(28, 12)
            };

            Add(radioButton);

            radioButton = new RadioButton(20, 1)
            {
                Text     = "Group 1 Option 2",
                Position = new Point(28, 13)
            };
            Add(radioButton);

            var selButton = new SadConsole.Controls.SelectionButton(24, 1)
            {
                Text     = "Selection Button 1",
                Position = new Point(51, 3)
            };

            Add(selButton);

            var selButton1 = new SadConsole.Controls.SelectionButton(24, 1)
            {
                Text     = "Selection Button 2",
                Position = new Point(51, 4)
            };

            Add(selButton1);

            var selButton2 = new SadConsole.Controls.SelectionButton(24, 1)
            {
                Text     = "Selection Button 3",
                Position = new Point(51, 5)
            };

            Add(selButton2);

            selButton.PreviousSelection  = selButton2;
            selButton.NextSelection      = selButton1;
            selButton1.PreviousSelection = selButton;
            selButton1.NextSelection     = selButton2;
            selButton2.PreviousSelection = selButton1;
            selButton2.NextSelection     = selButton;

            var input = new TextBox(10)
            {
                Position = new Point(51, 9)
            };

            Add(input);

            var password = new TextBox(10)
            {
                PasswordChar = "*",
                Position     = new Point(65, 9)
            };

            Add(password);

            var button = new SadConsole.Controls.Button(11, 1)
            {
                Text     = "Click",
                Position = new Point(1, 3)
            };

            button.Click += (s, a) => Window.Message("This has been clicked -- and your password field contains '" + password.Text + "'", "Close");
            Add(button);

            button = new SadConsole.Controls.Button(11, 3)
            {
                Text     = "Click",
                Position = new Point(1, 5),
                Theme    = new Button3dTheme()
            };
            //button.AlternateFont = SadConsole.Global.LoadFont("Fonts/Cheepicus12.font").GetFont(Font.FontSizes.One);
            Add(button);

            button = new SadConsole.Controls.Button(11, 3)
            {
                Text     = "Click",
                Position = new Point(1, 10),
                Theme    = new ButtonLinesTheme()
            };
            Add(button);

            var checkbox = new SadConsole.Controls.CheckBox(13, 1)
            {
                Text     = "Check box",
                Position = new Point(51, 13)
            };

            Add(checkbox);

            FocusedControl = null;
            //DisableControlFocusing = true;

            var colorValues = ThemeColors ?? Library.Default.Colors;

            List <Tuple <Color, string> > colors = new List <Tuple <Color, string> >
            {
                new Tuple <Color, string>(colorValues.Red, "Red"),
                new Tuple <Color, string>(colorValues.RedDark, "DRed"),
                new Tuple <Color, string>(colorValues.Purple, "Prp"),
                new Tuple <Color, string>(colorValues.PurpleDark, "DPrp"),
                new Tuple <Color, string>(colorValues.Blue, "Blu"),
                new Tuple <Color, string>(colorValues.BlueDark, "DBlu"),
                new Tuple <Color, string>(colorValues.Cyan, "Cya"),
                new Tuple <Color, string>(colorValues.CyanDark, "DCya"),
                new Tuple <Color, string>(colorValues.Green, "Gre"),
                new Tuple <Color, string>(colorValues.GreenDark, "DGre"),
                new Tuple <Color, string>(colorValues.Yellow, "Yel"),
                new Tuple <Color, string>(colorValues.YellowDark, "DYel"),
                new Tuple <Color, string>(colorValues.Orange, "Ora"),
                new Tuple <Color, string>(colorValues.OrangeDark, "DOra"),
                new Tuple <Color, string>(colorValues.Brown, "Bro"),
                new Tuple <Color, string>(colorValues.BrownDark, "DBrow"),
                new Tuple <Color, string>(colorValues.Gray, "Gray"),
                new Tuple <Color, string>(colorValues.GrayDark, "DGray"),
                new Tuple <Color, string>(colorValues.White, "White"),
                new Tuple <Color, string>(colorValues.Black, "Black")
            };

            backgroundcycle = colors.Select(i => i.Item1).ToArray();
            backIndex       = 5;

            // Ensure our color changes take affect.
            Invalidate();

            //int y = 25 - 20;
            //int x = 0;
            //int colorLength = 4;
            //foreach (var color1 in colors)
            //{
            //    foreach (var color2 in colors)
            //    {
            //        _Print(x, y, new ColoredString(color2.Item2.PadRight(colorLength).Substring(0, colorLength), color2.Item1, color1.Item1, null));
            //        y++;
            //    }

            //    y = 25 -20;
            //    x += colorLength;
            //}
        }
Exemple #3
0
        public ControlsTest() : base(80, 23)
        {
            var prog1 = new ProgressBar(10, 1, HorizontalAlignment.Left);

            prog1.Position = new Point(16, 5);
            Add(prog1);

            var prog2 = new ProgressBar(1, 6, VerticalAlignment.Bottom);

            prog2.Position = new Point(18, 7);
            Add(prog2);

            var slider = new ScrollBar(Orientation.Horizontal, 10);

            slider.Position = new Point(16, 3);
            slider.Maximum  = 18;
            Add(slider);

            slider          = new ScrollBar(Orientation.Vertical, 6);
            slider.Position = new Point(16, 7);
            slider.Maximum  = 6;
            Add(slider);

            progressTimer = new Timer(0.5, (timer, time) => { prog1.Progress = prog1.Progress >= 1f ? 0f : prog1.Progress + 0.1f; prog2.Progress = prog2.Progress >= 1f ? 0f : prog2.Progress + 0.1f; });

            var listbox = new SadConsole.Controls.ListBox(20, 6);

            listbox.Position = new Point(28, 3);
            listbox.Items.Add("item 1");
            listbox.Items.Add("item 2");
            listbox.Items.Add("item 3");
            listbox.Items.Add("item 4");
            listbox.Items.Add("item 5");
            listbox.Items.Add("item 6");
            listbox.Items.Add("item 7");
            listbox.Items.Add("item 8");
            Add(listbox);

            var radioButton = new RadioButton(20, 1);

            radioButton.Text     = "Group 1 Option 1";
            radioButton.Position = new Point(28, 12);
            Add(radioButton);

            radioButton          = new RadioButton(20, 1);
            radioButton.Text     = "Group 1 Option 2";
            radioButton.Position = new Point(28, 13);
            Add(radioButton);

            var selButton = new SadConsole.Controls.SelectionButton(24, 1);

            selButton.Text     = "Selection Button 1";
            selButton.Position = new Point(51, 3);
            Add(selButton);

            var selButton1 = new SadConsole.Controls.SelectionButton(24, 1);

            selButton1.Text     = "Selection Button 2";
            selButton1.Position = new Point(51, 4);
            Add(selButton1);

            var selButton2 = new SadConsole.Controls.SelectionButton(24, 1);

            selButton2.Text     = "Selection Button 3";
            selButton2.Position = new Point(51, 5);
            Add(selButton2);

            selButton.PreviousSelection  = selButton2;
            selButton.NextSelection      = selButton1;
            selButton1.PreviousSelection = selButton;
            selButton1.NextSelection     = selButton2;
            selButton2.PreviousSelection = selButton1;
            selButton2.NextSelection     = selButton;

            var input = new TextBox(10);

            input.Position = new Point(51, 9);
            Add(input);

            var password = new TextBox(10);

            password.PasswordChar = "*";
            password.Position     = new Point(65, 9);
            Add(password);

            var button = new SadConsole.Controls.Button(11, 1)
            {
                Text     = "Click",
                Position = new Point(1, 3)
            };

            button.Click += (s, a) => Window.Message("This has been clicked -- and your password field contains '" + password.Text + "'", "Close");
            Add(button);

            button = new SadConsole.Controls.Button(11, 3)
            {
                Text     = "Click",
                Position = new Point(1, 5),
                Theme    = new Button3dTheme()
            };
            Add(button);

            button = new SadConsole.Controls.Button(11, 3)
            {
                Text     = "Click",
                Position = new Point(1, 10),
                Theme    = new ButtonLinesTheme()
            };
            Add(button);

            var checkbox = new SadConsole.Controls.CheckBox(13, 1)
            {
                Text     = "Check box",
                Position = new Point(51, 13)
            };

            Add(checkbox);

            FocusedControl = null;
            //DisableControlFocusing = true;

            List <Tuple <Color, string> > colors = new List <Tuple <Color, string> >();

            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Red, "Red"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.RedDark, "DRed"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Purple, "Prp"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.PurpleDark, "DPrp"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Blue, "Blu"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.BlueDark, "DBlu"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Cyan, "Cya"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.CyanDark, "DCya"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Green, "Gre"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.GreenDark, "DGre"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Yellow, "Yel"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.YellowDark, "DYel"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Orange, "Ora"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.OrangeDark, "DOra"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Brown, "Bro"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.BrownDark, "DBrow"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Gray, "Gray"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.GrayDark, "DGray"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.White, "White"));
            colors.Add(new Tuple <Color, string>(Library.Default.Colors.Black, "Black"));

            backgroundcycle = colors.Select(i => i.Item1).ToArray();
            backIndex       = 5;


            //int y = 25 - 20;
            //int x = 0;
            //int colorLength = 4;
            //foreach (var color1 in colors)
            //{
            //    foreach (var color2 in colors)
            //    {
            //        _Print(x, y, new ColoredString(color2.Item2.PadRight(colorLength).Substring(0, colorLength), color2.Item1, color1.Item1, null));
            //        y++;
            //    }

            //    y = 25 -20;
            //    x += colorLength;
            //}
        }