32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using System;
|
|
using Eto.Forms;
|
|
using UpToolLib.DataStructures;
|
|
using UpToolLib.v2;
|
|
|
|
namespace UpToolEto.Controls
|
|
{
|
|
public class AppListSearchProvider : StackLayout
|
|
{
|
|
private readonly bool _online;
|
|
private readonly TextBox _search;
|
|
private readonly EnumDropDown<Status> _state;
|
|
|
|
public AppListSearchProvider(bool online, Action refresh)
|
|
{
|
|
_online = online;
|
|
_search = new SearchBox();
|
|
_state = new EnumDropDown<Status>();
|
|
_state.SelectedValue = online ? Status.NotInstalled : Status.Installed;
|
|
_state.Enabled = online;
|
|
_search.TextChanged += (_, _) => refresh();
|
|
_state.SelectedIndexChanged += (_, _) => refresh();
|
|
Orientation = Orientation.Vertical;
|
|
Items.Add(new StackLayoutItem(_search, HorizontalAlignment.Stretch));
|
|
Items.Add(_state);
|
|
}
|
|
|
|
public bool Matches(App app) => app.Status.Contains(_online ? _state.SelectedValue : Status.Installed);
|
|
|
|
public string GetSearchTerms() => _search.Text;
|
|
}
|
|
} |