44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
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<Guid, App> _apps;
|
|
private readonly Action<Guid, App> _itemClickEvent;
|
|
private readonly StackLayout _layout;
|
|
|
|
public AppList(IDictionary<Guid, App> apps, Action<Guid, App> 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,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|