mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
structure change
This commit is contained in:
@@ -7,6 +7,8 @@ namespace WinAlfred
|
||||
{
|
||||
public partial class ResultPanel : UserControl
|
||||
{
|
||||
public bool Dirty { get; set; }
|
||||
|
||||
public delegate void ResultItemsChanged();
|
||||
|
||||
public event ResultItemsChanged resultItemChangedEvent;
|
||||
@@ -19,7 +21,14 @@ namespace WinAlfred
|
||||
|
||||
public void AddResults(List<Result> results)
|
||||
{
|
||||
pnlContainer.Children.Clear();
|
||||
if (results.Count == 0) return;
|
||||
|
||||
if (Dirty)
|
||||
{
|
||||
Dirty = false;
|
||||
pnlContainer.Children.Clear();
|
||||
}
|
||||
|
||||
for (int i = 0; i < results.Count; i++)
|
||||
{
|
||||
Result result = results[i];
|
||||
@@ -41,6 +50,11 @@ namespace WinAlfred
|
||||
OnResultItemChangedEvent();
|
||||
}
|
||||
|
||||
public int GetCurrentResultCount()
|
||||
{
|
||||
return pnlContainer.Children.Count;
|
||||
}
|
||||
|
||||
private int GetCurrentSelectedResultIndex()
|
||||
{
|
||||
for (int i = 0; i < pnlContainer.Children.Count; i++)
|
||||
@@ -114,7 +128,7 @@ namespace WinAlfred
|
||||
if (index < oldIndex)
|
||||
{
|
||||
//move up and old item is at the top of the scroll view
|
||||
if ( newItemBottomPoint.Y - sv.VerticalOffset == 0)
|
||||
if (newItemBottomPoint.Y - sv.VerticalOffset == 0)
|
||||
{
|
||||
scrollPosition = sv.VerticalOffset - resultItemControl.ActualHeight;
|
||||
}
|
||||
@@ -160,5 +174,12 @@ namespace WinAlfred
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
pnlContainer.Children.Clear();
|
||||
pnlContainer.Height = 0;
|
||||
OnResultItemChangedEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user