2021-12-30 00:15: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
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for ModListTileView.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ModListTileView : ReactiveUserControl<ModListMetadataVM>
|
|
|
|
|
{
|
|
|
|
|
public ModListTileView()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2021-12-30 00:15:37 +00:00
|
|
|
|
this.WhenActivated(disposables =>
|
2021-12-26 21:56:44 +00:00
|
|
|
|
{
|
2021-12-30 00:15:37 +00:00
|
|
|
|
ViewModel.WhenAnyValue(vm => vm.Image)
|
|
|
|
|
.BindToStrict(this, view => view.ModListImage.Source)
|
|
|
|
|
.DisposeWith(disposables);
|
|
|
|
|
|
|
|
|
|
var textXformed = ViewModel.WhenAnyValue(vm => vm.Metadata.Title)
|
|
|
|
|
.CombineLatest(ViewModel.WhenAnyValue(vm => vm.Metadata.ImageContainsTitle),
|
|
|
|
|
ViewModel.WhenAnyValue(vm => vm.IsBroken))
|
|
|
|
|
.Select(x => x.Second && !x.Third ? "" : x.First);
|
|
|
|
|
|
|
|
|
|
textXformed
|
|
|
|
|
.BindToStrict(this, view => view.ModListTitle.Text)
|
|
|
|
|
.DisposeWith(disposables);
|
|
|
|
|
|
|
|
|
|
textXformed
|
|
|
|
|
.BindToStrict(this, view => view.ModListTitleShadow.Text)
|
|
|
|
|
.DisposeWith(disposables);
|
|
|
|
|
|
|
|
|
|
ViewModel.WhenAnyValue(x => x.Metadata.Description)
|
|
|
|
|
.BindToStrict(this, x => x.MetadataDescription.Text)
|
|
|
|
|
.DisposeWith(disposables);
|
|
|
|
|
|
|
|
|
|
ViewModel.WhenAnyValue(x => x.ModListTagList)
|
|
|
|
|
.BindToStrict(this, x => x.TagsList.ItemsSource)
|
|
|
|
|
.DisposeWith(disposables);
|
|
|
|
|
|
|
|
|
|
ViewModel.WhenAnyValue(x => x.LoadingImageLock.IsLoading)
|
|
|
|
|
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
|
|
|
|
|
.BindToStrict(this, x => x.LoadingProgress.Visibility)
|
|
|
|
|
.DisposeWith(disposables);
|
|
|
|
|
|
|
|
|
|
ViewModel.WhenAnyValue(x => x.IsBroken)
|
|
|
|
|
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
|
|
|
|
|
.BindToStrict(this, view => view.Overlay.Visibility)
|
|
|
|
|
.DisposeWith(disposables);
|
|
|
|
|
|
|
|
|
|
ViewModel.WhenAnyValue(x => x.OpenWebsiteCommand)
|
|
|
|
|
.BindToStrict(this, x => x.OpenWebsiteButton.Command)
|
|
|
|
|
.DisposeWith(disposables);
|
|
|
|
|
|
|
|
|
|
ViewModel.WhenAnyValue(x => x.ExecuteCommand)
|
|
|
|
|
.BindToStrict(this, x => x.ExecuteButton.Command)
|
|
|
|
|
.DisposeWith(disposables);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ViewModel.WhenAnyValue(x => x.ProgressPercent)
|
|
|
|
|
.ObserveOnDispatcher()
|
|
|
|
|
.Select(p => p.Value)
|
|
|
|
|
.BindTo(this, x => x.DownloadProgressBar.Value)
|
|
|
|
|
.DisposeWith(disposables);
|
|
|
|
|
|
|
|
|
|
/*
|
2021-12-26 21:56:44 +00:00
|
|
|
|
this.MarkAsNeeded<ModListTileView, ModListMetadataVM, bool>(this.ViewModel, x => x.IsBroken);
|
|
|
|
|
this.MarkAsNeeded<ModListTileView, ModListMetadataVM, bool>(this.ViewModel, x => x.Exists);
|
|
|
|
|
this.MarkAsNeeded<ModListTileView, ModListMetadataVM, string>(this.ViewModel, x => x.Metadata.Links.ImageUri);
|
|
|
|
|
this.WhenAny(x => x.ViewModel.ProgressPercent)
|
|
|
|
|
.Select(p => p.Value)
|
|
|
|
|
.BindToStrict(this, x => x.DownloadProgressBar.Value)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
|
2021-12-30 00:15:37 +00:00
|
|
|
|
|
2021-12-26 21:56:44 +00:00
|
|
|
|
this.WhenAny(x => x.ViewModel.ModListContentsCommend)
|
|
|
|
|
.BindToStrict(this, x => x.ModListContentsButton.Command)
|
|
|
|
|
.DisposeWith(dispose);
|
2021-12-30 00:15:37 +00:00
|
|
|
|
|
2021-12-26 21:56:44 +00:00
|
|
|
|
this.WhenAny(x => x.ViewModel.Image)
|
|
|
|
|
.BindToStrict(this, x => x.ModListImage.Source)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
this.WhenAny(x => x.ViewModel.LoadingImage)
|
|
|
|
|
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
|
|
|
|
|
.BindToStrict(this, x => x.LoadingProgress.Visibility)
|
|
|
|
|
.DisposeWith(dispose);
|
2021-12-30 00:15:37 +00:00
|
|
|
|
*/
|
2021-12-26 21:56:44 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|