2019-11-17 05:31:54 +00:00
|
|
|
|
using ReactiveUI;
|
2020-01-17 00:28:52 +00:00
|
|
|
|
using ReactiveUI.Fody.Helpers;
|
|
|
|
|
using System;
|
2019-11-09 01:53:32 +00:00
|
|
|
|
using System.Linq;
|
2020-01-17 00:28:52 +00:00
|
|
|
|
using System.Reactive;
|
|
|
|
|
using System.Reactive.Disposables;
|
2019-11-17 05:31:54 +00:00
|
|
|
|
using System.Reactive.Linq;
|
2019-11-09 01:53:32 +00:00
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Media;
|
2020-01-17 00:28:52 +00:00
|
|
|
|
using Wabbajack.Lib;
|
2019-11-09 01:53:32 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for DetailImageView.xaml
|
|
|
|
|
/// </summary>
|
2020-01-17 00:28:52 +00:00
|
|
|
|
public partial class DetailImageView : UserControlRx<ViewModel>
|
2019-11-09 01:53:32 +00:00
|
|
|
|
{
|
|
|
|
|
public ImageSource Image
|
|
|
|
|
{
|
|
|
|
|
get => (ImageSource)GetValue(ImageProperty);
|
|
|
|
|
set => SetValue(ImageProperty, value);
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty ImageProperty = DependencyProperty.Register(nameof(Image), typeof(ImageSource), typeof(DetailImageView),
|
2020-05-13 00:31:04 +00:00
|
|
|
|
new FrameworkPropertyMetadata(default(ImageSource), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
|
2019-11-09 01:53:32 +00:00
|
|
|
|
|
|
|
|
|
public ImageSource Badge
|
|
|
|
|
{
|
|
|
|
|
get => (ImageSource)GetValue(BadgeProperty);
|
|
|
|
|
set => SetValue(BadgeProperty, value);
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty BadgeProperty = DependencyProperty.Register(nameof(Badge), typeof(ImageSource), typeof(DetailImageView),
|
2020-05-13 00:31:04 +00:00
|
|
|
|
new FrameworkPropertyMetadata(default(ImageSource), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
|
2019-11-09 01:53:32 +00:00
|
|
|
|
|
|
|
|
|
public string Title
|
|
|
|
|
{
|
|
|
|
|
get => (string)GetValue(TitleProperty);
|
|
|
|
|
set => SetValue(TitleProperty, value);
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(nameof(Title), typeof(string), typeof(DetailImageView),
|
2019-11-17 05:31:54 +00:00
|
|
|
|
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
|
2019-11-09 01:53:32 +00:00
|
|
|
|
|
|
|
|
|
public string Author
|
|
|
|
|
{
|
|
|
|
|
get => (string)GetValue(AuthorProperty);
|
|
|
|
|
set => SetValue(AuthorProperty, value);
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty AuthorProperty = DependencyProperty.Register(nameof(Author), typeof(string), typeof(DetailImageView),
|
2019-11-17 05:31:54 +00:00
|
|
|
|
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
|
2019-11-09 01:53:32 +00:00
|
|
|
|
|
|
|
|
|
public string Description
|
|
|
|
|
{
|
|
|
|
|
get => (string)GetValue(DescriptionProperty);
|
|
|
|
|
set => SetValue(DescriptionProperty, value);
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register(nameof(Description), typeof(string), typeof(DetailImageView),
|
2019-11-17 05:31:54 +00:00
|
|
|
|
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
|
|
|
|
|
|
2019-11-09 01:53:32 +00:00
|
|
|
|
public DetailImageView()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2019-11-17 05:31:54 +00:00
|
|
|
|
|
2020-01-17 00:28:52 +00:00
|
|
|
|
this.WhenActivated(dispose =>
|
|
|
|
|
{
|
2020-05-13 00:31:04 +00:00
|
|
|
|
// Update textboxes
|
|
|
|
|
var authorVisible = this.WhenAny(x => x.Author)
|
|
|
|
|
.Select(x => string.IsNullOrWhiteSpace(x) ? Visibility.Collapsed : Visibility.Visible)
|
|
|
|
|
.Replay(1)
|
|
|
|
|
.RefCount();
|
|
|
|
|
authorVisible
|
|
|
|
|
.BindToStrict(this, x => x.AuthorTextBlock.Visibility)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
authorVisible
|
|
|
|
|
.BindToStrict(this, x => x.AuthorTextShadow.Visibility)
|
|
|
|
|
.DisposeWith(dispose);
|
2020-01-17 00:28:52 +00:00
|
|
|
|
this.WhenAny(x => x.Author)
|
2020-05-13 00:31:04 +00:00
|
|
|
|
.BindToStrict(this, x => x.AuthorTextRun.Text)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
this.WhenAny(x => x.Author)
|
|
|
|
|
.BindToStrict(this, x => x.AuthorShadowTextRun.Text)
|
2020-01-17 00:28:52 +00:00
|
|
|
|
.DisposeWith(dispose);
|
2019-11-17 05:31:54 +00:00
|
|
|
|
|
2020-05-13 00:31:04 +00:00
|
|
|
|
var descVisible = this.WhenAny(x => x.Description)
|
|
|
|
|
.Select(x => string.IsNullOrWhiteSpace(x) ? Visibility.Collapsed : Visibility.Visible)
|
|
|
|
|
.Replay(1)
|
|
|
|
|
.RefCount();
|
|
|
|
|
descVisible
|
|
|
|
|
.BindToStrict(this, x => x.DescriptionTextBlock.Visibility)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
descVisible
|
|
|
|
|
.BindToStrict(this, x => x.DescriptionTextShadow.Visibility)
|
|
|
|
|
.DisposeWith(dispose);
|
2020-01-17 00:28:52 +00:00
|
|
|
|
this.WhenAny(x => x.Description)
|
2020-05-13 00:31:04 +00:00
|
|
|
|
.BindToStrict(this, x => x.DescriptionTextBlock.Text)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
this.WhenAny(x => x.Description)
|
|
|
|
|
.BindToStrict(this, x => x.DescriptionTextShadow.Text)
|
2020-01-17 00:28:52 +00:00
|
|
|
|
.DisposeWith(dispose);
|
2019-11-17 05:31:54 +00:00
|
|
|
|
|
2020-05-13 00:31:04 +00:00
|
|
|
|
var titleVisible = this.WhenAny(x => x.Title)
|
|
|
|
|
.Select(x => string.IsNullOrWhiteSpace(x) ? Visibility.Collapsed : Visibility.Visible)
|
|
|
|
|
.Replay(1)
|
|
|
|
|
.RefCount();
|
|
|
|
|
titleVisible
|
|
|
|
|
.BindToStrict(this, x => x.TitleTextBlock.Visibility)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
titleVisible
|
|
|
|
|
.BindToStrict(this, x => x.TitleTextShadow.Visibility)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
this.WhenAny(x => x.Title)
|
|
|
|
|
.BindToStrict(this, x => x.TitleTextBlock.Text)
|
|
|
|
|
.DisposeWith(dispose);
|
2020-01-17 00:28:52 +00:00
|
|
|
|
this.WhenAny(x => x.Title)
|
2020-05-13 00:31:04 +00:00
|
|
|
|
.BindToStrict(this, x => x.TitleTextShadow.Text)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
|
|
|
|
|
// Update other items
|
|
|
|
|
this.WhenAny(x => x.Badge)
|
|
|
|
|
.BindToStrict(this, x => x.BadgeImage.Source)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
this.WhenAny(x => x.Image)
|
|
|
|
|
.BindToStrict(this, x => x.ModlistImage.Source)
|
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
this.WhenAny(x => x.Image)
|
|
|
|
|
.Select(img => img == null ? Visibility.Hidden : Visibility.Visible)
|
|
|
|
|
.BindToStrict(this, x => x.Visibility)
|
2020-01-17 00:28:52 +00:00
|
|
|
|
.DisposeWith(dispose);
|
|
|
|
|
});
|
2019-11-09 01:53:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|