using System; using ElmSharp; namespace ElmSharp.Test { public class PanelTest2 : TestCaseBase { public override string TestName => "PanelTest2"; public override string TestDescription => "To test basic operation of Panel"; public override void Run(Window window) { Conformant conformant = new Conformant(window); conformant.Show(); Box box = new Box(window); conformant.SetContent(box); box.Show(); Label label = new Label(window) { Text = "Panel as Scrollable", AlignmentX = -1, WeightX = 1, }; label.Show(); box.PackEnd(label); Panel panel = new Panel(window) { Direction = PanelDirection.Left, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; panel.SetScrollable(true); panel.SetScrollableArea(1.0); Rectangle redbox = new Rectangle(window) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, Color = Color.Red, }; redbox.Show(); panel.SetContent(redbox); panel.Show(); panel.IsOpen = true; box.PackEnd(panel); Button button1 = new Button(window) { Text = "Toggle open", AlignmentX = -1, AlignmentY = -1, WeightX = 1, }; Button button2 = new Button(window) { Text = "Toggle direction", AlignmentX = -1, AlignmentY = -1, WeightX = 1, }; box.PackEnd(button1); box.PackEnd(button2); button1.Show(); button2.Show(); button1.Clicked += (s, e) => { panel.Toggle(); }; button2.Clicked += (s, e) => { panel.Direction = (PanelDirection)((int)(panel.Direction + 1) % 4); }; panel.Toggled += (s, e) => { Console.WriteLine("Panel Toggled!"); }; } } }