<UserControl x:Class="HistoryView.Controls.FileSelector.DirectorySelector"
             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:HistoryView.Controls.FileSelector"
             xmlns:resource="clr-namespace:HistoryView.Resources"
             mc:Ignorable="d" 
             x:Name="This"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <Style TargetType="Button">
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True" CornerRadius="0">
                            <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="4"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="border" Property="Background" Value="{StaticResource SubThemeColor}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>

                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Border  BorderThickness="0" BorderBrush="Black">
        
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition  Width="160" />
                <ColumnDefinition Width="0"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Border Background="{StaticResource LightThemeColor}" BorderBrush="{StaticResource ThemeColor}" BorderThickness="0" CornerRadius="0,0,0,8">

                <StackPanel>
                    <!--<Expander Background="Transparent" VerticalAlignment="Top" Margin="4" IsExpanded="True">-->
                        <!--<Expander.Header>
                            <Border CornerRadius="4">
                                <TextBlock FontWeight="Bold" Margin="4" Foreground="{StaticResource ThemeColor}" VerticalAlignment="Center">磁盘空间</TextBlock>
                            </Border>
                        </Expander.Header>-->
                        <Border Background="{StaticResource LightThemeColor}" Margin="0">
                            <ItemsControl ItemsSource="{Binding ElementName=This, Path=BaseFolder}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Button Background="Transparent" Foreground="Transparent" Click="Button_Click" CommandParameter="{Binding}">
                                            <local:FileHorizontal ImageSource="{Binding ImageSource}" FileName="{Binding Name}" Background="Transparent" TextElement.Foreground="{StaticResource ThemeColor}" Height="48"/>
                                        </Button>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </Border>
                    <!--</Expander>-->
    
                </StackPanel>
            </Border>

            <Grid Grid.Column="2">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="0"/>
                    <RowDefinition/>
                    <RowDefinition Height="0"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>

                <Border BorderBrush="{StaticResource ThemeColor}" Background="{StaticResource LightThemeColor}" >
                    <Grid Margin="0,4">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="0"/>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <!--<TextBlock FontWeight="Bold" Margin="4" Foreground="{StaticResource ThemeColor}">快速导航栏</TextBlock>-->

                        <Grid  Grid.Row="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition Width="12"/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <Button Style="{StaticResource FunctionButton}" Click="Button_Click_1" VerticalAlignment="Center" Height="28">
                                <TextBlock Text="&lt;" FontSize="14" FontWeight="Bold"/>
                            </Button>

                            <ItemsControl Grid.Column="2" ItemsSource="{Binding ElementName=This, Path=Parents}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <Button Style="{StaticResource FunctionButton}" Background="{StaticResource DarkBorderColor}" Click="Button_Click" CommandParameter="{Binding Value}" VerticalAlignment="Center"  Margin="4,2">
                                                <TextBlock VerticalAlignment="Center" Text="{Binding Value.Name}"/>
                                            </Button>
                                            <TextBlock VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Foreground="{StaticResource TextColor}" Margin="4,2">></TextBlock>
                                        </StackPanel>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <WrapPanel Orientation="Horizontal"/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>

                        </Grid>
                    </Grid>
                </Border>

                <Border Grid.Row="2"  BorderBrush="{StaticResource ThemeColor}" Background="{StaticResource BackgroundColor}" CornerRadius="0,0,8,0">
                    <resource:TouchableScrollViewer VerticalScrollBarVisibility="Hidden">
                        <ItemsControl ItemsSource="{Binding ElementName=This, Path=Displays}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Button Background="Transparent" Click="Button_Click" CommandParameter="{Binding}" VerticalAlignment="Top">
                                        <local:FileVertical ImageSource="{Binding ImageSource}" FileName="{Binding Name}" FileType="{Binding FileType}" Background="Transparent" TextElement.Foreground="{StaticResource ThemeColor}" Width="96"/>
                                    </Button>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapPanel Margin="8" VerticalAlignment="Top" HorizontalAlignment="Left"/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                        </ItemsControl>
                    </resource:TouchableScrollViewer>

                </Border>

                <Border Grid.Row="4" Background="Transparent" BorderBrush="{StaticResource DarkBorderColor}" BorderThickness="0,1,0,0">
                    <Grid Margin="8">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="8"/>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="8"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="8"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Margin="4" VerticalAlignment="Center" Text="文件选择："/>
                        <Border Grid.Column="2" Background="#cadce9" CornerRadius="4">
                            <TextBlock Margin="8,4" VerticalAlignment="Center" Text="{Binding ElementName=This, Path=SelectedFile.Name}"/>
                        </Border>
                        <Button Style="{StaticResource FunctionButton}" Grid.Column="4" Width="80" Height="28" Command="{Binding ElementName=This, Path=Confirm}">选择</Button>
                        <Button Style="{StaticResource FunctionButton}" Grid.Column="6" Width="80" Height="28" Command="{Binding ElementName=This,Path=Cancel}" Background="{StaticResource BackgroundDarkColor}">取消</Button>
                    </Grid>
                </Border>
            </Grid>
        </Grid>
    </Border>
</UserControl>
