mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 19:08:33 +08:00
411 lines
21 KiB
XML
411 lines
21 KiB
XML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<UserControl
|
|
x:Class="BetterLyrics.WinUI3.Controls.StatsDashboardControl"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
|
|
xmlns:converters="using:BetterLyrics.WinUI3.Converter"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:dev="using:DevWinUI"
|
|
xmlns:local="using:BetterLyrics.WinUI3.Controls"
|
|
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.WinUI"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:models="using:BetterLyrics.WinUI3.Models"
|
|
xmlns:statsmodels="using:BetterLyrics.WinUI3.Models.Stats"
|
|
xmlns:ui="using:CommunityToolkit.WinUI"
|
|
mc:Ignorable="d">
|
|
|
|
<UserControl.Resources>
|
|
<Style x:Key="StatsCardStyle" TargetType="Border">
|
|
<Setter Property="Background" Value="{ThemeResource CardBackgroundFillColorDefaultBrush}" />
|
|
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}" />
|
|
<Setter Property="BorderThickness" Value="1" />
|
|
<Setter Property="CornerRadius" Value="8" />
|
|
<Setter Property="Padding" Value="16" />
|
|
<Setter Property="Margin" Value="0,0,12,12" />
|
|
</Style>
|
|
</UserControl.Resources>
|
|
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="*" />
|
|
</Grid.RowDefinitions>
|
|
|
|
<ProgressBar
|
|
Grid.Row="0"
|
|
Background="Transparent"
|
|
IsIndeterminate="{x:Bind ViewModel.IsLoading, Mode=OneWay}"
|
|
Visibility="{x:Bind ViewModel.IsLoading, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
|
|
|
|
<Grid Grid.Row="1" Visibility="{x:Bind ViewModel.GSMTCService.IsScrobbled, Mode=OneWay, Converter={StaticResource BoolNegationToVisibilityConverter}}">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
<InfoBar
|
|
x:Uid="StatsDashboardControlRecording"
|
|
Grid.Row="0"
|
|
IsClosable="False"
|
|
IsOpen="True"
|
|
Message="{x:Bind ViewModel.GSMTCService.CurrentSongInfo.Title, Mode=OneWay}" />
|
|
<ProgressBar
|
|
Grid.Row="1"
|
|
Background="Transparent"
|
|
Maximum="{x:Bind ViewModel.GSMTCService.TargetScrobbledDuration.TotalSeconds, Mode=OneWay}"
|
|
ShowPaused="{x:Bind ViewModel.GSMTCService.CurrentIsPlaying, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
|
|
Value="{x:Bind ViewModel.GSMTCService.ScrobbledDuration.TotalSeconds, Mode=OneWay}" />
|
|
</Grid>
|
|
|
|
<controls:WrapPanel
|
|
Grid.Row="2"
|
|
Margin="36,36,36,12"
|
|
HorizontalSpacing="12"
|
|
Orientation="Horizontal"
|
|
VerticalSpacing="12">
|
|
<ComboBox
|
|
x:Uid="StatsDashboardControlTimeRange"
|
|
Header="Time Range"
|
|
SelectedIndex="{x:Bind ViewModel.SelectedTimeRange, Mode=TwoWay, Converter={StaticResource EnumToIntConverter}}">
|
|
<ComboBoxItem x:Uid="StatsDashboardControlToday" />
|
|
<ComboBoxItem x:Uid="StatsDashboardControlThisWeek" />
|
|
<ComboBoxItem x:Uid="StatsDashboardControlThisMonth" />
|
|
<ComboBoxItem x:Uid="StatsDashboardControlThisQuarter" />
|
|
<ComboBoxItem x:Uid="StatsDashboardControlThisYear" />
|
|
<ComboBoxItem x:Uid="StatsDashboardControlAllTime" />
|
|
<ComboBoxItem x:Uid="StatsDashboardControlCustom" />
|
|
</ComboBox>
|
|
|
|
<CalendarDatePicker
|
|
x:Uid="StatsDashboardControlStart"
|
|
Date="{x:Bind ViewModel.CustomStartDate, Mode=TwoWay}"
|
|
IsEnabled="{x:Bind ViewModel.IsCustomRangeSelected, Mode=OneWay}" />
|
|
<TimePicker
|
|
VerticalAlignment="Bottom"
|
|
IsEnabled="{x:Bind ViewModel.IsCustomRangeSelected, Mode=OneWay}"
|
|
Time="{x:Bind ViewModel.CustomStartTime, Mode=TwoWay}" />
|
|
<CalendarDatePicker
|
|
x:Uid="StatsDashboardControlEnd"
|
|
Date="{x:Bind ViewModel.CustomEndDate, Mode=TwoWay}"
|
|
IsEnabled="{x:Bind ViewModel.IsCustomRangeSelected, Mode=OneWay}" />
|
|
<TimePicker
|
|
VerticalAlignment="Bottom"
|
|
IsEnabled="{x:Bind ViewModel.IsCustomRangeSelected, Mode=OneWay}"
|
|
Time="{x:Bind ViewModel.CustomEndTime, Mode=TwoWay}" />
|
|
<Button
|
|
VerticalAlignment="Bottom"
|
|
Command="{x:Bind ViewModel.RefreshDataCommand}"
|
|
Content="{ui:FontIcon FontFamily={StaticResource IconFontFamily},
|
|
FontSize=16,
|
|
Glyph=}" />
|
|
</controls:WrapPanel>
|
|
|
|
<ScrollViewer Grid.Row="3" Padding="36,0">
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition />
|
|
<RowDefinition />
|
|
<RowDefinition />
|
|
<RowDefinition />
|
|
<RowDefinition />
|
|
</Grid.RowDefinitions>
|
|
|
|
<Grid Grid.Row="0">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*" />
|
|
<ColumnDefinition Width="*" />
|
|
<ColumnDefinition Width="*" />
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<Border Grid.Column="0" Style="{StaticResource StatsCardStyle}">
|
|
<StackPanel>
|
|
<StackPanel
|
|
Opacity="0.8"
|
|
Orientation="Horizontal"
|
|
Spacing="8">
|
|
<FontIcon FontSize="14" Glyph="" />
|
|
<TextBlock x:Uid="StatsDashboardControlTotalDuration" Style="{ThemeResource CaptionTextBlockStyle}" />
|
|
</StackPanel>
|
|
<StackPanel
|
|
Margin="0,8,0,0"
|
|
Orientation="Horizontal"
|
|
Spacing="4">
|
|
<TextBlock
|
|
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
|
|
Style="{ThemeResource SubtitleTextBlockStyle}"
|
|
Text="{x:Bind ViewModel.TotalDuration.TotalHours, Mode=OneWay, Converter={StaticResource DoubleToDecimalConverter}}" />
|
|
<TextBlock
|
|
Margin="0,0,0,2"
|
|
VerticalAlignment="Bottom"
|
|
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
|
|
Opacity="0.8"
|
|
Style="{ThemeResource CaptionTextBlockStyle}"
|
|
Text="Hrs" />
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</Border>
|
|
|
|
<Border Grid.Column="1" Style="{StaticResource StatsCardStyle}">
|
|
<StackPanel>
|
|
<StackPanel
|
|
Opacity="0.8"
|
|
Orientation="Horizontal"
|
|
Spacing="8">
|
|
<FontIcon FontSize="14" Glyph="" />
|
|
<TextBlock x:Uid="StatsDashboardControlTracksPlayed" Style="{ThemeResource CaptionTextBlockStyle}" />
|
|
</StackPanel>
|
|
<TextBlock
|
|
Margin="0,8,0,0"
|
|
Style="{ThemeResource SubtitleTextBlockStyle}"
|
|
Text="{x:Bind ViewModel.TotalTracksPlayed, Mode=OneWay}" />
|
|
</StackPanel>
|
|
</Border>
|
|
|
|
<Border
|
|
Grid.Column="2"
|
|
Margin="0,0,0,12"
|
|
Style="{StaticResource StatsCardStyle}">
|
|
<StackPanel>
|
|
<StackPanel
|
|
Opacity="0.8"
|
|
Orientation="Horizontal"
|
|
Spacing="8">
|
|
<FontIcon FontSize="14" Glyph="" />
|
|
<TextBlock x:Uid="StatsDashboardControlTopSource" Style="{ThemeResource CaptionTextBlockStyle}" />
|
|
</StackPanel>
|
|
<TextBlock
|
|
Margin="0,8,0,0"
|
|
Style="{ThemeResource SubtitleTextBlockStyle}"
|
|
Text="{x:Bind ViewModel.TopPlayerName, Mode=OneWay}" />
|
|
</StackPanel>
|
|
</Border>
|
|
</Grid>
|
|
|
|
<!-- Activity by hour -->
|
|
<Border
|
|
Grid.Row="1"
|
|
Margin="0,0,0,12"
|
|
Style="{StaticResource StatsCardStyle}">
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
|
|
<StackPanel
|
|
Margin="0,0,0,12"
|
|
Orientation="Horizontal"
|
|
Spacing="8">
|
|
<TextBlock x:Uid="StatsDashboardControlActivityByHour" Style="{ThemeResource SubtitleTextBlockStyle}" />
|
|
</StackPanel>
|
|
|
|
<Grid Grid.Row="1" Margin="0,0,0,16">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*" />
|
|
<ColumnDefinition Width="*" />
|
|
</Grid.ColumnDefinitions>
|
|
<StackPanel>
|
|
<TextBlock
|
|
x:Uid="StatsDashboardControlMostActive"
|
|
FontSize="12"
|
|
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
|
|
<TextBlock FontWeight="SemiBold" Text="{x:Bind ViewModel.PeakHourText, Mode=OneWay}" />
|
|
</StackPanel>
|
|
<StackPanel Grid.Column="1">
|
|
<TextBlock
|
|
x:Uid="StatsDashboardControlLeastActive"
|
|
FontSize="12"
|
|
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
|
|
<TextBlock FontWeight="SemiBold" Text="{x:Bind ViewModel.QuietHourText, Mode=OneWay}" />
|
|
</StackPanel>
|
|
</Grid>
|
|
|
|
<lvc:CartesianChart
|
|
Grid.Row="2"
|
|
Height="180"
|
|
Margin="0,8,0,0"
|
|
Background="Transparent"
|
|
TooltipPosition="Top">
|
|
|
|
<lvc:CartesianChart.XAxes>
|
|
<lvc:AxesCollection>
|
|
<lvc:XamlAxis Labels="{x:Bind ViewModel.HourlyXAxisLabels, Mode=OneWay}" TextSize="{StaticResource BodyTextBlockFontSize}" />
|
|
</lvc:AxesCollection>
|
|
</lvc:CartesianChart.XAxes>
|
|
|
|
<lvc:CartesianChart.YAxes>
|
|
<lvc:AxesCollection>
|
|
<lvc:XamlAxis
|
|
x:Uid="StatsDashboardControlTrackCountAxis"
|
|
NameTextSize="{StaticResource BodyTextBlockFontSize}"
|
|
ShowSeparatorLines="False"
|
|
TextSize="{StaticResource BodyTextBlockFontSize}" />
|
|
</lvc:AxesCollection>
|
|
</lvc:CartesianChart.YAxes>
|
|
|
|
<lvc:CartesianChart.Series>
|
|
<lvc:SeriesCollection>
|
|
<lvc:XamlColumnSeries
|
|
x:Name="HourlySeries"
|
|
Rx="4"
|
|
Ry="4"
|
|
Values="{x:Bind ViewModel.HourlySeriesValues, Mode=OneWay}" />
|
|
</lvc:SeriesCollection>
|
|
</lvc:CartesianChart.Series>
|
|
|
|
</lvc:CartesianChart>
|
|
</Grid>
|
|
</Border>
|
|
|
|
<!-- Top artists and sources -->
|
|
<Grid Grid.Row="2">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*" />
|
|
<ColumnDefinition Width="*" />
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<!-- Top artists -->
|
|
<Border Grid.Column="0" Style="{StaticResource StatsCardStyle}">
|
|
<StackPanel>
|
|
<TextBlock
|
|
x:Uid="StatsDashboardControlTopArtists"
|
|
Margin="0,0,0,12"
|
|
Style="{ThemeResource SubtitleTextBlockStyle}" />
|
|
|
|
<ItemsControl ItemsSource="{x:Bind ViewModel.TopArtists, Mode=OneWay}">
|
|
<ItemsControl.ItemTemplate>
|
|
<DataTemplate x:DataType="statsmodels:ArtistPlayCount">
|
|
<Grid Margin="0,4">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*" />
|
|
<ColumnDefinition Width="Auto" />
|
|
</Grid.ColumnDefinitions>
|
|
<StackPanel Orientation="Horizontal" Spacing="10">
|
|
<PersonPicture
|
|
Width="32"
|
|
Height="32"
|
|
DisplayName="{x:Bind Artist}" />
|
|
<TextBlock
|
|
VerticalAlignment="Center"
|
|
Style="{ThemeResource BodyStrongTextBlockStyle}"
|
|
Text="{x:Bind Artist}" />
|
|
</StackPanel>
|
|
<TextBlock
|
|
Grid.Column="1"
|
|
VerticalAlignment="Center"
|
|
FontWeight="SemiBold">
|
|
<Run Text="{x:Bind PlayCount}" />
|
|
<Run
|
|
x:Uid="StatsDashboardControlTrackCountText"
|
|
FontSize="10"
|
|
FontWeight="Normal"
|
|
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
|
|
</TextBlock>
|
|
</Grid>
|
|
</DataTemplate>
|
|
</ItemsControl.ItemTemplate>
|
|
</ItemsControl>
|
|
|
|
</StackPanel>
|
|
</Border>
|
|
|
|
<!-- Top tracks -->
|
|
<Border
|
|
Grid.Column="1"
|
|
Margin="0,0,0,12"
|
|
Style="{StaticResource StatsCardStyle}">
|
|
<StackPanel>
|
|
<TextBlock
|
|
x:Uid="StatsDashboardControlTopSongs"
|
|
Margin="0,0,0,12"
|
|
Style="{ThemeResource SubtitleTextBlockStyle}" />
|
|
<ItemsControl ItemsSource="{x:Bind ViewModel.TopSongs, Mode=OneWay}">
|
|
<ItemsControl.ItemTemplate>
|
|
<DataTemplate x:DataType="statsmodels:SongPlayCount">
|
|
<Grid Margin="0,4">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="*" />
|
|
<ColumnDefinition Width="Auto" />
|
|
</Grid.ColumnDefinitions>
|
|
<Grid
|
|
Width="40"
|
|
Height="40"
|
|
Margin="0,0,12,0"
|
|
Background="{ThemeResource LayerFillColorAltBrush}"
|
|
CornerRadius="4">
|
|
<FontIcon
|
|
FontSize="16"
|
|
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
|
|
Glyph="" />
|
|
</Grid>
|
|
|
|
<StackPanel Grid.Column="1" VerticalAlignment="Center">
|
|
<TextBlock Style="{ThemeResource BodyStrongTextBlockStyle}" Text="{x:Bind Title}" />
|
|
<TextBlock
|
|
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
|
|
Style="{ThemeResource CaptionTextBlockStyle}"
|
|
Text="{x:Bind Artist}" />
|
|
</StackPanel>
|
|
|
|
<TextBlock
|
|
Grid.Column="2"
|
|
VerticalAlignment="Center"
|
|
FontWeight="SemiBold">
|
|
<Run Text="{x:Bind PlayCount}" />
|
|
<Run
|
|
x:Uid="StatsDashboardControlTrackCountText"
|
|
FontSize="10"
|
|
FontWeight="Normal"
|
|
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
|
|
</TextBlock>
|
|
</Grid>
|
|
</DataTemplate>
|
|
</ItemsControl.ItemTemplate>
|
|
</ItemsControl>
|
|
</StackPanel>
|
|
</Border>
|
|
|
|
</Grid>
|
|
|
|
<!-- 播放源分布 -->
|
|
<Border
|
|
Grid.Row="3"
|
|
Margin="0,0,0,20"
|
|
Style="{StaticResource StatsCardStyle}">
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="*" />
|
|
</Grid.RowDefinitions>
|
|
<TextBlock
|
|
x:Uid="StatsDashboardControlSources"
|
|
Margin="0,0,0,12"
|
|
Style="{ThemeResource SubtitleTextBlockStyle}" />
|
|
|
|
<lvc:PieChart
|
|
Grid.Row="1"
|
|
MinHeight="250"
|
|
Background="Transparent"
|
|
LegendPosition="Bottom"
|
|
LegendTextSize="{StaticResource BodyTextBlockFontSize}"
|
|
Series="{x:Bind ViewModel.SourceSeries, Mode=OneWay}"
|
|
TooltipPosition="Center" />
|
|
|
|
</Grid>
|
|
</Border>
|
|
|
|
</Grid>
|
|
</ScrollViewer>
|
|
|
|
<!--<Button
|
|
Grid.Row="2"
|
|
HorizontalAlignment="Right"
|
|
VerticalAlignment="Bottom"
|
|
Command="{x:Bind ViewModel.GenerateTestDataCommand}"
|
|
Content="Generate test data" />-->
|
|
</Grid>
|
|
</UserControl> |