ea350bf7fd
Introduces a new core mask system for managing CPU affinity, including models, services, and Windows platform handlers. Adds a dedicated Core Masks tab and related views/viewmodels. Removes all Game Boost related code, settings, and UI. Updates process association models to support core masks and process priority. Improves graceful shutdown to clear masks and restore power plans. Refines affinity display and default settings for better usability.
356 lines
21 KiB
XML
356 lines
21 KiB
XML
<UserControl x:Class="ThreadPilot.Views.ProcessView"
|
||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||
xmlns:local="clr-namespace:ThreadPilot.Views"
|
||
xmlns:helpers="clr-namespace:ThreadPilot.Helpers"
|
||
xmlns:converters="clr-namespace:ThreadPilot.Converters"
|
||
xmlns:Diagnostics="clr-namespace:System.Diagnostics;assembly=System.Diagnostics.Process"
|
||
mc:Ignorable="d"
|
||
d:DesignHeight="650" d:DesignWidth="1200">
|
||
|
||
<UserControl.Resources>
|
||
<converters:CoreTypeToColorConverter x:Key="CoreTypeToColorConverter"/>
|
||
<converters:BoolToColorConverter x:Key="BoolToColorConverter"/>
|
||
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
|
||
<converters:AffinityMaskConverter x:Key="AffinityMaskConverter"/>
|
||
<converters:BytesToMbConverter x:Key="BytesToMbConverter"/>
|
||
</UserControl.Resources>
|
||
|
||
<Grid Margin="10">
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="*"/>
|
||
<RowDefinition Height="Auto"/>
|
||
</Grid.RowDefinitions>
|
||
|
||
<!-- Search and Refresh Controls -->
|
||
<GroupBox Grid.Row="0" Header="🔍 Process Search & Control" Margin="0,0,0,10">
|
||
<Grid Margin="5">
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="Auto"/>
|
||
</Grid.RowDefinitions>
|
||
|
||
<!-- Search and Basic Controls -->
|
||
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,5">
|
||
<TextBox Width="200"
|
||
Margin="0,0,10,0"
|
||
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}"
|
||
ToolTip="Search processes by name"
|
||
VerticalAlignment="Center"/>
|
||
<CheckBox Content="Active Applications Only"
|
||
IsChecked="{Binding ShowActiveApplicationsOnly}"
|
||
Margin="0,0,10,0"
|
||
VerticalAlignment="Center"
|
||
ToolTip="Show only applications with visible windows (like Process Lasso's Active Processes)"/>
|
||
<Button Command="{Binding LoadProcessesCommand}"
|
||
Content="🔄 Refresh"
|
||
Padding="10,5"
|
||
ToolTip="Refresh the process list"/>
|
||
<Button Command="{Binding LoadMoreProcessesCommand}"
|
||
Content="📄 Load More"
|
||
Padding="10,5"
|
||
Margin="5,0,0,0"
|
||
Visibility="{Binding HasMoreBatches, Converter={StaticResource BoolToVisibilityConverter}}"
|
||
ToolTip="Load more processes (virtualized loading)"/>
|
||
</StackPanel>
|
||
|
||
<!-- Smart Filtering Controls -->
|
||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||
<CheckBox Content="Hide System Processes"
|
||
IsChecked="{Binding HideSystemProcesses}"
|
||
Margin="0,0,15,0"
|
||
VerticalAlignment="Center"
|
||
ToolTip="Hide Windows system processes"/>
|
||
<CheckBox Content="Hide Idle Processes"
|
||
IsChecked="{Binding HideIdleProcesses}"
|
||
Margin="0,0,15,0"
|
||
VerticalAlignment="Center"
|
||
ToolTip="Hide processes with very low CPU usage"/>
|
||
<TextBlock Text="Sort by:" VerticalAlignment="Center" Margin="0,0,5,0"/>
|
||
<ComboBox SelectedValue="{Binding SortMode}"
|
||
SelectedValuePath="Tag"
|
||
Width="120"
|
||
VerticalAlignment="Center"
|
||
ToolTip="Choose how to sort the process list">
|
||
<ComboBoxItem Content="CPU Usage" Tag="CpuUsage"/>
|
||
<ComboBoxItem Content="Memory Usage" Tag="MemoryUsage"/>
|
||
<ComboBoxItem Content="Process Name" Tag="Name"/>
|
||
<ComboBoxItem Content="Process ID" Tag="ProcessId"/>
|
||
</ComboBox>
|
||
</StackPanel>
|
||
</Grid>
|
||
</GroupBox>
|
||
|
||
<!-- Process List with Loading Overlay -->
|
||
<Grid Grid.Row="1">
|
||
<DataGrid ItemsSource="{Binding FilteredProcesses}"
|
||
SelectedItem="{Binding SelectedProcess}"
|
||
AutoGenerateColumns="False"
|
||
IsReadOnly="True"
|
||
SelectionMode="Single"
|
||
GridLinesVisibility="Horizontal"
|
||
HeadersVisibility="Column"
|
||
CanUserResizeColumns="True"
|
||
CanUserSortColumns="True"
|
||
Margin="0,0,0,10"
|
||
VirtualizingPanel.IsVirtualizing="True"
|
||
VirtualizingPanel.VirtualizationMode="Recycling"
|
||
VirtualizingPanel.ScrollUnit="Item"
|
||
EnableRowVirtualization="True"
|
||
EnableColumnVirtualization="True"
|
||
ScrollViewer.CanContentScroll="True">
|
||
<DataGrid.Columns>
|
||
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="150"/>
|
||
<DataGridTextColumn Header="ID" Binding="{Binding ProcessId}" Width="60"/>
|
||
<DataGridTextColumn Header="Window Title" Binding="{Binding MainWindowTitle}" Width="200"/>
|
||
<DataGridCheckBoxColumn Header="Has Window" Binding="{Binding HasVisibleWindow}" Width="80"/>
|
||
<DataGridTextColumn Header="CPU Usage" Binding="{Binding CpuUsage, StringFormat={}{0:N1}%}" Width="80"/>
|
||
<DataGridTextColumn Header="Memory (MB)"
|
||
Binding="{Binding MemoryUsage, Converter={StaticResource BytesToMbConverter}}"
|
||
Width="80"/>
|
||
<DataGridTextColumn Header="Priority" Binding="{Binding Priority}" Width="*"/>
|
||
</DataGrid.Columns>
|
||
</DataGrid>
|
||
|
||
<!-- Progressive Loading Indicator -->
|
||
<Border Background="#80FFFFFF" Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibilityConverter}}">
|
||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||
<ProgressBar Value="{Binding LoadingProgress}" Maximum="100" Width="200" Height="20" Margin="0,0,0,10"/>
|
||
<TextBlock Text="{Binding LoadingStatusText}" HorizontalAlignment="Center" FontWeight="Bold"/>
|
||
</StackPanel>
|
||
</Border>
|
||
|
||
<!-- Virtualization Status -->
|
||
<Border Background="#F0F8FF" BorderBrush="#4169E1" BorderThickness="1"
|
||
Visibility="{Binding IsVirtualizationEnabled, Converter={StaticResource BoolToVisibilityConverter}}"
|
||
HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10" Padding="5">
|
||
<StackPanel Orientation="Horizontal">
|
||
<TextBlock Text="📊" FontSize="12" Margin="0,0,3,0"/>
|
||
<TextBlock FontSize="10" Foreground="#4169E1">
|
||
<Run Text="Batch:"/>
|
||
<Run Text="{Binding CurrentBatchIndex, StringFormat={}{0:N0}}"/>
|
||
<Run Text="/"/>
|
||
<Run Text="{Binding TotalBatches, StringFormat={}{0:N0}}"/>
|
||
<Run Text="("/>
|
||
<Run Text="{Binding TotalProcessCount, StringFormat={}{0:N0}}"/>
|
||
<Run Text="total)"/>
|
||
</TextBlock>
|
||
</StackPanel>
|
||
</Border>
|
||
</Grid>
|
||
|
||
<!-- Process Controls -->
|
||
<Grid Grid.Row="2">
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="Auto"/>
|
||
</Grid.RowDefinitions>
|
||
|
||
<Grid Grid.Row="0">
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="*"/>
|
||
<ColumnDefinition Width="*"/>
|
||
<ColumnDefinition Width="*"/>
|
||
<ColumnDefinition Width="*"/>
|
||
</Grid.ColumnDefinitions>
|
||
|
||
<!-- Priority Controls -->
|
||
<GroupBox Grid.Column="0" Header="Process Priority" Margin="0,0,5,0">
|
||
<StackPanel Margin="5">
|
||
<ComboBox x:Name="PriorityComboBox"
|
||
SelectedValue="{Binding SelectedProcess.Priority, Mode=TwoWay}"
|
||
SelectedValuePath="Tag"
|
||
Margin="0,0,0,5"
|
||
IsEnabled="{Binding SelectedProcess, Converter={StaticResource BoolToVisibilityConverter}}">
|
||
<ComboBoxItem Content="Realtime" Tag="{x:Static Diagnostics:ProcessPriorityClass.RealTime}"/>
|
||
<ComboBoxItem Content="High" Tag="{x:Static Diagnostics:ProcessPriorityClass.High}"/>
|
||
<ComboBoxItem Content="Above Normal" Tag="{x:Static Diagnostics:ProcessPriorityClass.AboveNormal}"/>
|
||
<ComboBoxItem Content="Normal" Tag="{x:Static Diagnostics:ProcessPriorityClass.Normal}"/>
|
||
<ComboBoxItem Content="Below Normal" Tag="{x:Static Diagnostics:ProcessPriorityClass.BelowNormal}"/>
|
||
<ComboBoxItem Content="Idle" Tag="{x:Static Diagnostics:ProcessPriorityClass.Idle}"/>
|
||
</ComboBox>
|
||
<Button Command="{Binding SetPriorityCommand}"
|
||
CommandParameter="{Binding ElementName=PriorityComboBox, Path=SelectedValue}"
|
||
Content="Set Priority"
|
||
Padding="10,5"
|
||
Margin="0,0,0,5"
|
||
IsEnabled="{Binding SelectedProcess, Converter={StaticResource BoolToVisibilityConverter}}"
|
||
ToolTip="Apply the selected priority to the process"/>
|
||
|
||
<!-- Registry Priority Enforcement -->
|
||
<CheckBox Content="Enforce Priority by Registry"
|
||
IsChecked="{Binding IsRegistryPriorityEnabled}"
|
||
IsEnabled="{Binding SelectedProcess, Converter={StaticResource BoolToVisibilityConverter}}"
|
||
Margin="0,0,0,5"
|
||
ToolTip="Apply priority through Windows registry. Process must be restarted for changes to take effect. This setting persists across system reboots."/>
|
||
|
||
<!-- Disable Idle Server -->
|
||
<CheckBox Content="Disable Idle Server"
|
||
IsChecked="{Binding IsIdleServerDisabled}"
|
||
IsEnabled="{Binding SelectedProcess, Converter={StaticResource BoolToVisibilityConverter}}"
|
||
ToolTip="Prevents the system from entering idle state while this process is running. Useful for games and performance-critical applications."/>
|
||
</StackPanel>
|
||
</GroupBox>
|
||
|
||
<!-- Core Mask Selection -->
|
||
<GroupBox Grid.Column="1" Header="Core Mask" Margin="5,0,5,0">
|
||
<StackPanel Margin="5">
|
||
<TextBlock Text="Quick apply a predefined core mask:" FontSize="10" Margin="0,0,0,5" Foreground="Gray"/>
|
||
<ComboBox ItemsSource="{Binding AvailableCoreMasks}"
|
||
SelectedItem="{Binding SelectedCoreMask, Mode=TwoWay}"
|
||
Margin="0,0,0,5">
|
||
<ComboBox.ItemTemplate>
|
||
<DataTemplate>
|
||
<StackPanel Orientation="Horizontal">
|
||
<TextBlock Text="{Binding Name}" FontWeight="SemiBold" Margin="0,0,8,0"/>
|
||
<TextBlock Text="{Binding SelectedCoreCount, StringFormat='({0} cores)'}"
|
||
FontSize="10" Foreground="Gray" VerticalAlignment="Center"/>
|
||
</StackPanel>
|
||
</DataTemplate>
|
||
</ComboBox.ItemTemplate>
|
||
</ComboBox>
|
||
<Button Content="➕ Create Custom Mask"
|
||
Command="{Binding CreateCustomMaskCommand}"
|
||
Padding="8,5"
|
||
Margin="0,0,0,5"
|
||
ToolTip="Open Core Masks tab to create a new custom mask"/>
|
||
<TextBlock FontSize="9" Foreground="DarkGreen" TextWrapping="Wrap">
|
||
<Run Text="ℹ️ Selecting a mask applies it immediately to the selected process."/>
|
||
</TextBlock>
|
||
</StackPanel>
|
||
</GroupBox>
|
||
|
||
<!-- Power Plan Selection -->
|
||
<GroupBox Grid.Column="2" Header="Power Plan" Margin="5,0,5,0">
|
||
<StackPanel Margin="5">
|
||
<ComboBox ItemsSource="{Binding PowerPlans}"
|
||
SelectedItem="{Binding SelectedPowerPlan}"
|
||
DisplayMemberPath="Name"
|
||
Margin="0,0,0,5"/>
|
||
<Button Command="{Binding SetPowerPlanCommand}"
|
||
Content="Set Power Plan"
|
||
Padding="10,5"
|
||
ToolTip="Apply the selected power plan to the system"/>
|
||
</StackPanel>
|
||
</GroupBox>
|
||
|
||
<!-- Advanced CPU Affinity Controls -->
|
||
<GroupBox Grid.Column="3" Header="Advanced CPU Affinity" Margin="5,0,0,0">
|
||
<Grid Margin="5">
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="Auto"/>
|
||
</Grid.RowDefinitions>
|
||
|
||
<!-- Topology Status and HyperThreading Status -->
|
||
<StackPanel Grid.Row="0" Orientation="Vertical" Margin="0,0,0,5">
|
||
<TextBlock Text="{Binding TopologyStatus}"
|
||
FontSize="10"
|
||
Foreground="{Binding IsTopologyDetectionSuccessful, Converter={StaticResource BoolToColorConverter}}"/>
|
||
<TextBlock Text="{Binding HyperThreadingStatusText}"
|
||
FontSize="10"
|
||
Margin="0,2,0,0"
|
||
Foreground="{Binding IsHyperThreadingActive, Converter={StaticResource BoolToColorConverter}}"
|
||
ToolTip="Shows whether Hyper-Threading (Intel) or SMT (AMD) is present and active on this system"/>
|
||
</StackPanel>
|
||
|
||
<!-- CPU Core Grid -->
|
||
<ScrollViewer Grid.Row="1"
|
||
MaxHeight="120"
|
||
VerticalScrollBarVisibility="Auto"
|
||
HorizontalScrollBarVisibility="Disabled"
|
||
Margin="0,0,0,5">
|
||
<ItemsControl ItemsSource="{Binding CpuCores}">
|
||
<ItemsControl.ItemsPanel>
|
||
<ItemsPanelTemplate>
|
||
<WrapPanel Orientation="Horizontal"/>
|
||
</ItemsPanelTemplate>
|
||
</ItemsControl.ItemsPanel>
|
||
<ItemsControl.ItemTemplate>
|
||
<DataTemplate>
|
||
<CheckBox Content="{Binding Label}"
|
||
IsChecked="{Binding IsSelected, Mode=OneWay}"
|
||
IsHitTestVisible="False"
|
||
Focusable="False"
|
||
IsEnabled="{Binding IsEnabled}"
|
||
Margin="2"
|
||
FontSize="9"
|
||
ToolTip="Read-only - modify cores in Core Mask tab">
|
||
<CheckBox.Foreground>
|
||
<MultiBinding Converter="{StaticResource CoreTypeToColorConverter}">
|
||
<Binding Path="CoreType"/>
|
||
<Binding Path="IsHyperThreaded"/>
|
||
</MultiBinding>
|
||
</CheckBox.Foreground>
|
||
</CheckBox>
|
||
</DataTemplate>
|
||
</ItemsControl.ItemTemplate>
|
||
</ItemsControl>
|
||
</ScrollViewer>
|
||
</Grid>
|
||
</GroupBox>
|
||
</Grid>
|
||
|
||
<!-- Profile Management & Process Association -->
|
||
<GroupBox Grid.Row="1" Header="Profile Management & Process Association" Margin="0,10,0,0">
|
||
<Grid Margin="5">
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="Auto"/>
|
||
</Grid.RowDefinitions>
|
||
|
||
<!-- Profile Management Row -->
|
||
<Grid Grid.Row="0" Margin="0,0,0,10">
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="*"/>
|
||
<ColumnDefinition Width="Auto"/>
|
||
<ColumnDefinition Width="Auto"/>
|
||
</Grid.ColumnDefinitions>
|
||
|
||
<TextBox Grid.Column="0"
|
||
Text="{Binding ProfileName, UpdateSourceTrigger=PropertyChanged}"
|
||
Margin="0,0,10,0"
|
||
ToolTip="Enter a profile name to save current settings"/>
|
||
<Button Grid.Column="1"
|
||
Command="{Binding SaveProfileCommand}"
|
||
Content="Save Profile"
|
||
Padding="10,5"
|
||
Margin="0,0,5,0"
|
||
ToolTip="Save current CPU affinity and priority as a reusable profile"/>
|
||
<Button Grid.Column="2"
|
||
Command="{Binding LoadProfileCommand}"
|
||
Content="Load Profile"
|
||
Padding="10,5"
|
||
ToolTip="Load a previously saved profile"/>
|
||
</Grid>
|
||
|
||
<!-- Process Association Row -->
|
||
<Grid Grid.Row="1">
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="*"/>
|
||
<ColumnDefinition Width="Auto"/>
|
||
</Grid.ColumnDefinitions>
|
||
|
||
<TextBlock Grid.Column="0"
|
||
VerticalAlignment="Center"
|
||
TextWrapping="Wrap"
|
||
Foreground="Gray"
|
||
FontSize="11">
|
||
<Run Text="💾 Save current settings (CPU mask, priority, power plan) as an automatic association for this process"/>
|
||
</TextBlock>
|
||
<Button Grid.Column="1"
|
||
Command="{Binding SaveCurrentAsAssociationCommand}"
|
||
Content="💾 Save as Association"
|
||
Padding="12,6"
|
||
FontWeight="SemiBold"
|
||
IsEnabled="{Binding SelectedProcess, Converter={StaticResource BoolToVisibilityConverter}}"
|
||
ToolTip="Save current process settings as an association. These settings will be automatically applied when this process starts in the future."/>
|
||
</Grid>
|
||
</Grid>
|
||
</GroupBox>
|
||
</Grid>
|
||
</Grid>
|
||
</UserControl> |