<UserControl
    x:Class="AppFramework.Views.LanguageTextView"
    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:extensions="clr-namespace:AppFramework.Extensions"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:perm="clr-namespace:AppFramework.Common;assembly=AppFramework.Common"
    xmlns:sync="http://schemas.syncfusion.com/wpf"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">
    <sync:SfBusyIndicator AnimationType="DualRing" IsBusy="{Binding IsBusy}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <Border Margin="1" Style="{StaticResource HeaderBorderStyle}" />

            <DockPanel Margin="20" LastChildFill="False">
                <StackPanel VerticalAlignment="Center" Orientation="Horizontal">
                    <TextBlock
                        FontSize="18"
                        FontWeight="Bold"
                        Text="{extensions:Translate LanguageTexts}" />
                    <TextBlock
                        Margin="10,0,0,0"
                        VerticalAlignment="Center"
                        Text="{extensions:Translate LanguageTextsHeaderInfo}" />
                </StackPanel>
            </DockPanel>

            <Grid Grid.Row="1" Margin="20">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition />
                    <RowDefinition Height="auto" />
                </Grid.RowDefinitions>

                <Border Grid.RowSpan="3" Style="{StaticResource BorderStyle}" />

                <Grid Margin="15">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>

                    <UniformGrid Columns="4">
                        <StackPanel Margin="10,0">
                            <TextBlock Text="{extensions:Translate BaseLanguage}" />
                            <ComboBox ItemsSource="{Binding BaseLanguages}" SelectedItem="{Binding SelectedBaseLanguage}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding DisplayName}" />
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </StackPanel>

                        <StackPanel Margin="10,0">
                            <TextBlock Text="{extensions:Translate TargetLanguage}" />
                            <ComboBox ItemsSource="{Binding TargetLanguages}" SelectedItem="{Binding SelectedTargetLanguage}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding DisplayName}" />
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </StackPanel>

                        <StackPanel Margin="10,0">
                            <TextBlock Text="{extensions:Translate Source}" />
                            <ComboBox ItemsSource="{Binding Sources}" SelectedItem="{Binding SelectedSource}" />
                        </StackPanel>

                        <StackPanel Margin="10,0">
                            <TextBlock Text="{extensions:Translate TargetValue}" />
                            <ComboBox SelectedIndex="{Binding TargetIndex}">
                                <ComboBoxItem Content="{extensions:Translate All}" />
                                <ComboBoxItem Content="{extensions:Translate EmptyOnes}" />
                            </ComboBox>
                        </StackPanel>
                    </UniformGrid>

                    <DockPanel Grid.Row="1" Margin="10">
                        <Button
                            Margin="5,0,0,0"
                            Command="{Binding SearchCommand}"
                            DockPanel.Dock="Right"
                            Style="{DynamicResource SearchButtonStyle}" />
                        <TextBox Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
                    </DockPanel>
                </Grid>

                <sync:SfDataGrid
                    x:Name="SfDataGrid"
                    Grid.Row="1"
                    Margin="15"
                    ItemsSource="{Binding dataPager.GridModelList}"
                    SelectedItem="{Binding dataPager.SelectedItem}"
                    Style="{StaticResource SimpleDataGridStyle}">
                    <sync:SfDataGrid.Columns>
                        <sync:GridTemplateColumn
                            Width="60"
                            AllowFiltering="False"
                            AllowSorting="False">
                            <sync:GridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button
                                        Padding="8"
                                        Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=sync:SfDataGrid}}"
                                        CommandParameter="{Binding}"
                                        Content="&#xe651;"
                                        Style="{StaticResource IconButtonStyle}" />
                                </DataTemplate>
                            </sync:GridTemplateColumn.CellTemplate>
                        </sync:GridTemplateColumn>
                        <sync:GridTextColumn HeaderText="{extensions:Translate Key}" MappingName="Key" />
                        <sync:GridTextColumn HeaderText="{extensions:Translate BaseValue}" MappingName="BaseValue" />
                        <sync:GridTextColumn HeaderText="{extensions:Translate TargetValue}" MappingName="TargetValue" />
                    </sync:SfDataGrid.Columns>
                </sync:SfDataGrid>

                <sync:SfDataPager
                    Grid.Row="2"
                    HorizontalAlignment="Right"
                    NumericButtonCount="{Binding dataPager.NumericButtonCount}"
                    PageCount="{Binding dataPager.PageCount, Mode=TwoWay}"
                    PageSize="{Binding dataPager.PageSize, Mode=TwoWay}"
                    UseOnDemandPaging="True"
                    PageIndex="{Binding dataPager.PageIndex, Mode=TwoWay}" />
            </Grid>
        </Grid>
    </sync:SfBusyIndicator>
</UserControl>
