<UserControl x:Class="SmartAquaViewer.View.FileListView"
             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:SmartAquaViewer.View"
             xmlns:vm="clr-namespace:SmartAquaViewer.ViewModel"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             mc:Ignorable="d" 
             d:DesignHeight="1040" d:DesignWidth="270">

    <UserControl.DataContext>
        <vm:FileListViewModel/>
    </UserControl.DataContext>

    <Border>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="100"/>
                <!-- Header Row -->
                <RowDefinition Height="*"/>
                <!-- File List Row -->
            </Grid.RowDefinitions>
            <Grid>
                <Image Source="/Resources/Images/ListImage.png"
                       Width="35" Margin="20 0"
                       HorizontalAlignment="Left"/>
                <TextBlock Text="파일 목록" FontFamily="{StaticResource SCDream5}"
                           FontSize="20" FontWeight="Bold" Foreground="White"
                           HorizontalAlignment="Center" VerticalAlignment="Center"
                           Margin="0 0 30 0"/>
                <Button Width="40" Height="40" 
                        Margin="20 0" Padding="0"
                        HorizontalAlignment="Right"
                        Background="#ffd663"
                        Command="{Binding OpenFileDialogCommand}">
                    <materialDesign:PackIcon Kind="FolderAdd"/>
                </Button>
            </Grid>

            <TextBlock Grid.Row="1" Text="파일을 업로드하세요"
                       VerticalAlignment="Center" HorizontalAlignment="Center"
                       FontSize="16" FontWeight="Medium" Foreground="Gray"
                       FontFamily="{StaticResource SCDream4}">
                <TextBlock.Style>
                    <Style TargetType="TextBlock">
                        <Setter Property="Visibility" Value="Collapsed"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding FileList.Count}" Value="0">
                                <Setter Property="Visibility" Value="Visible"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>

            <ScrollViewer Grid.Row="1" Margin="10" >
                <ListView             
                      ItemsSource="{Binding FileList}" 
                      SelectedItem="{Binding SelectedFile}"
                      ScrollViewer.VerticalScrollBarVisibility="Hidden"
                      BorderThickness="0" Background="Transparent">
                    <ListView.ItemContainerStyle>
                        <Style TargetType="ListViewItem">
                            <Setter Property="Margin" Value="2"/>
                            <Style.Triggers>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter Property="Background" Value="LightSkyBlue"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ListView.ItemContainerStyle>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0 5">
                                <TextBlock Text="{Binding Name}" Margin="5"
                                           FontSize="16" FontWeight="Medium" Foreground="White"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </ScrollViewer>
        </Grid>
    </Border>
</UserControl>
