<Window x:Class="WinUIResourcesConverter.MainWindow"
        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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WinUIResourcesConverter"
        xmlns:ui="http://schemas.modernwpf.com/2019"
        mc:Ignorable="d" ui:WindowHelper.UseModernWindowStyle="True"
        Title="WinUI Resources Converter" Height="450" Width="800">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </Window.Resources>
    <Grid>
        <ui:SplitView x:Name="SplitView1" DisplayMode="CompactInline" IsPaneOpen="True"
                      PanePlacement="Left" CompactPaneLength="40">
            <Grid>
                <ui:SimpleStackPanel x:Name="MainContentPanel" Spacing="20" Margin="10" VerticalAlignment="Center">
                    <ui:SimpleStackPanel Spacing="5" Orientation="Vertical">
                        <TextBlock Style="{DynamicResource BaseTextBlockStyle}" Text="Source Directory" />
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBox x:Name="TbSourceDirectory" />
                            <Button Margin="5,0,0,0" Grid.Column="1" Click="SelectSourceDirectory">
                                <ui:SymbolIcon Symbol="OpenLocal" />
                            </Button>
                        </Grid>
                        <TextBlock
                            TextWrapping="Wrap"
                            Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}">
                            <Run>The</Run>
                            <Bold>Strings</Bold>
                            <Run>directory of the target control from the</Run>
                            <Bold>local WinUI repo clone</Bold>
                            <Run>that you want to the convert the resources for</Run>
                        </TextBlock>
                    </ui:SimpleStackPanel>
                    <ui:SimpleStackPanel Spacing="5" Orientation="Vertical">
                        <TextBlock Style="{DynamicResource BaseTextBlockStyle}" Text="Destination Directory" />
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBox x:Name="TbDestinationDirectory" />
                            <Button Margin="5,0,0,0" Grid.Column="1" Click="SelectDestinationDirectory">
                                <ui:SymbolIcon Symbol="OpenLocal" />
                            </Button>
                        </Grid>
                        <TextBlock
                            TextWrapping="Wrap"
                            Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}">
                            <Run>The destination</Run>
                            <Bold>Strings</Bold>
                            <Run>directory of the target control that you want to the convert the resources for</Run>
                        </TextBlock>
                    </ui:SimpleStackPanel>
                    <ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="20">
                        <Button x:Name="LoadButton" Click="LoadButton_Click" Content="Load resources"/>
                        <Button x:Name="ConvertButton" Click="ConvertButton_Click"
                                Style="{DynamicResource AccentButtonStyle}" Content="Convert"/>
                    </ui:SimpleStackPanel>
                </ui:SimpleStackPanel>
                <ui:ProgressRing x:Name="ProgressRing1" Width="100" Height="100" />
                <ui:ProgressBar x:Name="ProgressBar1" VerticalAlignment="Top" />
            </Grid>
            <ui:SplitView.Pane>
                <Grid>
                    <ui:ScrollViewerEx Margin="0,40,0,0">
                        <ui:ItemsRepeater Margin="0,10" ItemsSource="{Binding ResourcesFiles}">
                            <ui:ItemsRepeater.Layout>
                                <ui:StackLayout Spacing="10"/>
                            </ui:ItemsRepeater.Layout>
                            <ui:ItemsRepeater.ItemTemplate>
                                <DataTemplate DataType="{x:Type local:ResourcesFile}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="40" />
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <ui:FontIcon Glyph="&#xE10B;" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"
                                                     Visibility="{Binding HasConverted, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                                        <TextBlock Grid.Column="1" VerticalAlignment="Center"  Text="{Binding LanguageName}" />
                                        <Border CornerRadius="{DynamicResource ControlCornerRadius}" BorderThickness="2"
                                                Grid.ColumnSpan="2" Height="40" BorderBrush="{DynamicResource SystemControlBackgroundAccentBrush}"
                                                Visibility="{Binding IsDefaultResource, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                    </Grid>
                                </DataTemplate>
                            </ui:ItemsRepeater.ItemTemplate>
                        </ui:ItemsRepeater>
                    </ui:ScrollViewerEx>
                    <TextBlock Text="{Binding ResourcesFiles.Count, StringFormat='Languages available - {0}'}" VerticalAlignment="Top" Margin="50,10,10,10" />
                </Grid>
            </ui:SplitView.Pane>
        </ui:SplitView>
        <ToggleButton VerticalAlignment="Top" HorizontalAlignment="Left" Width="40" Height="40"
                      IsChecked="{Binding ElementName=SplitView1, Path=IsPaneOpen}" ToolTip="Show details">
            <ui:SymbolIcon Symbol="More" />
        </ToggleButton>
    </Grid>
</Window>
