using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GrasscutterTools.Utils
{
public static class UIUtil
{
///
/// 播放按钮完成动画
///
///
///
public static async Task ButtonComplete(Button btn)
{
var t = btn.Text;
btn.Text = "√";
btn.Enabled = false;
await Task.Delay(300);
btn.Text = t;
btn.Enabled = true;
}
///
/// 列表过滤
///
/// 列表控件
/// 数据源
/// 过滤内容
public static void ListBoxFilter(ListBox listBox, string[] source, string filter)
{
filter = filter.Trim();
listBox.BeginUpdate();
listBox.Items.Clear();
if (source != null && source.Length > 0)
{
if (string.IsNullOrEmpty(filter))
listBox.Items.AddRange(source);
else
listBox.Items.AddRange(source.Where(n => n.Contains(filter)).ToArray());
}
listBox.EndUpdate();
}
}
}