2020-02-09 20:04:40 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
2020-01-19 04:01:51 +00:00
|
|
|
|
using System.Reactive.Disposables;
|
|
|
|
|
using System.Reactive.Linq;
|
2019-11-09 13:30:36 +00:00
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using MahApps.Metro.Controls;
|
2020-01-19 04:01:51 +00:00
|
|
|
|
using ReactiveUI;
|
2019-11-09 13:30:36 +00:00
|
|
|
|
using Wabbajack.Lib.ModListRegistry;
|
|
|
|
|
|
2019-11-30 09:08:04 +00:00
|
|
|
|
namespace Wabbajack
|
2019-11-09 13:30:36 +00:00
|
|
|
|
{
|
2020-01-19 04:01:51 +00:00
|
|
|
|
public partial class ModListGalleryView : ReactiveUserControl<ModListGalleryVM>
|
2019-11-09 13:30:36 +00:00
|
|
|
|
{
|
|
|
|
|
public ModListGalleryView()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2020-01-19 04:01:51 +00:00
|
|
|
|
|
|
|
|
|
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);
|
2020-02-09 20:04:40 +00:00
|
|
|
|
Observable.CombineLatest(
|
|
|
|
|
this.WhenAny(x => x.ViewModel.Error),
|
|
|
|
|
this.WhenAny(x => x.ViewModel.Loaded),
|
|
|
|
|
resultSelector: (err, loaded) =>
|
|
|
|
|
{
|
|
|
|
|
if (!err?.Succeeded ?? false) return true;
|
|
|
|
|
return !loaded;
|
|
|
|
|
})
|
|
|
|
|
.DistinctUntilChanged()
|
|
|
|
|
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
|
|
|
|
|
.StartWith(Visibility.Collapsed)
|
|
|
|
|
.BindToStrict(this, x => x.LoadingRing.Visibility)
|
|
|
|
|
.DisposeWith(dispose);
|
2020-01-19 04:37:21 +00:00
|
|
|
|
Observable.CombineLatest(
|
|
|
|
|
this.WhenAny(x => x.ViewModel.ModLists.Count)
|
|
|
|
|
.Select(x => x > 0),
|
2020-02-09 20:04:40 +00:00
|
|
|
|
this.WhenAny(x => x.ViewModel.Loaded),
|
|
|
|
|
resultSelector: (hasContent, loaded) =>
|
2020-01-19 04:37:21 +00:00
|
|
|
|
{
|
2020-02-09 20:04:40 +00:00
|
|
|
|
return !hasContent && loaded;
|
2020-01-19 04:37:21 +00:00
|
|
|
|
})
|
2020-02-09 20:04:40 +00:00
|
|
|
|
.DistinctUntilChanged()
|
2020-01-19 04:37:21 +00:00
|
|
|
|
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
|
2020-02-04 00:49:57 +00:00
|
|
|
|
.StartWith(Visibility.Collapsed)
|
2020-02-09 20:04:40 +00:00
|
|
|
|
.BindToStrict(this, x => x.NoneFound.Visibility)
|
2020-01-19 04:01:51 +00:00
|
|
|
|
.DisposeWith(dispose);
|
2020-01-19 04:37:21 +00:00
|
|
|
|
this.WhenAny(x => x.ViewModel.Error)
|
|
|
|
|
.Select(e => (e?.Succeeded ?? true) ? Visibility.Collapsed : Visibility.Visible)
|
2020-02-04 00:49:57 +00:00
|
|
|
|
.StartWith(Visibility.Collapsed)
|
2020-01-19 04:37:21 +00:00
|
|
|
|
.BindToStrict(this, x => x.ErrorIcon.Visibility)
|
|
|
|
|
.DisposeWith(dispose);
|
2020-02-09 20:04:40 +00:00
|
|
|
|
|
2020-04-27 10:18:08 +00:00
|
|
|
|
this.BindStrict(ViewModel, vm => vm.Search, x => x.SearchBox.Text)
|
2020-02-09 20:04:40 +00:00
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
|
2020-04-27 10:18:08 +00:00
|
|
|
|
this.BindStrict(ViewModel, vm => vm.OnlyInstalled, x => x.OnlyInstalledCheckbox.IsChecked)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
this.BindStrict(ViewModel, vm => vm.ShowNSFW, x => x.ShowNSFW.IsChecked)
|
2020-02-09 20:04:40 +00:00
|
|
|
|
.DisposeWith(dispose);
|
2020-11-14 19:30:28 +00:00
|
|
|
|
this.BindStrict(ViewModel, vm => vm.ShowUtilityLists, x => x.ShowUtilityLists.IsChecked)
|
|
|
|
|
.DisposeWith(dispose);
|
2020-02-09 20:04:40 +00:00
|
|
|
|
|
|
|
|
|
this.WhenAny(x => x.ViewModel.ClearFiltersCommand)
|
|
|
|
|
.BindToStrict(this, x => x.ClearFiltersButton.Command)
|
|
|
|
|
.DisposeWith(dispose);
|
2020-01-19 04:01:51 +00:00
|
|
|
|
});
|
2019-11-09 13:30:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|