mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-15 20:19:17 +08:00
15c5e9833a
1. bring history back, disabled in 56d08663410916df0a4e408da6e4af3d2a2722c0 2. fix #632 #722 3. hotkey: ctrl+H
38 lines
880 B
C#
38 lines
880 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Newtonsoft.Json;
|
|
using Wox.Plugin;
|
|
|
|
namespace Wox.Storage
|
|
{
|
|
public class History
|
|
{
|
|
public List<HistoryItem> Items { get; set; } = new List<HistoryItem>();
|
|
|
|
private int _maxHistory = 300;
|
|
|
|
public void Add(string query)
|
|
{
|
|
if (string.IsNullOrEmpty(query)) return;
|
|
if (Items.Count > _maxHistory)
|
|
{
|
|
Items.RemoveAt(0);
|
|
}
|
|
|
|
if (Items.Count > 0 && Items.Last().Query == query)
|
|
{
|
|
Items.Last().ExecutedDateTime = DateTime.Now;
|
|
}
|
|
else
|
|
{
|
|
Items.Add(new HistoryItem
|
|
{
|
|
Query = query,
|
|
ExecutedDateTime = DateTime.Now
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|