diff --git a/Dashboard/MainWindow.xaml.cs b/Dashboard/MainWindow.xaml.cs index f665f82c..10986daa 100644 --- a/Dashboard/MainWindow.xaml.cs +++ b/Dashboard/MainWindow.xaml.cs @@ -185,7 +185,7 @@ private void StartMcpServerIfEnabled() private void InitializeNotificationService() { - _notificationService = new NotificationService(this); + _notificationService = new NotificationService(this, _preferencesService); _notificationService.Initialize(); } @@ -756,7 +756,7 @@ private void ManageServers_Click(object sender, RoutedEventArgs e) private void Settings_Click(object sender, RoutedEventArgs e) { - var dialog = new SettingsWindow(); + var dialog = new SettingsWindow(_preferencesService); dialog.Owner = this; if (dialog.ShowDialog() == true) { diff --git a/Dashboard/Services/NotificationService.cs b/Dashboard/Services/NotificationService.cs index e04199a2..ffa38c2e 100644 --- a/Dashboard/Services/NotificationService.cs +++ b/Dashboard/Services/NotificationService.cs @@ -208,7 +208,7 @@ private void OpenSettings() // Trigger settings via the main window if (_mainWindow is MainWindow mainWin) { - var settingsWindow = new SettingsWindow { Owner = mainWin }; + var settingsWindow = new SettingsWindow(_preferencesService) { Owner = mainWin }; settingsWindow.ShowDialog(); } } diff --git a/Dashboard/SettingsWindow.xaml.cs b/Dashboard/SettingsWindow.xaml.cs index 3a40f770..18c2a89e 100644 --- a/Dashboard/SettingsWindow.xaml.cs +++ b/Dashboard/SettingsWindow.xaml.cs @@ -11,20 +11,21 @@ using System.Windows; using System.Windows.Controls; using PerformanceMonitorDashboard.Helpers; +using PerformanceMonitorDashboard.Interfaces; using PerformanceMonitorDashboard.Services; namespace PerformanceMonitorDashboard { public partial class SettingsWindow : Window { - private readonly UserPreferencesService _preferencesService; + private readonly IUserPreferencesService _preferencesService; private bool _isLoading = true; - public SettingsWindow() + public SettingsWindow(IUserPreferencesService preferencesService) { InitializeComponent(); - _preferencesService = new UserPreferencesService(); + _preferencesService = preferencesService; LoadSettings(); _isLoading = false; } @@ -495,7 +496,7 @@ private async void TestEmailButton_Click(object sender, RoutedEventArgs e) try { - var emailService = EmailAlertService.Current ?? new EmailAlertService(_preferencesService); + var emailService = EmailAlertService.Current ?? new EmailAlertService((UserPreferencesService)_preferencesService); var error = await emailService.SendTestEmailAsync(testPrefs); if (error == null) diff --git a/Lite/App.xaml.cs b/Lite/App.xaml.cs index 00bbb874..146c45e9 100644 --- a/Lite/App.xaml.cs +++ b/Lite/App.xaml.cs @@ -56,6 +56,9 @@ public partial class App : Application public static bool AlertDeadlockEnabled { get; set; } = true; public static int AlertDeadlockThreshold { get; set; } = 1; + /* System tray settings */ + public static bool MinimizeToTray { get; set; } = true; + /* Update check settings */ public static bool CheckForUpdatesOnStartup { get; set; } = true; @@ -199,6 +202,9 @@ public static void LoadAlertSettings() if (root.TryGetProperty("alert_deadlock_enabled", out v)) AlertDeadlockEnabled = v.GetBoolean(); if (root.TryGetProperty("alert_deadlock_threshold", out v)) AlertDeadlockThreshold = v.GetInt32(); + /* System tray settings */ + if (root.TryGetProperty("minimize_to_tray", out v)) MinimizeToTray = v.GetBoolean(); + /* Update check settings */ if (root.TryGetProperty("check_for_updates_on_startup", out v)) CheckForUpdatesOnStartup = v.GetBoolean(); diff --git a/Lite/Services/SystemTrayService.cs b/Lite/Services/SystemTrayService.cs index 209b1d97..8535777a 100644 --- a/Lite/Services/SystemTrayService.cs +++ b/Lite/Services/SystemTrayService.cs @@ -107,7 +107,7 @@ public void Initialize() private void MainWindow_StateChanged(object? sender, EventArgs e) { - if (_mainWindow.WindowState == WindowState.Minimized) + if (_mainWindow.WindowState == WindowState.Minimized && App.MinimizeToTray) { _mainWindow.Hide(); } diff --git a/Lite/Windows/SettingsWindow.xaml b/Lite/Windows/SettingsWindow.xaml index 5de35bb0..26641c98 100644 --- a/Lite/Windows/SettingsWindow.xaml +++ b/Lite/Windows/SettingsWindow.xaml @@ -97,6 +97,8 @@ +