refine view

This commit is contained in:
Lightczx
2024-05-22 16:46:06 +08:00
parent e93802d5a5
commit f7e94fe2f2
4 changed files with 72 additions and 46 deletions

View File

@@ -85,7 +85,7 @@ public sealed partial class App : Application
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
Debug.WriteLine(ex);
Process.GetCurrentProcess().Kill();
}
}

View File

@@ -44,6 +44,7 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
private readonly IServiceProvider serviceProvider;
private readonly ICurrentXamlWindowReference currentWindowReference;
private readonly ITaskContext taskContext;
private readonly SemaphoreSlim activateSemaphore = new(1);
/// <inheritdoc/>
@@ -65,16 +66,24 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
serviceProvider.GetRequiredService<PrivateNamedPipeServer>().RunAsync().SafeForget();
ToastNotificationManagerCompat.OnActivated += NotificationActivate;
serviceProvider.GetRequiredService<HotKeyOptions>().RegisterAll();
if (serviceProvider.GetRequiredService<AppOptions>().IsNotifyIconEnabled)
using (activateSemaphore.Enter())
{
XamlWindowLifetime.ApplicationLaunchedWithNotifyIcon = true;
serviceProvider.GetRequiredService<App>().DispatcherShutdownMode = DispatcherShutdownMode.OnExplicitShutdown;
_ = serviceProvider.GetRequiredService<NotifyIconController>();
}
serviceProvider.GetRequiredService<HotKeyOptions>().RegisterAll();
if (UnsafeLocalSetting.Get(SettingKeys.Major1Minor10Revision0GuideState, GuideState.Language) < GuideState.Completed)
{
return;
}
serviceProvider.GetRequiredService<IScheduleTaskInterop>().UnregisterAllTasks();
serviceProvider.GetRequiredService<IQuartzService>().StartAsync(default).SafeForget();
if (serviceProvider.GetRequiredService<AppOptions>().IsNotifyIconEnabled)
{
XamlWindowLifetime.ApplicationLaunchedWithNotifyIcon = true;
serviceProvider.GetRequiredService<App>().DispatcherShutdownMode = DispatcherShutdownMode.OnExplicitShutdown;
_ = serviceProvider.GetRequiredService<NotifyIconController>();
}
serviceProvider.GetRequiredService<IScheduleTaskInterop>().UnregisterAllTasks();
serviceProvider.GetRequiredService<IQuartzService>().StartAsync(default).SafeForget();
}
}
public void Dispose()
@@ -172,7 +181,6 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
}
}
// If it's the first time launch, show the guide window anyway.
if (UnsafeLocalSetting.Get(SettingKeys.Major1Minor10Revision0GuideState, GuideState.Language) < GuideState.Completed)
{
await taskContext.SwitchToMainThreadAsync();

View File

@@ -15,7 +15,7 @@ internal static class SemaphoreSlimExtension
}
catch (ObjectDisposedException ex)
{
ThrowHelper.OperationCanceled(SH.CoreThreadingSemaphoreSlimDisposed, ex);
HutaoException.OperationCanceled(SH.CoreThreadingSemaphoreSlimDisposed, ex);
}
return new SemaphoreSlimToken(semaphoreSlim);
@@ -29,7 +29,7 @@ internal static class SemaphoreSlimExtension
}
catch (ObjectDisposedException ex)
{
ThrowHelper.OperationCanceled(SH.CoreThreadingSemaphoreSlimDisposed, ex);
HutaoException.OperationCanceled(SH.CoreThreadingSemaphoreSlimDisposed, ex);
}
return new SemaphoreSlimToken(semaphoreSlim);

View File

@@ -2,6 +2,7 @@
x:Class="Snap.Hutao.View.Guide.GuideView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cw="using:CommunityToolkit.WinUI"
xmlns:cwc="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -210,14 +211,58 @@
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<StackPanel
<Grid
Grid.Row="0"
Margin="16"
Margin="72"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal"
Spacing="16">
<StackPanel VerticalAlignment="Center">
ColumnSpacing="32">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<cwc:ConstrainedBox Grid.Column="0" AspectRatio="1:1">
<Border cw:Effects.Shadow="{ThemeResource CompatCardShadow}">
<Grid
BorderBrush="{x:Null}"
BorderThickness="0"
Style="{ThemeResource GridCardStyle}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Image
HorizontalAlignment="Center"
VerticalAlignment="Center"
Source="ms-appx:///Resource/GuideStaticResourceQualityComparison.png"/>
<Rectangle
Width="2"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Fill="White"/>
</Grid>
<Grid
Grid.Row="1"
Padding="16"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Background="{ThemeResource ContentDialogBackground}"
BorderThickness="0,1,0,0"
CornerRadius="{ThemeResource ControlCornerRadiusBottom}"
Style="{ThemeResource GridCardStyle}">
<StackPanel HorizontalAlignment="Left" Orientation="Vertical">
<TextBlock Text="{shcm:ResourceString Name=ViewModelGuideStaticResourceQualityHigh}" TextAlignment="Left"/>
<TextBlock Text="233 KB" TextAlignment="Left"/>
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Vertical">
<TextBlock Text="{shcm:ResourceString Name=ViewModelGuideStaticResourceQualityRaw}" TextAlignment="Right"/>
<TextBlock Text="1030 KB" TextAlignment="Right"/>
</StackPanel>
</Grid>
</Grid>
</Border>
</cwc:ConstrainedBox>
<StackPanel Grid.Column="1" VerticalAlignment="Top">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{shcm:ResourceString Name=ViewGuideStepStaticResourceSettingQualityHeader}"/>
<ListView
MinWidth="320"
@@ -234,34 +279,7 @@
SelectedItem="{Binding StaticResourceOptions.ImageArchive, Mode=TwoWay}"/>
<TextBlock Margin="0,16,0,0" Text="{Binding StaticResourceOptions.SizeInformationText, Mode=OneWay}"/>
</StackPanel>
<Grid VerticalAlignment="Center" Style="{ThemeResource GridCardStyle}">
<Image
Width="320"
Height="320"
VerticalAlignment="Center"
Source="ms-appx:///Resource/GuideStaticResourceQualityComparison.png"/>
<Rectangle
Width="2"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Fill="White"/>
<Grid
Margin="4"
Padding="16"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Style="{ThemeResource GridCardStyle}">
<StackPanel HorizontalAlignment="Left" Orientation="Vertical">
<TextBlock Text="{shcm:ResourceString Name=ViewModelGuideStaticResourceQualityHigh}"/>
<TextBlock Text="233 KB"/>
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Vertical">
<TextBlock Text="{shcm:ResourceString Name=ViewModelGuideStaticResourceQualityRaw}" TextAlignment="Right"/>
<TextBlock Text="1030 KB" TextAlignment="Right"/>
</StackPanel>
</Grid>
</Grid>
</StackPanel>
</Grid>
<TextBlock
Grid.Row="1"