266834cbdf
Reduce Performance tab to optional diagnostics Hide the Performance/Diagnostics surface from the primary UX by default and remove hidden startup/tray runtime cost. - Hide Diagnostics from primary navigation and tray by default - Lazy-create PerformanceViewModel only when Diagnostics is opened - Stop initializing diagnostics snapshots during app startup - Gate tray CPU/RAM metrics behind the advanced diagnostics flag - Avoid starting the tray lightweight metrics timer when diagnostics are hidden - Lazily allocate PerformanceMonitoringService counters on first metrics use - Stop live diagnostics when inactive, minimized or tray-hidden - Preserve diagnostics internals for future selected-process summary work - Add tests for lazy diagnostics creation, tray metrics gating and explicit diagnostics activation No Process tab redesign, CPU affinity changes, memory priority changes, persistent rules changes, version bump or tag changes.
203 lines
6.3 KiB
C#
203 lines
6.3 KiB
C#
/*
|
|
* ThreadPilot - Advanced Windows Process and Power Plan Manager
|
|
* Copyright (C) 2025 Prime Build
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, version 3 only.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
namespace ThreadPilot.Services
|
|
{
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using ThreadPilot.Models;
|
|
|
|
/// <summary>
|
|
/// Service for managing system tray functionality.
|
|
/// </summary>
|
|
public interface ISystemTrayService : IDisposable
|
|
{
|
|
/// <summary>
|
|
/// Event fired when quick apply is requested from tray
|
|
/// </summary>
|
|
event EventHandler? QuickApplyRequested;
|
|
|
|
/// <summary>
|
|
/// Event fired when show main window is requested from tray
|
|
/// </summary>
|
|
event EventHandler? ShowMainWindowRequested;
|
|
|
|
/// <summary>
|
|
/// Event fired when exit is requested from tray
|
|
/// </summary>
|
|
event EventHandler? ExitRequested;
|
|
|
|
/// <summary>
|
|
/// Event fired when monitoring enable/disable is requested from tray
|
|
/// </summary>
|
|
event EventHandler<MonitoringToggleEventArgs>? MonitoringToggleRequested;
|
|
|
|
/// <summary>
|
|
/// Event fired when settings are requested from tray
|
|
/// </summary>
|
|
event EventHandler? SettingsRequested;
|
|
|
|
/// <summary>
|
|
/// Event fired when power plan change is requested from tray
|
|
/// </summary>
|
|
event EventHandler<PowerPlanChangeRequestedEventArgs>? PowerPlanChangeRequested;
|
|
|
|
/// <summary>
|
|
/// Event fired when profile application is requested from tray
|
|
/// </summary>
|
|
event EventHandler<ProfileApplicationRequestedEventArgs>? ProfileApplicationRequested;
|
|
|
|
/// <summary>
|
|
/// Event fired when performance dashboard is requested from tray
|
|
/// </summary>
|
|
event EventHandler? PerformanceDashboardRequested;
|
|
|
|
/// <summary>
|
|
/// Event fired when process management dashboard is requested from tray
|
|
/// </summary>
|
|
event EventHandler? DashboardRequested;
|
|
|
|
/// <summary>
|
|
/// Initializes the system tray icon.
|
|
/// </summary>
|
|
void Initialize();
|
|
|
|
/// <summary>
|
|
/// Shows the system tray icon.
|
|
/// </summary>
|
|
void Show();
|
|
|
|
/// <summary>
|
|
/// Hides the system tray icon.
|
|
/// </summary>
|
|
void Hide();
|
|
|
|
/// <summary>
|
|
/// Updates the tray icon tooltip.
|
|
/// </summary>
|
|
void UpdateTooltip(string tooltip);
|
|
|
|
/// <summary>
|
|
/// Shows a balloon tip notification.
|
|
/// </summary>
|
|
void ShowBalloonTip(string title, string text, int timeoutMs = 3000);
|
|
|
|
/// <summary>
|
|
/// Updates the context menu with current process information.
|
|
/// </summary>
|
|
void UpdateContextMenu(string? selectedProcessName = null, bool hasSelection = false);
|
|
|
|
/// <summary>
|
|
/// Updates the monitoring status in the context menu.
|
|
/// </summary>
|
|
void UpdateMonitoringStatus(bool isMonitoring, bool isWmiAvailable = true);
|
|
|
|
/// <summary>
|
|
/// Updates the tray icon based on application state.
|
|
/// </summary>
|
|
void UpdateTrayIcon(TrayIconState state);
|
|
|
|
/// <summary>
|
|
/// Shows a notification through the tray icon.
|
|
/// </summary>
|
|
void ShowTrayNotification(string title, string message, NotificationType type = NotificationType.Information, int timeoutMs = 3000);
|
|
|
|
/// <summary>
|
|
/// Updates settings for the tray service.
|
|
/// </summary>
|
|
void UpdateSettings(ApplicationSettingsModel settings);
|
|
|
|
/// <summary>
|
|
/// Applies theme to the tray context menu.
|
|
/// </summary>
|
|
void ApplyTheme(bool useDarkTheme);
|
|
|
|
/// <summary>
|
|
/// Updates the available power plans in the context menu.
|
|
/// </summary>
|
|
void UpdatePowerPlans(IEnumerable<PowerPlanModel> powerPlans, PowerPlanModel? activePlan);
|
|
|
|
/// <summary>
|
|
/// Updates the available profiles in the context menu.
|
|
/// </summary>
|
|
void UpdateProfiles(IEnumerable<string> profileNames);
|
|
|
|
/// <summary>
|
|
/// Updates the current system status in the tray.
|
|
/// </summary>
|
|
void UpdateSystemStatus(string currentPowerPlan);
|
|
|
|
/// <summary>
|
|
/// Updates the current system status in the tray with diagnostics metrics.
|
|
/// </summary>
|
|
void UpdateSystemStatus(string currentPowerPlan, double cpuUsage, double memoryUsage);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event args for monitoring toggle events.
|
|
/// </summary>
|
|
public class MonitoringToggleEventArgs : EventArgs
|
|
{
|
|
public bool EnableMonitoring { get; }
|
|
|
|
public MonitoringToggleEventArgs(bool enableMonitoring)
|
|
{
|
|
this.EnableMonitoring = enableMonitoring;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event args for power plan change requests.
|
|
/// </summary>
|
|
public class PowerPlanChangeRequestedEventArgs : EventArgs
|
|
{
|
|
public string PowerPlanGuid { get; }
|
|
|
|
public string PowerPlanName { get; }
|
|
|
|
public PowerPlanChangeRequestedEventArgs(string powerPlanGuid, string powerPlanName)
|
|
{
|
|
this.PowerPlanGuid = powerPlanGuid;
|
|
this.PowerPlanName = powerPlanName;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event args for profile application requests.
|
|
/// </summary>
|
|
public class ProfileApplicationRequestedEventArgs : EventArgs
|
|
{
|
|
public string ProfileName { get; }
|
|
|
|
public ProfileApplicationRequestedEventArgs(string profileName)
|
|
{
|
|
this.ProfileName = profileName;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tray icon states.
|
|
/// </summary>
|
|
public enum TrayIconState
|
|
{
|
|
Normal,
|
|
Monitoring,
|
|
Error,
|
|
Disabled,
|
|
}
|
|
}
|
|
|