This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
UpTool2/UpToolEto/UpToolEto/Controls/AppList.cs

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,
});
}
}
}
}