mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
@@ -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";
|
||||
|
||||
@@ -320,6 +320,8 @@ Please do not check it when the stage OF-1 is not unlocked.</system:String>
|
||||
<system:String x:Key="ReceiveMining">Collect daily Orundum reward from the provisional mining permit</system:String>
|
||||
<system:String x:Key="ReceiveSpecialAccess">Collect Special Access rewards</system:String>
|
||||
<system:String x:Key="DroneUsage">Drone Usage</system:String>
|
||||
<system:String x:Key="UseTray">Display Tray Icon</system:String>
|
||||
<system:String x:Key="HideTray">Disable Tray Icon</system:String>
|
||||
<system:String x:Key="MinimizeToTray">Hide to tray when minimized</system:String>
|
||||
<system:String x:Key="SystemNotification">System Notification</system:String>
|
||||
<system:String x:Key="HideCloseButton">Hide close button</system:String>
|
||||
|
||||
@@ -320,6 +320,8 @@
|
||||
<system:String x:Key="ReceiveMining">期間限定の採掘許可で毎日合成玉の報酬を受け取る</system:String>
|
||||
<system:String x:Key="ReceiveSpecialAccess">スペシャルアクセス特典を集める</system:String>
|
||||
<system:String x:Key="DroneUsage">ドローンの使用</system:String>
|
||||
<system:String x:Key="UseTray">トレイアイコンを表示</system:String>
|
||||
<system:String x:Key="HideTray">トレイアイコンを隠す</system:String>
|
||||
<system:String x:Key="MinimizeToTray">最小化した際にトレイに表示</system:String>
|
||||
<system:String x:Key="SystemNotification">重要な通知をポップアップする</system:String>
|
||||
<system:String x:Key="HideCloseButton">「閉じる」ボタンを隠す</system:String>
|
||||
|
||||
@@ -320,6 +320,8 @@ OF-1을 해금하지 않았다면 선택하지 말아 주세요.</system:String>
|
||||
<system:String x:Key="ReceiveMining">기간 한정 채굴 허가로 매일 합성 옥 보상 받기</system:String>
|
||||
<system:String x:Key="ReceiveSpecialAccess">스페셜 액세스 보상 수집</system:String>
|
||||
<system:String x:Key="DroneUsage">드론 사용처</system:String>
|
||||
<system:String x:Key="UseTray">트레이 아이콘 표시</system:String>
|
||||
<system:String x:Key="HideTray">트레이 아이콘 숨기기</system:String>
|
||||
<system:String x:Key="MinimizeToTray">트레이로 최소화</system:String>
|
||||
<system:String x:Key="SystemNotification">중요 알림 팝업</system:String>
|
||||
<system:String x:Key="HideCloseButton">닫기 버튼 숨기기</system:String>
|
||||
|
||||
@@ -323,6 +323,8 @@
|
||||
<system:String x:Key="ReceiveMining">领取限时开采许可的每日合成玉奖励</system:String>
|
||||
<system:String x:Key="ReceiveSpecialAccess">领取五周年赠送月卡奖励</system:String>
|
||||
<system:String x:Key="DroneUsage">无人机用途</system:String>
|
||||
<system:String x:Key="UseTray">显示托盘图标</system:String>
|
||||
<system:String x:Key="HideTray">隐藏托盘图标</system:String>
|
||||
<system:String x:Key="MinimizeToTray">最小化时隐藏至托盘</system:String>
|
||||
<system:String x:Key="SystemNotification">重要信息弹出系统通知</system:String>
|
||||
<system:String x:Key="HideCloseButton">隐藏关闭按钮</system:String>
|
||||
|
||||
@@ -314,6 +314,8 @@
|
||||
<system:String x:Key="ReceiveMining">領取限時開採許可的每日合成玉獎勵</system:String>
|
||||
<system:String x:Key="ReceiveSpecialAccess">領取特殊贈送月卡獎勵</system:String>
|
||||
<system:String x:Key="DroneUsage">無人機用途</system:String>
|
||||
<system:String x:Key="UseTray">顯示工作列圖標</system:String>
|
||||
<system:String x:Key="HideTray">隱藏工作列圖標</system:String>
|
||||
<system:String x:Key="MinimizeToTray">最小化時隱藏至工作列</system:String>
|
||||
<system:String x:Key="SystemNotification">重要訊息彈出系統通知</system:String>
|
||||
<system:String x:Key="HideCloseButton">隱藏關閉按鈕</system:String>
|
||||
|
||||
@@ -52,6 +52,12 @@ namespace MaaWpfGui.Services.Managers
|
||||
/// <param name="shouldMinimizeToTaskBar">Whether to minimize to taskBar.</param>
|
||||
void SetMinimizeToTaskBar(bool shouldMinimizeToTaskBar);
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether to use the tray icon.
|
||||
/// </summary>
|
||||
/// <param name="useTrayIcon">Whether to use the tray icon.</param>
|
||||
void SetUseTrayIcon(bool useTrayIcon);
|
||||
|
||||
/// <summary>
|
||||
/// Get the main window if it is visible.
|
||||
/// </summary>
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether whether minimize to tray.
|
||||
/// Gets or sets a value indicating whether minimize to tray.
|
||||
/// </summary>
|
||||
private bool ShouldMinimizeToTaskBar { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to use tray icon.
|
||||
/// </summary>
|
||||
private bool ShouldUseTrayIcon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MainWindowManager"/> class.
|
||||
/// </summary>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -84,6 +94,13 @@ namespace MaaWpfGui.Services.Managers
|
||||
ShouldMinimizeToTaskBar = shouldMinimizeToTaskBar;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void SetUseTrayIcon(bool useTrayIcon)
|
||||
{
|
||||
ShouldUseTrayIcon = useTrayIcon;
|
||||
((RootView)MainWindow).NotifyIcon.notifyIcon.Visibility = useTrayIcon ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle the main window's state changed event
|
||||
/// </summary>
|
||||
@@ -91,7 +108,7 @@ namespace MaaWpfGui.Services.Managers
|
||||
/// <param name="e">The event arguments.</param>
|
||||
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()
|
||||
|
||||
@@ -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));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether to use tray icon.
|
||||
/// Gets or sets a value indicating whether to use tray icon.
|
||||
/// </summary>
|
||||
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));
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<MenuItem Name="stopMenu" Header="{DynamicResource Stop}" />
|
||||
<MenuItem Name="switchLangMenu" Header="{DynamicResource SwitchLanguage}" />
|
||||
<MenuItem Name="forceShowMenu" Header="{DynamicResource ForceShow}" />
|
||||
<MenuItem Name="useTrayMenu" Header="{DynamicResource HideTray}" />
|
||||
<MenuItem Name="exitMenu" Header="{DynamicResource Exit}" />
|
||||
</ContextMenu>
|
||||
</hc:NotifyIcon.ContextMenu>
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -30,6 +30,13 @@
|
||||
Margin="10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Content="{DynamicResource UseTray}"
|
||||
IsChecked="{Binding UseTray}" />
|
||||
<CheckBox
|
||||
Margin="10"
|
||||
Visibility="{c:Binding UseTray,FalseToVisibility=Collapsed}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Content="{DynamicResource MinimizeToTray}"
|
||||
IsChecked="{Binding MinimizeToTray}" />
|
||||
<CheckBox
|
||||
|
||||
Reference in New Issue
Block a user