mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-15 07:43:20 +08:00
Merge pull request #327 from Mr-Quin/exit-to-tray
This commit is contained in:
@@ -20,4 +20,10 @@ public partial class CommonConfig : ObservableObject
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _screenshotUidCoverEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// 退出时最小化至托盘
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _exitToTray;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
<b:EventTrigger EventName="Loaded">
|
||||
<b:InvokeCommandAction Command="{Binding LoadedCommand}" CommandParameter="{Binding}" />
|
||||
</b:EventTrigger>
|
||||
<b:EventTrigger EventName="Closing">
|
||||
<b:InvokeCommandAction Command="{Binding ClosingCommand}" PassEventArgsToCommand="True"/>
|
||||
</b:EventTrigger>
|
||||
</b:Interaction.Triggers>
|
||||
|
||||
<Grid>
|
||||
|
||||
@@ -342,6 +342,33 @@
|
||||
|
||||
</StackPanel>
|
||||
</ui:CardExpander>
|
||||
|
||||
<!-- 退出时最小化 -->
|
||||
<ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon ArrowMinimize24}">
|
||||
<ui:CardControl.Header>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ui:TextBlock
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
TextWrapping="Wrap"
|
||||
Text="退出时最小化到系统托盘" />
|
||||
<ui:TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
TextWrapping="Wrap"
|
||||
Text="启用后点击右上角退出按钮会最小化到系统托盘继续运行,右键托盘图标退出" />
|
||||
</Grid>
|
||||
</ui:CardControl.Header>
|
||||
<ui:ToggleSwitch
|
||||
Margin="0,0,36,0"
|
||||
IsChecked="{Binding Config.CommonConfig.ExitToTray, Mode=TwoWay}" />
|
||||
</ui:CardControl>
|
||||
|
||||
<!-- 地图 -->
|
||||
<ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Cursor24}">
|
||||
|
||||
@@ -8,6 +8,7 @@ using CommunityToolkit.Mvvm.Input;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net.Http;
|
||||
@@ -45,6 +46,16 @@ public partial class MainWindowViewModel : ObservableObject
|
||||
IsVisible = false;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
if (Config.CommonConfig.ExitToTray)
|
||||
{
|
||||
e.Cancel = true;
|
||||
OnHide();
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
[SuppressMessage("CommunityToolkit.Mvvm.SourceGenerators.RelayCommandGenerator", "MVVMTK0039:Async void returning method annotated with RelayCommand")]
|
||||
private async void OnLoaded()
|
||||
|
||||
Reference in New Issue
Block a user