mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-06-16 09:25:25 +12:00
Merge 12002dcc76
into 992480facc
This commit is contained in:
commit
42f57b0eb8
|
@ -91,7 +91,20 @@
|
|||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn x:Name="InstalledColumn" Header="{DynamicResource Mods:Header:Installed}">
|
||||
<GridViewColumn x:Name="InstalledColumn">
|
||||
<GridViewColumn.Header>
|
||||
<CheckBox
|
||||
Name="InstalledButton"
|
||||
Margin="7,-5,-5,-5"
|
||||
Padding="9,-1,9,0"
|
||||
Background="#00000000"
|
||||
BorderThickness="0"
|
||||
Content="{DynamicResource Mods:Header:Installed}"
|
||||
FontSize="11"
|
||||
IsChecked="False"
|
||||
Checked="InstalledButton_Checked"
|
||||
Unchecked="InstalledButton_Unchecked" />
|
||||
</GridViewColumn.Header>
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
|
|
|
@ -40,6 +40,8 @@ namespace VRCMelonAssistant.Pages
|
|||
public CollectionView view;
|
||||
public bool PendingChanges;
|
||||
public bool HaveInstalledMods;
|
||||
public bool FilteredToInstalled = false;
|
||||
public bool FilteredBySearch = false;
|
||||
|
||||
private readonly SemaphoreSlim _modsLoadSem = new SemaphoreSlim(1, 1);
|
||||
|
||||
|
@ -508,19 +510,29 @@ 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));
|
||||
FilteredBySearch = false;
|
||||
if (FilteredToInstalled)
|
||||
{
|
||||
ModsListView.Items.Filter = ModsListView.Items.Filter;
|
||||
}
|
||||
// Only null this if both filters (search and installed) are off
|
||||
else
|
||||
{
|
||||
ModsListView.Items.Filter = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -534,12 +546,31 @@ namespace VRCMelonAssistant.Pages
|
|||
private bool SearchFilter(object mod)
|
||||
{
|
||||
ModListItem item = mod as ModListItem;
|
||||
// If the installed filter is on, don't search the text of mods that aren't installed
|
||||
if (FilteredToInstalled && !item.IsInstalled) return false;
|
||||
// SearchBar.Height does not adjust fast enough to be used here, FilteredBySearch is changed at the same time
|
||||
if (FilteredBySearch)
|
||||
{
|
||||
if (item.ModName.ToLower().Contains(SearchBar.Text.ToLower())) return true;
|
||||
if (item.ModDescription.ToLower().Contains(SearchBar.Text.ToLower())) return true;
|
||||
if (item.ModName.ToLower().Replace(" ", string.Empty).Contains(SearchBar.Text.ToLower().Replace(" ", string.Empty))) return true;
|
||||
if (item.ModDescription.ToLower().Replace(" ", string.Empty).Contains(SearchBar.Text.ToLower().Replace(" ", string.Empty))) return true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void InstalledButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
private void Animate(TextBlock target, double oldHeight, double newHeight, TimeSpan duration)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue