mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Swapped DetailImageView to RxUI bindings
This commit is contained in:
parent
03afaceadc
commit
799c7e2090
@ -43,9 +43,6 @@
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.ExitActions>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Image}" Value="{x:Null}">
|
||||
<Setter Property="Visibility" Value="Hidden" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
@ -74,9 +71,9 @@
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Stretch="UniformToFill">
|
||||
<Image Source="{Binding Image, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
|
||||
<Image x:Name="ModlistImage" />
|
||||
</Viewbox>
|
||||
<Image
|
||||
<Image x:Name="BadgeImage"
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="4"
|
||||
Grid.Column="0"
|
||||
@ -84,8 +81,7 @@
|
||||
Width="60"
|
||||
Height="60"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Source="{Binding Badge, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
|
||||
VerticalAlignment="Top" />
|
||||
<TextBlock
|
||||
x:Name="TitleTextShadow"
|
||||
Grid.Row="2"
|
||||
@ -98,15 +94,13 @@
|
||||
FontSize="65"
|
||||
FontWeight="Bold"
|
||||
Style="{StaticResource BackgroundBlurStyle}"
|
||||
Text="{Binding Title, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
Visibility="{Binding ShowTitle, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
|
||||
TextWrapping="WrapWithOverflow">
|
||||
<TextBlock.Effect>
|
||||
<BlurEffect Radius="85" />
|
||||
</TextBlock.Effect>
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
x:Name="ArtistTextShadow"
|
||||
x:Name="AuthorTextShadow"
|
||||
Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Margin="35,-10,-10,10"
|
||||
@ -116,15 +110,14 @@
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Style="{StaticResource BackgroundBlurStyle}"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
Visibility="{Binding ShowAuthor, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
|
||||
TextWrapping="WrapWithOverflow">
|
||||
<TextBlock.Effect>
|
||||
<BlurEffect Radius="55" />
|
||||
</TextBlock.Effect>
|
||||
<Run FontSize="15" Text="by" />
|
||||
<Run Text="{Binding Author, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
|
||||
<Run x:Name="AuthorShadowTextRun" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
<TextBlock x:Name="TitleTextBlock"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Margin="20,25,20,0"
|
||||
@ -133,27 +126,24 @@
|
||||
FontFamily="Lucida Sans"
|
||||
FontSize="65"
|
||||
FontWeight="Bold"
|
||||
Text="{Binding Title, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
Visibility="{Binding ShowTitle, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
|
||||
TextWrapping="WrapWithOverflow">
|
||||
<TextBlock.Effect>
|
||||
<DropShadowEffect />
|
||||
</TextBlock.Effect>
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
<TextBlock x:Name="AuthorTextBlock"
|
||||
Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Margin="55,0,20,20"
|
||||
FontFamily="Lucida Sans"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="{Binding ShowAuthor, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
|
||||
TextWrapping="Wrap">
|
||||
<TextBlock.Effect>
|
||||
<DropShadowEffect />
|
||||
</TextBlock.Effect>
|
||||
<Run FontSize="15" Text="by" />
|
||||
<Run Text="{Binding Author, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
|
||||
<Run x:Name="AuthorTextRun" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
x:Name="DescriptionTextShadow"
|
||||
@ -167,15 +157,13 @@
|
||||
FontFamily="Lucida Sans"
|
||||
FontSize="16"
|
||||
Style="{StaticResource BackgroundBlurStyle}"
|
||||
Text="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
|
||||
TextAlignment="Right"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="{Binding ShowDescription, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
|
||||
TextWrapping="Wrap">
|
||||
<TextBlock.Effect>
|
||||
<BlurEffect Radius="55" />
|
||||
</TextBlock.Effect>
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
<TextBlock x:Name="DescriptionTextBlock"
|
||||
Grid.Row="2"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
@ -184,10 +172,8 @@
|
||||
VerticalAlignment="Bottom"
|
||||
FontFamily="Lucida Sans"
|
||||
FontSize="16"
|
||||
Text="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
|
||||
TextAlignment="Right"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="{Binding ShowDescription, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource bool2VisibilityHiddenConverter}}">
|
||||
TextWrapping="Wrap">
|
||||
<TextBlock.Effect>
|
||||
<DropShadowEffect />
|
||||
</TextBlock.Effect>
|
||||
|
@ -22,7 +22,7 @@ namespace Wabbajack
|
||||
set => SetValue(ImageProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty ImageProperty = DependencyProperty.Register(nameof(Image), typeof(ImageSource), typeof(DetailImageView),
|
||||
new FrameworkPropertyMetadata(default(ImageSource)));
|
||||
new FrameworkPropertyMetadata(default(ImageSource), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
|
||||
|
||||
public ImageSource Badge
|
||||
{
|
||||
@ -30,7 +30,7 @@ namespace Wabbajack
|
||||
set => SetValue(BadgeProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty BadgeProperty = DependencyProperty.Register(nameof(Badge), typeof(ImageSource), typeof(DetailImageView),
|
||||
new FrameworkPropertyMetadata(default(ImageSource)));
|
||||
new FrameworkPropertyMetadata(default(ImageSource), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
|
||||
|
||||
public string Title
|
||||
{
|
||||
@ -56,34 +56,74 @@ namespace Wabbajack
|
||||
public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register(nameof(Description), typeof(string), typeof(DetailImageView),
|
||||
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
|
||||
|
||||
[Reactive]
|
||||
public bool ShowAuthor { get; private set; }
|
||||
|
||||
[Reactive]
|
||||
public bool ShowDescription { get; private set; }
|
||||
|
||||
[Reactive]
|
||||
public bool ShowTitle { get; private set; }
|
||||
|
||||
public DetailImageView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.WhenActivated(dispose =>
|
||||
{
|
||||
// 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);
|
||||
this.WhenAny(x => x.Author)
|
||||
.Select(x => !string.IsNullOrWhiteSpace(x))
|
||||
.Subscribe(x => ShowAuthor = x)
|
||||
.BindToStrict(this, x => x.AuthorTextRun.Text)
|
||||
.DisposeWith(dispose);
|
||||
this.WhenAny(x => x.Author)
|
||||
.BindToStrict(this, x => x.AuthorShadowTextRun.Text)
|
||||
.DisposeWith(dispose);
|
||||
|
||||
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);
|
||||
this.WhenAny(x => x.Description)
|
||||
.Select(x => !string.IsNullOrWhiteSpace(x))
|
||||
.Subscribe(x => ShowDescription = x)
|
||||
.BindToStrict(this, x => x.DescriptionTextBlock.Text)
|
||||
.DisposeWith(dispose);
|
||||
this.WhenAny(x => x.Description)
|
||||
.BindToStrict(this, x => x.DescriptionTextShadow.Text)
|
||||
.DisposeWith(dispose);
|
||||
|
||||
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)
|
||||
.Select(x => !string.IsNullOrWhiteSpace(x))
|
||||
.Subscribe(x => ShowTitle = x)
|
||||
.BindToStrict(this, x => x.TitleTextBlock.Text)
|
||||
.DisposeWith(dispose);
|
||||
this.WhenAny(x => x.Title)
|
||||
.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)
|
||||
.DisposeWith(dispose);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user