- Auto-update checker on startup via Gitea API - Balloon notification when update available, click to download - 5-second timeout on DDC/CI commands to prevent hangs - Simplified version scheme to match release tags - Workflow auto-updates version in csproj from tag 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
using Hardcodet.Wpf.TaskbarNotification;
|
|
using System.Windows;
|
|
|
|
namespace DellMonitorControl
|
|
{
|
|
public partial class App : Application
|
|
{
|
|
private TaskbarIcon? _trayIcon;
|
|
private MainWindow? _mainWindow;
|
|
private UpdateInfo? _pendingUpdate;
|
|
|
|
private async void Application_Startup(object sender, StartupEventArgs e)
|
|
{
|
|
_trayIcon = (TaskbarIcon)FindResource("TrayIcon");
|
|
_trayIcon.TrayLeftMouseUp += TrayIcon_Click;
|
|
_trayIcon.TrayBalloonTipClicked += TrayIcon_BalloonTipClicked;
|
|
|
|
_mainWindow = new MainWindow();
|
|
|
|
// Check for updates in background
|
|
await CheckForUpdatesAsync();
|
|
}
|
|
|
|
private async System.Threading.Tasks.Task CheckForUpdatesAsync()
|
|
{
|
|
try
|
|
{
|
|
_pendingUpdate = await UpdateChecker.CheckForUpdateAsync();
|
|
if (_pendingUpdate != null && _trayIcon != null)
|
|
{
|
|
_trayIcon.ShowBalloonTip(
|
|
"Update Available",
|
|
$"Monitor Control v{_pendingUpdate.LatestVersion} is available.\nClick to download.",
|
|
BalloonIcon.Info);
|
|
}
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
private void TrayIcon_BalloonTipClicked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (_pendingUpdate != null && !string.IsNullOrEmpty(_pendingUpdate.DownloadUrl))
|
|
{
|
|
UpdateChecker.OpenDownloadPage(_pendingUpdate.DownloadUrl);
|
|
}
|
|
}
|
|
|
|
private async void TrayIcon_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (_mainWindow == null) return;
|
|
|
|
if (_mainWindow.IsVisible)
|
|
{
|
|
_mainWindow.Hide();
|
|
}
|
|
else
|
|
{
|
|
_mainWindow.ShowNearTray();
|
|
await _mainWindow.LoadMonitors();
|
|
}
|
|
}
|
|
|
|
protected override void OnExit(ExitEventArgs e)
|
|
{
|
|
_trayIcon?.Dispose();
|
|
base.OnExit(e);
|
|
}
|
|
}
|
|
}
|