using System; using System.Collections.Generic; using Eto.Drawing; using Eto.Forms; using UpToolLib.v2; namespace UpToolEto.Controls { public class AppList : Scrollable { private readonly IDictionary _apps; private readonly Action _itemClickEvent; private readonly StackLayout _layout; public AppList(IDictionary apps, Action itemClickEvent) { _apps = apps; _itemClickEvent = itemClickEvent; _layout = new StackLayout { Padding = 10, Orientation = Orientation.Vertical, Width = 200 }; Content = _layout; Update(); } public void Update() { _layout.Items.Clear(); foreach ((Guid id, App app) in _apps) { _layout.Items.Add(new Button((_, _) => _itemClickEvent(id, app)) { Text = app.Name, Image = (Icon)app.Icon, ImagePosition = ButtonImagePosition.Left, }); } } } }