<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:vm="using:SourceGit.ViewModels"
             xmlns:c="using:SourceGit.Converters"
             mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="450"
             x:Class="SourceGit.Views.Discard"
             x:DataType="vm:Discard">
  <StackPanel Orientation="Vertical" Margin="8,0,0,0">
    <TextBlock FontSize="18"
               Classes="bold"
               Text="{DynamicResource Text.Discard}"/>
    
    <StackPanel Margin="0,6,0,0" Orientation="Horizontal">
      <Path Width="14" Height="14" 
            Data="{StaticResource Icons.Error}" 
            Fill="DarkOrange"/>
      <TextBlock Margin="4,0,0,0"
                 Text="{DynamicResource Text.Discard.Warning}"
                 Foreground="DarkOrange"/>
    </StackPanel>
    
    <ContentControl Margin="0,16,0,8" Content="{Binding Mode}">
      <ContentControl.DataTemplates>
        <DataTemplate DataType="vm:DiscardAllMode">
          <Grid RowDefinitions="32,32" ColumnDefinitions="120,*">
            <TextBlock Grid.Row="0" Grid.Column="0"
                       Margin="0,0,8,0"
                       HorizontalAlignment="Right"
                       Text="{DynamicResource Text.Discard.Changes}"/>
            <TextBlock Grid.Row="0" Grid.Column="1"
                       Text="{DynamicResource Text.Discard.All}"/>
            
            <CheckBox Grid.Row="1" Grid.Column="1"
                      Content="{DynamicResource Text.Discard.IncludeIgnored}"
                      IsChecked="{Binding IncludeIgnored, Mode=TwoWay}"/>
          </Grid>
        </DataTemplate>
        
        <DataTemplate DataType="vm:DiscardSingleFile">
          <Grid Height="32" ColumnDefinitions="120,*">
            <TextBlock Grid.Column="0"
                       Margin="0,0,8,0"
                       HorizontalAlignment="Right"
                       Text="{DynamicResource Text.Discard.Changes}"/>
            <StackPanel Grid.Column="1" Orientation="Horizontal">
              <Path Width="12" Height="12" Data="{StaticResource Icons.File}"/>
              <TextBlock Text="{Binding Path}" Margin="4,0,0,0"/>
            </StackPanel>
          </Grid>
        </DataTemplate>
        
        <DataTemplate DataType="vm:DiscardMultipleFiles">
          <Grid Height="32" ColumnDefinitions="120,*">
            <TextBlock Grid.Column="0"
                       Margin="0,0,8,0"
                       HorizontalAlignment="Right"
                       Text="{DynamicResource Text.Discard.Changes}"/>
            <StackPanel Grid.Column="1" Orientation="Horizontal">
              <Path Width="12" Height="12" Data="{StaticResource Icons.File}"/>
              <TextBlock Text="{Binding Count, Converter={x:Static c:StringConverters.FormatByResourceKey}, ConverterParameter='Discard.Total'}" 
                         Margin="4,0,0,0"/>
            </StackPanel>
          </Grid>
        </DataTemplate>
      </ContentControl.DataTemplates>
    </ContentControl>
  </StackPanel>
</UserControl>
