<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">
    <StackPanel Orientation="Horizontal">
      <Path Width="16" Height="16"
            Data="{StaticResource Icons.Undo}"/>

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

    <ContentControl Margin="0,16,0,8" Content="{Binding Mode}">
      <ContentControl.DataTemplates>
        <DataTemplate DataType="vm:DiscardAllMode">
          <Grid RowDefinitions="32,32,32,Auto" 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.IncludeUntracked}"
                      IsChecked="{Binding IncludeUntracked, Mode=TwoWay}"/>

            <CheckBox Grid.Row="2" Grid.Column="1"
                      Content="{DynamicResource Text.Discard.IncludeIgnored}"
                      IsChecked="{Binding IncludeIgnored, Mode=TwoWay}"/>

            <Grid Grid.Row="3" Grid.Column="1" ColumnDefinitions="Auto,*" Margin="0,6,0,0">
              <Path Grid.Column="0"
                    Width="14" Height="14"
                    Data="{StaticResource Icons.Error}"
                    Fill="DarkOrange"/>
              <TextBlock Grid.Column="1" Margin="8,0,0,0"
                         Text="{DynamicResource Text.Discard.Warning}"
                         TextWrapping="Wrap"
                         Foreground="DarkOrange"/>
            </Grid>
          </Grid>
        </DataTemplate>

        <DataTemplate DataType="vm:DiscardSingleFile">
          <Grid RowDefinitions="32,Auto" ColumnDefinitions="120,*">
            <TextBlock Grid.Row="0" Grid.Column="0"
                       Margin="0,0,8,0"
                       HorizontalAlignment="Right"
                       Text="{DynamicResource Text.Discard.Changes}"/>
            
            <StackPanel Grid.Row="0" 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 Grid.Row="1" Grid.Column="1" ColumnDefinitions="Auto,*" Margin="0,6,0,0">
              <Path Grid.Column="0"
                    Width="14" Height="14"
                    Data="{StaticResource Icons.Error}"
                    Fill="DarkOrange"/>
              <TextBlock Grid.Column="1" Margin="8,0,0,0"
                         Text="{DynamicResource Text.Discard.Warning}"
                         TextWrapping="Wrap"
                         Foreground="DarkOrange"/>
            </Grid>
          </Grid>
        </DataTemplate>

        <DataTemplate DataType="vm:DiscardMultipleFiles">
          <Grid RowDefinitions="32,Auto" ColumnDefinitions="120,*">
            <TextBlock Grid.Row="0" Grid.Column="0"
                       Margin="0,0,8,0"
                       HorizontalAlignment="Right"
                       Text="{DynamicResource Text.Discard.Changes}"/>
            <StackPanel Grid.Row="0" 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 Grid.Row="1" Grid.Column="1" ColumnDefinitions="Auto,*" Margin="0,6,0,0">
              <Path Grid.Column="0"
                    Width="14" Height="14"
                    Data="{StaticResource Icons.Error}"
                    Fill="DarkOrange"/>
              <TextBlock Grid.Column="1" Margin="8,0,0,0"
                         Text="{DynamicResource Text.Discard.Warning}"
                         TextWrapping="Wrap"
                         Foreground="DarkOrange"/>
            </Grid>
          </Grid>
        </DataTemplate>
      </ContentControl.DataTemplates>
    </ContentControl>
  </StackPanel>
</UserControl>
