<UserControl x:Class="FFXIV_TexTools.Views.Item.ItemViewControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:FFXIV_TexTools.Views.Item"
             xmlns:controls="clr-namespace:FFXIV_TexTools.Views.Controls"
            xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
            xmlns:metroControls="http://metro.mahapps.com/winfx/xaml/controls"
            xmlns:resx="clr-namespace:FFXIV_TexTools.Resources"
            xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"></RowDefinition>
            <RowDefinition Height="60"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
        </Grid.RowDefinitions>


        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="60"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="60"></ColumnDefinition>
            </Grid.ColumnDefinitions>


            <Button x:Name="RefreshButton" Margin="5" Grid.Column="0" IsEnabled="{Binding Path=RefreshEnabled}" Click="RefreshButton_Click" ToolTip="Reload the currently selected item from the Game Files/Transaction.">
                <iconPacks:Material Kind="Refresh" Height="12"/>
            </Button>


            <TextBox Grid.Column="1" IsReadOnly="True" Margin="5" TextAlignment="Center" x:Name="ItemNameBox" VerticalContentAlignment="Center" Text="{Binding Path=ItemNameText}"/>

            <Button x:Name="PopOutButton" Margin="5" Grid.Column="2" IsEnabled="{Binding Path=RefreshEnabled}" Click="PopOut_Click" ToolTip="Pop this item out in a new window.">
                <iconPacks:PackIconFontAwesome Kind="ExternalLinkSquareAltSolid" Height="12"/>
            </Button>
        </Grid>

        <Grid x:Name="ComboGrid" Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="60"></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <Button Grid.Column="0" Margin="5" Click="ShowExtraButtons_Click" ToolTip="Show/hide the addtional options panel." x:Name="ShowExtraButtonsButton">
                <iconPacks:PackIconFontAwesome Kind="BarsSolid"/>
            </Button>

            <Border x:Name="ModelBorder"  Grid.Column="1"  Margin="3" BorderBrush="Black" BorderThickness="2" >
                <Grid x:Name="ModelGrid" IsEnabled="{Binding Path=ModelsEnabled}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="60"></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button Grid.Column="0" Click="ShowModel_Click" ToolTip="View or edit the currently selected Model.">
                        <iconPacks:PackIconMaterial Kind="Eye"/>
                    </Button>

                    <ComboBox Grid.Column="1" x:Name="ModelComboBox" mah:TextBoxHelper.UseFloatingWatermark="True" mah:TextBoxHelper.Watermark="Model" 
                              DropDownClosed="ModelComboBox_DropDownClosed"
                              DropDownOpened="Combobox_DropdownOpened"
                      ItemsSource="{Binding Path=Models}" DisplayMemberPath="Key" SelectedValuePath="Value" SelectionChanged="Model_Changed"/>

                </Grid>
            </Border>

            <Border x:Name="MaterialBorder"  Grid.Column="2"    Margin="3" BorderBrush="Black" BorderThickness="2"  >
                <Grid x:Name="MaterialGrid" IsEnabled="{Binding Path=MaterialsEnabled}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="60"></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>

                    <Button Grid.Column="0" Click="ShowMaterial_Click" ToolTip="View or edit the currently selected Material.">
                        <iconPacks:PackIconMaterial Kind="Eye"/>
                    </Button>
                    <ComboBox Grid.Column="2" x:Name="MaterialComboBox" mah:TextBoxHelper.UseFloatingWatermark="True" mah:TextBoxHelper.Watermark="Material"
                              DropDownClosed="MaterialComboBox_DropDownClosed"
                              DropDownOpened="Combobox_DropdownOpened"
                          ItemsSource="{Binding Path=Materials}" DisplayMemberPath="Key" SelectedValuePath="Value" SelectionChanged="Material_Changed"/>
                </Grid>
            </Border>

            <Border x:Name="TextureBorder" Grid.Column="3"   Margin="3" BorderBrush="Black" BorderThickness="2" >
                <Grid x:Name="TextureGrid" IsEnabled="{Binding Path=TexturesEnabled}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="60"></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button Grid.Column="0" Click="ShowTexture_Click" ToolTip="View or edit the currently selected Texture.">
                        <iconPacks:PackIconMaterial Kind="Eye"/>
                    </Button>

                    <ComboBox Grid.Column="3" x:Name="TextureComboBox" mah:TextBoxHelper.UseFloatingWatermark="True" mah:TextBoxHelper.Watermark="Texture" 
                              DropDownClosed="TextureComboBox_DropDownClosed"
                              DropDownOpened="Combobox_DropdownOpened"
                      ItemsSource="{Binding Path=Textures}" DisplayMemberPath="Key" SelectedValuePath="Value" SelectionChanged="Texture_Changed"/>
                </Grid>
            </Border>
        </Grid>


        <Grid x:Name="ButtonGrid" Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200"></ColumnDefinition>
                <ColumnDefinition Width="200"></ColumnDefinition>
                <ColumnDefinition Width="200"></ColumnDefinition>
                <ColumnDefinition Width="200"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="40"/>
                <RowDefinition Height="5"/>
            </Grid.RowDefinitions>
            <Button Content="View/Edit Metadata" Margin="5" Grid.Column="0" Click="ShowMetadata_Click" IsEnabled="{Binding Path=MetadataEnabled}"></Button>
            <Button Content="Variant List" Margin="5" Grid.Column="1" Click="ItemInfo_Click" IsEnabled="{Binding Path=ItemInfoEnabled}"></Button>
            <Button Content="Delete Orphaned Files" Margin="5" Grid.Column="2" Click="RemoveOrphans_Click" IsEnabled="{Binding Path=AddMaterialEnabled}"></Button>
            <Button Content="Add New Material" Margin="5" Grid.Column="3" Click="AddMaterial_Click" IsEnabled="{Binding Path=AddMaterialEnabled}"></Button>

            <Separator Grid.Row="1" Grid.ColumnSpan="5"></Separator>
        </Grid>

        
        <Grid x:Name="FileGrid" Grid.Row="3">
            <controls:FileWrapperControl x:Name="ModelWrapper" Visibility="Collapsed"></controls:FileWrapperControl>
            <controls:FileWrapperControl x:Name="MaterialWrapper" Visibility="Collapsed"></controls:FileWrapperControl>
            <controls:FileWrapperControl x:Name="TextureWrapper" Visibility="Collapsed"></controls:FileWrapperControl>
            <controls:FileWrapperControl x:Name="MetadataWrapper" Visibility="Collapsed"></controls:FileWrapperControl>
        </Grid>

    </Grid>
</UserControl>
