mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
Stable sorting of ResultCollection (#5850)
* Stable sorting of ResultCollection * nit fixes for resultsViewModel and ResultCollection
This commit is contained in:
committed by
GitHub
parent
ac10c988b9
commit
2d2cb22806
@@ -4,6 +4,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -19,12 +20,12 @@ namespace PowerLauncher.ViewModel
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
public ResultCollection Results { get; }
|
||||
|
||||
private readonly object _collectionLock = new object();
|
||||
|
||||
private readonly Settings _settings;
|
||||
|
||||
// private int MaxResults => _settings?.MaxResultsToShow ?? 6;
|
||||
#endregion
|
||||
|
||||
public ResultsViewModel()
|
||||
{
|
||||
Results = new ResultCollection();
|
||||
@@ -46,8 +47,6 @@ namespace PowerLauncher.ViewModel
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public int MaxHeight
|
||||
@@ -90,6 +89,8 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
public Visibility Visibility { get; set; } = Visibility.Hidden;
|
||||
|
||||
public ResultCollection Results { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
@@ -238,6 +239,14 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
Results.AddRange(newResults);
|
||||
}
|
||||
|
||||
public void Sort()
|
||||
{
|
||||
var sorted = Results.OrderByDescending(x => x.Result.Score).ToList();
|
||||
Clear();
|
||||
Results.AddRange(sorted);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FormattedText Dependency Property
|
||||
|
||||
Reference in New Issue
Block a user