diff --git a/src/Starward.Language/Lang.Designer.cs b/src/Starward.Language/Lang.Designer.cs
index c14e2c908..7b2dabde5 100644
--- a/src/Starward.Language/Lang.Designer.cs
+++ b/src/Starward.Language/Lang.Designer.cs
@@ -466,6 +466,60 @@ public static string Common_Yes {
}
}
+ ///
+ /// 查找类似 Warning: The selected time period includes gacha records from more than 6 months ago, which cannot be retrieved after deleting. 的本地化字符串。
+ ///
+ public static string DeleteGachaLogDialog_6MonthsDeletingWarning {
+ get {
+ return ResourceManager.GetString("DeleteGachaLogDialog_6MonthsDeletingWarning", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Begin Time 的本地化字符串。
+ ///
+ public static string DeleteGachaLogDialog_BeginTime {
+ get {
+ return ResourceManager.GetString("DeleteGachaLogDialog_BeginTime", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Delete gacha records for a specific time period 的本地化字符串。
+ ///
+ public static string DeleteGachaLogDialog_DeleteGachaRecordsForASpecificTimePeriod {
+ get {
+ return ResourceManager.GetString("DeleteGachaLogDialog_DeleteGachaRecordsForASpecificTimePeriod", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 End Time 的本地化字符串。
+ ///
+ public static string DeleteGachaLogDialog_EndTime {
+ get {
+ return ResourceManager.GetString("DeleteGachaLogDialog_EndTime", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 The selected time period includes {0} gacha records. 的本地化字符串。
+ ///
+ public static string DeleteGachaLogDialog_TheSelectedTimePeriodIncludes0GachaRecords {
+ get {
+ return ResourceManager.GetString("DeleteGachaLogDialog_TheSelectedTimePeriodIncludes0GachaRecords", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 This account has {0} gacha record(s). 的本地化字符串。
+ ///
+ public static string DeleteGachaLogDialog_ThisAccountHas0GachaRecordS {
+ get {
+ return ResourceManager.GetString("DeleteGachaLogDialog_ThisAccountHas0GachaRecordS", resourceCulture);
+ }
+ }
+
///
/// 查找类似 Downloaded: 的本地化字符串。
///
@@ -1223,6 +1277,15 @@ public static string GachaLogPage_CopyURL {
}
}
+ ///
+ /// 查找类似 Delete All 的本地化字符串。
+ ///
+ public static string GachaLogPage_DeleteAll {
+ get {
+ return ResourceManager.GetString("GachaLogPage_DeleteAll", resourceCulture);
+ }
+ }
+
///
/// 查找类似 Deleted {0} gacha record(s) of UID {1}. 的本地化字符串。
///
@@ -1358,6 +1421,15 @@ public static string GachaLogPage_ShowNoviceGachaType {
}
}
+ ///
+ /// 查找类似 Specific Time Period 的本地化字符串。
+ ///
+ public static string GachaLogPage_SpecificTimePeriod {
+ get {
+ return ResourceManager.GetString("GachaLogPage_SpecificTimePeriod", resourceCulture);
+ }
+ }
+
///
/// 查找类似 Update (All) 的本地化字符串。
///
diff --git a/src/Starward.Language/Lang.resx b/src/Starward.Language/Lang.resx
index 9c8f9e9ed..7d191ee06 100644
--- a/src/Starward.Language/Lang.resx
+++ b/src/Starward.Language/Lang.resx
@@ -1609,4 +1609,28 @@ Do you accept the risk and continue to use it?
Other Rewards
+
+ Begin Time
+
+
+ End Time
+
+
+ Delete gacha records for a specific time period
+
+
+ Warning: The selected time period includes gacha records from more than 6 months ago, which cannot be retrieved after deleting.
+
+
+ This account has {0} gacha record(s).
+
+
+ The selected time period includes {0} gacha records.
+
+
+ Delete All
+
+
+ Specific Time Period
+
\ No newline at end of file
diff --git a/src/Starward.Language/Lang.zh-CN.resx b/src/Starward.Language/Lang.zh-CN.resx
index 3687f014f..040e5bb83 100644
--- a/src/Starward.Language/Lang.zh-CN.resx
+++ b/src/Starward.Language/Lang.zh-CN.resx
@@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
@@ -1609,4 +1609,28 @@
其他奖励
+
+ 起始时间
+
+
+ 结束时间
+
+
+ 删除特定时间段的抽卡记录
+
+
+ 警告:所选时间段包含6个月之前的抽卡记录,删除后无法再次获取。
+
+
+ 此账号有 {0} 条抽卡记录
+
+
+ 所选时间段包含 {0} 条抽卡记录
+
+
+ 全部删除
+
+
+ 指定时间段
+
\ No newline at end of file
diff --git a/src/Starward/Controls/DeleteGachaLogDialog.xaml b/src/Starward/Controls/DeleteGachaLogDialog.xaml
new file mode 100644
index 000000000..694bd1cfd
--- /dev/null
+++ b/src/Starward/Controls/DeleteGachaLogDialog.xaml
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Starward/Controls/DeleteGachaLogDialog.xaml.cs b/src/Starward/Controls/DeleteGachaLogDialog.xaml.cs
new file mode 100644
index 000000000..13c795550
--- /dev/null
+++ b/src/Starward/Controls/DeleteGachaLogDialog.xaml.cs
@@ -0,0 +1,227 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.Extensions.Logging;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Starward.Core;
+using Starward.Helpers;
+using Starward.Models;
+using Starward.Services.Gacha;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+
+
+namespace Starward.Controls;
+
+[INotifyPropertyChanged]
+public sealed partial class DeleteGachaLogDialog : ContentDialog
+{
+
+
+ private readonly ILogger _logger = AppConfig.GetLogger();
+
+
+ public GameBiz CurrentGameBiz { get; set; }
+
+
+ public long? DefaultUid { get; set; }
+
+
+ public bool Deleted { get; set; }
+
+
+
+ private GachaLogService _gachaLogService;
+
+
+ public DeleteGachaLogDialog()
+ {
+ this.InitializeComponent();
+ }
+
+
+
+
+ [ObservableProperty]
+ private ObservableCollection uidList;
+
+
+
+ [ObservableProperty]
+ private long? selectUid;
+ partial void OnSelectUidChanged(long? value)
+ {
+ if (value.HasValue)
+ {
+ LoadGachaLog(value.Value);
+ }
+ }
+
+
+ private List gachalogs;
+
+
+ private void ContentDialog_Loaded(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (CurrentGameBiz.ToGame() is GameBiz.GenshinImpact)
+ {
+ _gachaLogService = AppConfig.GetService();
+ }
+ if (CurrentGameBiz.ToGame() is GameBiz.StarRail)
+ {
+ _gachaLogService = AppConfig.GetService();
+ }
+ if (CurrentGameBiz.ToGame() is GameBiz.ZZZ)
+ {
+ _gachaLogService = AppConfig.GetService();
+ }
+
+ if (_gachaLogService is not null)
+ {
+ UidList = new(_gachaLogService.GetUids());
+ if (DefaultUid.HasValue && UidList.Contains(DefaultUid.Value))
+ {
+ SelectUid = DefaultUid;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Delete gacha log dialog initialize.");
+ }
+ }
+
+
+
+ private void LoadGachaLog(long uid)
+ {
+ try
+ {
+ gachalogs = _gachaLogService.GetGachaLogItemEx(uid);
+ TextBlock_GachaLogNumber.Visibility = Visibility.Visible;
+ TextBlock_GachaLogNumber.Text = string.Format(Lang.DeleteGachaLogDialog_ThisAccountHas0GachaRecordS, gachalogs.Count);
+ CalendarDatePicker_BeginTime.Date = null;
+ CalendarDatePicker_EndTime.Date = null;
+ TimePicker_BeginTime.SelectedTime = null;
+ TimePicker_EndTime.SelectedTime = null;
+ Button_Delete.IsEnabled = false;
+ TextBlock_SelectedCount.Visibility = Visibility.Collapsed;
+ TextBlock_Warning.Visibility = Visibility.Collapsed;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Delete gacha log dialog load gacha log.");
+ }
+ }
+
+
+
+
+ private void CalendarDatePicker_DateChanged(CalendarDatePicker sender, CalendarDatePickerDateChangedEventArgs args)
+ {
+ if (sender == CalendarDatePicker_BeginTime && TimePicker_BeginTime.SelectedTime == null)
+ {
+ TimePicker_BeginTime.Time = TimeSpan.Zero;
+ }
+ if (sender == CalendarDatePicker_EndTime && TimePicker_EndTime.SelectedTime == null)
+ {
+ TimePicker_EndTime.Time = TimeSpan.Zero;
+ }
+ OnTimePeriodChanged();
+ }
+
+
+
+ private void TimePicker_SelectedTimeChanged(TimePicker sender, TimePickerSelectedValueChangedEventArgs args)
+ {
+ OnTimePeriodChanged();
+ }
+
+
+
+
+ private void OnTimePeriodChanged()
+ {
+ try
+ {
+ var beginDate = CalendarDatePicker_BeginTime.Date;
+ var beginTime = TimePicker_BeginTime.SelectedTime;
+ var endDate = CalendarDatePicker_EndTime.Date;
+ var endTime = TimePicker_EndTime.SelectedTime;
+ if (beginDate.HasValue && beginTime.HasValue && endDate.HasValue && endTime.HasValue)
+ {
+ var begin = beginDate + beginTime;
+ var end = endDate + endTime;
+ if (begin <= end)
+ {
+ var count = gachalogs.Count(x => x.Time >= begin && x.Time <= end);
+ TextBlock_SelectedCount.Visibility = Visibility.Visible;
+ TextBlock_SelectedCount.Text = string.Format(Lang.DeleteGachaLogDialog_TheSelectedTimePeriodIncludes0GachaRecords, count);
+ Button_Delete.IsEnabled = count > 0;
+ TextBlock_Warning.Visibility = begin < DateTimeOffset.Now - TimeSpan.FromDays(180) ? Visibility.Visible : Visibility.Collapsed;
+ return;
+ }
+ }
+ Button_Delete.IsEnabled = false;
+ TextBlock_SelectedCount.Visibility = Visibility.Collapsed;
+ TextBlock_Warning.Visibility = Visibility.Collapsed;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Delete gacha log dialog time changed.");
+ }
+ }
+
+
+
+
+
+ [RelayCommand]
+ private void Delete()
+ {
+ try
+ {
+ var beginDate = CalendarDatePicker_BeginTime.Date;
+ var beginTime = TimePicker_BeginTime.SelectedTime;
+ var endDate = CalendarDatePicker_EndTime.Date;
+ var endTime = TimePicker_EndTime.SelectedTime;
+ if (SelectUid.HasValue && beginDate.HasValue && beginTime.HasValue && endDate.HasValue && endTime.HasValue)
+ {
+ var begin = beginDate + beginTime;
+ var end = endDate + endTime;
+ if (begin <= end)
+ {
+ var count = gachalogs.Count(x => x.Time >= begin && x.Time <= end);
+ if (count > 0)
+ {
+ _logger.LogInformation("Deleting {count} gachalogs from {begin} to {end} of {uid} ({biz}).", count, begin, end, SelectUid, CurrentGameBiz);
+ _gachaLogService.DeleteGachaLogByTime(SelectUid.Value, begin.Value.LocalDateTime, end.Value.LocalDateTime);
+ NotificationBehavior.Instance.Success(string.Format(Lang.GachaLogPage_DeletedGachaRecordsOfUid, count, SelectUid));
+ Deleted = true;
+ this.Hide();
+ return;
+ }
+ }
+ }
+ Button_Delete.IsEnabled = false;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Delete gacha log dialog delete method.");
+ }
+ }
+
+
+
+ [RelayCommand]
+ private void Cancel()
+ {
+ this.Hide();
+ }
+
+
+}
diff --git a/src/Starward/Pages/GachaLogPage.xaml b/src/Starward/Pages/GachaLogPage.xaml
index 9ef24663c..d44559272 100644
--- a/src/Starward/Pages/GachaLogPage.xaml
+++ b/src/Starward/Pages/GachaLogPage.xaml
@@ -191,7 +191,7 @@
OffContent="{x:Bind lang:Lang.GachaLogPage_ShowChronicledWish}"
OnContent="{x:Bind lang:Lang.GachaLogPage_ShowChronicledWish}"
Visibility="Collapsed" />
-