Skip to content

Commit

Permalink
UI: Super-mini Mod
Browse files Browse the repository at this point in the history
* 超小的界面也要拿出真本事
  • Loading branch information
kengwang committed Feb 22, 2021
1 parent 038ded1 commit 0d28a4c
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 4 deletions.
18 changes: 16 additions & 2 deletions HyPlayer/Controls/PlayBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
mc:Ignorable="d"
d:DesignHeight="100"
d:DesignWidth="1080">
<Grid>
<Grid
Name="GridThis">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
Expand Down Expand Up @@ -52,15 +53,28 @@
Value="0,0,0,0"></Setter>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0">
</AdaptiveTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter
Target="GridThis.Visibility" Value="Collapsed"></Setter>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger
MinWindowWidth="0" />
MinWindowWidth="200" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter
Target="SubControlGrid.Visibility"
Value="Collapsed" />
<Setter
Target="GridThis.Visibility"
Value="Visible"></Setter>
<Setter
Target="MainControlGrid.(Grid.ColumnSpan)"
Value="2" />
Expand Down
95 changes: 94 additions & 1 deletion HyPlayer/Pages/ExpandedPlayer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,76 @@
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
mc:Ignorable="d"
Background="{ThemeResource SystemControlAcrylicElementBrush}">

<Grid
Background="{ThemeResource SystemControlAcrylicElementBrush}"
Margin="0,0,0,0">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger
MinWindowWidth="0">
<!--小窗模式 -->
</AdaptiveTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter
Target="ImageAlbum.(Grid.Column)"
Value="0" />
<Setter
Target="ImageAlbum.(Grid.ColumnSpan)"
Value="12" />
<Setter
Target="ImageAlbum.(Grid.Row)"
Value="0" />
<Setter
Target="ImageAlbum.(Grid.RowSpan)"
Value="13" />
<Setter
Target="DockPanelRight.Visibility"
Value="Collapsed"/>
<Setter
Target="BtnPlayStateChange.Visibility"
Value="Visible"/>
<Setter
Target="ProgressBarPlayProg.Visibility"
Value="Visible"/>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger
MinWindowWidth="250">
<!--正常模式 -->
</AdaptiveTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter
Target="ImageAlbum.(Grid.Column)"
Value="1" />
<Setter
Target="ImageAlbum.(Grid.ColumnSpan)"
Value="4" />
<Setter
Target="ImageAlbum.(Grid.Row)"
Value="2" />
<Setter
Target="ImageAlbum.(Grid.RowSpan)"
Value="8" />
<Setter
Target="DockPanelRight.Visibility"
Value="Visible"/>
<Setter
Target="BtnPlayStateChange.Visibility"
Value="Collapsed"/>
<Setter
Target="ProgressBarPlayProg.Visibility"
Value="Collapsed" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
Expand Down Expand Up @@ -40,6 +107,7 @@
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<Image
DoubleTapped="ImageAlbum_OnDoubleTapped"
x:FieldModifier="public"
Expand All @@ -49,7 +117,26 @@
Grid.RowSpan="8"
Name="ImageAlbum"
Source="/Assets/Icon.png" />
<Button
Grid.RowSpan="6"
Grid.Row="3"
Style="{StaticResource ButtonRevealStyle}"
Name="BtnPlayStateChange"
Width="50"
Height="50"
Grid.Column="4"
Grid.ColumnSpan="4"
VerticalAlignment="Center"
Click="BtnPlayStateChange_OnClick"
CornerRadius="30">
<FontIcon
Name="PlayStateIcon"
FontFamily="{StaticResource SymbolThemeFontFamily}"
Glyph="&#xEDB4;"></FontIcon>
<!--EDB5 -->
</Button>
<controls:DockPanel
Name="DockPanelRight"
LastChildFill="True"
Grid.Row="1"
Margin="0,0,0,100"
Expand Down Expand Up @@ -84,7 +171,13 @@
ScrollViewer.VerticalScrollBarVisibility="Auto" />
</ScrollViewer.Content>
</ScrollViewer>

</controls:DockPanel>
<ProgressBar
Name="ProgressBarPlayProg"
Visibility="Collapsed"
Grid.Column="0"
Grid.ColumnSpan="12"
Grid.Row="12"
Value="0" />
</Grid>
</Page>
16 changes: 16 additions & 0 deletions HyPlayer/Pages/ExpandedPlayer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ private void RefreshLyricTime()
LyricBoxContainer.ChangeView(null, position.Y - (LyricBoxContainer.ViewportHeight / 3), null, false);
showed = true;
}

//暂停按钮
PlayStateIcon.Glyph = AudioPlayer.AudioMediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing ? "\uEDB4" : "\uEDB5";
//播放进度
ProgressBarPlayProg.Value = AudioPlayer.AudioMediaPlayer.PlaybackSession.Position.TotalMilliseconds;
}

public void LoadLyricsBox()
Expand Down Expand Up @@ -152,6 +157,7 @@ public void OnSongChange(MediaPlaybackItem mpi)
TextBlockSongTitle.Text = AudioPlayer.AudioInfos[mpi]
.SongName;
this.Background = new ImageBrush() { ImageSource = ImageAlbum.Source };
ProgressBarPlayProg.Maximum = AudioPlayer.AudioInfos[mpi].LengthInMilliseconds;
LoadLyricsBox();
}
catch (Exception) { }
Expand Down Expand Up @@ -239,5 +245,15 @@ private void ImageAlbum_OnDoubleTapped(object sender, DoubleTappedRoutedEventArg
iscompact = false;
}
}

private void BtnPlayStateChange_OnClick(object sender, RoutedEventArgs e)
{
if (AudioPlayer.AudioMediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing)
AudioPlayer.AudioMediaPlayer.Pause();
else if (AudioPlayer.AudioMediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Paused)
AudioPlayer.AudioMediaPlayer.Play();
PlayStateIcon.Glyph = AudioPlayer.AudioMediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing ? "\uEDB5" : "\uEDB4";

}
}
}
2 changes: 1 addition & 1 deletion HyPlayer/Pages/SongListFrame.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
mc:Ignorable="d">

<Grid>
<controls:WrapPanel Margin="0,0,0,350" HorizontalSpacing="50" VerticalSpacing="50" Name="GridContainer" />
<controls:WrapPanel Margin="0,0,0,350" HorizontalSpacing="50" VerticalSpacing="50" x:Name="GridContainer" />
</Grid>
</Page>

0 comments on commit 0d28a4c

Please sign in to comment.