/// <summary> /// Sets the next selection button and optionally sets the previous of the referenced selection to this button. /// </summary> /// <param name="nextSelection">The selection button to be used as next.</param> /// <param name="setPreviousOnNext">Sets the PreviousSelection property on the <paramref name="nextSelection"/> instance to current selection button. Defaults to true.</param> /// <returns></returns> public SelectionButton SetNextSelection(ref SelectionButton nextSelection, bool setPreviousOnNext = true) { NextSelection = nextSelection; if (setPreviousOnNext) nextSelection.PreviousSelection = this; return nextSelection; }
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; //} }
public SampleConsole( ) : base(50, 36) { Title = "Preview"; Global.FocusedConsoles.Push(this); var panel = new Panel(20, 2) { Fake3D = false }; panel.DrawPanel(); panel.Position = new Point(1, 24); panel.AddLine("This is a Panel."); Children.Add(panel); var button = new SadConsole.Controls.Button(11, 3) { Text = "Click", Position = new Point(1, 6), 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 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 = SadConsole.Controls.ScrollBar.Create(Orientation.Horizontal, 10); slider.Position = new Point(16, 3); slider.Maximum = 18; Add(slider); slider = SadConsole.Controls.ScrollBar.Create(Orientation.Vertical, 6); slider.Position = new Point(16, 7); slider.Maximum = 6; Add(slider); var listbox = new SadConsole.Controls.ListBox(20, 6); listbox.Position = new Point(28, 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 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(1, 15); Add(selButton); var selButton1 = new SadConsole.Controls.SelectionButton(24, 1); selButton1.Text = "Selection Button 2"; selButton1.Position = new Point(1, 16); Add(selButton1); var selButton2 = new SadConsole.Controls.SelectionButton(24, 1); selButton2.Text = "Selection Button 3"; selButton2.Position = new Point(1, 17); Add(selButton2); selButton.PreviousSelection = selButton2; selButton.NextSelection = selButton1; selButton1.PreviousSelection = selButton; selButton1.NextSelection = selButton2; selButton2.PreviousSelection = selButton1; selButton2.NextSelection = selButton; var input = new TextBox(20); input.Position = new Point(1, 20); Add(input); var checkbox = new SadConsole.Controls.CheckBox(13, 1) { Text = "Check box", Position = new Point(24, 20) }; Add(checkbox); }
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; //} }