277 lines
16 KiB
XML
277 lines
16 KiB
XML
<UserControl x:Class="ThreadPilot.Views.ProcessPowerPlanAssociationView"
|
|
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:converters="clr-namespace:ThreadPilot.Converters"
|
|
xmlns:local="clr-namespace:ThreadPilot.Views"
|
|
mc:Ignorable="d"
|
|
d:DesignHeight="800" d:DesignWidth="1200">
|
|
|
|
<UserControl.Resources>
|
|
<converters:BoolToColorConverter x:Key="BoolToColorConverter"/>
|
|
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
|
|
<converters:InverseBooleanConverter x:Key="InverseBoolConverter"/>
|
|
</UserControl.Resources>
|
|
<Grid Margin="10">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="*"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<!-- Standardized Header -->
|
|
<GroupBox Grid.Row="0" Header="🔗 Process-Power Plan Associations" Margin="0,0,0,10">
|
|
<Grid Margin="5">
|
|
<TextBlock Text="Configure automatic power plan switching based on running processes"
|
|
FontSize="12" Foreground="Gray" VerticalAlignment="Center"/>
|
|
</Grid>
|
|
</GroupBox>
|
|
|
|
<!-- Main Content -->
|
|
<TabControl Grid.Row="1" Background="White" BorderThickness="0">
|
|
|
|
<!-- Associations Tab -->
|
|
<TabItem Header="🔗 Process Associations">
|
|
<Grid Margin="10">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="2*"/>
|
|
<ColumnDefinition Width="10"/>
|
|
<ColumnDefinition Width="*"/>
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<!-- Associations List -->
|
|
<GroupBox Grid.Column="0" Header="📋 Current Associations">
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="*"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<DataGrid Grid.Row="0"
|
|
ItemsSource="{Binding Associations}"
|
|
SelectedItem="{Binding SelectedAssociation}"
|
|
AutoGenerateColumns="False"
|
|
CanUserAddRows="False"
|
|
GridLinesVisibility="Horizontal"
|
|
HeadersVisibility="Column"
|
|
BorderThickness="1">
|
|
<DataGrid.Columns>
|
|
<DataGridCheckBoxColumn Header="Enabled"
|
|
Binding="{Binding IsEnabled}"
|
|
Width="60"/>
|
|
<DataGridTextColumn Header="Executable"
|
|
Binding="{Binding ExecutableName}"
|
|
Width="150"/>
|
|
<DataGridTextColumn Header="Power Plan"
|
|
Binding="{Binding PowerPlanName}"
|
|
Width="120"/>
|
|
<DataGridTextColumn Header="Core Mask"
|
|
Binding="{Binding CoreMaskName}"
|
|
Width="100"/>
|
|
<DataGridTextColumn Header="Priority"
|
|
Binding="{Binding ProcessPriority}"
|
|
Width="80"/>
|
|
<DataGridTextColumn Header="Assoc. Priority"
|
|
Binding="{Binding Priority}"
|
|
Width="60"/>
|
|
<DataGridCheckBoxColumn Header="Match by Path"
|
|
Binding="{Binding MatchByPath}"
|
|
Width="100"/>
|
|
<DataGridTextColumn Header="Description"
|
|
Binding="{Binding Description}"
|
|
Width="*"/>
|
|
</DataGrid.Columns>
|
|
</DataGrid>
|
|
|
|
<StackPanel Grid.Row="1" Orientation="Horizontal"
|
|
HorizontalAlignment="Right" Margin="0,10,0,0">
|
|
<Button Content="Update"
|
|
Command="{Binding UpdateAssociationCommand}"
|
|
Margin="0,0,5,0" Padding="10,5"
|
|
ToolTip="Update the selected association"/>
|
|
<Button Content="Remove"
|
|
Command="{Binding RemoveAssociationCommand}"
|
|
Padding="10,5"
|
|
ToolTip="Remove the selected association"/>
|
|
</StackPanel>
|
|
</Grid>
|
|
</GroupBox>
|
|
|
|
<!-- Add New Association -->
|
|
<GroupBox Grid.Column="2" Header="Add New Association">
|
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
|
<StackPanel>
|
|
<!-- Executable Selection Section -->
|
|
<TextBlock Text="Select Executable:" FontWeight="Bold" Margin="0,0,0,5"/>
|
|
|
|
<!-- Browse Button -->
|
|
<Button Content="📁 Browse for Executable"
|
|
Command="{Binding BrowseExecutableCommand}"
|
|
Padding="10,8" Margin="0,0,0,10"
|
|
HorizontalAlignment="Left"
|
|
ToolTip="Click to select an executable file (.exe) from your computer"/>
|
|
|
|
<!-- Selected Executable Display -->
|
|
<Border BorderBrush="#CCCCCC" BorderThickness="1"
|
|
Background="#F8F8F8" Padding="8" Margin="0,0,0,10"
|
|
Visibility="{Binding HasSelectedExecutable, Converter={StaticResource BoolToVisibilityConverter}}">
|
|
<StackPanel>
|
|
<TextBlock Text="Selected Executable:" FontSize="10" Foreground="#666666" Margin="0,0,0,2"/>
|
|
<TextBlock Text="{Binding SelectedExecutableDisplayName}"
|
|
FontWeight="Bold" Margin="0,0,0,2"/>
|
|
<TextBlock Text="{Binding SelectedExecutableFullPath}"
|
|
FontSize="10" Foreground="#666666" TextWrapping="Wrap"/>
|
|
</StackPanel>
|
|
</Border>
|
|
|
|
<!-- Clear Selection Button -->
|
|
<Button Content="✖ Clear Selection"
|
|
Command="{Binding ClearSelectedExecutableCommand}"
|
|
Padding="5,3" Margin="0,0,0,15"
|
|
HorizontalAlignment="Left" FontSize="10"
|
|
Visibility="{Binding HasSelectedExecutable, Converter={StaticResource BoolToVisibilityConverter}}"
|
|
ToolTip="Clear the selected executable"/>
|
|
|
|
<CheckBox Content="Match by Path"
|
|
IsChecked="{Binding MatchByPath}"
|
|
Margin="0,0,0,10"
|
|
ToolTip="Match processes by full path instead of just executable name"/>
|
|
|
|
<TextBlock Text="Power Plan:" Margin="0,0,0,5"/>
|
|
<ComboBox ItemsSource="{Binding AvailablePowerPlans}"
|
|
SelectedItem="{Binding SelectedPowerPlan}"
|
|
DisplayMemberPath="Name"
|
|
Padding="5" Margin="0,0,0,10"/>
|
|
|
|
<TextBlock Text="Core Mask:" Margin="0,0,0,5"/>
|
|
<ComboBox ItemsSource="{Binding AvailableCoreMasks}"
|
|
SelectedItem="{Binding SelectedCoreMask}"
|
|
DisplayMemberPath="Name"
|
|
Padding="5" Margin="0,0,0,10"
|
|
ToolTip="Optional: Select a CPU core mask to apply when this process starts"/>
|
|
|
|
<TextBlock Text="Process Priority:" Margin="0,0,0,5"/>
|
|
<ComboBox ItemsSource="{Binding AvailablePriorities}"
|
|
SelectedItem="{Binding SelectedProcessPriority}"
|
|
Padding="5" Margin="0,0,0,10"
|
|
ToolTip="Optional: Select the process priority to apply when this process starts"/>
|
|
|
|
<TextBlock Text="Association Priority:" Margin="0,0,0,5"/>
|
|
<TextBox Text="{Binding Priority}"
|
|
Padding="5" Margin="0,0,0,10"
|
|
ToolTip="Higher priority associations take precedence when multiple match"/>
|
|
|
|
<TextBlock Text="Description:" Margin="0,0,0,5"/>
|
|
<TextBox Text="{Binding Description}"
|
|
Padding="5" Margin="0,0,0,15"/>
|
|
|
|
<Button Content="Add Association"
|
|
Command="{Binding AddAssociationCommand}"
|
|
Padding="10,8"/>
|
|
|
|
<Separator Margin="0,15,0,15"/>
|
|
|
|
<TextBlock Text="Or Select from Running Processes:"
|
|
FontWeight="Bold" Margin="0,0,0,10"/>
|
|
|
|
<ComboBox ItemsSource="{Binding RunningProcesses}"
|
|
SelectedItem="{Binding SelectedProcess}"
|
|
DisplayMemberPath="Name"
|
|
Padding="5" Margin="0,0,0,10"
|
|
ToolTip="Select a currently running process to use its executable"/>
|
|
|
|
<Button Content="📋 Use Selected Process"
|
|
Command="{Binding UseSelectedProcessForAssociationCommand}"
|
|
Padding="10,5"
|
|
ToolTip="Use the executable from the selected running process"/>
|
|
</StackPanel>
|
|
</ScrollViewer>
|
|
</GroupBox>
|
|
</Grid>
|
|
</TabItem>
|
|
|
|
<!-- Settings Tab -->
|
|
<TabItem Header="⚙️ Configuration">
|
|
<ScrollViewer Margin="10">
|
|
<StackPanel>
|
|
<!-- Service Control -->
|
|
<GroupBox Header="Service Control" Margin="0,0,0,15">
|
|
<StackPanel>
|
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
|
|
<TextBlock Text="Status: " VerticalAlignment="Center"/>
|
|
<TextBlock Text="{Binding ServiceStatus}"
|
|
Foreground="{Binding IsServiceRunning, Converter={StaticResource BoolToColorConverter}}"
|
|
FontWeight="Bold" VerticalAlignment="Center"/>
|
|
</StackPanel>
|
|
|
|
<StackPanel Orientation="Horizontal">
|
|
<Button Content="Start Monitoring"
|
|
Command="{Binding StartMonitoringCommand}"
|
|
IsEnabled="{Binding IsServiceRunning, Converter={StaticResource InverseBoolConverter}}"
|
|
Padding="15,8" Margin="0,0,10,0"/>
|
|
<Button Content="Stop Monitoring"
|
|
Command="{Binding StopMonitoringCommand}"
|
|
IsEnabled="{Binding IsServiceRunning}"
|
|
Padding="15,8"/>
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</GroupBox>
|
|
|
|
<!-- Default Power Plan -->
|
|
<GroupBox Header="Default Power Plan" Margin="0,0,0,15">
|
|
<StackPanel>
|
|
<TextBlock Text="Power plan to use when no associated processes are running:"
|
|
Foreground="#666666" Margin="0,0,0,10"/>
|
|
|
|
<ComboBox ItemsSource="{Binding AvailablePowerPlans}"
|
|
SelectedItem="{Binding DefaultPowerPlan}"
|
|
DisplayMemberPath="Name"
|
|
Padding="5" Margin="0,0,0,10"/>
|
|
|
|
<Button Content="Set Default Power Plan"
|
|
Command="{Binding SetDefaultPowerPlanCommand}"
|
|
Padding="10,5" HorizontalAlignment="Left"/>
|
|
</StackPanel>
|
|
</GroupBox>
|
|
|
|
<!-- Monitoring Settings -->
|
|
<GroupBox Header="Monitoring Settings" Margin="0,0,0,15">
|
|
<StackPanel>
|
|
<CheckBox Content="Enable Event-Based Monitoring (WMI)"
|
|
IsChecked="{Binding IsEventBasedMonitoringEnabled}"
|
|
Margin="0,0,0,10"/>
|
|
|
|
<CheckBox Content="Enable Fallback Polling"
|
|
IsChecked="{Binding IsFallbackPollingEnabled}"
|
|
Margin="0,0,0,10"/>
|
|
|
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
|
|
<TextBlock Text="Polling Interval (seconds): "
|
|
VerticalAlignment="Center" Margin="0,0,10,0"/>
|
|
<TextBox Text="{Binding PollingIntervalSeconds}"
|
|
Width="60" Padding="5"/>
|
|
</StackPanel>
|
|
|
|
<CheckBox Content="Prevent Duplicate Power Plan Changes"
|
|
IsChecked="{Binding PreventDuplicatePowerPlanChanges}"
|
|
Margin="0,0,0,10"/>
|
|
|
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
|
|
<TextBlock Text="Power Plan Change Delay (ms): "
|
|
VerticalAlignment="Center" Margin="0,0,10,0"/>
|
|
<TextBox Text="{Binding PowerPlanChangeDelayMs}"
|
|
Width="80" Padding="5"/>
|
|
</StackPanel>
|
|
|
|
<Button Content="Save Configuration"
|
|
Command="{Binding SaveConfigurationCommand}"
|
|
Padding="15,8" HorizontalAlignment="Left"/>
|
|
</StackPanel>
|
|
</GroupBox>
|
|
</StackPanel>
|
|
</ScrollViewer>
|
|
</TabItem>
|
|
</TabControl>
|
|
</Grid>
|
|
</UserControl>
|