<adonisControls:AdonisWindow x:Class="FModel.Views.DirectorySelector"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:FModel.Views.Resources.Controls"
        xmlns:converters="clr-namespace:FModel.Views.Resources.Converters"
        xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI"
        xmlns:adonisControls="clr-namespace:AdonisUI.Controls;assembly=AdonisUI"
        xmlns:adonisExtensions="clr-namespace:AdonisUI.Extensions;assembly=AdonisUI"
        WindowStartupLocation="CenterScreen" ResizeMode="NoResize" IconVisibility="Collapsed" SizeToContent="Height"
        MinHeight="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenHeight}, Converter={converters:RatioConverter}, ConverterParameter='0.20'}"
        Width="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenWidth}, Converter={converters:RatioConverter}, ConverterParameter='0.25'}"
        AllowDrop="True">
    <adonisControls:AdonisWindow.Style>
        <Style TargetType="adonisControls:AdonisWindow" BasedOn="{StaticResource {x:Type adonisControls:AdonisWindow}}" >
            <Setter Property="Title" Value="Directory Selector" />
        </Style>
    </adonisControls:AdonisWindow.Style>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Orientation="Vertical" Margin="10 5 10 10">
            <TextBlock Text="Instruction" HorizontalAlignment="Center" FontSize="20" FontWeight="SemiBold" />
            <TextBlock TextAlignment="Center" TextWrapping="Wrap" HorizontalAlignment="Center"
                       Text="We like to make things as simple as possible. Choose between the detected games or manually add your own. FModel will use this information to automatically find archives to load and decrypt if needed. Make sure to not skip this step!" />
        </StackPanel>

        <GroupBox Grid.Row="1" adonisExtensions:LayerExtension.Layer="2" Margin="10 10 10 18"
                  Padding="{adonisUi:Space 0}" Background="Transparent">
            <StackPanel>
                <Grid x:Name="Hello" Margin="0 5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="10" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="5" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <TextBlock Grid.Row="0" Grid.Column="0" Text="Detected Game" VerticalAlignment="Center" Margin="0 0 0 5" />
                    <controls:FilterableComboBox Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="3"
                                                 ItemsSource="{Binding DetectedDirectories}" Margin="0 0 0 5"
                                                 Style="{StaticResource UComboBox}"
                                                 adonisExtensions:WatermarkExtension.Watermark="Search for a game..."
                                                 VerticalAlignment="Center" SelectedItem="{Binding SelectedDirectory, Mode=TwoWay}">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding GameName, Converter={x:Static converters:StringToGameConverter.Instance}}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </controls:FilterableComboBox>

                    <TextBlock Grid.Row="1" Grid.Column="0" Text="UE Versions" VerticalAlignment="Center" Margin="0 0 0 5" />
                    <controls:FilterableComboBox Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5"
                                                 ItemsSource="{Binding UeGames}"
                                                 Style="{StaticResource UComboBox}"
                                                 VerticalAlignment="Center" SelectedItem="{Binding SelectedDirectory.UeVersion, Mode=TwoWay}">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </controls:FilterableComboBox>

                    <TextBlock Grid.Row="2" Grid.Column="0" Text="Directory" VerticalAlignment="Center" />
                    <TextBox Grid.Row="2" Grid.Column="2" Text="{Binding SelectedDirectory.GameDirectory, Mode=TwoWay}" />
                    <Button Grid.Row="2" Grid.Column="4" Content="..." HorizontalAlignment="Right" Click="OnBrowseDirectories" />
                    <Button Grid.Row="2" Grid.Column="4" Style="{DynamicResource {x:Static adonisUi:Styles.AccentButton}}" Padding="0"
                            Click="OnDeleteDirectory" Width="{Binding ActualWidth, ElementName=OkGuysButWhoFuckingAsked}" ToolTip="Delete Game"
                            Visibility="{Binding SelectedDirectory.IsManual, Converter={StaticResource BoolToVisibilityConverter}}">
                        <Viewbox Width="16" Height="16" HorizontalAlignment="Center">
                            <Canvas Width="24" Height="24">
                                <Path Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" Data="{StaticResource RemoveIcon}" />
                            </Canvas>
                        </Viewbox>
                    </Button>
                </Grid>

                <Separator Style="{StaticResource CustomSeparator}" Tag="ADD UNDETECTED GAME" Margin="0,0,0,0"/>
                <TextBlock Text="Drag &amp; drop folder to quickly configure new game" 
                           HorizontalAlignment="Center"
                           Foreground="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}"
                           Margin="0,0,0,5" />
                <Expander x:Name="ManualGameExpander" ExpandDirection="Down" IsExpanded="False">
                    <Grid MaxWidth="{Binding ActualWidth, ElementName=Hello}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="5" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="5" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="5" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Row="0" Grid.Column="0" Text="Name" VerticalAlignment="Center" />
                        <TextBox x:Name="HelloMyNameIsGame" Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="5" />

                        <TextBlock Grid.Row="2" Grid.Column="0" Text="Directory" VerticalAlignment="Center" />
                        <TextBox x:Name="HelloGameMyNameIsDirectory" Grid.Row="2" Grid.Column="2" />
                        <Button x:Name="OkGuysButWhoFuckingAsked" Grid.Row="2" Grid.Column="4" Content="..." HorizontalAlignment="Right" Click="OnBrowseManualDirectories" />
                        <Button Grid.Row="2" Grid.Column="6" Style="{DynamicResource {x:Static adonisUi:Styles.AccentButton}}" Padding="0"
                                Click="OnAddDirectory" ToolTip="Add Game" Width="{Binding ActualWidth, ElementName=OkGuysButWhoFuckingAsked}">
                            <Viewbox Width="16" Height="16" HorizontalAlignment="Center">
                                <Canvas Width="24" Height="24">
                                    <Path Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" Data="{StaticResource AddIcon}" />
                                </Canvas>
                            </Viewbox>
                        </Button>
                    </Grid>
                </Expander>
            </StackPanel>
        </GroupBox>

        <Border Grid.Row="2"
                Background="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}"
                adonisExtensions:LayerExtension.IncreaseLayer="True">
            <Grid Margin="30, 12, 6, 12">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <Button Grid.Column="1" MinWidth="78" Margin="0 0 12 0" IsDefault="True" IsCancel="False"
                        HorizontalAlignment="Right" VerticalAlignment="Bottom" Content="OK" Click="OnClick" />
                <Button Grid.Column="2" MinWidth="78" Margin="0 0 12 0" IsDefault="False"  IsCancel="True"
                        HorizontalAlignment="Right" VerticalAlignment="Bottom" Content="Cancel" />
            </Grid>
        </Border>
        <controls:DropOverlay Grid.RowSpan="99"
                              Grid.ColumnSpan="99"
                              Panel.ZIndex="1000" />
    </Grid>
</adonisControls:AdonisWindow>
