Files
ThreadPilot/MainWindow.xaml
T
PrimeBuild-pc 7be4cef428 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.
2026-04-11 17:41:13 +02:00

179 lines
8.5 KiB
XML

<Window x:Class="ThreadPilot.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ThreadPilot"
xmlns:views="clr-namespace:ThreadPilot.Views"
xmlns:viewModels="clr-namespace:ThreadPilot.ViewModels"
mc:Ignorable="d"
Title="ThreadPilot - Process &amp; Power Plan Manager"
Height="720"
Width="1280"
WindowStartupLocation="CenterScreen">
<Window.Resources>
<Style TargetType="StatusBar">
<Setter Property="Background" Value="{DynamicResource SurfaceAltBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}"/>
</Style>
<!-- Loading Spinner Animation -->
<Storyboard x:Key="SpinnerAnimation" RepeatBehavior="Forever">
<DoubleAnimation Storyboard.TargetName="SpinnerRotation"
Storyboard.TargetProperty="Angle"
From="0" To="360" Duration="0:0:1"/>
</Storyboard>
<!-- Fade In Animation -->
<Storyboard x:Key="FadeInAnimation">
<DoubleAnimation Storyboard.TargetName="LoadingOverlay"
Storyboard.TargetProperty="Opacity"
From="0" To="1" Duration="0:0:0.2"/>
</Storyboard>
<!-- Fade Out Animation -->
<Storyboard x:Key="FadeOutAnimation">
<DoubleAnimation Storyboard.TargetName="LoadingOverlay"
Storyboard.TargetProperty="Opacity"
From="1" To="0" Duration="0:0:0.3"/>
</Storyboard>
</Window.Resources>
<Grid Background="{DynamicResource AppBackgroundBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Elevation Status Bar -->
<Border Grid.Row="0" Background="{DynamicResource WarningBackgroundBrush}" BorderBrush="{DynamicResource WarningBorderBrush}" BorderThickness="1"
Visibility="{Binding ShowElevationPrompt, Converter={StaticResource BoolToVisibilityConverter}}"
Margin="5,5,5,0">
<Grid Margin="10,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="⚠️" FontSize="16" VerticalAlignment="Center" Margin="0,0,10,0"/>
<TextBlock Grid.Column="1"
Text="ThreadPilot is running with limited privileges. Some features may not be available. Administrator privileges are required for full functionality."
TextWrapping="Wrap" VerticalAlignment="Center"/>
<Button Grid.Column="2" Content="Request Elevation"
Command="{Binding RequestElevationCommand}"
Margin="10,0,0,0" Padding="10,5"/>
</Grid>
</Border>
<!-- Main Application Content -->
<Grid x:Name="MainContent" Grid.Row="2">
<TabControl x:Name="MainTabControl" Margin="10" SelectionChanged="OnMainTabSelectionChanged">
<TabItem x:Name="ProcessManagementTab" Header="🔧 Process Management">
<views:ProcessView/>
</TabItem>
<TabItem x:Name="CoreMasksTab" Header="🎯 Core Masks">
<views:MasksView/>
</TabItem>
<TabItem x:Name="PowerPlansTab" Header="⚡ Power Plans">
<views:PowerPlanView x:Name="PowerPlanViewControl"/>
</TabItem>
<TabItem x:Name="ProcessAssociationsTab" Header="📐 Rules">
<views:ProcessPowerPlanAssociationView x:Name="AssociationView"/>
</TabItem>
<TabItem x:Name="PerformanceTab" Header="📊 Performance">
<views:PerformanceView x:Name="PerformanceViewControl"/>
</TabItem>
<TabItem x:Name="SystemTweaksTab" Header="🔧 Tweaks">
<views:SystemTweaksView x:Name="SystemTweaksView"/>
</TabItem>
<TabItem x:Name="SettingsTab" Header="Settings">
<views:SettingsView x:Name="SettingsView"/>
</TabItem>
</TabControl>
</Grid>
<!-- Status Bar -->
<StatusBar Grid.Row="3" Height="25">
<StatusBarItem>
<TextBlock Text="{Binding StatusMessage}"/>
</StatusBarItem>
<Separator/>
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding ElevationStatusText}"
FontWeight="{Binding IsRunningAsAdministrator, Converter={StaticResource BoolToFontWeightConverter}}"
Foreground="{Binding IsRunningAsAdministrator, Converter={StaticResource BoolToColorConverter}}"/>
<TextBlock Text="🔒"
Margin="5,0,0,0"
Visibility="{Binding IsRunningAsAdministrator, Converter={StaticResource BoolToVisibilityConverter}}"/>
</StackPanel>
</StatusBarItem>
</StatusBar>
<!-- Startup Loading Overlay -->
<Grid x:Name="LoadingOverlay"
Grid.RowSpan="4"
Background="{DynamicResource OverlayBrush}"
Visibility="Visible"
Panel.ZIndex="1000">
<Border Background="{DynamicResource SurfaceBrush}"
BorderBrush="{DynamicResource BorderBrush}"
BorderThickness="1"
CornerRadius="8"
Padding="30"
HorizontalAlignment="Center"
VerticalAlignment="Center"
MinWidth="300"
MaxWidth="400">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<!-- Application Icon -->
<Image x:Name="LoadingIcon"
Source="pack://application:,,,/ico.ico"
Width="64"
Height="64"
Margin="0,0,0,20"
HorizontalAlignment="Center"/>
<!-- Loading Spinner -->
<Grid Width="32" Height="32" Margin="0,0,0,20" HorizontalAlignment="Center">
<Ellipse Width="32" Height="32"
Stroke="{DynamicResource SpinnerTrackBrush}"
StrokeThickness="3"
Opacity="0.3"/>
<Ellipse x:Name="SpinnerEllipse"
Width="32"
Height="32"
Stroke="{DynamicResource AccentBrush}"
StrokeThickness="3"
StrokeDashArray="20,10"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<RotateTransform x:Name="SpinnerRotation"/>
</Ellipse.RenderTransform>
</Ellipse>
</Grid>
<!-- Loading Text -->
<TextBlock x:Name="LoadingText"
Text="Loading ThreadPilot..."
FontSize="16"
FontWeight="SemiBold"
HorizontalAlignment="Center"
Margin="0,0,0,10"/>
<!-- Status Text -->
<TextBlock x:Name="LoadingStatus"
Text="Initializing services..."
FontSize="12"
Foreground="{DynamicResource TextSecondaryBrush}"
HorizontalAlignment="Center"/>
</StackPanel>
</Border>
</Grid>
</Grid>
</Window>