wabbajack/Wabbajack.App.Wpf/Views/ModListTileView.xaml.cs

46 lines
1.7 KiB
C#

using System;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using MahApps.Metro.IconPacks;
using ReactiveUI;
using Wabbajack.DTOs;
namespace Wabbajack
{
/// <summary>
/// Interaction logic for ModListTileView.xaml
/// </summary>
public partial class ModListTileView : ReactiveUserControl<GalleryModListMetadataVM>
{
public ModListTileView()
{
InitializeComponent();
this.WhenActivated(disposables =>
{
ViewModel.WhenAnyValue(vm => vm.Image)
.BindToStrict(this, v => v.ModlistImage.ImageSource)
.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);
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);
});
}
}
}