Added filter when you click on the "Installed" header, currently does not work with search

This commit is contained in:
BlazyNights 2022-03-22 21:06:39 -07:00
parent 992480facc
commit e098a22f14
2 changed files with 35 additions and 1 deletions

View file

@ -91,7 +91,19 @@
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn x:Name="InstalledColumn" Header="{DynamicResource Mods:Header:Installed}">
<GridViewColumn x:Name="InstalledColumn">
<GridViewColumn.Header>
<Button
Name="InstalledButton"
Margin="-5"
Padding="9,-1,9,0"
Background="#00000000"
BorderThickness="0"
Click="InstalledButton_Click"
Content="{DynamicResource Mods:Header:Installed}"
FontSize="11"
/>
</GridViewColumn.Header>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock

View file

@ -40,6 +40,7 @@ namespace VRCMelonAssistant.Pages
public CollectionView view;
public bool PendingChanges;
public bool HaveInstalledMods;
public bool FilteredToInstalled = false;
private readonly SemaphoreSlim _modsLoadSem = new SemaphoreSlim(1, 1);
@ -541,6 +542,27 @@ namespace VRCMelonAssistant.Pages
return false;
}
private void InstalledButton_Click(object sender, RoutedEventArgs e)
{
if (!FilteredToInstalled)
{
FilteredToInstalled = true;
ModsListView.Items.Filter = new Predicate<object>(InstalledFilter);
}
else
{
ModsListView.Items.Filter = null;
FilteredToInstalled = false;
}
}
private bool InstalledFilter(object mod)
{
ModListItem item = mod as ModListItem;
if (item.IsInstalled) return true;
return false;
}
private void Animate(TextBlock target, double oldHeight, double newHeight, TimeSpan duration)
{
target.Height = oldHeight;