diff --git a/CollapseLauncher/CollapseLauncher.csproj b/CollapseLauncher/CollapseLauncher.csproj
index 3343f1c26..ffb9e8603 100644
--- a/CollapseLauncher/CollapseLauncher.csproj
+++ b/CollapseLauncher/CollapseLauncher.csproj
@@ -90,7 +90,7 @@
-
+
diff --git a/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs b/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs
index 627465944..378959aee 100644
--- a/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs
+++ b/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs
@@ -43,7 +43,6 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using Windows.Foundation;
using Microsoft.UI.Xaml.Media;
using static CollapseLauncher.Dialogs.SimpleDialogs;
using static CollapseLauncher.InnerLauncherConfig;
@@ -53,6 +52,7 @@
using static Hi3Helper.Shared.Region.LauncherConfig;
using Brush = Microsoft.UI.Xaml.Media.Brush;
using Image = Microsoft.UI.Xaml.Controls.Image;
+using Point = Windows.Foundation.Point;
using Size = System.Drawing.Size;
using Timer = System.Timers.Timer;
using UIElementExtensions = CollapseLauncher.Extension.UIElementExtensions;
@@ -69,8 +69,8 @@ public sealed partial class HomePage
private int barWidth;
private int consoleWidth;
- public static int RefreshRateDefault { get; } = 500;
- public static int RefreshRateSlow { get; } = 1000;
+ public static int RefreshRateDefault => 500;
+ public static int RefreshRateSlow => 1000;
private static int _refreshRate;
diff --git a/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml.cs b/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml.cs
index 4bdda4292..7e3cabf62 100644
--- a/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml.cs
+++ b/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml.cs
@@ -5,9 +5,9 @@
using Hi3Helper;
using Hi3Helper.Shared.Region;
using Microsoft.UI.Xaml;
-using Microsoft.UI.Xaml.Controls;
using System;
using System.Drawing;
+using System.Threading.Tasks;
using static CollapseLauncher.InnerLauncherConfig;
using static CollapseLauncher.Pages.HomePage;
using static Hi3Helper.InvokeProp;
@@ -69,18 +69,42 @@ public TrayIcon()
#endif
CloseButton.Text = _exitApp;
- // Switch toggle text to see if its started with Start
+ // Switch toggle text to see if it's started with Start
MainTaskbarToggle.Text = (m_appMode == AppMode.StartOnTray) ? _showApp : _hideApp;
ConsoleTaskbarToggle.Text = (m_appMode == AppMode.StartOnTray) ? _showConsole : _hideConsole;
CollapseTaskbar.Icon = Icon.FromHandle(LauncherConfig.AppIconSmall);
CollapseTaskbar.Visibility = Visibility.Visible;
+
+ CollapseTaskbar.TrayIcon.MessageWindow.BalloonToolTipChanged += BalloonChangedEvent;
}
public void Dispose()
{
CollapseTaskbar.Dispose();
}
+
+ private void BalloonChangedEvent(object o, MessageWindow.BalloonToolTipChangedEventArgs args)
+ {
+ // Subscribe to the event when the Balloon is visible, and unsub when it's not.
+ // Due to bug, this MouseEvent is not available when the notification already went to the tray.
+ if (args.IsVisible)
+ CollapseTaskbar.TrayIcon.MessageWindow.MouseEventReceived += NotificationOnMouseEventReceived;
+ else
+ CollapseTaskbar.TrayIcon.MessageWindow.MouseEventReceived -= NotificationOnMouseEventReceived;
+ }
+
+ private bool _mouseEventProcessing;
+ private async void NotificationOnMouseEventReceived(object o, MessageWindow.MouseEventReceivedEventArgs args)
+ {
+ if (_mouseEventProcessing) return;
+ if (args.MouseEvent != MouseEvent.BalloonToolTipClicked) return;
+
+ _mouseEventProcessing = true;
+ BringToForeground();
+ await Task.Delay(250);
+ _mouseEventProcessing = false;
+ }
#endregion
#region Visibility Toggler
@@ -97,7 +121,7 @@ public void Dispose()
private void ToggleConsoleVisibilityButton() => ToggleConsoleVisibility();
///
- /// Toggle both main and console visibility while avoiding flip flop condition
+ /// Toggle both main and console visibility while avoiding flip-flop condition
///
[RelayCommand]
private void ToggleAllVisibilityInvoke() => ToggleAllVisibility();
@@ -125,6 +149,7 @@ public void Dispose()
///
/// Toggle console window visibility
///
+ // ReSharper disable once MemberCanBePrivate.Global
public void ToggleConsoleVisibility(bool forceShow = false)
{
if (LauncherConfig.GetAppConfigValue("EnableConsole").ToBool())
@@ -162,7 +187,7 @@ public void ToggleMainVisibility(bool forceShow = false)
// Increase refresh rate to 1000ms when main window is hidden
RefreshRate = RefreshRateSlow;
LogWriteLine("Main window is hidden!");
- ShowNotification("Main window is hidden!", "a");
+ WindowUtility.Tray_ShowNotification("test1", "neon stinki");
}
else
{
@@ -204,6 +229,7 @@ public void ToggleAllVisibility()
///
/// Bring all windows into foreground, also brought all windows if they were hidden in taskbar.
///
+ // ReSharper disable once MemberCanBePrivate.Global
public void BringToForeground()
{
IntPtr mainWindowHandle = WindowUtility.CurrentWindowPtr;
@@ -233,6 +259,7 @@ public void BringToForeground()
///
/// Update tray context menu
///
+ // ReSharper disable once MemberCanBePrivate.Global
public void UpdateContextMenu()
{
// Enable visibility toggle for console if the console is enabled
@@ -253,11 +280,8 @@ public void UpdateContextMenu()
bool isMainWindowVisible = IsWindowVisible(mainWindowHandle);
bool isConsoleVisible = LauncherConfig.GetAppConfigValue("EnableConsole").ToBool() && IsWindowVisible(consoleWindowHandle);
- if (isConsoleVisible) ConsoleTaskbarToggle.Text = _hideConsole;
- else ConsoleTaskbarToggle.Text = _showConsole;
-
- if (isMainWindowVisible) MainTaskbarToggle.Text = _hideApp;
- else MainTaskbarToggle.Text = _showApp;
+ ConsoleTaskbarToggle.Text = isConsoleVisible ? _hideConsole : _showConsole;
+ MainTaskbarToggle.Text = isMainWindowVisible ? _hideApp : _showApp;
}
///
diff --git a/CollapseLauncher/packages.lock.json b/CollapseLauncher/packages.lock.json
index 0c27a447e..cb0f8a967 100644
--- a/CollapseLauncher/packages.lock.json
+++ b/CollapseLauncher/packages.lock.json
@@ -123,11 +123,11 @@
},
"H.NotifyIcon.WinUI": {
"type": "Direct",
- "requested": "[2.1.2, )",
- "resolved": "2.1.2",
- "contentHash": "Iwu5zEtP4ihPCUs3m0SowyKS6hA9AEcnvt0hQHZ9Tl4xu8O7lBfvmV1bomBpJPfPvpmrvTe9EfQcz+uRwiQm8A==",
+ "requested": "[2.1.3, )",
+ "resolved": "2.1.3",
+ "contentHash": "1tAYbvV2vyQ0lXKrMmNvpIiP5tXZibtyXCqlmH2Wjcc3i/W/EatihtVATpeuWZpxM6RA9T1H5pTZhT8+5y7wcQ==",
"dependencies": {
- "H.NotifyIcon": "2.1.2",
+ "H.NotifyIcon": "2.1.3",
"Microsoft.WindowsAppSDK": "1.5.240627000"
}
},
@@ -376,18 +376,18 @@
},
"H.GeneratedIcons.System.Drawing": {
"type": "Transitive",
- "resolved": "2.1.2",
- "contentHash": "f2mF27nQRBGbXbEiSSxe6H12BElcH0WH3MI9lucID4Fa9I/WywFdhkFmPgALZTa2STi8rcsHTRWC7vuTfcblBQ==",
+ "resolved": "2.1.3",
+ "contentHash": "GH6MR2Qc/yyNaCj1205v2J3jT4siDmg5W+jlbJzxDuMZZtX20pEIb/QBABDS+l9brHlwPs7WygboRNeMii40Qw==",
"dependencies": {
"System.Drawing.Common": "8.0.7"
}
},
"H.NotifyIcon": {
"type": "Transitive",
- "resolved": "2.1.2",
- "contentHash": "5FllMntYHOHYQoLZGSMNUB2aSRrwciiQ3PT925NkI+XguZH5eDuXOQnOZvslHcmZ8VU0Qkp37XyG7agfP5nByw==",
+ "resolved": "2.1.3",
+ "contentHash": "aiCL1gjfKWh/jRlV4oDOycOqRaRj/C9E5cwHL2KCc+jre5vyUw5lHcHW6t4e/U3ssDmBKJgwhcgAW3JwMUP3ow==",
"dependencies": {
- "H.GeneratedIcons.System.Drawing": "2.1.2"
+ "H.GeneratedIcons.System.Drawing": "2.1.3"
}
},
"Hi3Helper.ZstdNet": {