<ContentDialog
    x:Class="PCUT.Pages.FileAddDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:PCUT.Pages"
    xmlns:viewmodels="using:PCUT.ViewModels"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    PrimaryButtonText="Save"
    CloseButtonText="Cancel"
    PrimaryButtonStyle="{StaticResource PrimaryDialogButton}"
    CloseButtonStyle="{StaticResource CloseDialogButton}"
    PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
    Loaded="ContentDialog_Loaded">

    <ContentDialog.DataContext>
        <viewmodels:FileAddViewModel/>
    </ContentDialog.DataContext>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="2*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" MinWidth="100"/>
            <ColumnDefinition Width="*" MinWidth="200"/>
            <ColumnDefinition Width="*" MaxWidth="280"/>
        </Grid.ColumnDefinitions>
        
        <!--Name Box-->
        <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Text="ADD FILE" FontSize="30" HorizontalAlignment="Center" Margin="10" />

        <!--File Name-->
        <TextBlock
            Grid.Row="1" Grid.Column="0"
            Text="Name:" 
            FontFamily="/Fonts/#Rubik Medium" 
            FontSize="20"
            HorizontalAlignment="Left" />
        <TextBox
            Grid.Row="1" Grid.Column="1"
            x:Name="Name"
            MaxLength="255"
            HorizontalAlignment="Stretch"
            Margin="5,0,5,0"
            PlaceholderText="File Name"
            Text="{Binding Name, Mode=TwoWay}" />

        <!-- Category Name-->
        <TextBlock
            Grid.Row="2" Grid.Column="0"
            Text="Category:" 
            FontFamily="/Fonts/#Rubik Medium" 
            FontSize="20" />
        <ComboBox
            Grid.Row="2" Grid.Column="1"
            x:Name="Category"
            HorizontalAlignment="Stretch"
            Margin="5,0,5,0"
            PlaceholderText="Category"
            ItemsSource="{Binding Categories.Items, Mode=OneWay}"
            DisplayMemberPath="Name"
            SelectedIndex="{Binding Categories.SelectedIndex, Mode=TwoWay}"
            SelectionChanged="Category_SelectionChanged" />

        <!--Type-->
        <TextBlock
            Grid.Row="3" Grid.Column="0" 
            Text="Type:" 
            FontFamily="/Fonts/#Rubik Medium" 
            FontSize="20" />
        <ComboBox
            Grid.Row="3" Grid.Column="1" 
            x:Name="Type"
            HorizontalAlignment="Stretch"
            Margin="5,0,5,0"
            PlaceholderText="Type"
            ItemsSource="{Binding MetadataModel.Types.Items, Mode=OneWay}"
            DisplayMemberPath="Value"
            SelectedIndex="{Binding MetadataModel.Types.SelectedIndex, Mode=TwoWay}" />

        <!--Brand-->
        <TextBlock
            Grid.Row="4" Grid.Column="0" 
            Text="Brand:" 
            FontFamily="/Fonts/#Rubik Medium" 
            FontSize="20" />
        <ComboBox
            Grid.Row="4" Grid.Column="1" 
            x:Name="Brand" 
            HorizontalAlignment="Stretch"
            Margin="5,0,5,0"
            PlaceholderText="Brand"
            ItemsSource="{Binding MetadataModel.Brands.Items, Mode=OneWay}"
            DisplayMemberPath="Value"
            SelectedIndex="{Binding MetadataModel.Brands.SelectedIndex, Mode=TwoWay}" />

        <!--Series-->
        <TextBlock
            Grid.Row="5" Grid.Column="0" 
            Text="Series:" 
            FontFamily="/Fonts/#Rubik Medium" 
            FontSize="20"/>
        <ComboBox
            Grid.Row="5" Grid.Column="1" 
            x:Name="Series" 
            HorizontalAlignment="Stretch"
            Margin="5,0,5,0"
            PlaceholderText="Series"
            ItemsSource="{Binding MetadataModel.Series.Items, Mode=OneWay}"
            DisplayMemberPath="Value"
            SelectedIndex="{Binding MetadataModel.Series.SelectedIndex, Mode=TwoWay}" />

        <!--Model-->
        <TextBlock
            Grid.Row="6" Grid.Column="0" 
            Text="Model:" 
            FontFamily="/Fonts/#Rubik Medium" 
            FontSize="20"/>
        <ComboBox
            Grid.Row="6" Grid.Column="1" 
            x:Name="Model"
            HorizontalAlignment="Stretch"
            Margin="5,0,5,0"
            PlaceholderText="Model"
            ItemsSource="{Binding MetadataModel.Models.Items, Mode=OneWay}"
            DisplayMemberPath="Value"
            SelectedIndex="{Binding MetadataModel.Models.SelectedIndex, Mode=TwoWay}" />

        <!-- Sub Type-->
        <TextBlock
            Grid.Row="7" Grid.Column="0" 
            Text="Sub Type:" 
            FontFamily="/Fonts/#Rubik Medium" 
            FontSize="20"/>
        <ComboBox
            Grid.Row="7" Grid.Column="1" 
            x:Name="SubType"
            HorizontalAlignment="Stretch"
            Margin="5,0,5,0"
            PlaceholderText="Sub Type"
            ItemsSource="{Binding MetadataModel.SubTypes.Items, Mode=OneWay}"
            DisplayMemberPath="Value"
            SelectedIndex="{Binding MetadataModel.SubTypes.SelectedIndex, Mode=TwoWay}" />

        <!--Year-->
        <TextBlock
            Grid.Row="8" Grid.Column="0" 
            Text="Year:" 
            FontFamily="/Fonts/#Rubik Medium"
            FontSize="20"/>
        <ComboBox
            Grid.Row="8" Grid.Column="1"
            x:Name="Year"
            HorizontalAlignment="Left"
            Margin="5,0,5,0"
            PlaceholderText="Year"
            ItemsSource="{Binding MetadataModel.Years.Items, Mode=OneWay}"
            DisplayMemberPath="Value"
            SelectedIndex="{Binding MetadataModel.Years.SelectedIndex, Mode=TwoWay}" />

        <!--Area-->
        <TextBlock
            Grid.Row="9" Grid.Column="0"  
            Text="Area:" 
            FontFamily="/Fonts/#Rubik Medium" 
            FontSize="20"/>
        <TextBox
            Grid.Row="9" Grid.Column="1"
            Grid.ColumnSpan="2"
            x:Name="Area"
            HorizontalAlignment="Stretch"
            Margin="5,0,5,0"
            PlaceholderText="Area"
            Text="{Binding Area, Mode=TwoWay}" />

        <!--Remarks-->
        <TextBlock
            Grid.Row="10" Grid.Column="0"
            Text="Remarks:" 
            FontFamily="/Fonts/#Rubik Medium" 
            FontSize="20"/>
        <TextBox
            Grid.Row="10" Grid.Column="1"
            Grid.ColumnSpan="2"
            x:Name="Remark"
            AcceptsReturn="True"
            TextWrapping="Wrap"
            MinHeight="69"
            MaxHeight="69"
            HorizontalAlignment="Stretch"
            Margin="5,0,5,0"
            PlaceholderText="Remark"
            Text="{Binding Remarks, Mode=TwoWay}" />

        <!--Button-->
        <Button
            Grid.Row="1" Grid.Column="2"
            Margin="10,0,0,0"
            Click="UploadFile_CLick">
            <Button.Template>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <Path Fill="SkyBlue" Data="M20,10 C20,4.48 24.48,0 30,0 C35.52,0 40,4.48 40,10 C40,10 45.52,10 50,10 C54.48,10 60,14.48 60,20 C60,25.52 55.52,30 50,30 L20,30 C14.48,30 10,25.52 10,20 C10,14.48 14.48,10 20,10 Z"/>
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Grid>
                </ControlTemplate>
            </Button.Template>
            <Button.Content>
                <TextBlock Text="Add File" FontSize="10" Margin="10,5,0,0"/>
            </Button.Content>
        </Button>
        <Viewbox Grid.Row="2" Grid.Column="2" Grid.RowSpan="6">
            <Image x:Name="ThumbnailPreview" Source="{Binding PreviewSource, Mode=OneWay}" />
        </Viewbox>
    </Grid>
</ContentDialog>
