mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02:00
Add top most function.
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Wox.Helper;
|
||||
using Wox.Plugin;
|
||||
using Wox.Storage;
|
||||
using UserControl = System.Windows.Controls.UserControl;
|
||||
|
||||
namespace Wox
|
||||
@@ -34,7 +35,6 @@ namespace Wox
|
||||
|
||||
public void AddResults(List<Result> results)
|
||||
{
|
||||
|
||||
if (Dirty)
|
||||
{
|
||||
Dirty = false;
|
||||
@@ -42,13 +42,30 @@ namespace Wox
|
||||
}
|
||||
foreach (var result in results)
|
||||
{
|
||||
int position = GetInsertLocation(result.Score);
|
||||
int position = 0;
|
||||
if (IsTopMostResult(result))
|
||||
{
|
||||
result.Score = int.MaxValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.Score >= int.MaxValue)
|
||||
{
|
||||
result.Score = int.MaxValue - 1;
|
||||
}
|
||||
position = GetInsertLocation(result.Score);
|
||||
}
|
||||
lbResults.Items.Insert(position, result);
|
||||
}
|
||||
lbResults.Margin = lbResults.Items.Count > 0 ? new Thickness { Top = 8 } : new Thickness { Top = 0 };
|
||||
SelectFirst();
|
||||
}
|
||||
|
||||
private bool IsTopMostResult(Result result)
|
||||
{
|
||||
return TopMostRecordStorage.Instance.IsTopMost(result);
|
||||
}
|
||||
|
||||
private int GetInsertLocation(int currentScore)
|
||||
{
|
||||
int location = lbResults.Items.Count;
|
||||
|
||||
Reference in New Issue
Block a user