<Window x:Class="ServerManagerTool.ProcessorAffinityWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        MinWidth="300" MinHeight="200" Width="300" Height="300" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False" ResizeMode="CanResize"
        Icon="../Art/favicon.ico" Title="{DynamicResource ProcessorAffinity_Title}"
        FocusManager.FocusedElement="{Binding ElementName=AllProcessorsCheckBox}">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Globalization\en-US\en-US.xaml"/>
                <ResourceDictionary Source="..\Styles\Default.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    
    <Grid Background="{StaticResource GradientBackground}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Margin="5,5,5,0" Text="{DynamicResource ProcessorAffinity_InstructionLabel}" VerticalAlignment="Center" TextWrapping="Wrap" />

        <CheckBox x:Name="AllProcessorsCheckBox" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Margin="5,5,5,0" VerticalAlignment="Center" HorizontalAlignment="Left" Content="{DynamicResource ProcessorAffinity_AllCpuLabel}" IsChecked="{Binding ProcessorAffinityList.AllProcessors, Mode=TwoWay}" ToolTip="{DynamicResource ProcessorAffinity_AllCpuTooltip}"/>

        <DataGrid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" Margin="5" Name="ModDetailsGrid" ItemsSource="{Binding ProcessorAffinityList}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserReorderColumns="False" CanUserSortColumns="False" RowHeaderWidth="0" SelectionMode="Single" IsEnabled="{Binding ProcessorAffinityList.AllProcessors, Converter={StaticResource InvertBooleanConverter}}">
            <DataGrid.Resources>
                <Style TargetType="{x:Type DataGridRow}">
                    <Style.Resources>
                        <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="{x:Static SystemColors.HighlightColor}"/>
                        <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="{x:Static SystemColors.HighlightTextColor}"/>
                    </Style.Resources>
                </Style>
            </DataGrid.Resources>

            <DataGrid.HorizontalGridLinesBrush>
                <SolidColorBrush Color="#FFB4B4B4"/>
            </DataGrid.HorizontalGridLinesBrush>
            <DataGrid.VerticalGridLinesBrush>
                <SolidColorBrush Color="#FFB4B4B4"/>
            </DataGrid.VerticalGridLinesBrush>

            <DataGrid.Columns>
                <DataGridCheckBoxColumn Width="Auto" Binding="{Binding Selected, Mode=TwoWay}">
                    <DataGridCheckBoxColumn.Header>
                        <TextBlock Text="{DynamicResource ProcessorAffinity_SelectedColumnLabel}" />
                    </DataGridCheckBoxColumn.Header>
                </DataGridCheckBoxColumn>
                <DataGridTextColumn     Width="*" Binding="{Binding Description, Mode=OneWay}">
                    <DataGridTextColumn.Header>
                        <TextBlock Text="{DynamicResource ProcessorAffinity_DescriptionColumnLabel}" />
                    </DataGridTextColumn.Header>
                </DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>

        <Button Grid.Row="3" Grid.Column="0" Content="{DynamicResource ProcessorAffinity_SelectAllButtonLabel}" Margin="5" MinWidth="40" HorizontalAlignment="Right" Click="SelectAll_Click" IsEnabled="{Binding ProcessorAffinityList.AllProcessors, Converter={StaticResource InvertBooleanConverter}}"/>
        <Button Grid.Row="3" Grid.Column="1" Content="{DynamicResource ProcessorAffinity_UnselectAllButtonLabel}" Margin="5" MinWidth="40" HorizontalAlignment="Right" Click="UnselectAll_Click" IsEnabled="{Binding ProcessorAffinityList.AllProcessors, Converter={StaticResource InvertBooleanConverter}}"/>
        <Button Grid.Row="3" Grid.Column="2" Content="{DynamicResource ProcessorAffinity_ProcessButtonLabel}" Margin="5" MinWidth="75" HorizontalAlignment="Right" Click="Process_Click"/>
        <Button Grid.Row="3" Grid.Column="3" Content="{DynamicResource ProcessorAffinity_CancelButtonLabel}" Margin="5" MinWidth="75" HorizontalAlignment="Left" IsCancel="True"/>
    </Grid>
</Window>
