2021-12-28 19:18:37 +00:00
|
|
|
|
using System.Reactive.Disposables;
|
2021-12-26 21:56:44 +00:00
|
|
|
|
using System.Reactive.Linq;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using ReactiveUI;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
|
|
|
|
public partial class ModListGalleryView : ReactiveUserControl<ModListGalleryVM>
|
|
|
|
|
{
|
|
|
|
|
public ModListGalleryView()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
this.WhenActivated(dispose =>
|
|
|
|
|
{
|
|
|
|
|
this.WhenAny(x => x.ViewModel.BackCommand)
|
|
|
|
|
.BindToStrict(this, x => x.BackButton.Command)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
this.WhenAny(x => x.ViewModel.ModLists)
|
|
|
|
|
.BindToStrict(this, x => x.ModListGalleryControl.ItemsSource)
|
|
|
|
|
.DisposeWith(dispose);
|
2021-12-29 17:26:12 +00:00
|
|
|
|
|
|
|
|
|
this.WhenAny(x => x.ViewModel.LoadingLock.IsLoading)
|
2021-12-26 21:56:44 +00:00
|
|
|
|
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
|
|
|
|
|
.StartWith(Visibility.Collapsed)
|
2021-12-29 17:26:12 +00:00
|
|
|
|
.BindTo(this, x => x.LoadingRing.Visibility)
|
2021-12-26 21:56:44 +00:00
|
|
|
|
.DisposeWith(dispose);
|
2021-12-29 17:26:12 +00:00
|
|
|
|
|
|
|
|
|
this.WhenAny(x => x.ViewModel.LoadingLock.ErrorState)
|
|
|
|
|
.Select(e => (e?.Succeeded ?? true) ? Visibility.Collapsed : Visibility.Visible)
|
|
|
|
|
.StartWith(Visibility.Collapsed)
|
|
|
|
|
.BindToStrict(this, x => x.ErrorIcon.Visibility)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
|
2021-12-26 21:56:44 +00:00
|
|
|
|
Observable.CombineLatest(
|
|
|
|
|
this.WhenAny(x => x.ViewModel.ModLists.Count)
|
|
|
|
|
.Select(x => x > 0),
|
|
|
|
|
this.WhenAny(x => x.ViewModel.Loaded),
|
|
|
|
|
resultSelector: (hasContent, loaded) =>
|
|
|
|
|
{
|
|
|
|
|
return !hasContent && loaded;
|
|
|
|
|
})
|
|
|
|
|
.DistinctUntilChanged()
|
|
|
|
|
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
|
|
|
|
|
.StartWith(Visibility.Collapsed)
|
|
|
|
|
.BindToStrict(this, x => x.NoneFound.Visibility)
|
|
|
|
|
.DisposeWith(dispose);
|
2021-12-29 17:26:12 +00:00
|
|
|
|
|
2021-12-26 21:56:44 +00:00
|
|
|
|
|
|
|
|
|
this.BindStrict(ViewModel, vm => vm.Search, x => x.SearchBox.Text)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
|
|
|
|
|
this.BindStrict(ViewModel, vm => vm.OnlyInstalled, x => x.OnlyInstalledCheckbox.IsChecked)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
this.BindStrict(ViewModel, vm => vm.ShowNSFW, x => x.ShowNSFW.IsChecked)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
this.BindStrict(ViewModel, vm => vm.ShowUtilityLists, x => x.ShowUtilityLists.IsChecked)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
|
|
|
|
|
this.WhenAny(x => x.ViewModel.ClearFiltersCommand)
|
|
|
|
|
.BindToStrict(this, x => x.ClearFiltersButton.Command)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|