diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Markup/Int32Extension.cs b/src/Snap.Hutao/Snap.Hutao/Control/Markup/Int32Extension.cs new file mode 100644 index 00000000..ee0480f4 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Control/Markup/Int32Extension.cs @@ -0,0 +1,18 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Microsoft.UI.Xaml.Markup; + +namespace Snap.Hutao.Control.Markup; + +[MarkupExtensionReturnType(ReturnType = typeof(int))] +internal sealed class Int32Extension : MarkupExtension +{ + public string Value { get; set; } = default!; + + protected override object ProvideValue() + { + _ = int.TryParse(Value, out int result); + return result; + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Extension/EnumerableExtension.List.cs b/src/Snap.Hutao/Snap.Hutao/Extension/EnumerableExtension.List.cs index bac4c6d9..1add186f 100644 --- a/src/Snap.Hutao/Snap.Hutao/Extension/EnumerableExtension.List.cs +++ b/src/Snap.Hutao/Snap.Hutao/Extension/EnumerableExtension.List.cs @@ -84,6 +84,11 @@ internal static partial class EnumerableExtension return false; } + public static void RemoveLast(this IList collection) + { + collection.RemoveAt(collection.Count - 1); + } + /// /// 转换到新类型的列表 /// diff --git a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.Designer.cs b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.Designer.cs index 27ec564c..0c5ef13c 100644 --- a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.Designer.cs +++ b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.Designer.cs @@ -2094,6 +2094,33 @@ namespace Snap.Hutao.Resource.Localization { } } + /// + /// 查找类似 预测 的本地化字符串。 + /// + internal static string ViewControlStatisticsSegmentedItemContentPrediction { + get { + return ResourceManager.GetString("ViewControlStatisticsSegmentedItemContentPrediction", resourceCulture); + } + } + + /// + /// 查找类似 比例 的本地化字符串。 + /// + internal static string ViewControlStatisticsSegmentedItemContentProportion { + get { + return ResourceManager.GetString("ViewControlStatisticsSegmentedItemContentProportion", resourceCulture); + } + } + + /// + /// 查找类似 统计 的本地化字符串。 + /// + internal static string ViewControlStatisticsSegmentedItemContentStatistics { + get { + return ResourceManager.GetString("ViewControlStatisticsSegmentedItemContentStatistics", resourceCulture); + } + } + /// /// 查找类似 养成计划 的本地化字符串。 /// @@ -3103,7 +3130,7 @@ namespace Snap.Hutao.Resource.Localization { } /// - /// 查找类似 {1:00.000%} 概率 {0} 抽后获得五星物品 的本地化字符串。 + /// 查找类似 {1:P3} 概率 {0} 抽后获得五星物品 的本地化字符串。 /// internal static string ViewModelGachaLogPredictedPullLeftToOrange { get { @@ -3112,7 +3139,7 @@ namespace Snap.Hutao.Resource.Localization { } /// - /// 查找类似 {0:00.000%} 概率下一抽获得五星物品 的本地化字符串。 + /// 查找类似 {0:P3} 概率下一抽获得五星物品 的本地化字符串。 /// internal static string ViewModelGachaLogProbabilityOfNextPullIsOrange { get { diff --git a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx index 62e601f7..1150b286 100644 --- a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx +++ b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx @@ -851,6 +851,15 @@ UP + + 预测 + + + 比例 + + + 统计 + 养成计划 @@ -1188,10 +1197,10 @@ 导入失败 - {1:00.000%} 概率 {0} 抽后获得五星物品 + {1:P3} 概率 {0} 抽后获得五星物品 - {0:00.000%} 概率下一抽获得五星物品 + {0:P3} 概率下一抽获得五星物品 获取祈愿记录失败 diff --git a/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj b/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj index 9fa86bcd..5288bf55 100644 --- a/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj +++ b/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj @@ -119,6 +119,7 @@ + @@ -298,6 +299,12 @@ + + + MSBuild:Compile + + + MSBuild:Compile diff --git a/src/Snap.Hutao/Snap.Hutao/View/Card/GachaStatisticsCard.xaml b/src/Snap.Hutao/Snap.Hutao/View/Card/GachaStatisticsCard.xaml index f05afc46..0822c630 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Card/GachaStatisticsCard.xaml +++ b/src/Snap.Hutao/Snap.Hutao/View/Card/GachaStatisticsCard.xaml @@ -305,4 +305,4 @@ Visibility="{Binding IsInitialized, Converter={StaticResource BoolToVisibilityConverter}}"/> - + \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsCard.xaml b/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsCard.xaml index 5a86442d..b72150cc 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsCard.xaml +++ b/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsCard.xaml @@ -2,12 +2,10 @@ x:Class="Snap.Hutao.View.Control.StatisticsCard" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:clws="using:CommunityToolkit.Labs.WinUI" + xmlns:cwc="using:CommunityToolkit.WinUI.Controls" xmlns:cwuc="using:CommunityToolkit.WinUI.UI.Converters" - xmlns:cwucont="using:CommunityToolkit.WinUI.UI.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:shc="using:Snap.Hutao.Control" xmlns:shci="using:Snap.Hutao.Control.Image" xmlns:shcm="using:Snap.Hutao.Control.Markup" xmlns:shcp="using:Snap.Hutao.Control.Panel" @@ -237,15 +235,18 @@ - - - - + + + + - - - - - - - - - + + + - - - + + + + + + + + @@ -341,23 +333,23 @@ Grid.Row="2" Margin="12,6,12,12" VerticalScrollBarVisibility="Hidden"> - - + + - - + + - - + + - - + + diff --git a/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsSegmented.xaml b/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsSegmented.xaml new file mode 100644 index 00000000..d5d4d5ac --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsSegmented.xaml @@ -0,0 +1,13 @@ + + + + + diff --git a/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsSegmented.xaml.cs b/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsSegmented.xaml.cs new file mode 100644 index 00000000..a5f3279c --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsSegmented.xaml.cs @@ -0,0 +1,36 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using CommunityToolkit.WinUI.Controls; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace Snap.Hutao.View.Control; + +[DependencyProperty("IsPredictPullAvailable", typeof(bool), false, nameof(OnIsPredictPullAvailableChanged))] +internal sealed partial class StatisticsSegmented : Segmented +{ + private readonly SegmentedItem predictPullItem = new() + { + Content = SH.ViewControlStatisticsSegmentedItemContentPrediction, + Icon = new FontIcon() { Glyph = "\uEA80" }, + }; + + public StatisticsSegmented() + { + InitializeComponent(); + } + + private static void OnIsPredictPullAvailableChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) + { + StatisticsSegmented segmented = (StatisticsSegmented)obj; + if (args.NewValue is true) + { + segmented.Items.Add(segmented.predictPullItem); + } + else + { + segmented.Items.RemoveLast(); + } + } +}