<Window x:Class="Translator.TranslatorWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:c="clr-namespace:Translator.Controls"
        xmlns:cv="clr-namespace:Translator.Converters"
        Title="ScreenToGif - Translator" Height="450" Width="1000" MinHeight="400" MinWidth="800"
        WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" Closing="Window_Closing" Icon="Logo.ico">

    <Window.Resources>
        <cv:NullToInvertedBool x:Key="NullToInvertedBool"/>
    </Window.Resources>

    <Window.CommandBindings>
        <CommandBinding Command="Save" CanExecute="Export_CanExecute" Executed="Export_Executed"/>
        <CommandBinding Command="Open" CanExecute="Load_CanExecute" Executed="Load_Executed"/>
    </Window.CommandBindings>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Background="#FFF9F9FF">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="40"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto" MinWidth="100"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto" MinWidth="100"/>
                <ColumnDefinition Width="40"/>
            </Grid.ColumnDefinitions>

            <Viewbox Grid.Column="0" x:Name="IconViewBox" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center" 
                     Stretch="Uniform" Child="{StaticResource Vector.Translate}" Width="30" Height="30"/>

            <Label Grid.Column="1" x:Name="HeaderLabel" Content="Translator" Margin="5,0,5,0" VerticalAlignment="Center" Padding="2" FontSize="18" FontFamily="Segoe UI Semilight"/>

            <Label Grid.Column="3" Content="From" VerticalAlignment="Center" Padding="2" FontSize="16" FontFamily="Segoe UI Semilight"/>
            <ComboBox Grid.Column="4" x:Name="FromComboBox" Margin="5,0" SelectedValuePath="Code" DisplayMemberPath="CodeName" IsEditable="True" IsEnabled="False" 
                      PreviewKeyDown="ComboBox_KeyDown"/>

            <Label Grid.Column="5" Content="into" VerticalAlignment="Center" Padding="2" FontSize="16" FontFamily="Segoe UI Semilight"/>
            <ComboBox Grid.Column="6" x:Name="ToComboBox" Margin="5,0" SelectedValuePath="Code" DisplayMemberPath="CodeName" IsEditable="True" 
                      PreviewKeyDown="ComboBox_KeyDown"/>

            <c:ImageButton Grid.Column="7" x:Name="RefreshButton" Content="{StaticResource Vector.Synchronize}" MaxSize="22"
                           Style="{StaticResource Style.Button.NoText}" ToolTip="Update the table with the selected languages."
                           Click="Refresh_Click"/>
        </Grid>

        <c:StatusBand Grid.Row="1" x:Name="StatusBand"/>

        <Grid Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="23"/>
                <RowDefinition/>
            </Grid.RowDefinitions>

            <Label Grid.Row="0" Grid.Column="0" Content="List of text resources and translations " Style="{StaticResource LabelSeparator}"/>
            <DataGrid Grid.Row="1" Grid.Column="0" x:Name="BaseDataGrid" Margin="3" EnableColumnVirtualization="True" RowHeight="22" IsEnabled="False"
                      CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" AutoGenerateColumns="False" HeadersVisibility="Column">

                <DataGrid.Columns>
                    <DataGridTemplateColumn Header="Identifier" Width="220" CanUserSort="True" CanUserReorder="False" SortMemberPath="Key" SortDirection="Ascending">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <c:ExtendedTextBox x:Name="KeyColumn" Style="{StaticResource TextBoxCell}" Height="20" IsReadOnly="True"
                                                   Text="{Binding Key, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                   GotFocus="Itens_GotFocus" PreviewKeyDown="Item_PreviewKeyDown"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTemplateColumn Header="English base translation" Width="*" CanUserSort="True" SortMemberPath="BaseText">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <c:ExtendedTextBox x:Name="KeyColumn" Style="{StaticResource TextBoxCell}" Height="20" IsReadOnly="True"
                                                   Text="{Binding BaseText, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                   GotFocus="Itens_GotFocus" PreviewKeyDown="Item_PreviewKeyDown"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTemplateColumn Header="Selected language translation" Width="*" CanUserSort="True" SortMemberPath="SpecificText">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <c:ExtendedTextBox x:Name="KeyColumn" Style="{StaticResource TextBoxCell}" Height="20" IsReadOnly="{Binding ElementName=ToComboBox, Path=SelectedItem, Converter={StaticResource NullToInvertedBool}}"
                                                   Text="{Binding SpecificText, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                   GotFocus="Itens_GotFocus" PreviewKeyDown="Item_PreviewKeyDown"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
        </Grid>

        <Grid Grid.Row="3" Background="WhiteSmoke">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Column="0" VerticalAlignment="Center" Margin="5"
                       ToolTip="https://github.com/NickeManarin/ScreenToGif/wiki/Localization">
                <Hyperlink RequestNavigate="TutorialHyperlink_RequestNavigate" 
                           NavigateUri="https://github.com/NickeManarin/ScreenToGif/wiki/Localization">
                    <Run Text="Tutorial"/>
                </Hyperlink>
            </TextBlock>

            <TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="5"
                       ToolTip="New Line: &amp;#10;">
                <Hyperlink Click="NewLineHyperlink_Click">
                    <Run Text="Copy [NewLine]"/>
                </Hyperlink>
            </TextBlock>

            <c:ImageButton x:Name="OpenButton" Grid.Column="3" Text="Open" Margin="5" Padding="10,5" MaxSize="20"
                           Content="{StaticResource Vector.Open}" MinWidth="90" MinHeight="20" Command="Open"/>
            <c:ImageButton x:Name="OkButton" Grid.Column="4" Text="Export" Margin="5" Padding="10,5" MaxSize="20"
                           Content="{StaticResource Vector.Save}" MinWidth="90" MinHeight="20" Command="Save"/>
            <c:ImageButton x:Name="CancelButton" Grid.Column="5" Text="Cancel" Margin="5" Padding="10,5" MaxSize="20"
                           Content="{StaticResource Vector.Cancel}" MinWidth="90" MinHeight="20" Click="CancelButton_Click"/>
        </Grid>
    </Grid>
</Window>