Skip to content

Commit c859020

Browse files
committed
chores: improve music stats
1 parent 32ba453 commit c859020

29 files changed

+1085
-361
lines changed

BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<PackageReference Include="H.NotifyIcon.WinUI" Version="2.4.1" />
8787
<PackageReference Include="Hqub.Last.fm" Version="2.5.1" />
8888
<PackageReference Include="Interop.UIAutomationClient" Version="10.19041.0" />
89+
<PackageReference Include="LiveChartsCore.SkiaSharpView.WinUI" Version="2.0.0-rc6.1" />
8990
<PackageReference Include="Lyricify.Lyrics.Helper-NativeAot" Version="0.1.4-alpha.5" />
9091
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
9192
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="10.0.1" />

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/MediaSettingsControl.xaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,14 @@
124124
</ListView.ItemTemplate>
125125
</ListView>
126126

127-
<dev:SettingsCard Style="{StaticResource DefaultSettingsExpanderItemStyle}">
127+
<StackPanel
128+
Margin="0,6,0,0"
129+
HorizontalAlignment="Right"
130+
Orientation="Horizontal"
131+
Spacing="6">
132+
<Button Command="{x:Bind ViewModel.OpenMusicGalleryWindowCommand}">
133+
<TextBlock x:Uid="SystemTrayMusicGallery" />
134+
</Button>
128135
<DropDownButton x:Uid="SettingsPageAddFolderButton">
129136
<DropDownButton.Flyout>
130137
<MenuFlyout>
@@ -169,7 +176,7 @@
169176
</MenuFlyout>
170177
</DropDownButton.Flyout>
171178
</DropDownButton>
172-
</dev:SettingsCard>
179+
</StackPanel>
173180

174181
</StackPanel>
175182
</Grid>

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/StatsDashboardControl.xaml

Lines changed: 225 additions & 136 deletions
Large diffs are not rendered by default.

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/StatsDashboardControl.xaml.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,6 @@ public StatsDashboardControl()
2929
{
3030
InitializeComponent();
3131
DataContext = Ioc.Default.GetRequiredService<StatsDashboardControlViewModel>();
32-
this.Loaded += StatsDashboardControl_Loaded;
3332
}
3433

35-
private async void StatsDashboardControl_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
36-
{
37-
await ViewModel.LoadDataAsync(StatsRange.Day);
38-
}
39-
40-
private async void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
41-
{
42-
if (ViewModel == null) return;
43-
44-
if (TimeRangePivot.SelectedItem is PivotItem item && item.Tag is string tag)
45-
{
46-
var range = tag switch
47-
{
48-
"Day" => StatsRange.Day,
49-
"Week" => StatsRange.Week,
50-
"Month" => StatsRange.Month,
51-
"Quarter" => StatsRange.Quarter,
52-
"Year" => StatsRange.Year,
53-
_ => StatsRange.Day
54-
};
55-
await ViewModel.LoadDataAsync(range);
56-
}
57-
}
5834
}

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Enums/StatsRange.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ namespace BetterLyrics.WinUI3.Enums
66
{
77
public enum StatsRange
88
{
9-
Day,
10-
Week,
11-
Month,
12-
Quarter,
13-
Year
9+
Today,
10+
ThisWeek,
11+
ThisMonth,
12+
ThisQuarter,
13+
ThisYear,
14+
Custom
1415
}
1516
}

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/ColorHelper.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using BetterLyrics.WinUI3.Hooks;
55
using Microsoft.UI;
66
using Microsoft.UI.Xaml;
7+
using SkiaSharp;
78
using System;
89
using System.Collections.Generic;
910
using System.Drawing.Imaging;
@@ -15,6 +16,16 @@ namespace BetterLyrics.WinUI3.Helper
1516
{
1617
public static class ColorHelper
1718
{
19+
public static Color GetSystemAccentColor()
20+
{
21+
if (Application.Current.Resources.TryGetValue("SystemAccentColor", out var resource) &&
22+
resource is Color uiColor)
23+
{
24+
return uiColor;
25+
}
26+
return Color.FromArgb(255, 0, 120, 215);
27+
}
28+
1829
public static ElementTheme GetElementThemeFromBackgroundColor(Color backgroundColor)
1930
{
2031
// 计算亮度(YIQ公式)

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PaletteHelper.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using ColorThiefDotNet;
2+
using CommunityToolkit.WinUI.Helpers;
23
using Impressionist.Abstractions;
34
using Impressionist.Implementations;
45
using System;
@@ -50,7 +51,29 @@ public static async Task<PaletteResult> MedianCutGetAccentColorsFromByteAsync(Bi
5051
return paletteResult;
5152
}
5253

53-
public static async Task<Dictionary<Vector3, int>> GetPixelColor(BitmapDecoder bitmapDecoder)
54+
public static List<Windows.UI.Color> GenerateChartColors(Windows.UI.Color baseColor, int count)
55+
{
56+
List<Windows.UI.Color> results = [];
57+
58+
var baseHsl = baseColor.ToHsl();
59+
double baseHue = baseHsl.H;
60+
double baseSaturation = baseHsl.S;
61+
double baseBrightness = baseHsl.L;
62+
63+
double step = 360.0 / count;
64+
65+
for (int i = 0; i < count; i++)
66+
{
67+
double newHue = (baseHue + (step * i)) % 360;
68+
69+
Windows.UI.Color newColor = CommunityToolkit.WinUI.Helpers.ColorHelper.FromHsl(newHue, baseSaturation, baseBrightness);
70+
results.Add(newColor);
71+
}
72+
73+
return results;
74+
}
75+
76+
private static async Task<Dictionary<Vector3, int>> GetPixelColor(BitmapDecoder bitmapDecoder)
5477
{
5578
var pixelDataProvider = await bitmapDecoder.GetPixelDataAsync();
5679
var pixels = pixelDataProvider.DetachPixelData();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace BetterLyrics.WinUI3.Models.Stats
6+
{
7+
public class HourlyStatBar
8+
{
9+
public int Hour { get; set; }
10+
public double NormalizedHeight { get; set; } // 0 - 100,用于UI高度
11+
public int RawCount { get; set; } // 实际播放数
12+
public string Label { get; set; } // Tooltip: "09:00 - 15 plays"
13+
}
14+
}

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/PlayHistoryService/PlayHistoryService.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using BetterLyrics.WinUI3.Models;
1+
using BetterLyrics.WinUI3.Constants;
2+
using BetterLyrics.WinUI3.Models;
23
using BetterLyrics.WinUI3.Models.Db;
34
using BetterLyrics.WinUI3.Models.Stats;
45
using Microsoft.EntityFrameworkCore;
@@ -197,7 +198,14 @@ public async Task GenerateTestDataAsync(int count = 100)
197198
("Summer", "Calvin Harris", "Motion"),
198199
};
199200

200-
var playerIds = new[] { "Spotify", "Spotify", "Spotify", "MusicBee", "MusicBee", "QQMusic", "NeteaseCloudMusic", "AppleMusic" };
201+
var playerIds = new[]
202+
{
203+
PlayerId.Spotify, PlayerId.Spotify, PlayerId.Spotify,
204+
PlayerId.MusicBee, PlayerId.MusicBee,
205+
PlayerId.QQMusic,
206+
PlayerId.NetEaseCloudMusic,
207+
PlayerId.AppleMusic,
208+
};
201209

202210
var batchList = new List<PlayHistoryItem>();
203211

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ar/Resources.resw

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,22 +1467,46 @@
14671467
<data name="StandardMode" xml:space="preserve">
14681468
<value>الوضع القياسي</value>
14691469
</data>
1470+
<data name="StatsDashboardControlActivityByHour.Text" xml:space="preserve">
1471+
<value>النشاط بالساعة</value>
1472+
</data>
1473+
<data name="StatsDashboardControlCustom.Content" xml:space="preserve">
1474+
<value>مخصص</value>
1475+
</data>
1476+
<data name="StatsDashboardControlEnd.Header" xml:space="preserve">
1477+
<value>النهاية</value>
1478+
</data>
1479+
<data name="StatsDashboardControlLeastActive.Text" xml:space="preserve">
1480+
<value>الأقل نشاطاً</value>
1481+
</data>
1482+
<data name="StatsDashboardControlMostActive.Text" xml:space="preserve">
1483+
<value>الأكثر نشاطاً</value>
1484+
</data>
14701485
<data name="StatsDashboardControlSources.Text" xml:space="preserve">
14711486
<value>المصادر</value>
14721487
</data>
1473-
<data name="StatsDashboardControlThisMonth.Header" xml:space="preserve">
1488+
<data name="StatsDashboardControlStart.Header" xml:space="preserve">
1489+
<value>ابدأ</value>
1490+
</data>
1491+
<data name="StatsDashboardControlThisMonth.Content" xml:space="preserve">
14741492
<value>هذا الشهر</value>
14751493
</data>
1476-
<data name="StatsDashboardControlThisQuarter.Header" xml:space="preserve">
1494+
<data name="StatsDashboardControlThisQuarter.Content" xml:space="preserve">
14771495
<value>هذا الربع</value>
14781496
</data>
1479-
<data name="StatsDashboardControlThisWeek.Header" xml:space="preserve">
1497+
<data name="StatsDashboardControlThisWeek.Content" xml:space="preserve">
14801498
<value>هذا الأسبوع</value>
14811499
</data>
1482-
<data name="StatsDashboardControlThisYear.Header" xml:space="preserve">
1500+
<data name="StatsDashboardControlThisYear.Content" xml:space="preserve">
14831501
<value>هذا العام</value>
14841502
</data>
1485-
<data name="StatsDashboardControlToday.Header" xml:space="preserve">
1503+
<data name="StatsDashboardControlTimeRange.Header" xml:space="preserve">
1504+
<value>النطاق الزمني</value>
1505+
</data>
1506+
<data name="StatsDashboardControlTimes" xml:space="preserve">
1507+
<value>التايمز</value>
1508+
</data>
1509+
<data name="StatsDashboardControlToday.Content" xml:space="preserve">
14861510
<value>اليوم</value>
14871511
</data>
14881512
<data name="StatsDashboardControlTopArtists.Text" xml:space="preserve">
@@ -1497,6 +1521,12 @@
14971521
<data name="StatsDashboardControlTotalDuration.Text" xml:space="preserve">
14981522
<value>المدة الإجمالية</value>
14991523
</data>
1524+
<data name="StatsDashboardControlTrackCountAxis.AxisName" xml:space="preserve">
1525+
<value>التايمز</value>
1526+
</data>
1527+
<data name="StatsDashboardControlTrackCountText.Text" xml:space="preserve">
1528+
<value>التايمز</value>
1529+
</data>
15001530
<data name="StatsDashboardControlTracksPlayed.Text" xml:space="preserve">
15011531
<value>المسارات التي تم تشغيلها</value>
15021532
</data>

0 commit comments

Comments
 (0)