attempt to fix cultivation selection

This commit is contained in:
Lightczx
2023-08-30 14:34:44 +08:00
parent 00c13ec333
commit 686d2bd3b8
16 changed files with 84 additions and 55 deletions

View File

@@ -4,6 +4,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Snap.Hutao.SourceGeneration.Primitive;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@@ -16,6 +17,7 @@ namespace Snap.Hutao.SourceGeneration.Automation;
internal sealed class ConstructorGenerator : IIncrementalGenerator
{
private const string AttributeName = "Snap.Hutao.Core.Annotation.ConstructorGeneratedAttribute";
private const string CompilerGenerated = "System.Runtime.CompilerServices.CompilerGeneratedAttribute";
//private static readonly DiagnosticDescriptor genericTypeNotSupportedDescriptor = new("SH102", "Generic type is not supported to generate .ctor", "Type [{0}] is not supported", "Quality", DiagnosticSeverity.Error, true);
@@ -98,6 +100,11 @@ internal sealed class ConstructorGenerator : IIncrementalGenerator
foreach (IFieldSymbol fieldSymbol in fields)
{
if (fieldSymbol.Name.AsSpan()[0] is '<')
{
continue;
}
bool shoudSkip = false;
foreach (SyntaxReference syntaxReference in fieldSymbol.DeclaringSyntaxReferences)
{

View File

@@ -3,10 +3,10 @@
using Microsoft.UI.Xaml;
namespace Snap.Hutao.View.Helper;
namespace Snap.Hutao.Control.Helper;
[SuppressMessage("", "SH001")]
[DependencyProperty("SquareLength", typeof(double), 0D, nameof(OnSquareLengthChanged), IsAttached = true, AttachedType = typeof(Microsoft.UI.Xaml.FrameworkElement))]
[DependencyProperty("SquareLength", typeof(double), 0D, nameof(OnSquareLengthChanged), IsAttached = true, AttachedType = typeof(FrameworkElement))]
public sealed partial class FrameworkElementHelper
{
private static void OnSquareLengthChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)

View File

@@ -1,6 +1,7 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Microsoft.UI.Xaml.Media;
using System.Buffers.Binary;
using System.Runtime.CompilerServices;
using Windows.UI;

View File

@@ -0,0 +1,23 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Shapes;
namespace Snap.Hutao.Control;
[DependencyProperty("Source", typeof(GradientStopCollection))]
internal sealed partial class SegmentedBar : ContentControl
{
private readonly LinearGradientBrush brush = new();
public SegmentedBar()
{
Content = new Rectangle()
{
Fill = brush,
};
}
}

View File

@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Snap.Hutao.Core.Database;
using Snap.Hutao.Model.Entity;
using Snap.Hutao.Model.Entity.Database;
using System.Collections.ObjectModel;
namespace Snap.Hutao.Service.Cultivation;
@@ -153,4 +154,13 @@ internal sealed partial class CultivationDbService : ICultivationDbService
.ConfigureAwait(false);
}
}
public ObservableCollection<CultivateProject> GetCultivateProjectCollection()
{
using (IServiceScope scope = serviceProvider.CreateScope())
{
AppDbContext appDbContext = scope.ServiceProvider.GetRequiredService<AppDbContext>();
return appDbContext.CultivateProjects.AsNoTracking().ToObservableCollection();
}
}
}

View File

@@ -29,12 +29,7 @@ internal sealed partial class CultivationService
{
if (projects is null)
{
using (IServiceScope scope = serviceProvider.CreateScope())
{
AppDbContext appDbContext = scope.ServiceProvider.GetRequiredService<AppDbContext>();
projects = appDbContext.CultivateProjects.ToObservableCollection();
}
projects = cultivationDbService.GetCultivateProjectCollection();
Current ??= projects.SelectedOrDefault();
}

View File

@@ -2,6 +2,7 @@
// Licensed under the MIT license.
using Snap.Hutao.Model.Entity;
using System.Collections.ObjectModel;
namespace Snap.Hutao.Service.Cultivation;
@@ -21,6 +22,8 @@ internal interface ICultivationDbService
ValueTask<List<CultivateItem>> GetCultivateItemListByEntryIdAsync(Guid entryId);
ObservableCollection<CultivateProject> GetCultivateProjectCollection();
List<InventoryItem> GetInventoryItemListByProjectId(Guid projectId);
ValueTask<List<InventoryItem>> GetInventoryItemListByProjectIdAsync(Guid projectId);

View File

@@ -8,14 +8,16 @@ using Snap.Hutao.Model.Entity;
using Snap.Hutao.Service.Abstraction;
using Snap.Hutao.Service.Notification;
using System.Globalization;
using System.Runtime.CompilerServices;
namespace Snap.Hutao.Service.DailyNote;
/// <summary>
/// 实时便笺选项
/// </summary>
[ConstructorGenerated(CallBaseConstructor = true)]
[Injection(InjectAs.Singleton)]
internal sealed class DailyNoteOptions : DbStoreOptions
internal sealed partial class DailyNoteOptions : DbStoreOptions
{
private const int OneMinute = 60;
@@ -27,17 +29,6 @@ internal sealed class DailyNoteOptions : DbStoreOptions
private bool? isReminderNotification;
private bool? isSilentWhenPlayingGame;
/// <summary>
/// 构造一个新的实时便笺选项
/// </summary>
/// <param name="serviceProvider">服务提供器</param>
public DailyNoteOptions(IServiceProvider serviceProvider)
: base(serviceProvider)
{
scheduleTaskInterop = serviceProvider.GetRequiredService<IScheduleTaskInterop>();
this.serviceProvider = serviceProvider;
}
/// <summary>
/// 刷新时间
/// </summary>

View File

@@ -6,10 +6,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
xmlns:shch="using:Snap.Hutao.Control.Helper"
xmlns:shci="using:Snap.Hutao.Control.Image"
xmlns:shvc="using:Snap.Hutao.View.Control"
xmlns:shvd="using:Snap.Hutao.ViewModel.DailyNote"
xmlns:shvh="using:Snap.Hutao.View.Helper"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
@@ -64,7 +64,7 @@
<Grid Grid.Row="1" Style="{StaticResource BorderGridStyle}">
<StackPanel VerticalAlignment="Center">
<shci:CachedImage shvh:FrameworkElementHelper.SquareLength="64" Source="{StaticResource UI_ItemIcon_210}"/>
<shci:CachedImage shch:FrameworkElementHelper.SquareLength="64" Source="{StaticResource UI_ItemIcon_210}"/>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
@@ -75,7 +75,7 @@
Margin="8"
HorizontalAlignment="Right"
VerticalAlignment="Top"
shvh:FrameworkElementHelper.SquareLength="8"
shch:FrameworkElementHelper.SquareLength="8"
Style="{ThemeResource AttentionDotInfoBadgeStyle}"
Visibility="{Binding ResinNotifySuppressed, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Grid>
@@ -92,7 +92,7 @@
<Grid Grid.Row="0" Style="{StaticResource BorderGridStyle}">
<StackPanel VerticalAlignment="Center">
<shci:CachedImage shvh:FrameworkElementHelper.SquareLength="32" Source="{StaticResource UI_ItemIcon_204}"/>
<shci:CachedImage shch:FrameworkElementHelper.SquareLength="32" Source="{StaticResource UI_ItemIcon_204}"/>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
@@ -103,14 +103,14 @@
Margin="8"
HorizontalAlignment="Right"
VerticalAlignment="Top"
shvh:FrameworkElementHelper.SquareLength="8"
shch:FrameworkElementHelper.SquareLength="8"
Style="{ThemeResource AttentionDotInfoBadgeStyle}"
Visibility="{Binding HomeCoinNotifySuppressed, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Grid>
<Grid Grid.Row="1" Style="{StaticResource BorderGridStyle}">
<StackPanel VerticalAlignment="Center">
<shci:CachedImage shvh:FrameworkElementHelper.SquareLength="32" Source="{StaticResource UI_MarkQuest_Events_Proce}"/>
<shci:CachedImage shch:FrameworkElementHelper.SquareLength="32" Source="{StaticResource UI_MarkQuest_Events_Proce}"/>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
@@ -121,7 +121,7 @@
Margin="8"
HorizontalAlignment="Right"
VerticalAlignment="Top"
shvh:FrameworkElementHelper.SquareLength="8"
shch:FrameworkElementHelper.SquareLength="8"
Style="{ThemeResource AttentionDotInfoBadgeStyle}"
Visibility="{Binding DailyTaskNotifySuppressed, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Grid>
@@ -138,7 +138,7 @@
<Grid Grid.Row="0" Style="{StaticResource BorderGridStyle}">
<StackPanel VerticalAlignment="Center">
<shci:CachedImage shvh:FrameworkElementHelper.SquareLength="32" Source="{StaticResource UI_MarkTower}"/>
<shci:CachedImage shch:FrameworkElementHelper.SquareLength="32" Source="{StaticResource UI_MarkTower}"/>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
@@ -149,7 +149,7 @@
<Grid Grid.Row="1" Style="{StaticResource BorderGridStyle}">
<StackPanel VerticalAlignment="Center">
<shci:CachedImage shvh:FrameworkElementHelper.SquareLength="32" Source="{StaticResource UI_ItemIcon_220021}"/>
<shci:CachedImage shch:FrameworkElementHelper.SquareLength="32" Source="{StaticResource UI_ItemIcon_220021}"/>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
@@ -160,7 +160,7 @@
Margin="8"
HorizontalAlignment="Right"
VerticalAlignment="Top"
shvh:FrameworkElementHelper.SquareLength="8"
shch:FrameworkElementHelper.SquareLength="8"
Style="{ThemeResource AttentionDotInfoBadgeStyle}"
Visibility="{Binding TransformerNotifySuppressed, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Grid>

View File

@@ -2,15 +2,14 @@
x:Class="Snap.Hutao.View.Control.HutaoStatisticsCard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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:shch="using:Snap.Hutao.Control.Helper"
xmlns:shci="using:Snap.Hutao.Control.Image"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shcp="using:Snap.Hutao.Control.Panel"
xmlns:shvcont="using:Snap.Hutao.View.Control"
xmlns:shvg="using:Snap.Hutao.ViewModel.GachaLog"
xmlns:shvh="using:Snap.Hutao.View.Helper"
d:DataContext="{d:DesignInstance shvg:HutaoWishSummary}"
mc:Ignorable="d">
@@ -22,7 +21,7 @@
Style="{StaticResource BorderCardStyle}">
<StackPanel>
<shvcont:ItemIcon
shvh:FrameworkElementHelper.SquareLength="40"
shch:FrameworkElementHelper.SquareLength="40"
Icon="{Binding Icon}"
Quality="{Binding Quality}"/>
<TextBlock

View File

@@ -4,10 +4,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shch="using:Snap.Hutao.Control.Helper"
xmlns:shci="using:Snap.Hutao.Control.Image"
xmlns:shmmc="using:Snap.Hutao.Model.Metadata.Converter"
xmlns:shvh="using:Snap.Hutao.View.Helper"
shvh:FrameworkElementHelper.SquareLength="80"
shch:FrameworkElementHelper.SquareLength="80"
mc:Ignorable="d">
<UserControl.Resources>
<shmmc:QualityConverter x:Key="QualityConverter"/>

View File

@@ -4,9 +4,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shch="using:Snap.Hutao.Control.Helper"
xmlns:shci="using:Snap.Hutao.Control.Image"
xmlns:shmmc="using:Snap.Hutao.Model.Metadata.Converter"
xmlns:shvh="using:Snap.Hutao.View.Helper"
mc:Ignorable="d">
<UserControl.Resources>
@@ -26,7 +26,7 @@
<Pivot.HeaderTemplate>
<DataTemplate>
<StackPanel>
<shci:MonoChrome shvh:FrameworkElementHelper.SquareLength="36" Source="{Binding Icon, Converter={StaticResource SkillIconConverter}}"/>
<shci:MonoChrome shch:FrameworkElementHelper.SquareLength="36" Source="{Binding Icon, Converter={StaticResource SkillIconConverter}}"/>
<TextBlock
Margin="0,8,0,0"
HorizontalAlignment="Center"

View File

@@ -6,13 +6,13 @@
xmlns:cwuc="using:CommunityToolkit.WinUI.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shch="using:Snap.Hutao.Control.Helper"
xmlns:shci="using:Snap.Hutao.Control.Image"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shcp="using:Snap.Hutao.Control.Panel"
xmlns:shvcont="using:Snap.Hutao.View.Control"
xmlns:shvconv="using:Snap.Hutao.View.Converter"
xmlns:shvg="using:Snap.Hutao.ViewModel.GachaLog"
xmlns:shvh="using:Snap.Hutao.View.Helper"
d:DataContext="{d:DesignInstance shvg:TypedWishSummary}"
mc:Ignorable="d">
@@ -39,7 +39,7 @@
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<shci:CachedImage
shvh:FrameworkElementHelper.SquareLength="40"
shch:FrameworkElementHelper.SquareLength="40"
CornerRadius="{ThemeResource ControlCornerRadius}"
Source="{Binding Icon}"/>
<TextBlock
@@ -94,7 +94,7 @@
<SolidColorBrush Color="{Binding Color}"/>
</shvcont:BottomTextSmallControl.Foreground>
<shvcont:ItemIcon
shvh:FrameworkElementHelper.SquareLength="40"
shch:FrameworkElementHelper.SquareLength="40"
Icon="{Binding Icon}"
Quality="{Binding Quality}"/>
</shvcont:BottomTextSmallControl>
@@ -236,10 +236,10 @@
</StackPanel>
<MenuFlyoutSeparator Margin="-12,0"/>
<shvcont:StatisticsSegmented
IsPredictPullAvailable="{Binding IsPredictPullAvailable}"
x:Name="StatisticsSegmented"
Margin="0,16,0,0"
Margin="0,12,0,0"
HorizontalAlignment="Stretch"
IsPredictPullAvailable="{Binding IsPredictPullAvailable}"
SelectedIndex="0"/>
<cwc:SwitchPresenter
Height="85"

View File

@@ -5,9 +5,9 @@
xmlns:cwc="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shch="using:Snap.Hutao.Control.Helper"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shvc="using:Snap.Hutao.View.Control"
xmlns:shvh="using:Snap.Hutao.View.Helper"
Title="{shcm:ResourceString Name=ViewDialogGachaLogRefreshProgressTitle}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">
@@ -15,7 +15,7 @@
<ContentDialog.Resources>
<DataTemplate x:Key="GachaItemDataTemplate">
<shvc:ItemIcon
shvh:FrameworkElementHelper.SquareLength="60"
shch:FrameworkElementHelper.SquareLength="60"
Badge="{Binding Badge}"
Icon="{Binding Icon}"
Quality="{Binding Quality}"/>

View File

@@ -9,11 +9,11 @@
xmlns:mxic="using:Microsoft.Xaml.Interactions.Core"
xmlns:shc="using:Snap.Hutao.Control"
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
xmlns:shch="using:Snap.Hutao.Control.Helper"
xmlns:shci="using:Snap.Hutao.Control.Image"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shcp="using:Snap.Hutao.Control.Panel"
xmlns:shva="using:Snap.Hutao.ViewModel.Achievement"
xmlns:shvh="using:Snap.Hutao.View.Helper"
d:DataContext="{d:DesignInstance shva:AchievementViewModel}"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
@@ -236,7 +236,7 @@
Visibility="{Binding IsChecked, Converter={StaticResource BoolToVisibilityConverter}}"/>
<shci:CachedImage
Grid.Column="2"
shvh:FrameworkElementHelper.SquareLength="32"
shch:FrameworkElementHelper.SquareLength="32"
Source="{StaticResource UI_ItemIcon_201}"/>
<TextBlock
Grid.Column="3"

View File

@@ -12,11 +12,11 @@
xmlns:mxim="using:Microsoft.Xaml.Interactions.Media"
xmlns:shc="using:Snap.Hutao.Control"
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
xmlns:shch="using:Snap.Hutao.Control.Helper"
xmlns:shci="using:Snap.Hutao.Control.Image"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shvc="using:Snap.Hutao.View.Control"
xmlns:shvd="using:Snap.Hutao.ViewModel.DailyNote"
xmlns:shvh="using:Snap.Hutao.View.Helper"
d:DataContext="{d:DesignInstance shvd:DailyNoteViewModel}"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
@@ -255,7 +255,7 @@
Margin="8,0,0,0"
HorizontalAlignment="Right"
VerticalAlignment="Stretch"
shvh:FrameworkElementHelper.SquareLength="40"
shch:FrameworkElementHelper.SquareLength="40"
Background="Transparent"
BorderBrush="{x:Null}"
BorderThickness="0"
@@ -267,7 +267,7 @@
<Button
Margin="8,0,0,0"
VerticalAlignment="Stretch"
shvh:FrameworkElementHelper.SquareLength="40"
shch:FrameworkElementHelper.SquareLength="40"
Background="Transparent"
BorderBrush="{x:Null}"
BorderThickness="0"
@@ -301,7 +301,7 @@
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
shvh:FrameworkElementHelper.SquareLength="32"
shch:FrameworkElementHelper.SquareLength="32"
Source="{StaticResource UI_ItemIcon_210}"/>
<StackPanel
Grid.Column="1"
@@ -338,7 +338,7 @@
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
shvh:FrameworkElementHelper.SquareLength="32"
shch:FrameworkElementHelper.SquareLength="32"
Source="{StaticResource UI_ItemIcon_204}"/>
<StackPanel
Grid.Column="1"
@@ -375,7 +375,7 @@
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
shvh:FrameworkElementHelper.SquareLength="32"
shch:FrameworkElementHelper.SquareLength="32"
Source="{StaticResource UI_MarkQuest_Events_Proce}"/>
<StackPanel
Grid.Column="1"
@@ -412,7 +412,7 @@
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
shvh:FrameworkElementHelper.SquareLength="32"
shch:FrameworkElementHelper.SquareLength="32"
Source="{StaticResource UI_MarkTower}"/>
<StackPanel
Grid.Column="1"
@@ -449,7 +449,7 @@
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
shvh:FrameworkElementHelper.SquareLength="32"
shch:FrameworkElementHelper.SquareLength="32"
Source="{StaticResource UI_ItemIcon_220021}"/>
<StackPanel
Grid.Column="1"
@@ -502,7 +502,7 @@
Value="{Binding PassedTime, Mode=OneWay}"/>
<shci:CachedImage
Margin="0,0,0,8"
shvh:FrameworkElementHelper.SquareLength="32"
shch:FrameworkElementHelper.SquareLength="32"
Source="{Binding AvatarSideIcon, Mode=OneWay}"/>
<TextBlock
Grid.Column="1"