diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs
index eff871b089..b846b54e8c 100644
--- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs
+++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs
@@ -30,6 +30,7 @@ namespace MaaWpfGui.Constants
public const string ConfigurationCron = "Cron";
public const string Localization = "GUI.Localization";
+ public const string UseTray = "GUI.UseTray";
public const string MinimizeToTray = "GUI.MinimizeToTray";
public const string HideCloseButton = "GUI.HideCloseButton";
public const string WindowTitleScrollable = "GUI.WindowTitleScrollable";
diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml
index ea4ebe5323..f897f648f5 100644
--- a/src/MaaWpfGui/Res/Localizations/en-us.xaml
+++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml
@@ -320,6 +320,8 @@ Please do not check it when the stage OF-1 is not unlocked.
Collect daily Orundum reward from the provisional mining permit
Collect Special Access rewards
Drone Usage
+ Display Tray Icon
+ Disable Tray Icon
Hide to tray when minimized
System Notification
Hide close button
diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
index fd4f2bdcc4..37be4b9e05 100644
--- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
@@ -320,6 +320,8 @@
期間限定の採掘許可で毎日合成玉の報酬を受け取る
スペシャルアクセス特典を集める
ドローンの使用
+ トレイアイコンを表示
+ トレイアイコンを隠す
最小化した際にトレイに表示
重要な通知をポップアップする
「閉じる」ボタンを隠す
diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
index 743b3356ac..9ffa54422a 100644
--- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
@@ -320,6 +320,8 @@ OF-1을 해금하지 않았다면 선택하지 말아 주세요.
기간 한정 채굴 허가로 매일 합성 옥 보상 받기
스페셜 액세스 보상 수집
드론 사용처
+ 트레이 아이콘 표시
+ 트레이 아이콘 숨기기
트레이로 최소화
중요 알림 팝업
닫기 버튼 숨기기
diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
index 4eb8b61a51..7aea9160bb 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
@@ -323,6 +323,8 @@
领取限时开采许可的每日合成玉奖励
领取五周年赠送月卡奖励
无人机用途
+ 显示托盘图标
+ 隐藏托盘图标
最小化时隐藏至托盘
重要信息弹出系统通知
隐藏关闭按钮
diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
index 9bf9237f4c..e51097de2e 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
@@ -314,6 +314,8 @@
領取限時開採許可的每日合成玉獎勵
領取特殊贈送月卡獎勵
無人機用途
+ 顯示工作列圖標
+ 隱藏工作列圖標
最小化時隱藏至工作列
重要訊息彈出系統通知
隱藏關閉按鈕
diff --git a/src/MaaWpfGui/Services/Managers/IMainWindowManager.cs b/src/MaaWpfGui/Services/Managers/IMainWindowManager.cs
index 63606137fd..3f1607220b 100644
--- a/src/MaaWpfGui/Services/Managers/IMainWindowManager.cs
+++ b/src/MaaWpfGui/Services/Managers/IMainWindowManager.cs
@@ -52,6 +52,12 @@ namespace MaaWpfGui.Services.Managers
/// Whether to minimize to taskBar.
void SetMinimizeToTaskBar(bool shouldMinimizeToTaskBar);
+ ///
+ /// Sets whether to use the tray icon.
+ ///
+ /// Whether to use the tray icon.
+ void SetUseTrayIcon(bool useTrayIcon);
+
///
/// Get the main window if it is visible.
///
diff --git a/src/MaaWpfGui/Services/Managers/MainWindowManager.cs b/src/MaaWpfGui/Services/Managers/MainWindowManager.cs
index ab3b287f09..5314ded5db 100644
--- a/src/MaaWpfGui/Services/Managers/MainWindowManager.cs
+++ b/src/MaaWpfGui/Services/Managers/MainWindowManager.cs
@@ -15,6 +15,7 @@ using System;
using System.Windows;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
+using MaaWpfGui.Views.UI;
namespace MaaWpfGui.Services.Managers
{
@@ -27,10 +28,16 @@ namespace MaaWpfGui.Services.Managers
private static Window MainWindow => Application.Current.MainWindow;
///
- /// Gets or sets a value indicating whether whether minimize to tray.
+ /// Gets or sets a value indicating whether minimize to tray.
///
private bool ShouldMinimizeToTaskBar { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to use tray icon.
+ ///
+ private bool ShouldUseTrayIcon { get; set; }
+
///
/// Initializes a new instance of the class.
///
@@ -40,6 +47,9 @@ namespace MaaWpfGui.Services.Managers
bool minimizeToTray = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.MinimizeToTray, bool.FalseString));
SetMinimizeToTaskBar(minimizeToTray);
+
+ bool useTrayIcon = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseTray, bool.TrueString));
+ SetUseTrayIcon(useTrayIcon);
}
///
@@ -84,6 +94,13 @@ namespace MaaWpfGui.Services.Managers
ShouldMinimizeToTaskBar = shouldMinimizeToTaskBar;
}
+ ///
+ public void SetUseTrayIcon(bool useTrayIcon)
+ {
+ ShouldUseTrayIcon = useTrayIcon;
+ ((RootView)MainWindow).NotifyIcon.notifyIcon.Visibility = useTrayIcon ? Visibility.Visible : Visibility.Collapsed;
+ }
+
///
/// Handle the main window's state changed event
///
@@ -91,7 +108,7 @@ namespace MaaWpfGui.Services.Managers
/// The event arguments.
private void MainWindowStateChanged(object sender, EventArgs e)
{
- if (ShouldMinimizeToTaskBar)
+ if (ShouldMinimizeToTaskBar && ShouldUseTrayIcon)
{
ChangeVisibility(MainWindow.WindowState != WindowState.Minimized);
}
@@ -113,6 +130,8 @@ namespace MaaWpfGui.Services.Managers
MainWindow.ShowInTaskbar = false;
MainWindow.Visibility = Visibility.Hidden;
}
+
+ ((RootView)MainWindow).NotifyIcon.useTrayMenu.Visibility = visible ? Visibility.Visible : Visibility.Collapsed;
}
public Window GetWindowIfVisible()
diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
index fcaad2549b..8e40c99d06 100644
--- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
@@ -4355,12 +4355,22 @@ namespace MaaWpfGui.ViewModels.UI
new() { Display = LocalizationHelper.GetString("Switchable"), Value = "ClearInverse" },
];
- /*
+ private bool _useTray = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseTray, bool.TrueString));
+
///
- /// Gets a value indicating whether to use tray icon.
+ /// Gets or sets a value indicating whether to use tray icon.
///
- public bool UseTray => true;
- */
+ public bool UseTray
+ {
+ get => _useTray;
+ set
+ {
+ SetAndNotify(ref _useTray, value);
+ ConfigurationHelper.SetValue(ConfigurationKeys.UseTray, value.ToString());
+ Instances.MainWindowManager.SetUseTrayIcon(value);
+ }
+ }
+
private bool _minimizeToTray = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.MinimizeToTray, bool.FalseString));
diff --git a/src/MaaWpfGui/Views/UI/NotifyIcon.xaml b/src/MaaWpfGui/Views/UI/NotifyIcon.xaml
index 6c9cd5501c..b575e73bf6 100644
--- a/src/MaaWpfGui/Views/UI/NotifyIcon.xaml
+++ b/src/MaaWpfGui/Views/UI/NotifyIcon.xaml
@@ -20,6 +20,7 @@
+
diff --git a/src/MaaWpfGui/Views/UI/NotifyIcon.xaml.cs b/src/MaaWpfGui/Views/UI/NotifyIcon.xaml.cs
index 850e16b99f..bf95cc223d 100644
--- a/src/MaaWpfGui/Views/UI/NotifyIcon.xaml.cs
+++ b/src/MaaWpfGui/Views/UI/NotifyIcon.xaml.cs
@@ -14,6 +14,7 @@
using System;
using System.Windows;
using System.Windows.Controls;
+using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
using MaaWpfGui.Main;
using MaaWpfGui.ViewModels.UI;
@@ -39,6 +40,7 @@ namespace MaaWpfGui.Views.UI
private void InitIcon()
{
notifyIcon.Icon = AppIcon.GetIcon();
+ notifyIcon.Visibility = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseTray, bool.TrueString)) ? Visibility.Visible : Visibility.Collapsed;
notifyIcon.Click += NotifyIcon_MouseClick;
notifyIcon.MouseDoubleClick += OnNotifyIconDoubleClick;
@@ -46,6 +48,7 @@ namespace MaaWpfGui.Views.UI
startMenu.Click += StartTask;
stopMenu.Click += StopTask;
forceShowMenu.Click += ForceShow;
+ useTrayMenu.Click += UseTray;
exitMenu.Click += App_exit;
foreach (var lang in LocalizationHelper.SupportedLanguages)
@@ -104,6 +107,12 @@ namespace MaaWpfGui.Views.UI
_logger.Information("WindowManager force show.");
}
+ private void UseTray(object sender, RoutedEventArgs e)
+ {
+ Instances.SettingsViewModel.UseTray = !Instances.SettingsViewModel.UseTray;
+ _logger.Information("Use tray icon: {0}", Instances.SettingsViewModel.UseTray);
+ }
+
private void App_exit(object sender, RoutedEventArgs e)
{
if (Instances.TaskQueueViewModel.ConfirmExit())
diff --git a/src/MaaWpfGui/Views/UserControl/GUISettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/GUISettingsUserControl.xaml
index 0f47d50cbf..99997ae69f 100644
--- a/src/MaaWpfGui/Views/UserControl/GUISettingsUserControl.xaml
+++ b/src/MaaWpfGui/Views/UserControl/GUISettingsUserControl.xaml
@@ -30,6 +30,13 @@
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
+ Content="{DynamicResource UseTray}"
+ IsChecked="{Binding UseTray}" />
+