<UserControl xmlns="https://github.com/avaloniaui"
             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:m="using:SourceGit.Models"
             xmlns:vm="using:SourceGit.ViewModels"
             xmlns:v="using:SourceGit.Views"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="SourceGit.Views.Apply"
             x:DataType="vm:Apply">
  <StackPanel Orientation="Vertical" Margin="8,0">
    <StackPanel Orientation="Horizontal">
      <Path Width="16" Height="16"
            Data="{StaticResource Icons.Diff}"/>

      <TextBlock FontSize="18"
                 Margin="8,0,0,0"
                 Classes="bold"
                 Text="{DynamicResource Text.Apply.Title}"/>
    </StackPanel>

    <Grid Margin="0,16,0,0" RowDefinitions="32,32,32" ColumnDefinitions="120,*">
      <TextBlock Grid.Column="0"
                 HorizontalAlignment="Right" VerticalAlignment="Center"
                 Margin="0,0,8,0"
                 Text="{DynamicResource Text.Apply.File}"/>
      <TextBox Grid.Row="0" Grid.Column="1"
               x:Name="TxtPatchFile"
               Height="28"
               CornerRadius="3"
               Watermark="{DynamicResource Text.Apply.File.Placeholder}"
               Text="{Binding PatchFile, Mode=TwoWay}"
               v:AutoFocusBehaviour.IsEnabled="True">
        <TextBox.InnerRightContent>
          <Button Classes="icon_button" Width="30" Height="30" Click="SelectPatchFile">
            <Path Data="{StaticResource Icons.Folder.Open}" Fill="{DynamicResource Brush.FG1}"/>
          </Button>
        </TextBox.InnerRightContent>
      </TextBox>

      <TextBlock Grid.Row="1" Grid.Column="0"
                 HorizontalAlignment="Right" VerticalAlignment="Center"
                 Margin="0,0,8,0"
                 Text="{DynamicResource Text.Apply.WS}"/>
      <ComboBox Grid.Row="1" Grid.Column="1"
                Height="28" Padding="8,0"
                VerticalAlignment="Center" HorizontalAlignment="Stretch"
                ItemsSource="{Binding Source={x:Static m:ApplyWhiteSpaceMode.Supported}}"
                SelectedItem="{Binding SelectedWhiteSpaceMode, Mode=TwoWay}"
                IsEnabled="{Binding !IgnoreWhiteSpace}"
                Grid.IsSharedSizeScope="True">
        <ComboBox.ItemTemplate>
          <DataTemplate DataType="m:ApplyWhiteSpaceMode">
            <Grid Height="20" VerticalAlignment="Center">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" SharedSizeGroup="ApplyModeNameColumn"/>
                <ColumnDefinition Width="Auto" SharedSizeGroup="ApplyModeDescColumn"/>
                <ColumnDefinition Width="Auto" SharedSizeGroup="ApplyModeArgsColumn"/>
              </Grid.ColumnDefinitions>

              <TextBlock Grid.Column="0" Text="{Binding Name}"/>
              <TextBlock Grid.Column="1" Text="{Binding Desc}" Margin="8,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
              <TextBlock Grid.Column="2" Text="{Binding Arg}" HorizontalAlignment="Right" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
            </Grid>
          </DataTemplate>
        </ComboBox.ItemTemplate>

        <ComboBox.SelectionBoxItemTemplate>
          <DataTemplate DataType="m:ApplyWhiteSpaceMode">
            <Grid ColumnDefinitions="Auto,*">
              <TextBlock Grid.Column="0" Text="{Binding Name}" Margin="0,0,8,0"/>
              <TextBlock Grid.Column="1" Text="{Binding Desc}" HorizontalAlignment="Right" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
            </Grid>
          </DataTemplate>
        </ComboBox.SelectionBoxItemTemplate>
      </ComboBox>

      <CheckBox Grid.Row="2" Grid.Column="1"
                Content="{DynamicResource Text.Apply.IgnoreWS}"
                IsChecked="{Binding IgnoreWhiteSpace, Mode=TwoWay}"
                ToolTip.Tip="--ignore-whitespace"/>
    </Grid>
  </StackPanel>
</UserControl>
