Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dashboard/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private void StartMcpServerIfEnabled()

private void InitializeNotificationService()
{
_notificationService = new NotificationService(this);
_notificationService = new NotificationService(this, _preferencesService);
_notificationService.Initialize();
}

Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion Dashboard/Services/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
9 changes: 5 additions & 4 deletions Dashboard/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions Lite/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion Lite/Services/SystemTrayService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions Lite/Windows/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
<Border Grid.Row="4" Background="{DynamicResource BackgroundLightBrush}" CornerRadius="4" Padding="12" Margin="0,0,0,12">
<StackPanel>
<TextBlock Text="Notifications" FontSize="14" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundBrush}"/>
<CheckBox x:Name="MinimizeToTrayCheckBox" Content="Minimize to system tray" Margin="0,8,0,0"
Foreground="{DynamicResource ForegroundBrush}"/>
<CheckBox x:Name="AlertsEnabledCheckBox" Content="Enable notifications" Margin="0,8,0,0"
Foreground="{DynamicResource ForegroundBrush}" Checked="AlertsEnabledCheckBox_Changed" Unchecked="AlertsEnabledCheckBox_Changed"/>
<CheckBox x:Name="NotifyConnectionCheckBox" Content="Connection lost / restored" Margin="20,6,0,0"
Expand Down
3 changes: 3 additions & 0 deletions Lite/Windows/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ private void CopyMcpCommandButton_Click(object sender, RoutedEventArgs e)

private void LoadAlertSettings()
{
MinimizeToTrayCheckBox.IsChecked = App.MinimizeToTray;
AlertsEnabledCheckBox.IsChecked = App.AlertsEnabled;
NotifyConnectionCheckBox.IsChecked = App.NotifyConnectionChanges;
AlertCpuCheckBox.IsChecked = App.AlertCpuEnabled;
Expand All @@ -234,6 +235,7 @@ private void LoadAlertSettings()

private void SaveAlertSettings()
{
App.MinimizeToTray = MinimizeToTrayCheckBox.IsChecked == true;
App.AlertsEnabled = AlertsEnabledCheckBox.IsChecked == true;
App.NotifyConnectionChanges = NotifyConnectionCheckBox.IsChecked == true;
App.AlertCpuEnabled = AlertCpuCheckBox.IsChecked == true;
Expand All @@ -260,6 +262,7 @@ private void SaveAlertSettings()
root = new JsonObject();
}

root["minimize_to_tray"] = App.MinimizeToTray;
root["alerts_enabled"] = App.AlertsEnabled;
root["notify_connection_changes"] = App.NotifyConnectionChanges;
root["alert_cpu_enabled"] = App.AlertCpuEnabled;
Expand Down
2 changes: 1 addition & 1 deletion Lite/config/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"archive_retention_days": 90,
"default_time_range_hours": 24,
"theme": "light",
"minimize_to_tray": false,
"minimize_to_tray": true,
"start_collection_on_launch": true,
"mcp_enabled": false,
"mcp_port": 5151
Expand Down