Exemple #1
0
        public ControlsTest() : base(80, 25)
        {
            IsVisible = false;


            var button1 = new SadConsole.Controls.Button(11, 1);

            button1.Text           = "Click";
            button1.Position       = new Point(1, 3);
            button1.ButtonClicked += (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, 5);
            Add(radioButton);

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

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

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

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

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

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

            listbox.Position   = new Point(25, 3);
            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, 10);
            slider.Maximum  = 18;
            Add(slider);

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

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

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

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

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

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

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

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

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

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

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

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

            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 SerializationTests()
        {
            controlsConsole = new ControlsConsole(80, 4);

            masterView = new Console(34, 15);
            loadedView = new Console(34, 15);

            masterView.Fill(Color.White, Color.Red, 0);
            loadedView.Fill(Color.White, Color.Blue, 0);

            UseMouse = true;

            // Add the consoles to the list.
            Children.Add(controlsConsole);
            Children.Add(masterView);
            Children.Add(loadedView);

            // Setup main view
            masterView.Position = new Point(3, 6);

            // Setup sub view
            loadedView.Position = new Point(80 - 37, 6);


            // Setup controls
            controlsConsole.Position = new Point(0, 0);

            optionButtonSurface = new SadConsole.Controls.RadioButton(18, 1)
            {
                Text     = "Surface",
                Position = new Point(1, 1),
            };
            optionButtonSurface.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonSurface);

            optionButtonView = new SadConsole.Controls.RadioButton(18, 1)
            {
                Text     = "Surface View",
                Position = new Point(1, 2)
            };
            optionButtonView.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonView);

            optionButtonLayered = new SadConsole.Controls.RadioButton(21, 1)
            {
                Text     = "Layered Surface",
                Position = new Point(optionButtonSurface.Bounds.Right + 1, 1)
            };
            optionButtonLayered.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonLayered);

            optionButtonAnimated = new SadConsole.Controls.RadioButton(21, 1)
            {
                Text     = "Animated Surface",
                Position = new Point(optionButtonSurface.Bounds.Right + 1, 2)
            };
            optionButtonAnimated.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonAnimated);

            var buttonSave = new SadConsole.Controls.Button(17)
            {
                Text     = "Save and Load",
                Position = new Point(controlsConsole.Width - 19, 1)
            };

            buttonSave.Click += ButtonSave_Click;
            controlsConsole.Add(buttonSave);

            basicSurface    = new SadConsole.Surfaces.BasicSurface(34, 15);
            layeredSurface  = new SadConsole.Surfaces.LayeredSurface(34, 15, 3);
            animatedSurface = SadConsole.GameHelpers.Animations.CreateStatic(34, 15, 15, 0.3d);
            viewSurface     = new SadConsole.Surfaces.SurfaceView(basicSurface, new Rectangle(5, 2, 34 - 10, 15 - 4));
            emptySurface    = (SadConsole.Surfaces.BasicSurface)loadedView.TextSurface;

            MakeBasicSurface();
            MakeLayeredSurface();
        }
Exemple #3
0
        public ControlsTest()
            : base(80, 25)
        {
            IsVisible = false;

            var button1 = new SadConsole.Controls.Button(11);
            button1.Text = "Click";
            button1.Position = new Point(1, 3);
            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, 5);
            Add(radioButton);

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

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

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

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

            var listbox = new SadConsole.Controls.ListBox(20, 6);
            listbox.Position = new Point(25, 3);
            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, 10);
            slider.Maximum = 18;
            Add(slider);

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

            var input = new SadConsole.Controls.InputBox(20);
            input.Position = new Point(25, 12);
            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;
            //}
        }