mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-05-17 19:02:18 +12:00
Moved _Click logic for installed filter to _Checked and _Unchecked. Added FilteredBySearch to fix a bug I introduced, SearchBar.Height does not update fast enough to be used in SearchFilter().
This commit is contained in:
parent
3fc3394070
commit
aef7b9f15d
|
@ -41,6 +41,7 @@ namespace VRCMelonAssistant.Pages
|
|||
public bool PendingChanges;
|
||||
public bool HaveInstalledMods;
|
||||
public bool FilteredToInstalled = false;
|
||||
public bool FilteredBySearch = false;
|
||||
|
||||
private readonly SemaphoreSlim _modsLoadSem = new SemaphoreSlim(1, 1);
|
||||
|
||||
|
@ -509,13 +510,19 @@ namespace VRCMelonAssistant.Pages
|
|||
SearchBar.Focus();
|
||||
Animate(SearchBar, 0, 16, new TimeSpan(0, 0, 0, 0, 300));
|
||||
Animate(SearchText, 0, 16, new TimeSpan(0, 0, 0, 0, 300));
|
||||
FilteredBySearch = true;
|
||||
ModsListView.Items.Filter = new Predicate<object>(SearchFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
Animate(SearchBar, 16, 0, new TimeSpan(0, 0, 0, 0, 300));
|
||||
Animate(SearchText, 16, 0, new TimeSpan(0, 0, 0, 0, 300));
|
||||
if (!FilteredToInstalled)
|
||||
FilteredBySearch = false;
|
||||
if (FilteredToInstalled)
|
||||
{
|
||||
ModsListView.Items.Filter = ModsListView.Items.Filter;
|
||||
}
|
||||
else
|
||||
{
|
||||
ModsListView.Items.Filter = null;
|
||||
}
|
||||
|
@ -524,7 +531,7 @@ namespace VRCMelonAssistant.Pages
|
|||
|
||||
private void SearchBar_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
ModsListView.Items.Filter = new Predicate<object>(SearchFilter);
|
||||
ModsListView.Items.Filter = ModsListView.Items.Filter;
|
||||
if (SearchBar.Text.Length > 0)
|
||||
{
|
||||
SearchText.Text = null;
|
||||
|
@ -539,7 +546,7 @@ namespace VRCMelonAssistant.Pages
|
|||
{
|
||||
ModListItem item = mod as ModListItem;
|
||||
if (FilteredToInstalled && !item.IsInstalled) return false;
|
||||
if (SearchBar.Height != 0)
|
||||
if (FilteredBySearch)
|
||||
{
|
||||
if (item.ModName.ToLower().Contains(SearchBar.Text.ToLower())) return true;
|
||||
if (item.ModDescription.ToLower().Contains(SearchBar.Text.ToLower())) return true;
|
||||
|
@ -550,16 +557,15 @@ namespace VRCMelonAssistant.Pages
|
|||
return true;
|
||||
}
|
||||
|
||||
private void InstalledButton_Click(object sender, RoutedEventArgs e)
|
||||
private void InstalledButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!FilteredToInstalled)
|
||||
{
|
||||
FilteredToInstalled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FilteredToInstalled = false;
|
||||
}
|
||||
FilteredToInstalled = true;
|
||||
ModsListView.Items.Filter = new Predicate<object>(SearchFilter);
|
||||
}
|
||||
|
||||
private void InstalledButton_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FilteredToInstalled = false;
|
||||
ModsListView.Items.Filter = new Predicate<object>(SearchFilter);
|
||||
}
|
||||
|
||||
|
@ -591,5 +597,6 @@ namespace VRCMelonAssistant.Pages
|
|||
if (selectedMod == null) return;
|
||||
MainWindow.ShowModInfoWindow(selectedMod.ModInfo);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue