2026-01-29 18:14:58 -05:00
|
|
|
using CMM.Library.Method;
|
Add brightness/contrast sliders, input source switching, and 9-language localization
- Add VCP commands for brightness (10), contrast (12), input source (60)
- Fix UTF-16 encoding for monitor data parsing
- Add system tray app with monitor controls
- Add localization for en, es, fr, de, zh, ja, pt, it, hi
- Update to .NET 9.0
- Add LICENSE and README
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 22:11:35 -05:00
|
|
|
using Hardcodet.Wpf.TaskbarNotification;
|
2026-01-29 18:14:58 -05:00
|
|
|
using Microsoft.Win32;
|
2023-07-02 22:17:57 +08:00
|
|
|
using System.Windows;
|
|
|
|
|
|
2026-01-29 18:14:58 -05:00
|
|
|
namespace MonitorControl
|
2023-07-02 22:17:57 +08:00
|
|
|
{
|
|
|
|
|
public partial class App : Application
|
|
|
|
|
{
|
Add brightness/contrast sliders, input source switching, and 9-language localization
- Add VCP commands for brightness (10), contrast (12), input source (60)
- Fix UTF-16 encoding for monitor data parsing
- Add system tray app with monitor controls
- Add localization for en, es, fr, de, zh, ja, pt, it, hi
- Update to .NET 9.0
- Add LICENSE and README
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 22:11:35 -05:00
|
|
|
private TaskbarIcon? _trayIcon;
|
|
|
|
|
private MainWindow? _mainWindow;
|
2026-01-07 11:48:19 -05:00
|
|
|
private UpdateInfo? _pendingUpdate;
|
Add brightness/contrast sliders, input source switching, and 9-language localization
- Add VCP commands for brightness (10), contrast (12), input source (60)
- Fix UTF-16 encoding for monitor data parsing
- Add system tray app with monitor controls
- Add localization for en, es, fr, de, zh, ja, pt, it, hi
- Update to .NET 9.0
- Add LICENSE and README
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 22:11:35 -05:00
|
|
|
|
2026-01-07 11:48:19 -05:00
|
|
|
private async void Application_Startup(object sender, StartupEventArgs e)
|
Add brightness/contrast sliders, input source switching, and 9-language localization
- Add VCP commands for brightness (10), contrast (12), input source (60)
- Fix UTF-16 encoding for monitor data parsing
- Add system tray app with monitor controls
- Add localization for en, es, fr, de, zh, ja, pt, it, hi
- Update to .NET 9.0
- Add LICENSE and README
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 22:11:35 -05:00
|
|
|
{
|
|
|
|
|
_trayIcon = (TaskbarIcon)FindResource("TrayIcon");
|
|
|
|
|
_trayIcon.TrayLeftMouseUp += TrayIcon_Click;
|
2026-01-07 11:48:19 -05:00
|
|
|
_trayIcon.TrayBalloonTipClicked += TrayIcon_BalloonTipClicked;
|
Add brightness/contrast sliders, input source switching, and 9-language localization
- Add VCP commands for brightness (10), contrast (12), input source (60)
- Fix UTF-16 encoding for monitor data parsing
- Add system tray app with monitor controls
- Add localization for en, es, fr, de, zh, ja, pt, it, hi
- Update to .NET 9.0
- Add LICENSE and README
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 22:11:35 -05:00
|
|
|
|
|
|
|
|
_mainWindow = new MainWindow();
|
2026-01-07 11:48:19 -05:00
|
|
|
|
2026-01-29 18:14:58 -05:00
|
|
|
// Listen for system sleep/resume to protect monitors during wake
|
|
|
|
|
SystemEvents.PowerModeChanged += OnPowerModeChanged;
|
|
|
|
|
|
2026-01-07 11:48:19 -05:00
|
|
|
// Check for updates in background
|
|
|
|
|
await CheckForUpdatesAsync();
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-29 18:14:58 -05:00
|
|
|
private void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Mode == PowerModes.Resume)
|
|
|
|
|
{
|
|
|
|
|
// Notify the DDC/CI layer that monitors need time to wake up
|
|
|
|
|
CMMCommand.NotifySystemResumed();
|
|
|
|
|
DebugLogger.Log("System resumed from sleep - DDC/CI grace period activated");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-07 11:48:19 -05:00
|
|
|
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);
|
|
|
|
|
}
|
Add brightness/contrast sliders, input source switching, and 9-language localization
- Add VCP commands for brightness (10), contrast (12), input source (60)
- Fix UTF-16 encoding for monitor data parsing
- Add system tray app with monitor controls
- Add localization for en, es, fr, de, zh, ja, pt, it, hi
- Update to .NET 9.0
- Add LICENSE and README
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 22:11:35 -05:00
|
|
|
}
|
|
|
|
|
|
2026-01-03 22:30:42 -05:00
|
|
|
private async void TrayIcon_Click(object sender, RoutedEventArgs e)
|
Add brightness/contrast sliders, input source switching, and 9-language localization
- Add VCP commands for brightness (10), contrast (12), input source (60)
- Fix UTF-16 encoding for monitor data parsing
- Add system tray app with monitor controls
- Add localization for en, es, fr, de, zh, ja, pt, it, hi
- Update to .NET 9.0
- Add LICENSE and README
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 22:11:35 -05:00
|
|
|
{
|
|
|
|
|
if (_mainWindow == null) return;
|
|
|
|
|
|
|
|
|
|
if (_mainWindow.IsVisible)
|
2026-01-03 22:30:42 -05:00
|
|
|
{
|
Add brightness/contrast sliders, input source switching, and 9-language localization
- Add VCP commands for brightness (10), contrast (12), input source (60)
- Fix UTF-16 encoding for monitor data parsing
- Add system tray app with monitor controls
- Add localization for en, es, fr, de, zh, ja, pt, it, hi
- Update to .NET 9.0
- Add LICENSE and README
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 22:11:35 -05:00
|
|
|
_mainWindow.Hide();
|
2026-01-03 22:30:42 -05:00
|
|
|
}
|
Add brightness/contrast sliders, input source switching, and 9-language localization
- Add VCP commands for brightness (10), contrast (12), input source (60)
- Fix UTF-16 encoding for monitor data parsing
- Add system tray app with monitor controls
- Add localization for en, es, fr, de, zh, ja, pt, it, hi
- Update to .NET 9.0
- Add LICENSE and README
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 22:11:35 -05:00
|
|
|
else
|
|
|
|
|
{
|
2026-01-03 22:30:42 -05:00
|
|
|
_mainWindow.ShowNearTray();
|
|
|
|
|
await _mainWindow.LoadMonitors();
|
Add brightness/contrast sliders, input source switching, and 9-language localization
- Add VCP commands for brightness (10), contrast (12), input source (60)
- Fix UTF-16 encoding for monitor data parsing
- Add system tray app with monitor controls
- Add localization for en, es, fr, de, zh, ja, pt, it, hi
- Update to .NET 9.0
- Add LICENSE and README
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 22:11:35 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnExit(ExitEventArgs e)
|
|
|
|
|
{
|
2026-01-29 18:14:58 -05:00
|
|
|
SystemEvents.PowerModeChanged -= OnPowerModeChanged;
|
Add brightness/contrast sliders, input source switching, and 9-language localization
- Add VCP commands for brightness (10), contrast (12), input source (60)
- Fix UTF-16 encoding for monitor data parsing
- Add system tray app with monitor controls
- Add localization for en, es, fr, de, zh, ja, pt, it, hi
- Update to .NET 9.0
- Add LICENSE and README
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 22:11:35 -05:00
|
|
|
_trayIcon?.Dispose();
|
|
|
|
|
base.OnExit(e);
|
|
|
|
|
}
|
2023-07-02 22:17:57 +08:00
|
|
|
}
|
|
|
|
|
}
|