mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-09-28 15:21:24 +12:00
Merge 12002dcc76
into 992480facc
This commit is contained in:
commit
42f57b0eb8
2 changed files with 52 additions and 8 deletions
|
@ -91,7 +91,20 @@
|
||||||
</GridViewColumn.CellTemplate>
|
</GridViewColumn.CellTemplate>
|
||||||
</GridViewColumn>
|
</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>
|
<GridViewColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
|
|
@ -40,6 +40,8 @@ namespace VRCMelonAssistant.Pages
|
||||||
public CollectionView view;
|
public CollectionView view;
|
||||||
public bool PendingChanges;
|
public bool PendingChanges;
|
||||||
public bool HaveInstalledMods;
|
public bool HaveInstalledMods;
|
||||||
|
public bool FilteredToInstalled = false;
|
||||||
|
public bool FilteredBySearch = false;
|
||||||
|
|
||||||
private readonly SemaphoreSlim _modsLoadSem = new SemaphoreSlim(1, 1);
|
private readonly SemaphoreSlim _modsLoadSem = new SemaphoreSlim(1, 1);
|
||||||
|
|
||||||
|
@ -508,19 +510,29 @@ namespace VRCMelonAssistant.Pages
|
||||||
SearchBar.Focus();
|
SearchBar.Focus();
|
||||||
Animate(SearchBar, 0, 16, new TimeSpan(0, 0, 0, 0, 300));
|
Animate(SearchBar, 0, 16, new TimeSpan(0, 0, 0, 0, 300));
|
||||||
Animate(SearchText, 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);
|
ModsListView.Items.Filter = new Predicate<object>(SearchFilter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Animate(SearchBar, 16, 0, new TimeSpan(0, 0, 0, 0, 300));
|
Animate(SearchBar, 16, 0, new TimeSpan(0, 0, 0, 0, 300));
|
||||||
Animate(SearchText, 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;
|
ModsListView.Items.Filter = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SearchBar_TextChanged(object sender, TextChangedEventArgs e)
|
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)
|
if (SearchBar.Text.Length > 0)
|
||||||
{
|
{
|
||||||
SearchText.Text = null;
|
SearchText.Text = null;
|
||||||
|
@ -534,12 +546,31 @@ namespace VRCMelonAssistant.Pages
|
||||||
private bool SearchFilter(object mod)
|
private bool SearchFilter(object mod)
|
||||||
{
|
{
|
||||||
ModListItem item = mod as ModListItem;
|
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.ModName.ToLower().Contains(SearchBar.Text.ToLower())) return true;
|
||||||
if (item.ModDescription.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.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;
|
if (item.ModDescription.ToLower().Replace(" ", string.Empty).Contains(SearchBar.Text.ToLower().Replace(" ", string.Empty))) return true;
|
||||||
return false;
|
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)
|
private void Animate(TextBlock target, double oldHeight, double newHeight, TimeSpan duration)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue