public static Widget Explorer(ExplorerEntry explorer) { var widgets = new WidgetList(); // Gridformat is broken, cannot use foreach (var entry in explorer.GetDirectories()) { var label = Label(entry.Key); var spacer = new Widget(); spacer.Width = 30; //spacer.IsFixedWidth = true; var widget = new Widget().WithAddedBehavior(new GridFormat(2, 1)); widget[0, 0] = spacer; widget[1, 0] = label; widgets.Add(widget); } foreach (var entry in explorer.GetFiles()) { var widget = Label(entry.Key); widgets.Add(widget); } var result = new Widget(); result.AddRange(widgets); result.Behaviors.Add(new GridFormat(1, widgets.Count)); return(result); }
//public static Widget DropDown(IEnumerable<string> items, PopInOut pop_in_out_behavior = null) //{ // WidgetList widgets = new WidgetList(); // foreach (string item in items) widgets.Add(new Widget().WithAddedBehavior(new DrawText() { Text = item, ConstrainAreaToText = true })); // return DropDown(widgets, pop_in_out_behavior); //} public static Widget DropDown( IEnumerable <Widget> widgets, PopInOut pop_in_out_behavior = null ) { var widgets_ = widgets.ToList(); var dropdown = new Widget(); dropdown.VisualSettings.VisualRole = VisualRoleType.pop_up; dropdown.Behaviors.GroupBehaviors.AcceptancePolicy += GroupBehaviorAcceptancePolicy.NoUserScrolling; dropdown.MinimumSize = new Point2(1f, 1f); dropdown.AddRange(widgets_); dropdown.Behaviors.Add(new GridFormat(1, widgets_.Count)); dropdown.Behaviors.Add( pop_in_out_behavior ?? new PopInOut( RectanglePart.Uniform(0.95f, Directions2D.DLR), RectanglePart.Uniform(0f, Directions2D.D, 1f) ) { OpeningMotion = InterpolationSettings.Fast, ClosingMotion = InterpolationSettings.Faster } ); return(dropdown); }