Files
ThreadPilot/Views/MasksView.xaml
T
Prime Build 1540aeb7be Polish Windows 11 tweaks and add one-click updates (#40)
Verify persisted Windows tweak state on startup, modernize selection styling, and make in-app updates check every launch, install automatically after consent, preserve settings, and relaunch ThreadPilot.
2026-08-01 13:50:11 +02:00

257 lines
16 KiB
XML

<UserControl x:Class="ThreadPilot.Views.MasksView"
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"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="900">
<UserControl.Resources>
<Style x:Key="MaskListItemStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Padding" Value="4"/>
<Setter Property="Margin" Value="4"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{DynamicResource StandardCardCornerRadius}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="True">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
TextElement.Foreground="{TemplateBinding Foreground}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource QuietRowHoverBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderSubtleBrush}"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{DynamicResource MaskSelectedListBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource MaskSelectedBorderBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}"/>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="0,0,0,16">
<TextBlock Text="{DynamicResource MasksView_Title}" Style="{StaticResource PageTitleTextStyle}" Margin="0,0,0,4"/>
<TextBlock Text="{DynamicResource MasksView_Subtitle}" Style="{StaticResource PageSubtitleTextStyle}"/>
<TextBlock FontSize="11" Foreground="{DynamicResource TextFillColorSecondaryBrush}" TextWrapping="Wrap" Margin="0,6,0,0">
Selecting a mask here only edits the preset. It does not change CPU affinity until you apply it to a process or save it in a process rule.
</TextBlock>
</StackPanel>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" MinWidth="200"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="3*" MinWidth="300"/>
</Grid.ColumnDefinitions>
<DockPanel Grid.Column="0">
<!-- Mask list actions -->
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="0,0,0,10">
<Button Content="{DynamicResource MasksView_New}" Command="{Binding CreateMaskCommand}"
Padding="10,5" FontSize="13" Margin="0,0,5,0"
ToolTip="{DynamicResource MasksView_CreateNewTooltip}"/>
<Button Content="{DynamicResource MasksView_Delete}" Command="{Binding DeleteMaskCommand}"
Padding="10,5" FontSize="13"
ToolTip="{DynamicResource MasksView_DeleteTooltip}"/>
</StackPanel>
<Border BorderBrush="{DynamicResource BorderSubtleBrush}"
Background="{DynamicResource CardSurfaceBrush}"
BorderThickness="1"
CornerRadius="{DynamicResource StandardCardCornerRadius}">
<ListBox ItemsSource="{Binding CoreMasks}"
SelectedItem="{Binding SelectedCoreMask, Mode=TwoWay}"
ItemContainerStyle="{StaticResource MaskListItemStyle}"
Background="{DynamicResource CardSurfaceBrush}"
BorderThickness="0">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<TextBlock Text="{Binding Name}" FontWeight="SemiBold" FontSize="13"/>
<TextBlock Text="{Binding Description}"
FontSize="11" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
TextTrimming="CharacterEllipsis"
Margin="0,2,0,0"/>
<TextBlock FontSize="10" Foreground="{DynamicResource TextFillColorSecondaryBrush}" Margin="0,2,0,0">
<Run Text="{Binding SelectedCoreCount, Mode=OneWay}"/>
<Run Text="/"/>
<Run Text="{Binding BoolMask.Count, Mode=OneWay}"/>
<Run Text="{DynamicResource MasksView_CpusHeader}"/>
</TextBlock>
</StackPanel>
<TextBlock Grid.Column="1"
Text="⭐" FontSize="14"
VerticalAlignment="Center"
Margin="5,0,0,0">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsDefault}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
</DockPanel>
<!-- DIVIDER -->
<GridSplitter Grid.Column="1" Width="8" HorizontalAlignment="Stretch" Background="Transparent"/>
<ScrollViewer Grid.Column="2" VerticalScrollBarVisibility="Auto">
<StackPanel Margin="10,0,0,0">
<StackPanel.Style>
<Style TargetType="StackPanel">
<Setter Property="IsEnabled" Value="True"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedCoreMask}" Value="{x:Null}">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<GroupBox Header="{DynamicResource MasksView_Info}" Padding="{DynamicResource CompactCardPadding}" Margin="0,0,0,10">
<StackPanel>
<TextBlock Text="{DynamicResource MasksView_SavedAutomatically}"
FontSize="11"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
TextWrapping="Wrap"
Margin="0,0,0,10"/>
<TextBlock Text="{DynamicResource MasksView_Name}" FontWeight="SemiBold" Margin="0,0,0,5"/>
<TextBox Text="{Binding SelectedCoreMask.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Padding="8,6" FontSize="13" Margin="0,0,0,10"/>
<TextBlock Text="{DynamicResource MasksView_Description}" FontWeight="SemiBold" Margin="0,0,0,5"/>
<TextBox Text="{Binding SelectedCoreMask.Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Padding="8,6" MinHeight="52" MaxHeight="90" TextWrapping="Wrap" AcceptsReturn="True"
VerticalScrollBarVisibility="Auto"/>
</StackPanel>
</GroupBox>
<!-- CPU Selection Grid -->
<GroupBox Header="{DynamicResource MasksView_SelectCpus}" Padding="{DynamicResource CompactCardPadding}" Margin="0,10,0,10">
<StackPanel>
<TextBlock Text="{DynamicResource MasksView_SelectCpusTip}"
FontSize="11"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
TextWrapping="Wrap"
Margin="0,0,0,10"/>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsControl x:Name="CoreItemsControl" ItemsSource="{Binding CoreBits}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="{DynamicResource BorderSubtleBrush}"
Margin="2" Padding="4" CornerRadius="4">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="{DynamicResource QuietRowBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderSubtleBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected}" Value="True">
<Setter Property="Background" Value="{DynamicResource MaskSelectedBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource MaskSelectedBorderBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
FontSize="11"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
MinWidth="60">
<CheckBox.Content>
<TextBlock>
<Run Text="{DynamicResource MasksView_Cpu}"/>
<Run Text="{Binding Index, Mode=OneWay}"/>
</TextBlock>
</CheckBox.Content>
</CheckBox>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</StackPanel>
</GroupBox>
<GroupBox Header="{DynamicResource MasksView_Options}" Padding="{DynamicResource CompactCardPadding}">
<StackPanel>
<Button Content="{DynamicResource MasksView_Duplicate}" Command="{Binding DuplicateMaskCommand}"
HorizontalAlignment="Left" Padding="10,6" Margin="0,0,0,5"/>
<CheckBox Content="{DynamicResource MasksView_DefaultPreset}"
IsChecked="{Binding SelectedCoreMask.IsDefault, Mode=TwoWay}"
Margin="0,10,0,5"
ToolTip="{DynamicResource MasksView_DefaultPresetTip}"/>
<CheckBox Content="{DynamicResource MasksView_Enabled}"
IsChecked="{Binding SelectedCoreMask.IsEnabled, Mode=TwoWay}"
Margin="0,5"
ToolTip="{DynamicResource MasksView_DisableTip}"/>
</StackPanel>
</GroupBox>
</StackPanel>
</ScrollViewer>
</Grid>
<!-- Status Bar -->
<Border Grid.Row="2"
Background="{DynamicResource StatusPillBackgroundBrush}"
BorderBrush="{DynamicResource StatusPillBorderBrush}"
BorderThickness="1"
Padding="10,5"
Margin="0,10,0,0"
CornerRadius="{DynamicResource StandardCardCornerRadius}">
<TextBlock Text="{Binding StatusMessage}"
FontSize="12" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Opacity="{Binding StatusOpacity}"
TextTrimming="CharacterEllipsis"/>
</Border>
</Grid>
</UserControl>