Enhance theming, UI behavior, perf & add CI
Multiple improvements across theming, UI flow, performance refresh logic, and CI: - Add CI DevSecOps GH Action workflow: .NET restore/build (Debug/Release), dependency audit, and gitleaks secret scan. - Theming: preload and apply theme at startup; add HasUserThemePreference to settings model; detect legacy theme flag when loading settings; ThemeService now reads system theme from registry (GetSystemUsesDarkTheme) and exposes system-use check. - Richer theme resources: major updates to FluentDark.xaml and FluentLight.xaml (expanded color palette, control styles/templates, system brushes) to modernize visuals and controls. - Startup/UI behavior: improved autostart/minimize-to-tray handling, consistent ShowInTaskbar/Visibility logic, OnSourceInitialized hook to reapply caption theme, and apply DWM immersive dark caption via DwmSetWindowAttribute. - Robust UI error handling: throttle dispatcher exception dialog to avoid multiple dialogs using an interlocked flag and short time window. - MainWindow refactor: introduce ShowWindowFromTray helper, unify show/activate flows, apply caption theming, and adjust several shortcut handlers to use the helper. - Tab switching: add SemaphoreSlim guard and improved selection logic to debounce concurrent tab changes; prompt/save/discard unsaved settings when switching away from Settings; dispose semaphore on shutdown. - PerformanceViewModel: debounce/gate top-process refreshes with SemaphoreSlim and a pending flag to avoid overlapping refreshes; update TopCpuProcesses on UI dispatcher and refresh selected process impact safely. - Misc: small XAML cleanups (Settings tab header simplification), add COMPLIANCE_AUDIT.md to .gitignore, and various logging/error message tweaks. These changes aim to reduce UI flicker on startup, respect user/system theme preferences, harden UI interactions, prevent concurrent refresh race conditions, and add CI/DevSecOps checks.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
name: CI DevSecOps
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main", "master"]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build-and-scan:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: "8.0.x"
|
||||
|
||||
- name: Restore
|
||||
run: dotnet restore "ThreadPilot.csproj"
|
||||
|
||||
- name: Build Debug
|
||||
run: dotnet build "ThreadPilot.csproj" --configuration Debug --no-restore
|
||||
|
||||
- name: Build Release
|
||||
run: dotnet build "ThreadPilot.csproj" --configuration Release --no-restore
|
||||
|
||||
- name: Dependency Audit
|
||||
run: dotnet list "ThreadPilot.csproj" package --vulnerable --include-transitive
|
||||
|
||||
- name: Secret Scan
|
||||
uses: gitleaks/gitleaks-action@v2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -131,3 +131,4 @@ GAME_BOOST_VALIDATION.md
|
||||
PROJECT_STRUCTURE.md
|
||||
TRADEMARK.md
|
||||
UI_STYLE_GUIDE.md
|
||||
COMPLIANCE_AUDIT.md
|
||||
|
||||
+57
-8
@@ -34,6 +34,8 @@ namespace ThreadPilot
|
||||
public partial class App : System.Windows.Application
|
||||
{
|
||||
private Mutex? _singleInstanceMutex;
|
||||
private int _uiExceptionDialogOpen;
|
||||
private DateTime _lastUiExceptionDialogUtc = DateTime.MinValue;
|
||||
public IServiceProvider ServiceProvider { get; private set; }
|
||||
|
||||
public App()
|
||||
@@ -135,6 +137,24 @@ namespace ThreadPilot
|
||||
}
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
var settingsService = ServiceProvider.GetRequiredService<IApplicationSettingsService>();
|
||||
var themeService = ServiceProvider.GetRequiredService<IThemeService>();
|
||||
|
||||
Task.Run(async () => await settingsService.LoadSettingsAsync()).GetAwaiter().GetResult();
|
||||
var settings = settingsService.Settings;
|
||||
var useDarkTheme = settings.HasUserThemePreference
|
||||
? settings.UseDarkTheme
|
||||
: themeService.GetSystemUsesDarkTheme();
|
||||
|
||||
themeService.ApplyTheme(useDarkTheme);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Failed to preload theme settings during startup");
|
||||
}
|
||||
|
||||
var mainWindow = ServiceProvider.GetRequiredService<MainWindow>();
|
||||
|
||||
// Handle startup behavior with comprehensive error handling
|
||||
@@ -148,15 +168,27 @@ namespace ThreadPilot
|
||||
throw new InvalidOperationException("MainWindow could not be created");
|
||||
}
|
||||
|
||||
// Show the window with explicit visibility settings
|
||||
mainWindow.Visibility = Visibility.Visible;
|
||||
mainWindow.WindowState = (startMinimized || isAutostart)
|
||||
? WindowState.Minimized
|
||||
: WindowState.Normal;
|
||||
mainWindow.Show();
|
||||
if (mainWindow.WindowState != WindowState.Minimized)
|
||||
if (isAutostart)
|
||||
{
|
||||
mainWindow.Activate();
|
||||
mainWindow.ShowInTaskbar = false;
|
||||
mainWindow.Visibility = Visibility.Hidden;
|
||||
mainWindow.WindowState = WindowState.Minimized;
|
||||
mainWindow.Show();
|
||||
mainWindow.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show the window with explicit visibility settings
|
||||
mainWindow.ShowInTaskbar = true;
|
||||
mainWindow.Visibility = Visibility.Visible;
|
||||
mainWindow.WindowState = startMinimized
|
||||
? WindowState.Minimized
|
||||
: WindowState.Normal;
|
||||
mainWindow.Show();
|
||||
if (mainWindow.WindowState != WindowState.Minimized)
|
||||
{
|
||||
mainWindow.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
logger.LogInformation("Main window displayed successfully");
|
||||
@@ -247,6 +279,21 @@ namespace ThreadPilot
|
||||
|
||||
logger?.LogError(e.Exception, "Unhandled dispatcher exception occurred");
|
||||
|
||||
if (Interlocked.CompareExchange(ref _uiExceptionDialogOpen, 1, 0) != 0)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (DateTime.UtcNow - _lastUiExceptionDialogUtc < TimeSpan.FromSeconds(2))
|
||||
{
|
||||
e.Handled = true;
|
||||
Interlocked.Exchange(ref _uiExceptionDialogOpen, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
_lastUiExceptionDialogUtc = DateTime.UtcNow;
|
||||
|
||||
var errorMessage = $"An error occurred in the user interface:\n\n{e.Exception.Message}\n\nDo you want to continue?";
|
||||
var result = System.Windows.MessageBox.Show(errorMessage, "UI Error",
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Error);
|
||||
@@ -259,6 +306,8 @@ namespace ThreadPilot
|
||||
{
|
||||
e.Handled = false; // Let the application crash
|
||||
}
|
||||
|
||||
Interlocked.Exchange(ref _uiExceptionDialogOpen, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-19
@@ -13,18 +13,6 @@
|
||||
WindowStartupLocation="CenterScreen">
|
||||
|
||||
<Window.Resources>
|
||||
<Style TargetType="GroupBox">
|
||||
<Setter Property="Background" Value="{DynamicResource SurfaceBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TabControl">
|
||||
<Setter Property="Background" Value="{DynamicResource AppBackgroundBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="StatusBar">
|
||||
<Setter Property="Background" Value="{DynamicResource SurfaceAltBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
|
||||
@@ -102,13 +90,7 @@
|
||||
<TabItem x:Name="SystemTweaksTab" Header="🔧 Tweaks">
|
||||
<views:SystemTweaksView x:Name="SystemTweaksView"/>
|
||||
</TabItem>
|
||||
<TabItem x:Name="SettingsTab">
|
||||
<TabItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="" FontFamily="Segoe Fluent Icons, Segoe MDL2 Assets, Segoe UI Symbol, Segoe UI" Margin="0,0,6,0"/>
|
||||
<TextBlock Text="Settings"/>
|
||||
</StackPanel>
|
||||
</TabItem.Header>
|
||||
<TabItem x:Name="SettingsTab" Header="Settings">
|
||||
<views:SettingsView x:Name="SettingsView"/>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
+147
-76
@@ -18,6 +18,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
@@ -34,6 +36,9 @@ namespace ThreadPilot
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private const int DwmUseImmersiveDarkMode = 20;
|
||||
private const int DwmUseImmersiveDarkModeLegacy = 19;
|
||||
|
||||
private readonly ProcessViewModel _processViewModel;
|
||||
private readonly PowerPlanViewModel _powerPlanViewModel;
|
||||
private readonly PerformanceViewModel _performanceViewModel;
|
||||
@@ -66,6 +71,10 @@ namespace ThreadPilot
|
||||
private bool _isPerformingShutdown = false;
|
||||
private int _currentTabIndex = -1;
|
||||
private bool _isHandlingTabSelection;
|
||||
private readonly SemaphoreSlim _tabSwitchGuard = new(1, 1);
|
||||
|
||||
[DllImport("dwmapi.dll")]
|
||||
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, ref int pvAttribute, int cbAttribute);
|
||||
|
||||
public MainWindow(
|
||||
ProcessViewModel processViewModel,
|
||||
@@ -559,7 +568,13 @@ namespace ThreadPilot
|
||||
|
||||
// Apply initial settings
|
||||
var settings = _settingsService.Settings;
|
||||
_themeService.ApplyTheme(settings.UseDarkTheme);
|
||||
var useDarkTheme = settings.HasUserThemePreference
|
||||
? settings.UseDarkTheme
|
||||
: _themeService.GetSystemUsesDarkTheme();
|
||||
|
||||
_themeService.ApplyTheme(useDarkTheme);
|
||||
ApplyWindowCaptionTheme(useDarkTheme);
|
||||
|
||||
if (settings.StartMinimized)
|
||||
{
|
||||
WindowState = WindowState.Minimized;
|
||||
@@ -637,9 +652,7 @@ namespace ThreadPilot
|
||||
|
||||
private void OnShowMainWindowRequested(object? sender, EventArgs e)
|
||||
{
|
||||
Show();
|
||||
WindowState = WindowState.Normal;
|
||||
Activate();
|
||||
ShowWindowFromTray();
|
||||
}
|
||||
|
||||
private async void OnExitRequested(object? sender, EventArgs e)
|
||||
@@ -649,10 +662,7 @@ namespace ThreadPilot
|
||||
|
||||
private void OnDashboardRequested(object? sender, EventArgs e)
|
||||
{
|
||||
Show();
|
||||
WindowState = WindowState.Normal;
|
||||
Activate();
|
||||
SelectMainTab(ProcessManagementTab);
|
||||
ShowWindowFromTray(ProcessManagementTab);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -945,15 +955,11 @@ namespace ThreadPilot
|
||||
{
|
||||
try
|
||||
{
|
||||
Show();
|
||||
WindowState = WindowState.Normal;
|
||||
Activate();
|
||||
|
||||
SelectMainTab(PerformanceTab);
|
||||
ShowWindowFromTray(PerformanceTab);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Failed to open system tweaks: {ex.Message}");
|
||||
System.Diagnostics.Debug.WriteLine($"Failed to open performance dashboard: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1014,13 +1020,12 @@ namespace ThreadPilot
|
||||
case ShortcutActions.ShowMainWindow:
|
||||
if (IsVisible && WindowState != WindowState.Minimized)
|
||||
{
|
||||
ShowInTaskbar = false;
|
||||
Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
Show();
|
||||
WindowState = WindowState.Normal;
|
||||
Activate();
|
||||
ShowWindowFromTray();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1035,17 +1040,11 @@ namespace ThreadPilot
|
||||
break;
|
||||
|
||||
case ShortcutActions.OpenTweaks:
|
||||
Show();
|
||||
WindowState = WindowState.Normal;
|
||||
Activate();
|
||||
SelectMainTab(SystemTweaksTab);
|
||||
ShowWindowFromTray(SystemTweaksTab);
|
||||
break;
|
||||
|
||||
case ShortcutActions.OpenSettings:
|
||||
Show();
|
||||
WindowState = WindowState.Normal;
|
||||
Activate();
|
||||
SelectMainTab(SettingsTab);
|
||||
ShowWindowFromTray(SettingsTab);
|
||||
break;
|
||||
|
||||
case ShortcutActions.RefreshProcessList:
|
||||
@@ -1250,6 +1249,12 @@ namespace ThreadPilot
|
||||
{
|
||||
// Update tray service with new settings
|
||||
_systemTrayService.UpdateSettings(e.NewSettings);
|
||||
|
||||
var useDarkTheme = e.NewSettings.HasUserThemePreference
|
||||
? e.NewSettings.UseDarkTheme
|
||||
: _themeService.GetSystemUsesDarkTheme();
|
||||
|
||||
ApplyWindowCaptionTheme(useDarkTheme);
|
||||
}
|
||||
|
||||
private void OnMonitoringStatusChanged(object? sender, MonitoringStatusEventArgs e)
|
||||
@@ -1288,6 +1293,7 @@ namespace ThreadPilot
|
||||
{
|
||||
if (WindowState == WindowState.Minimized && _settingsService.Settings.MinimizeToTray)
|
||||
{
|
||||
ShowInTaskbar = false;
|
||||
Hide();
|
||||
_systemTrayService.Show();
|
||||
|
||||
@@ -1304,6 +1310,8 @@ namespace ThreadPilot
|
||||
}
|
||||
else if (WindowState == WindowState.Normal)
|
||||
{
|
||||
ShowInTaskbar = true;
|
||||
|
||||
// Resume process refresh when restored
|
||||
if (_processViewModel != null)
|
||||
{
|
||||
@@ -1324,6 +1332,12 @@ namespace ThreadPilot
|
||||
base.OnStateChanged(e);
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
base.OnSourceInitialized(e);
|
||||
ApplyWindowCaptionTheme(_themeService.IsDarkTheme);
|
||||
}
|
||||
|
||||
[System.Diagnostics.Conditional("DEBUG")]
|
||||
private void LogDebug(string message)
|
||||
{
|
||||
@@ -1355,6 +1369,52 @@ namespace ThreadPilot
|
||||
return ReferenceEquals(item, target);
|
||||
}
|
||||
|
||||
private void ShowWindowFromTray(TabItem? tabToSelect = null)
|
||||
{
|
||||
ShowInTaskbar = true;
|
||||
Visibility = Visibility.Visible;
|
||||
|
||||
if (!IsVisible)
|
||||
{
|
||||
Show();
|
||||
}
|
||||
|
||||
if (WindowState == WindowState.Minimized)
|
||||
{
|
||||
WindowState = WindowState.Normal;
|
||||
}
|
||||
|
||||
Activate();
|
||||
|
||||
if (tabToSelect != null)
|
||||
{
|
||||
SelectMainTab(tabToSelect);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyWindowCaptionTheme(bool useDarkTheme)
|
||||
{
|
||||
try
|
||||
{
|
||||
var windowHandle = new System.Windows.Interop.WindowInteropHelper(this).Handle;
|
||||
if (windowHandle == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var darkMode = useDarkTheme ? 1 : 0;
|
||||
var result = DwmSetWindowAttribute(windowHandle, DwmUseImmersiveDarkMode, ref darkMode, Marshal.SizeOf<int>());
|
||||
if (result != 0)
|
||||
{
|
||||
_ = DwmSetWindowAttribute(windowHandle, DwmUseImmersiveDarkModeLegacy, ref darkMode, Marshal.SizeOf<int>());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Failed to apply window caption theme: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectMainTab(TabItem tab)
|
||||
{
|
||||
if (tab != null)
|
||||
@@ -1370,72 +1430,81 @@ namespace ThreadPilot
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsLoaded || e.Source != MainTabControl)
|
||||
await _tabSwitchGuard.WaitAsync();
|
||||
|
||||
try
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!IsLoaded || e.Source != MainTabControl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var newIndex = MainTabControl.SelectedIndex;
|
||||
if (_currentTabIndex < 0)
|
||||
{
|
||||
_currentTabIndex = newIndex;
|
||||
return;
|
||||
}
|
||||
var newIndex = MainTabControl.SelectedIndex;
|
||||
if (_currentTabIndex < 0)
|
||||
{
|
||||
_currentTabIndex = newIndex;
|
||||
return;
|
||||
}
|
||||
|
||||
if (newIndex == _currentTabIndex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (newIndex == _currentTabIndex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var previousTab = _currentTabIndex >= 0 && _currentTabIndex < MainTabControl.Items.Count
|
||||
? MainTabControl.Items[_currentTabIndex]
|
||||
: null;
|
||||
var currentTab = MainTabControl.SelectedItem;
|
||||
var previousTab = _currentTabIndex >= 0 && _currentTabIndex < MainTabControl.Items.Count
|
||||
? MainTabControl.Items[_currentTabIndex]
|
||||
: null;
|
||||
var currentTab = MainTabControl.SelectedItem;
|
||||
|
||||
var settingsTabChanged = IsTabItem(previousTab, SettingsTab) || IsTabItem(currentTab, SettingsTab);
|
||||
if (!settingsTabChanged)
|
||||
{
|
||||
_currentTabIndex = newIndex;
|
||||
return;
|
||||
}
|
||||
var settingsTabChanged = IsTabItem(previousTab, SettingsTab) || IsTabItem(currentTab, SettingsTab);
|
||||
if (!settingsTabChanged)
|
||||
{
|
||||
_currentTabIndex = newIndex;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_settingsViewModel.HasPendingChanges)
|
||||
{
|
||||
_currentTabIndex = newIndex;
|
||||
return;
|
||||
}
|
||||
if (!_settingsViewModel.HasPendingChanges)
|
||||
{
|
||||
_currentTabIndex = newIndex;
|
||||
return;
|
||||
}
|
||||
|
||||
var result = System.Windows.MessageBox.Show(
|
||||
"You have unsaved changes in Settings.\n\nChoose an action:\n- Yes: Save changes\n- No: Discard changes\n- Cancel: Stay on current tab",
|
||||
"Unsaved Settings",
|
||||
MessageBoxButton.YesNoCancel,
|
||||
MessageBoxImage.Warning);
|
||||
var result = System.Windows.MessageBox.Show(
|
||||
"You have unsaved changes in Settings.\n\nChoose an action:\n- Yes: Save changes\n- No: Discard changes\n- Cancel: Stay on current tab",
|
||||
"Unsaved Settings",
|
||||
MessageBoxButton.YesNoCancel,
|
||||
MessageBoxImage.Warning);
|
||||
|
||||
if (result == MessageBoxResult.Cancel)
|
||||
{
|
||||
_isHandlingTabSelection = true;
|
||||
MainTabControl.SelectedIndex = _currentTabIndex;
|
||||
_isHandlingTabSelection = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
var saved = await _settingsViewModel.SaveIfDirtyAsync();
|
||||
if (!saved)
|
||||
if (result == MessageBoxResult.Cancel)
|
||||
{
|
||||
_isHandlingTabSelection = true;
|
||||
MainTabControl.SelectedIndex = _currentTabIndex;
|
||||
_isHandlingTabSelection = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (result == MessageBoxResult.No)
|
||||
{
|
||||
await _settingsViewModel.DiscardPendingChangesAsync();
|
||||
}
|
||||
|
||||
_currentTabIndex = MainTabControl.SelectedIndex;
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
var saved = await _settingsViewModel.SaveIfDirtyAsync();
|
||||
if (!saved)
|
||||
{
|
||||
_isHandlingTabSelection = true;
|
||||
MainTabControl.SelectedIndex = _currentTabIndex;
|
||||
_isHandlingTabSelection = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (result == MessageBoxResult.No)
|
||||
{
|
||||
await _settingsViewModel.DiscardPendingChangesAsync();
|
||||
}
|
||||
|
||||
_currentTabIndex = MainTabControl.SelectedIndex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_tabSwitchGuard.Release();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
@@ -1469,6 +1538,8 @@ namespace ThreadPilot
|
||||
|
||||
_initializationTimeoutTimer?.Stop();
|
||||
_initializationTimeoutTimer?.Dispose();
|
||||
|
||||
_tabSwitchGuard.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -142,6 +142,9 @@ namespace ThreadPilot.Models
|
||||
[ObservableProperty]
|
||||
private bool useDarkTheme = false;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool hasUserThemePreference = false;
|
||||
|
||||
// Monitoring Settings
|
||||
[ObservableProperty]
|
||||
private int pollingIntervalMs = 5000;
|
||||
@@ -218,6 +221,7 @@ namespace ThreadPilot.Models
|
||||
RestoreDefaultPowerPlanOnExit = other.RestoreDefaultPowerPlanOnExit;
|
||||
ClearMasksOnClose = other.ClearMasksOnClose;
|
||||
UseDarkTheme = other.UseDarkTheme;
|
||||
HasUserThemePreference = other.HasUserThemePreference;
|
||||
|
||||
// Monitoring Settings
|
||||
PollingIntervalMs = other.PollingIntervalMs;
|
||||
|
||||
@@ -72,10 +72,32 @@ namespace ThreadPilot.Services
|
||||
}
|
||||
|
||||
var json = await File.ReadAllTextAsync(_settingsFilePath);
|
||||
var legacyThemePreferenceDetected = false;
|
||||
|
||||
try
|
||||
{
|
||||
using var document = JsonDocument.Parse(json);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
var hasThemePreferenceFlag = document.RootElement.TryGetProperty("hasUserThemePreference", out _);
|
||||
var hasUseDarkThemeFlag = document.RootElement.TryGetProperty("useDarkTheme", out _);
|
||||
legacyThemePreferenceDetected = !hasThemePreferenceFlag && hasUseDarkThemeFlag;
|
||||
}
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Unable to parse settings JSON metadata, continuing with standard deserialization");
|
||||
}
|
||||
|
||||
var loadedSettings = JsonSerializer.Deserialize<ApplicationSettingsModel>(json, JsonOptions);
|
||||
|
||||
if (loadedSettings != null)
|
||||
{
|
||||
if (legacyThemePreferenceDetected)
|
||||
{
|
||||
loadedSettings.HasUserThemePreference = true;
|
||||
}
|
||||
|
||||
var oldSettings = (ApplicationSettingsModel)_settings.Clone();
|
||||
_settings.CopyFrom(loadedSettings);
|
||||
ValidateAndFixSettings();
|
||||
|
||||
@@ -23,5 +23,7 @@ namespace ThreadPilot.Services
|
||||
bool IsDarkTheme { get; }
|
||||
|
||||
void ApplyTheme(bool useDarkTheme);
|
||||
|
||||
bool GetSystemUsesDarkTheme();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace ThreadPilot.Services
|
||||
{
|
||||
@@ -70,5 +71,32 @@ namespace ThreadPilot.Services
|
||||
_logger.LogError(ex, "Failed to apply theme {ThemeUri}", targetUri);
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetSystemUsesDarkTheme()
|
||||
{
|
||||
try
|
||||
{
|
||||
const string personalizeKey = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
|
||||
|
||||
using var key = Registry.CurrentUser.OpenSubKey(personalizeKey, writable: false);
|
||||
var value = key?.GetValue("AppsUseLightTheme");
|
||||
|
||||
if (value is int intValue)
|
||||
{
|
||||
return intValue == 0;
|
||||
}
|
||||
|
||||
if (value is long longValue)
|
||||
{
|
||||
return longValue == 0;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to read system theme preference, falling back to light theme");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+249
-14
@@ -1,14 +1,23 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<SolidColorBrush x:Key="AppBackgroundBrush" Color="#FF0F141A"/>
|
||||
<SolidColorBrush x:Key="SurfaceBrush" Color="#FF1A222C"/>
|
||||
<SolidColorBrush x:Key="SurfaceAltBrush" Color="#FF23303C"/>
|
||||
<SolidColorBrush x:Key="TextPrimaryBrush" Color="#FFE7EDF3"/>
|
||||
<SolidColorBrush x:Key="TextSecondaryBrush" Color="#FFAFBDC9"/>
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=PresentationFramework">
|
||||
<SolidColorBrush x:Key="AppBackgroundBrush" Color="#FF0B1118"/>
|
||||
<SolidColorBrush x:Key="SurfaceBrush" Color="#FF16212D"/>
|
||||
<SolidColorBrush x:Key="SurfaceAltBrush" Color="#FF1D2A38"/>
|
||||
<SolidColorBrush x:Key="SurfaceMutedBrush" Color="#FF101923"/>
|
||||
<SolidColorBrush x:Key="TextPrimaryBrush" Color="#FFE8EEF5"/>
|
||||
<SolidColorBrush x:Key="TextSecondaryBrush" Color="#FFB3C0CC"/>
|
||||
<SolidColorBrush x:Key="TextDisabledBrush" Color="#FF7D8996"/>
|
||||
<SolidColorBrush x:Key="AccentBrush" Color="#FF45A0FF"/>
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#FF344555"/>
|
||||
<SolidColorBrush x:Key="AccentAltBrush" Color="#FF2E78BA"/>
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#FF314454"/>
|
||||
<SolidColorBrush x:Key="BorderSubtleBrush" Color="#FF243241"/>
|
||||
<SolidColorBrush x:Key="OverlayBrush" Color="#99060A10"/>
|
||||
<SolidColorBrush x:Key="SpinnerTrackBrush" Color="#FF4B5E71"/>
|
||||
<SolidColorBrush x:Key="InputBackgroundBrush" Color="#FF101A24"/>
|
||||
<SolidColorBrush x:Key="InputBorderBrush" Color="#FF405466"/>
|
||||
<SolidColorBrush x:Key="InputHoverBorderBrush" Color="#FF6288A8"/>
|
||||
<SolidColorBrush x:Key="InputDisabledBackgroundBrush" Color="#FF253340"/>
|
||||
<SolidColorBrush x:Key="InfoBackgroundBrush" Color="#FF1A2B3A"/>
|
||||
<SolidColorBrush x:Key="InfoBorderBrush" Color="#FF2D4A64"/>
|
||||
<SolidColorBrush x:Key="InfoTextBrush" Color="#FF9DD3FF"/>
|
||||
@@ -22,6 +31,18 @@
|
||||
<SolidColorBrush x:Key="ErrorBorderBrush" Color="#FF653333"/>
|
||||
<SolidColorBrush x:Key="ErrorTextBrush" Color="#FFFFA4A4"/>
|
||||
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="#FF101A24"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.WindowTextBrushKey}" Color="#FFE8EEF5"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#FF16212D"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="#FFE8EEF5"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlLightBrushKey}" Color="#FF1D2A38"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlLightLightBrushKey}" Color="#FF2A3B4B"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlDarkBrushKey}" Color="#FF0E1721"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlDarkDarkBrushKey}" Color="#FF091019"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.GrayTextBrushKey}" Color="#FF7D8996"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF2E78BA"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="#FFE8EEF5"/>
|
||||
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="Background" Value="{StaticResource AppBackgroundBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
@@ -34,39 +55,253 @@
|
||||
<Setter Property="FontFamily" Value="Segoe UI, Segoe UI Variable Text, Arial"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="GroupBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="6"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GroupBox">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="10"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<DockPanel LastChildFill="True">
|
||||
<ContentPresenter ContentSource="Header"
|
||||
DockPanel.Dock="Top"
|
||||
Margin="0,0,0,6"
|
||||
RecognizesAccessKey="True"
|
||||
TextElement.Foreground="{TemplateBinding Foreground}"
|
||||
TextElement.FontWeight="SemiBold"/>
|
||||
<ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TabControl">
|
||||
<Setter Property="Background" Value="{StaticResource AppBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TabItem">
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceAltBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="Padding" Value="14,7"/>
|
||||
<Setter Property="Margin" Value="0,0,6,0"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceAltBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="10,6"/>
|
||||
<Setter Property="MinHeight" Value="30"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="ButtonBorder"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="8"
|
||||
SnapsToDevicePixels="True">
|
||||
<ContentPresenter HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="ButtonBorder" Property="BorderBrush" Value="{DynamicResource AccentBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="ButtonBorder" Property="Background" Value="{DynamicResource SurfaceMutedBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}"/>
|
||||
<Setter TargetName="ButtonBorder" Property="Opacity" Value="0.7"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource InputBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource InputBorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="CaretBrush" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="SelectionBrush" Value="{StaticResource AccentAltBrush}"/>
|
||||
<Setter Property="Padding" Value="8,5"/>
|
||||
<Setter Property="MinHeight" Value="30"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource InputHoverBorderBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource InputDisabledBackgroundBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="PasswordBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource InputBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource InputBorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="8,5"/>
|
||||
<Setter Property="MinHeight" Value="30"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource InputHoverBorderBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource InputDisabledBackgroundBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ComboBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource InputBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource InputBorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="6,4"/>
|
||||
<Setter Property="MinHeight" Value="30"/>
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
|
||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsKeyboardFocusWithin" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource InputHoverBorderBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource InputDisabledBackgroundBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="Padding" Value="8,4"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsHighlighted" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource SurfaceAltBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource AccentAltBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DatePicker">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource InputBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource InputBorderBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="primitives:DatePickerTextBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource InputBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource InputBorderBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="CheckBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ListView">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ListBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DataGrid">
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="RowBackground" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="AlternatingRowBackground" Value="{StaticResource SurfaceAltBrush}"/>
|
||||
<Setter Property="HorizontalGridLinesBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="VerticalGridLinesBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="HorizontalGridLinesBrush" Value="{StaticResource BorderSubtleBrush}"/>
|
||||
<Setter Property="VerticalGridLinesBrush" Value="{StaticResource BorderSubtleBrush}"/>
|
||||
<Setter Property="HeadersVisibility" Value="Column"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Style TargetType="DataGridRow">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource AccentAltBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderSubtleBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,1"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DataGridColumnHeader">
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceAltBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextSecondaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="Padding" Value="10,6"/>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,1"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="8,6"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="StatusBar">
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceAltBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1,1,1,0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBlock">
|
||||
|
||||
+248
-13
@@ -1,14 +1,23 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<SolidColorBrush x:Key="AppBackgroundBrush" Color="#FFF7F9FC"/>
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=PresentationFramework">
|
||||
<SolidColorBrush x:Key="AppBackgroundBrush" Color="#FFF2F6FB"/>
|
||||
<SolidColorBrush x:Key="SurfaceBrush" Color="#FFFFFFFF"/>
|
||||
<SolidColorBrush x:Key="SurfaceAltBrush" Color="#FFF1F5FA"/>
|
||||
<SolidColorBrush x:Key="TextPrimaryBrush" Color="#FF1E2A35"/>
|
||||
<SolidColorBrush x:Key="TextSecondaryBrush" Color="#FF5D6A76"/>
|
||||
<SolidColorBrush x:Key="SurfaceAltBrush" Color="#FFF4F8FD"/>
|
||||
<SolidColorBrush x:Key="SurfaceMutedBrush" Color="#FFE9EFF6"/>
|
||||
<SolidColorBrush x:Key="TextPrimaryBrush" Color="#FF1B2835"/>
|
||||
<SolidColorBrush x:Key="TextSecondaryBrush" Color="#FF5B6B7A"/>
|
||||
<SolidColorBrush x:Key="TextDisabledBrush" Color="#FF98A6B4"/>
|
||||
<SolidColorBrush x:Key="AccentBrush" Color="#FF0A66C2"/>
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#FFD3DEE8"/>
|
||||
<SolidColorBrush x:Key="AccentAltBrush" Color="#FFDCEAFE"/>
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#FFD0DCE8"/>
|
||||
<SolidColorBrush x:Key="BorderSubtleBrush" Color="#FFE1E8F0"/>
|
||||
<SolidColorBrush x:Key="OverlayBrush" Color="#66050A12"/>
|
||||
<SolidColorBrush x:Key="SpinnerTrackBrush" Color="#FFB8C5D1"/>
|
||||
<SolidColorBrush x:Key="InputBackgroundBrush" Color="#FFFFFFFF"/>
|
||||
<SolidColorBrush x:Key="InputBorderBrush" Color="#FFB3C4D5"/>
|
||||
<SolidColorBrush x:Key="InputHoverBorderBrush" Color="#FF6D93BD"/>
|
||||
<SolidColorBrush x:Key="InputDisabledBackgroundBrush" Color="#FFF2F4F7"/>
|
||||
<SolidColorBrush x:Key="InfoBackgroundBrush" Color="#FFEAF4FF"/>
|
||||
<SolidColorBrush x:Key="InfoBorderBrush" Color="#FFB9D8F7"/>
|
||||
<SolidColorBrush x:Key="InfoTextBrush" Color="#FF154B7D"/>
|
||||
@@ -22,6 +31,18 @@
|
||||
<SolidColorBrush x:Key="ErrorBorderBrush" Color="#FFF3B8B8"/>
|
||||
<SolidColorBrush x:Key="ErrorTextBrush" Color="#FFA12626"/>
|
||||
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="#FFFFFFFF"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.WindowTextBrushKey}" Color="#FF1B2835"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#FFF4F8FD"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="#FF1B2835"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlLightBrushKey}" Color="#FFF9FBFE"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlLightLightBrushKey}" Color="#FFFFFFFF"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlDarkBrushKey}" Color="#FFD3DFEA"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlDarkDarkBrushKey}" Color="#FFBCCCDC"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.GrayTextBrushKey}" Color="#FF98A6B4"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF0A66C2"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="#FFFFFFFF"/>
|
||||
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="Background" Value="{StaticResource AppBackgroundBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
@@ -34,39 +55,253 @@
|
||||
<Setter Property="FontFamily" Value="Segoe UI, Segoe UI Variable Text, Arial"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="GroupBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="6"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GroupBox">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="10"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<DockPanel LastChildFill="True">
|
||||
<ContentPresenter ContentSource="Header"
|
||||
DockPanel.Dock="Top"
|
||||
Margin="0,0,0,6"
|
||||
RecognizesAccessKey="True"
|
||||
TextElement.Foreground="{TemplateBinding Foreground}"
|
||||
TextElement.FontWeight="SemiBold"/>
|
||||
<ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TabControl">
|
||||
<Setter Property="Background" Value="{StaticResource AppBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TabItem">
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceAltBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="Padding" Value="14,7"/>
|
||||
<Setter Property="Margin" Value="0,0,6,0"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceAltBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="10,6"/>
|
||||
<Setter Property="MinHeight" Value="30"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="ButtonBorder"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="8"
|
||||
SnapsToDevicePixels="True">
|
||||
<ContentPresenter HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="ButtonBorder" Property="BorderBrush" Value="{DynamicResource AccentBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="ButtonBorder" Property="Background" Value="{DynamicResource SurfaceMutedBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}"/>
|
||||
<Setter TargetName="ButtonBorder" Property="Opacity" Value="0.7"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource InputBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource InputBorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="CaretBrush" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="SelectionBrush" Value="{StaticResource AccentAltBrush}"/>
|
||||
<Setter Property="Padding" Value="8,5"/>
|
||||
<Setter Property="MinHeight" Value="30"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource InputHoverBorderBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource InputDisabledBackgroundBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="PasswordBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource InputBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource InputBorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="8,5"/>
|
||||
<Setter Property="MinHeight" Value="30"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource InputHoverBorderBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource InputDisabledBackgroundBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ComboBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource InputBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource InputBorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="6,4"/>
|
||||
<Setter Property="MinHeight" Value="30"/>
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
|
||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsKeyboardFocusWithin" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource InputHoverBorderBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource InputDisabledBackgroundBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="Padding" Value="8,4"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsHighlighted" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource SurfaceAltBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource AccentAltBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DatePicker">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource InputBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource InputBorderBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="primitives:DatePickerTextBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource InputBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource InputBorderBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="CheckBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ListView">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ListBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DataGrid">
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="RowBackground" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Setter Property="AlternatingRowBackground" Value="{StaticResource SurfaceAltBrush}"/>
|
||||
<Setter Property="HorizontalGridLinesBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="VerticalGridLinesBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="HorizontalGridLinesBrush" Value="{StaticResource BorderSubtleBrush}"/>
|
||||
<Setter Property="VerticalGridLinesBrush" Value="{StaticResource BorderSubtleBrush}"/>
|
||||
<Setter Property="HeadersVisibility" Value="Column"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceBrush}"/>
|
||||
<Style TargetType="DataGridRow">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource AccentAltBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderSubtleBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,1"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DataGridColumnHeader">
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceAltBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextSecondaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="Padding" Value="10,6"/>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,1"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="8,6"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="StatusBar">
|
||||
<Setter Property="Background" Value="{StaticResource SurfaceAltBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource TextPrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1,1,1,0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBlock">
|
||||
|
||||
@@ -19,6 +19,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@@ -154,6 +155,8 @@ namespace ThreadPilot.ViewModels
|
||||
|
||||
private readonly Dictionary<string, DateTime> _lastRuleApplyByExecutable = new(StringComparer.OrdinalIgnoreCase);
|
||||
private bool _monitoringWasActiveBeforeSuspend;
|
||||
private readonly SemaphoreSlim _topProcessRefreshGate = new(1, 1);
|
||||
private bool _pendingTopProcessRefresh;
|
||||
|
||||
public PerformanceViewModel(
|
||||
IPerformanceMonitoringService performanceService,
|
||||
@@ -528,64 +531,87 @@ namespace ThreadPilot.ViewModels
|
||||
|
||||
private async Task LoadTopProcessesAsync()
|
||||
{
|
||||
if (_topProcessRefreshGate.CurrentCount == 0)
|
||||
{
|
||||
_pendingTopProcessRefresh = true;
|
||||
return;
|
||||
}
|
||||
|
||||
await _topProcessRefreshGate.WaitAsync();
|
||||
|
||||
try
|
||||
{
|
||||
var topCpu = await _performanceService.GetTopCpuProcessesAsync(25);
|
||||
var topMemory = await _performanceService.GetTopMemoryProcessesAsync(25);
|
||||
|
||||
var merged = topCpu
|
||||
.Concat(topMemory)
|
||||
.GroupBy(p => p.ProcessId)
|
||||
.Select(g => g.OrderByDescending(x => x.CpuUsage).First())
|
||||
.ToList();
|
||||
|
||||
var associations = await _associationService.GetAssociationsAsync();
|
||||
var associationSet = associations
|
||||
.Select(a => NormalizeExecutableName(a.ExecutableName))
|
||||
.Where(name => !string.IsNullOrWhiteSpace(name))
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
IEnumerable<ProcessPerformanceInfo> filtered = merged;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(ProcessSearchText))
|
||||
do
|
||||
{
|
||||
filtered = filtered.Where(p => p.ProcessName.Contains(ProcessSearchText, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
_pendingTopProcessRefresh = false;
|
||||
|
||||
if (ShowOnlyRuleBackedHotspots)
|
||||
{
|
||||
filtered = filtered.Where(p => associationSet.Contains(NormalizeExecutableName(p.ProcessName)));
|
||||
}
|
||||
var topCpu = await _performanceService.GetTopCpuProcessesAsync(25);
|
||||
var topMemory = await _performanceService.GetTopMemoryProcessesAsync(25);
|
||||
|
||||
if (ShowOnlyActionableHotspots)
|
||||
{
|
||||
filtered = filtered.Where(p => p.CpuUsage >= 1.0 || p.MemoryUsage >= (200L * 1024 * 1024));
|
||||
}
|
||||
var merged = topCpu
|
||||
.Concat(topMemory)
|
||||
.GroupBy(p => p.ProcessId)
|
||||
.Select(g => g.OrderByDescending(x => x.CpuUsage).First())
|
||||
.ToList();
|
||||
|
||||
filtered = SortMode switch
|
||||
{
|
||||
"Memory" => filtered.OrderByDescending(p => p.MemoryUsage),
|
||||
"Name" => filtered.OrderBy(p => p.ProcessName),
|
||||
_ => filtered.OrderByDescending(p => p.CpuUsage)
|
||||
};
|
||||
var associations = await _associationService.GetAssociationsAsync();
|
||||
var associationSet = associations
|
||||
.Select(a => NormalizeExecutableName(a.ExecutableName))
|
||||
.Where(name => !string.IsNullOrWhiteSpace(name))
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
TopCpuProcesses = new ObservableCollection<ProcessPerformanceInfo>(filtered.Take(50));
|
||||
IEnumerable<ProcessPerformanceInfo> filtered = merged;
|
||||
|
||||
if (SelectedHotspotProcess != null)
|
||||
{
|
||||
var refreshedSelection = TopCpuProcesses.FirstOrDefault(p => p.ProcessId == SelectedHotspotProcess.ProcessId);
|
||||
if (refreshedSelection != null)
|
||||
if (!string.IsNullOrWhiteSpace(ProcessSearchText))
|
||||
{
|
||||
SelectedHotspotProcess = refreshedSelection;
|
||||
filtered = filtered.Where(p => p.ProcessName.Contains(ProcessSearchText, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
|
||||
await RefreshSelectedProcessRuleImpactAsync();
|
||||
if (ShowOnlyRuleBackedHotspots)
|
||||
{
|
||||
filtered = filtered.Where(p => associationSet.Contains(NormalizeExecutableName(p.ProcessName)));
|
||||
}
|
||||
|
||||
if (ShowOnlyActionableHotspots)
|
||||
{
|
||||
filtered = filtered.Where(p => p.CpuUsage >= 1.0 || p.MemoryUsage >= (200L * 1024 * 1024));
|
||||
}
|
||||
|
||||
filtered = SortMode switch
|
||||
{
|
||||
"Memory" => filtered.OrderByDescending(p => p.MemoryUsage),
|
||||
"Name" => filtered.OrderBy(p => p.ProcessName),
|
||||
_ => filtered.OrderByDescending(p => p.CpuUsage)
|
||||
};
|
||||
|
||||
var snapshot = filtered.Take(50).ToList();
|
||||
|
||||
await System.Windows.Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
TopCpuProcesses = new ObservableCollection<ProcessPerformanceInfo>(snapshot);
|
||||
|
||||
if (SelectedHotspotProcess != null)
|
||||
{
|
||||
var refreshedSelection = TopCpuProcesses.FirstOrDefault(p => p.ProcessId == SelectedHotspotProcess.ProcessId);
|
||||
if (refreshedSelection != null)
|
||||
{
|
||||
SelectedHotspotProcess = refreshedSelection;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await RefreshSelectedProcessRuleImpactAsync();
|
||||
}
|
||||
while (_pendingTopProcessRefresh);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error loading hotspot process lists");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_topProcessRefreshGate.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RefreshGlobalPowerPlanAsync()
|
||||
@@ -632,18 +658,31 @@ namespace ThreadPilot.ViewModels
|
||||
MemoryUsageText = $"{FormatBytes(TotalMemoryUsage)} / {FormatBytes(TotalMemory)}";
|
||||
ProcessCountText = ActiveProcessCount.ToString();
|
||||
|
||||
CoreUsages = new ObservableCollection<CpuCoreUsage>(metrics.CpuCoreUsages);
|
||||
|
||||
if (IsMonitoring)
|
||||
void apply()
|
||||
{
|
||||
HistoricalData.Add(metrics);
|
||||
while (HistoricalData.Count > 360)
|
||||
CoreUsages = new ObservableCollection<CpuCoreUsage>(metrics.CpuCoreUsages);
|
||||
|
||||
if (IsMonitoring)
|
||||
{
|
||||
HistoricalData.RemoveAt(0);
|
||||
HistoricalData.Add(metrics);
|
||||
while (HistoricalData.Count > 360)
|
||||
{
|
||||
HistoricalData.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateTimelineSummary();
|
||||
}
|
||||
|
||||
UpdateTimelineSummary();
|
||||
var dispatcher = System.Windows.Application.Current?.Dispatcher;
|
||||
if (dispatcher != null && !dispatcher.CheckAccess())
|
||||
{
|
||||
dispatcher.Invoke(apply);
|
||||
}
|
||||
else
|
||||
{
|
||||
apply();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnProcessPowerPlanChanged(object? sender, ProcessPowerPlanChangeEventArgs e)
|
||||
@@ -687,13 +726,26 @@ namespace ThreadPilot.ViewModels
|
||||
Timestamp = DateTime.Now
|
||||
};
|
||||
|
||||
TimelineEvents.Insert(0, evt);
|
||||
while (TimelineEvents.Count > 200)
|
||||
void apply()
|
||||
{
|
||||
TimelineEvents.RemoveAt(TimelineEvents.Count - 1);
|
||||
TimelineEvents.Insert(0, evt);
|
||||
while (TimelineEvents.Count > 200)
|
||||
{
|
||||
TimelineEvents.RemoveAt(TimelineEvents.Count - 1);
|
||||
}
|
||||
|
||||
UpdateTimelineSummary();
|
||||
}
|
||||
|
||||
UpdateTimelineSummary();
|
||||
var dispatcher = System.Windows.Application.Current?.Dispatcher;
|
||||
if (dispatcher != null && !dispatcher.CheckAccess())
|
||||
{
|
||||
dispatcher.Invoke(apply);
|
||||
}
|
||||
else
|
||||
{
|
||||
apply();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTimelineSummary()
|
||||
@@ -768,6 +820,8 @@ namespace ThreadPilot.ViewModels
|
||||
_powerPlanService.PowerPlanChanged -= OnPowerPlanChanged;
|
||||
_systemTweaksService.TweakStatusChanged -= OnTweakStatusChanged;
|
||||
|
||||
_topProcessRefreshGate.Dispose();
|
||||
|
||||
if (IsMonitoring)
|
||||
{
|
||||
_ = Task.Run(async () => await _performanceService.StopMonitoringAsync());
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace ThreadPilot.ViewModels
|
||||
private readonly IGameModeService _gameModeService;
|
||||
private System.Timers.Timer? _refreshTimer;
|
||||
private System.Timers.Timer? _searchDebounceTimer;
|
||||
private bool _isApplyingFilter;
|
||||
private bool _filterRefreshPending;
|
||||
private bool _suppressCoreSelectionEvents;
|
||||
private bool _hasPendingAffinityEdits;
|
||||
|
||||
@@ -1528,80 +1530,61 @@ namespace ThreadPilot.ViewModels
|
||||
|
||||
private void FilterProcesses()
|
||||
{
|
||||
var dispatcher = System.Windows.Application.Current?.Dispatcher;
|
||||
if (dispatcher != null && !dispatcher.CheckAccess())
|
||||
{
|
||||
dispatcher.Invoke(FilterProcesses);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isApplyingFilter)
|
||||
{
|
||||
_filterRefreshPending = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_isApplyingFilter = true;
|
||||
var filtered = Processes.AsEnumerable();
|
||||
|
||||
// Apply search filter
|
||||
if (!string.IsNullOrWhiteSpace(SearchText))
|
||||
try
|
||||
{
|
||||
filtered = filtered.Where(p => p.Name.Contains(SearchText, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
// Apply system process filter
|
||||
if (HideSystemProcesses)
|
||||
{
|
||||
filtered = filtered.Where(p => !IsSystemProcess(p));
|
||||
}
|
||||
|
||||
// Apply idle process filter
|
||||
if (HideIdleProcesses)
|
||||
{
|
||||
filtered = filtered.Where(p => p.CpuUsage > 0.1);
|
||||
}
|
||||
|
||||
// Apply sorting
|
||||
filtered = SortMode switch
|
||||
{
|
||||
"CpuUsage" => filtered.OrderByDescending(p => p.CpuUsage),
|
||||
"MemoryUsage" => filtered.OrderByDescending(p => p.MemoryUsage),
|
||||
"Name" => filtered.OrderBy(p => p.Name),
|
||||
"ProcessId" => filtered.OrderBy(p => p.ProcessId),
|
||||
_ => filtered.OrderByDescending(p => p.CpuUsage)
|
||||
};
|
||||
|
||||
// PERFORMANCE OPTIMIZATION: Update existing collection instead of creating new one
|
||||
var filteredList = filtered.ToList();
|
||||
|
||||
// Remove items that are no longer in the filtered list
|
||||
for (int i = FilteredProcesses.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (!filteredList.Contains(FilteredProcesses[i]))
|
||||
do
|
||||
{
|
||||
FilteredProcesses.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
_filterRefreshPending = false;
|
||||
|
||||
// Add new items that aren't already in the collection
|
||||
foreach (var item in filteredList)
|
||||
{
|
||||
if (!FilteredProcesses.Contains(item))
|
||||
{
|
||||
FilteredProcesses.Add(item);
|
||||
}
|
||||
}
|
||||
filtered = Processes.AsEnumerable();
|
||||
|
||||
// Reorder existing items if necessary (only if sort order changed)
|
||||
if (FilteredProcesses.Count > 1)
|
||||
{
|
||||
var currentOrder = FilteredProcesses.ToList();
|
||||
bool needsReordering = false;
|
||||
|
||||
for (int i = 0; i < Math.Min(currentOrder.Count, filteredList.Count); i++)
|
||||
{
|
||||
if (currentOrder[i] != filteredList[i])
|
||||
if (!string.IsNullOrWhiteSpace(SearchText))
|
||||
{
|
||||
needsReordering = true;
|
||||
break;
|
||||
filtered = filtered.Where(p => p.Name.Contains(SearchText, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
|
||||
if (needsReordering)
|
||||
{
|
||||
FilteredProcesses.Clear();
|
||||
foreach (var item in filteredList)
|
||||
if (HideSystemProcesses)
|
||||
{
|
||||
FilteredProcesses.Add(item);
|
||||
filtered = filtered.Where(p => !IsSystemProcess(p));
|
||||
}
|
||||
|
||||
if (HideIdleProcesses)
|
||||
{
|
||||
filtered = filtered.Where(p => p.CpuUsage > 0.1);
|
||||
}
|
||||
|
||||
filtered = SortMode switch
|
||||
{
|
||||
"CpuUsage" => filtered.OrderByDescending(p => p.CpuUsage),
|
||||
"MemoryUsage" => filtered.OrderByDescending(p => p.MemoryUsage),
|
||||
"Name" => filtered.OrderBy(p => p.Name),
|
||||
"ProcessId" => filtered.OrderBy(p => p.ProcessId),
|
||||
_ => filtered.OrderByDescending(p => p.CpuUsage)
|
||||
};
|
||||
|
||||
FilteredProcesses = new ObservableCollection<ProcessModel>(filtered);
|
||||
}
|
||||
while (_filterRefreshPending);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isApplyingFilter = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,11 @@ namespace ThreadPilot.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.Equals(e.PropertyName, nameof(ApplicationSettingsModel.UseDarkTheme), StringComparison.Ordinal))
|
||||
{
|
||||
Settings.HasUserThemePreference = true;
|
||||
}
|
||||
|
||||
HasUnsavedChanges = true;
|
||||
StatusMessage = "Settings have been modified";
|
||||
}
|
||||
@@ -193,7 +198,14 @@ namespace ThreadPilot.ViewModels
|
||||
|
||||
await _settingsService.UpdateSettingsAsync(Settings);
|
||||
|
||||
_themeService.ApplyTheme(Settings.UseDarkTheme);
|
||||
var useDarkTheme = Settings.HasUserThemePreference
|
||||
? Settings.UseDarkTheme
|
||||
: _themeService.GetSystemUsesDarkTheme();
|
||||
|
||||
_isSyncingFromService = true;
|
||||
Settings.UseDarkTheme = useDarkTheme;
|
||||
_isSyncingFromService = false;
|
||||
_themeService.ApplyTheme(useDarkTheme);
|
||||
|
||||
// Update monitoring services with new settings
|
||||
_processMonitorManagerService.UpdateSettings();
|
||||
@@ -370,7 +382,14 @@ namespace ThreadPilot.ViewModels
|
||||
Settings.CopyFrom(settingsSnapshot);
|
||||
_isSyncingFromService = false;
|
||||
|
||||
_themeService.ApplyTheme(Settings.UseDarkTheme);
|
||||
var useDarkTheme = Settings.HasUserThemePreference
|
||||
? Settings.UseDarkTheme
|
||||
: _themeService.GetSystemUsesDarkTheme();
|
||||
|
||||
_isSyncingFromService = true;
|
||||
Settings.UseDarkTheme = useDarkTheme;
|
||||
_isSyncingFromService = false;
|
||||
_themeService.ApplyTheme(useDarkTheme);
|
||||
|
||||
HasUnsavedChanges = false;
|
||||
StatusMessage = "Settings loaded";
|
||||
|
||||
+313
-302
@@ -36,340 +36,351 @@
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Margin="12" Background="{DynamicResource AppBackgroundBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border Grid.Row="0" Style="{StaticResource CardStyle}">
|
||||
<Grid Margin="10" Background="{DynamicResource AppBackgroundBrush}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
Padding="0">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Text="Performance Intelligence" Style="{StaticResource TitleTextStyle}"/>
|
||||
<TextBlock Text="System snapshot, actionable hotspots, rule impact, and stability timeline." Style="{StaticResource LabelTextStyle}" Margin="0,4,0,0"/>
|
||||
<TextBlock Text="All actions are safety-first and route through existing Rules and Tweaks workflows." Style="{StaticResource LabelTextStyle}" Margin="0,2,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<WrapPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" ItemHeight="32">
|
||||
<Button Content="Start Monitoring"
|
||||
Command="{Binding StartMonitoringCommand}"
|
||||
IsEnabled="{Binding IsMonitoring, Converter={StaticResource InverseBooleanConverter}}"
|
||||
MinWidth="118"
|
||||
Margin="0,0,8,0"/>
|
||||
<Button Content="Stop Monitoring"
|
||||
Command="{Binding StopMonitoringCommand}"
|
||||
IsEnabled="{Binding IsMonitoring}"
|
||||
MinWidth="108"
|
||||
Margin="0,0,8,0"/>
|
||||
<Button Content="Refresh"
|
||||
Command="{Binding RefreshMetricsCommand}"
|
||||
MinWidth="84"
|
||||
Margin="0,0,8,0"/>
|
||||
<Button Content="Clear History"
|
||||
MinWidth="104"
|
||||
Command="{Binding ClearHistoricalDataCommand}"/>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1" Margin="0,0,0,12">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Column="0" Style="{StaticResource CardStyle}" Margin="0,0,10,0">
|
||||
<StackPanel>
|
||||
<TextBlock Text="CPU" Style="{StaticResource LabelTextStyle}"/>
|
||||
<TextBlock Text="{Binding CpuUsageText}" Style="{StaticResource ValueTextStyle}"/>
|
||||
<TextBlock Text="{Binding LastManualRefreshText}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="1" Style="{StaticResource CardStyle}" Margin="0,0,10,0">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Memory" Style="{StaticResource LabelTextStyle}"/>
|
||||
<TextBlock Text="{Binding MemoryUsageText}" Style="{StaticResource ValueTextStyle}" FontSize="18"/>
|
||||
<TextBlock Text="{Binding MemoryUsagePercentage, StringFormat={}{0:F1}% utilized}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="2" Style="{StaticResource CardStyle}" Margin="0,0,10,0">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Active Processes" Style="{StaticResource LabelTextStyle}"/>
|
||||
<TextBlock Text="{Binding ProcessCountText}" Style="{StaticResource ValueTextStyle}"/>
|
||||
<TextBlock Text="{Binding MonitoringStateText, StringFormat=Monitoring: {0}}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="3" Style="{StaticResource CardStyle}" Margin="0">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Global Power Plan" Style="{StaticResource LabelTextStyle}"/>
|
||||
<TextBlock Text="{Binding CurrentGlobalPowerPlanText}" Style="{StaticResource ValueTextStyle}" FontSize="16"/>
|
||||
<TextBlock Text="{Binding LastUpdateTime, StringFormat=Last metric update: {0:HH:mm:ss}}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2.2*"/>
|
||||
<ColumnDefinition Width="1.3*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Column="0" Style="{StaticResource CardStyle}" Margin="0,0,10,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0" Margin="0,0,0,10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border Style="{StaticResource CardStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Text="Process Hotspots" Style="{StaticResource TitleTextStyle}"/>
|
||||
<TextBlock Text="Top CPU and memory consumers with one-click rule creation." Style="{StaticResource LabelTextStyle}" Margin="0,2,0,0"/>
|
||||
<TextBlock Text="Performance Intelligence" Style="{StaticResource TitleTextStyle}"/>
|
||||
<TextBlock Text="System snapshot, actionable hotspots, rule impact, and stability timeline." Style="{StaticResource LabelTextStyle}" Margin="0,4,0,0"/>
|
||||
<TextBlock Text="All actions are safety-first and route through existing Rules and Tweaks workflows." Style="{StaticResource LabelTextStyle}" Margin="0,2,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<Button Content="Create/Update Rule from Selection"
|
||||
Command="{Binding CreateRuleFromSelectedProcessCommand}"
|
||||
IsEnabled="{Binding CanCreateRuleFromSelectedProcess}"
|
||||
<WrapPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" ItemHeight="32">
|
||||
<Button Content="Start Monitoring"
|
||||
Command="{Binding StartMonitoringCommand}"
|
||||
IsEnabled="{Binding IsMonitoring, Converter={StaticResource InverseBooleanConverter}}"
|
||||
MinWidth="118"
|
||||
Margin="0,0,8,0"/>
|
||||
<Button Content="Toggle Core Panel"
|
||||
Command="{Binding ToggleCoreDetailsCommand}"
|
||||
<Button Content="Stop Monitoring"
|
||||
Command="{Binding StopMonitoringCommand}"
|
||||
IsEnabled="{Binding IsMonitoring}"
|
||||
MinWidth="108"
|
||||
Margin="0,0,8,0"/>
|
||||
<Button Content="Toggle Process Panel"
|
||||
Command="{Binding ToggleProcessDetailsCommand}"/>
|
||||
<Button Content="Refresh"
|
||||
Command="{Binding RefreshMetricsCommand}"
|
||||
MinWidth="84"
|
||||
Margin="0,0,8,0"/>
|
||||
<Button Content="Clear History"
|
||||
MinWidth="104"
|
||||
Command="{Binding ClearHistoricalDataCommand}"/>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1" Margin="0,0,0,12">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Column="0" Style="{StaticResource CardStyle}" Margin="0,0,10,0">
|
||||
<StackPanel>
|
||||
<TextBlock Text="CPU" Style="{StaticResource LabelTextStyle}"/>
|
||||
<TextBlock Text="{Binding CpuUsageText}" Style="{StaticResource ValueTextStyle}"/>
|
||||
<TextBlock Text="{Binding LastManualRefreshText}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1" Margin="0,0,0,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="1" Style="{StaticResource CardStyle}" Margin="0,0,10,0">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Memory" Style="{StaticResource LabelTextStyle}"/>
|
||||
<TextBlock Text="{Binding MemoryUsageText}" Style="{StaticResource ValueTextStyle}" FontSize="18"/>
|
||||
<TextBlock Text="{Binding MemoryUsagePercentage, StringFormat={}{0:F1}% utilized}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<TextBlock Grid.Column="0"
|
||||
Text="Filter"
|
||||
Style="{StaticResource LabelTextStyle}"
|
||||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"/>
|
||||
<Border Grid.Column="2" Style="{StaticResource CardStyle}" Margin="0,0,10,0">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Active Processes" Style="{StaticResource LabelTextStyle}"/>
|
||||
<TextBlock Text="{Binding ProcessCountText}" Style="{StaticResource ValueTextStyle}"/>
|
||||
<TextBlock Text="{Binding MonitoringStateText, StringFormat=Monitoring: {0}}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<TextBox Grid.Column="1"
|
||||
Text="{Binding ProcessSearchText, UpdateSourceTrigger=PropertyChanged}"
|
||||
MinWidth="220"
|
||||
Margin="0,0,8,0"
|
||||
VerticalContentAlignment="Center"/>
|
||||
|
||||
<ComboBox Grid.Column="2"
|
||||
SelectedValue="{Binding SortMode}"
|
||||
SelectedValuePath="Tag"
|
||||
Width="110"
|
||||
Margin="0,0,8,0">
|
||||
<ComboBoxItem Content="CPU" Tag="Cpu"/>
|
||||
<ComboBoxItem Content="Memory" Tag="Memory"/>
|
||||
<ComboBoxItem Content="Name" Tag="Name"/>
|
||||
</ComboBox>
|
||||
|
||||
<CheckBox Grid.Column="3"
|
||||
Content="Actionable only"
|
||||
IsChecked="{Binding ShowOnlyActionableHotspots}"
|
||||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"/>
|
||||
|
||||
<CheckBox Grid.Column="4"
|
||||
Content="Rule-backed only"
|
||||
IsChecked="{Binding ShowOnlyRuleBackedHotspots}"
|
||||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"/>
|
||||
|
||||
<TextBlock Grid.Column="5"
|
||||
Text="{Binding MonitoringStatusText}"
|
||||
Style="{StaticResource LabelTextStyle}"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
|
||||
<DataGrid Grid.Row="2"
|
||||
ItemsSource="{Binding TopCpuProcesses}"
|
||||
SelectedItem="{Binding SelectedHotspotProcess}"
|
||||
Visibility="{Binding ShowProcessDetails, Converter={StaticResource BoolToVisibilityConverter}}"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
CanUserDeleteRows="False"
|
||||
IsReadOnly="True"
|
||||
HeadersVisibility="Column"
|
||||
GridLinesVisibility="Horizontal">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Process" Binding="{Binding ProcessName}" Width="2*"/>
|
||||
<DataGridTextColumn Header="CPU %" Binding="{Binding CpuUsage, StringFormat={}{0:F1}}" Width="90"/>
|
||||
<DataGridTextColumn Header="Memory" Binding="{Binding MemoryUsage, Converter={StaticResource BytesToStringConverter}}" Width="110"/>
|
||||
<DataGridTextColumn Header="Threads" Binding="{Binding ThreadCount}" Width="80"/>
|
||||
<DataGridTextColumn Header="Priority" Binding="{Binding Priority}" Width="110"/>
|
||||
<DataGridTextColumn Header="Window" Binding="{Binding WindowTitle}" Width="3*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Border Grid.Row="3"
|
||||
Margin="0,10,0,0"
|
||||
Padding="10,7"
|
||||
CornerRadius="6"
|
||||
BorderThickness="1"
|
||||
Visibility="{Binding StatusMessage, Converter={x:Static converters:StringToVisibilityConverter.Instance}}">
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Background" Value="{DynamicResource SuccessBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource SuccessBorderBrush}"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding HasError}" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource ErrorBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ErrorBorderBrush}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<TextBlock Text="{Binding StatusMessage}">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SuccessTextBrush}"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding HasError}" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ErrorTextBrush}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
<Border Grid.Column="3" Style="{StaticResource CardStyle}" Margin="0">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Global Power Plan" Style="{StaticResource LabelTextStyle}"/>
|
||||
<TextBlock Text="{Binding CurrentGlobalPowerPlanText}" Style="{StaticResource ValueTextStyle}" FontSize="16"/>
|
||||
<TextBlock Text="{Binding LastUpdateTime, StringFormat=Last metric update: {0:HH:mm:ss}}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2.2*"/>
|
||||
<ColumnDefinition Width="1.3*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Row="0" Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Rule Impact" Style="{StaticResource TitleTextStyle}"/>
|
||||
<TextBlock Text="Selected hotspot process" Style="{StaticResource LabelTextStyle}" Margin="0,4,0,8"/>
|
||||
<Border Grid.Column="0" Style="{StaticResource CardStyle}" Margin="0,0,10,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding SelectedProcessName}" FontWeight="SemiBold" FontSize="14"/>
|
||||
<TextBlock Text="{Binding SelectedProcessExecutable}" Style="{StaticResource LabelTextStyle}" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Margin="0,2,0,8"/>
|
||||
<Grid Grid.Row="0" Margin="0,0,0,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding SelectedProcessCpuText}"/>
|
||||
<TextBlock Text="{Binding SelectedProcessMemoryText}" Margin="0,2,0,8"/>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Text="Process Hotspots" Style="{StaticResource TitleTextStyle}"/>
|
||||
<TextBlock Text="Top CPU and memory consumers with one-click rule creation." Style="{StaticResource LabelTextStyle}" Margin="0,2,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Text="{Binding SelectedProcessRuleStatus}" FontWeight="SemiBold"/>
|
||||
<TextBlock Text="{Binding SelectedProcessRuleSummary}" Style="{StaticResource LabelTextStyle}" TextWrapping="Wrap" Margin="0,2,0,0"/>
|
||||
<TextBlock Text="{Binding SelectedProcessLastApplyText}" Style="{StaticResource LabelTextStyle}" Margin="0,8,0,0"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<Button Content="Create/Update Rule from Selection"
|
||||
Command="{Binding CreateRuleFromSelectedProcessCommand}"
|
||||
IsEnabled="{Binding CanCreateRuleFromSelectedProcess}"
|
||||
Margin="0,0,8,0"/>
|
||||
<Button Content="Toggle Core Panel"
|
||||
Command="{Binding ToggleCoreDetailsCommand}"
|
||||
Margin="0,0,8,0"/>
|
||||
<Button Content="Toggle Process Panel"
|
||||
Command="{Binding ToggleProcessDetailsCommand}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="1" Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Core Snapshot" Style="{StaticResource TitleTextStyle}"/>
|
||||
<TextBlock Text="Per-core utilization for quick imbalance checks." Style="{StaticResource LabelTextStyle}" Margin="0,4,0,8"/>
|
||||
<Grid Grid.Row="1" Margin="0,0,0,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
MaxHeight="220"
|
||||
Visibility="{Binding ShowCoreDetails, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<ItemsControl ItemsSource="{Binding CoreUsages}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Columns="2"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="6" Padding="8" Margin="0,0,6,6" Background="{DynamicResource SurfaceAltBrush}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding CoreId, StringFormat=Core {0}}" FontWeight="SemiBold"/>
|
||||
<TextBlock Text="{Binding CoreType}" Style="{StaticResource LabelTextStyle}"/>
|
||||
<ProgressBar Value="{Binding Usage}" Maximum="100" Height="5" Margin="0,6,0,2"/>
|
||||
<TextBlock Text="{Binding Usage, StringFormat={}{0:F1}%}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<TextBlock Grid.Column="0"
|
||||
Text="Filter"
|
||||
Style="{StaticResource LabelTextStyle}"
|
||||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"/>
|
||||
|
||||
<Border Grid.Row="2" Style="{StaticResource CardStyle}" Margin="0,0,0,0">
|
||||
<Grid>
|
||||
<TextBox Grid.Column="1"
|
||||
Text="{Binding ProcessSearchText, UpdateSourceTrigger=PropertyChanged}"
|
||||
MinWidth="220"
|
||||
Margin="0,0,8,0"
|
||||
VerticalContentAlignment="Center"/>
|
||||
|
||||
<ComboBox Grid.Column="2"
|
||||
SelectedValue="{Binding SortMode}"
|
||||
SelectedValuePath="Tag"
|
||||
Width="110"
|
||||
Margin="0,0,8,0">
|
||||
<ComboBoxItem Content="CPU" Tag="Cpu"/>
|
||||
<ComboBoxItem Content="Memory" Tag="Memory"/>
|
||||
<ComboBoxItem Content="Name" Tag="Name"/>
|
||||
</ComboBox>
|
||||
|
||||
<CheckBox Grid.Column="3"
|
||||
Content="Actionable only"
|
||||
IsChecked="{Binding ShowOnlyActionableHotspots}"
|
||||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"/>
|
||||
|
||||
<CheckBox Grid.Column="4"
|
||||
Content="Rule-backed only"
|
||||
IsChecked="{Binding ShowOnlyRuleBackedHotspots}"
|
||||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"/>
|
||||
|
||||
<TextBlock Grid.Column="5"
|
||||
Text="{Binding MonitoringStatusText}"
|
||||
Style="{StaticResource LabelTextStyle}"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
|
||||
<DataGrid Grid.Row="2"
|
||||
ItemsSource="{Binding TopCpuProcesses}"
|
||||
SelectedItem="{Binding SelectedHotspotProcess}"
|
||||
Visibility="{Binding ShowProcessDetails, Converter={StaticResource BoolToVisibilityConverter}}"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
CanUserDeleteRows="False"
|
||||
IsReadOnly="True"
|
||||
HeadersVisibility="Column"
|
||||
GridLinesVisibility="Horizontal"
|
||||
MinHeight="220"
|
||||
MaxHeight="380">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Process" Binding="{Binding ProcessName}" Width="2*"/>
|
||||
<DataGridTextColumn Header="CPU %" Binding="{Binding CpuUsage, StringFormat={}{0:F1}}" Width="90"/>
|
||||
<DataGridTextColumn Header="Memory" Binding="{Binding MemoryUsage, Converter={StaticResource BytesToStringConverter}}" Width="110"/>
|
||||
<DataGridTextColumn Header="Threads" Binding="{Binding ThreadCount}" Width="80"/>
|
||||
<DataGridTextColumn Header="Priority" Binding="{Binding Priority}" Width="110"/>
|
||||
<DataGridTextColumn Header="Window" Binding="{Binding WindowTitle}" Width="3*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Border Grid.Row="3"
|
||||
Margin="0,10,0,0"
|
||||
Padding="10,7"
|
||||
CornerRadius="6"
|
||||
BorderThickness="1"
|
||||
Visibility="{Binding StatusMessage, Converter={x:Static converters:StringToVisibilityConverter.Instance}}">
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Background" Value="{DynamicResource SuccessBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource SuccessBorderBrush}"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding HasError}" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource ErrorBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ErrorBorderBrush}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<TextBlock Text="{Binding StatusMessage}">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SuccessTextBrush}"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding HasError}" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ErrorTextBrush}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Text="Stability Timeline" Style="{StaticResource TitleTextStyle}"/>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,6,0,8">
|
||||
<TextBlock Text="{Binding TimelineSampleCountText}" Style="{StaticResource LabelTextStyle}" Margin="0,0,14,0"/>
|
||||
<TextBlock Text="{Binding LastTimelineEventText}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
<Border Grid.Row="0" Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Rule Impact" Style="{StaticResource TitleTextStyle}"/>
|
||||
<TextBlock Text="Selected hotspot process" Style="{StaticResource LabelTextStyle}" Margin="0,4,0,8"/>
|
||||
|
||||
<TabControl Grid.Row="2">
|
||||
<TabItem Header="Events">
|
||||
<DataGrid ItemsSource="{Binding TimelineEvents}"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
CanUserAddRows="False"
|
||||
CanUserDeleteRows="False"
|
||||
GridLinesVisibility="Horizontal"
|
||||
HeadersVisibility="Column">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Time" Binding="{Binding Timestamp, StringFormat={}{0:HH:mm:ss}}" Width="80"/>
|
||||
<DataGridTextColumn Header="Category" Binding="{Binding Category}" Width="110"/>
|
||||
<DataGridTextColumn Header="Severity" Binding="{Binding Severity}" Width="90"/>
|
||||
<DataGridTextColumn Header="Detail" Binding="{Binding Detail}" Width="*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</TabItem>
|
||||
<TabItem Header="Metrics">
|
||||
<DataGrid ItemsSource="{Binding HistoricalData}"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
CanUserAddRows="False"
|
||||
CanUserDeleteRows="False"
|
||||
GridLinesVisibility="Horizontal"
|
||||
HeadersVisibility="Column">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Time" Binding="{Binding Timestamp, StringFormat={}{0:HH:mm:ss}}" Width="80"/>
|
||||
<DataGridTextColumn Header="CPU %" Binding="{Binding TotalCpuUsage, StringFormat={}{0:F1}}" Width="70"/>
|
||||
<DataGridTextColumn Header="Mem %" Binding="{Binding MemoryUsagePercentage, StringFormat={}{0:F1}}" Width="70"/>
|
||||
<DataGridTextColumn Header="Processes" Binding="{Binding ActiveProcessCount}" Width="90"/>
|
||||
<DataGridTextColumn Header="Memory Used" Binding="{Binding TotalMemoryUsage, Converter={StaticResource BytesToStringConverter}}" Width="110"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
<TextBlock Text="{Binding SelectedProcessName}" FontWeight="SemiBold" FontSize="14"/>
|
||||
<TextBlock Text="{Binding SelectedProcessExecutable}" Style="{StaticResource LabelTextStyle}" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Margin="0,2,0,8"/>
|
||||
|
||||
<TextBlock Text="{Binding SelectedProcessCpuText}"/>
|
||||
<TextBlock Text="{Binding SelectedProcessMemoryText}" Margin="0,2,0,8"/>
|
||||
|
||||
<TextBlock Text="{Binding SelectedProcessRuleStatus}" FontWeight="SemiBold"/>
|
||||
<TextBlock Text="{Binding SelectedProcessRuleSummary}" Style="{StaticResource LabelTextStyle}" TextWrapping="Wrap" Margin="0,2,0,0"/>
|
||||
<TextBlock Text="{Binding SelectedProcessLastApplyText}" Style="{StaticResource LabelTextStyle}" Margin="0,8,0,0"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="1" Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Core Snapshot" Style="{StaticResource TitleTextStyle}"/>
|
||||
<TextBlock Text="Per-core utilization for quick imbalance checks." Style="{StaticResource LabelTextStyle}" Margin="0,4,0,8"/>
|
||||
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
MaxHeight="220"
|
||||
Visibility="{Binding ShowCoreDetails, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<ItemsControl ItemsSource="{Binding CoreUsages}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Columns="2"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="6" Padding="8" Margin="0,0,6,6" Background="{DynamicResource SurfaceAltBrush}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding CoreId, StringFormat=Core {0}}" FontWeight="SemiBold"/>
|
||||
<TextBlock Text="{Binding CoreType}" Style="{StaticResource LabelTextStyle}"/>
|
||||
<ProgressBar Value="{Binding Usage}" Maximum="100" Height="5" Margin="0,6,0,2"/>
|
||||
<TextBlock Text="{Binding Usage, StringFormat={}{0:F1}%}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="2" Style="{StaticResource CardStyle}" Margin="0,0,0,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Text="Stability Timeline" Style="{StaticResource TitleTextStyle}"/>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,6,0,8">
|
||||
<TextBlock Text="{Binding TimelineSampleCountText}" Style="{StaticResource LabelTextStyle}" Margin="0,0,14,0"/>
|
||||
<TextBlock Text="{Binding LastTimelineEventText}" Style="{StaticResource LabelTextStyle}"/>
|
||||
</StackPanel>
|
||||
|
||||
<TabControl Grid.Row="2" MinHeight="260">
|
||||
<TabItem Header="Events">
|
||||
<DataGrid ItemsSource="{Binding TimelineEvents}"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
CanUserAddRows="False"
|
||||
CanUserDeleteRows="False"
|
||||
GridLinesVisibility="Horizontal"
|
||||
HeadersVisibility="Column"
|
||||
MaxHeight="280"
|
||||
MinHeight="220">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Time" Binding="{Binding Timestamp, StringFormat={}{0:HH:mm:ss}}" Width="80"/>
|
||||
<DataGridTextColumn Header="Category" Binding="{Binding Category}" Width="110"/>
|
||||
<DataGridTextColumn Header="Severity" Binding="{Binding Severity}" Width="90"/>
|
||||
<DataGridTextColumn Header="Detail" Binding="{Binding Detail}" Width="*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</TabItem>
|
||||
<TabItem Header="Metrics">
|
||||
<DataGrid ItemsSource="{Binding HistoricalData}"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
CanUserAddRows="False"
|
||||
CanUserDeleteRows="False"
|
||||
GridLinesVisibility="Horizontal"
|
||||
HeadersVisibility="Column"
|
||||
MaxHeight="280"
|
||||
MinHeight="220">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Time" Binding="{Binding Timestamp, StringFormat={}{0:HH:mm:ss}}" Width="80"/>
|
||||
<DataGridTextColumn Header="CPU %" Binding="{Binding TotalCpuUsage, StringFormat={}{0:F1}}" Width="70"/>
|
||||
<DataGridTextColumn Header="Mem %" Binding="{Binding MemoryUsagePercentage, StringFormat={}{0:F1}}" Width="70"/>
|
||||
<DataGridTextColumn Header="Processes" Binding="{Binding ActiveProcessCount}" Width="90"/>
|
||||
<DataGridTextColumn Header="Memory Used" Binding="{Binding TotalMemoryUsage, Converter={StaticResource BytesToStringConverter}}" Width="110"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -201,7 +201,7 @@
|
||||
</TabItem>
|
||||
|
||||
<!-- Monitoring Configuration Tab -->
|
||||
<TabItem Header="⚙️ Monitoring Configuration">
|
||||
<TabItem Header="Monitoring Configuration">
|
||||
<ScrollViewer Margin="10">
|
||||
<StackPanel>
|
||||
<!-- Service Control -->
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Standardized Header -->
|
||||
<GroupBox Grid.Row="0" Header="⚙️ Application Settings" Margin="0,0,0,10">
|
||||
<GroupBox Grid.Row="0" Header="Application Settings" Margin="0,0,0,10">
|
||||
<Grid Margin="5">
|
||||
<TextBlock Text="Configure notifications, system tray, and application behavior"
|
||||
FontSize="12" Foreground="{DynamicResource TextSecondaryBrush}" VerticalAlignment="Center"/>
|
||||
|
||||
Reference in New Issue
Block a user