Skip to content

Commit 42605f5

Browse files
committed
Simplify styles
1 parent 9e7efe6 commit 42605f5

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

SpotifyNet.Cover/View/MainWindow.xaml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@
2626
</WindowChrome.WindowChrome>
2727

2828
<Window.Resources>
29+
<Style x:Key="CoverGrid" TargetType="Grid">
30+
<Setter Property="Width" Value="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Canvas}}" />
31+
<Setter Property="Height" Value="{Binding ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Canvas}}" />
32+
</Style>
33+
34+
<Style x:Key="CoverViewbox" TargetType="Viewbox">
35+
<Setter Property="Width" Value="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Grid}}" />
36+
<Setter Property="Height" Value="{Binding ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Grid}}" />
37+
<Setter Property="Stretch" Value="Fill" />
38+
<Setter Property="StretchDirection" Value="Both" />
39+
<Setter Property="Grid.Row" Value="0" />
40+
<Setter Property="Grid.Column" Value="0" />
41+
<Setter Property="Grid.ColumnSpan" Value="99" />
42+
<Setter Property="Margin" Value="0" />
43+
</Style>
44+
2945
<Style x:Key="CoverIcon" TargetType="materialDesign:PackIcon" BasedOn="{StaticResource {x:Type materialDesign:PackIcon}}">
3046
<Setter Property="HorizontalAlignment" Value="Center" />
3147
<Setter Property="VerticalAlignment" Value="Center" />
@@ -92,44 +108,32 @@
92108
</Grid.RowDefinitions>
93109

94110
<Image Margin="0" Grid.Column="0" Grid.ColumnSpan="99" Grid.Row="0" Source="{Binding Cover}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="{Binding IsPrivateSession, Converter={StaticResource InverseBoolToVisConverter}}"/>
95-
96-
<Viewbox StretchDirection="Both" Stretch="Fill"
97-
Margin="0" Grid.Column="0" Grid.ColumnSpan="99" Grid.Row="0"
98-
Height="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Grid}}"
99-
Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Grid}}">
111+
112+
<Viewbox Style="{StaticResource CoverViewbox}">
100113
<TextBlock Text="{Binding CurrentVolumeString, NotifyOnTargetUpdated=True}" FontSize="50" TextAlignment="Center" Style="{StaticResource animateFadeOut}"/>
101114
</Viewbox>
102-
103-
<Viewbox StretchDirection="Both" Stretch="Fill"
104-
Visibility="{Binding IsPrivateSession, Converter={StaticResource BooleanToVisibilityConverter}}"
105-
Margin="0" Grid.Column="0" Grid.ColumnSpan="99" Grid.Row="0"
106-
Height="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Grid}}"
107-
Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Grid}}">
115+
116+
<Viewbox Style="{StaticResource CoverViewbox}"
117+
Visibility="{Binding IsPrivateSession, Converter={StaticResource BooleanToVisibilityConverter}}">
108118
<materialDesign:PackIcon Kind="Incognito" />
109119
</Viewbox>
110120

111121
<Canvas Grid.Row="0" Grid.Column="0" Background="Transparent" MouseLeftButtonDown="CanvasLeft_MouseLeftButtonDown">
112-
<Grid
113-
Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Canvas}}"
114-
Height="{Binding ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Canvas}}">
122+
<Grid Style="{StaticResource CoverGrid}">
115123
<materialDesign:PackIcon Kind="SkipPrevious" Style="{StaticResource CoverIcon}" />
116124
</Grid>
117125
</Canvas>
118126
<Canvas Grid.Row="0" Grid.Column="1" Background="Transparent" MouseLeftButtonDown="CanvasMid_MouseLeftButtonDown">
119-
<Grid
120-
Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Canvas}}"
121-
Height="{Binding ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Canvas}}">
127+
<Grid Style="{StaticResource CoverGrid}">
122128
<materialDesign:PackIcon Kind="PlayPause" Style="{StaticResource CoverIcon}" />
123129
</Grid>
124130
</Canvas>
125-
<Canvas Grid.Row="0" Grid.Column="2" Background="Transparent" MouseLeftButtonDown="CanvasRight_MouseLeftButtonDown" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
126-
<Grid
127-
Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Canvas}}"
128-
Height="{Binding ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=Canvas}}">
131+
<Canvas Grid.Row="0" Grid.Column="2" Background="Transparent" MouseLeftButtonDown="CanvasRight_MouseLeftButtonDown">
132+
<Grid Style="{StaticResource CoverGrid}">
129133
<materialDesign:PackIcon Kind="SkipNext" Style="{StaticResource CoverIcon}" />
130134
</Grid>
131135
</Canvas>
132-
136+
133137
<ToggleButton Grid.Column="0" Style="{StaticResource CoverToggle}" VerticalAlignment="Bottom" x:Name="TopMostToggle" HorizontalAlignment="Left"/>
134138
</Grid>
135139
</Window>

0 commit comments

Comments
 (0)