<sync:ChromelessWindow
    x:Class="AppFramework.Views.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:coll="clr-namespace:System.Collections;assembly=mscorlib"
    xmlns:const="clr-namespace:AppFramework.Common;assembly=AppFramework.Common"
    xmlns:converter="clr-namespace:AppFramework.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="http://prismlibrary.com/"
    xmlns:region="clr-namespace:AppFramework.Common;assembly=AppFramework.Common"
    xmlns:sync="http://schemas.syncfusion.com/wpf"
    xmlns:win="clr-namespace:AppFramework.WindowHost"
    Title="AppFramework"
    MinWidth="1280"
    MinHeight="768"
    d:DesignHeight="450"
    d:DesignWidth="800"
    prism:ViewModelLocator.AutoWireViewModel="True"
    BorderBrush="Transparent"
    Icon="/Assets/Images/logo.ico"
    TitleBarHeight="0"
    WindowStartupLocation="CenterScreen"
    mc:Ignorable="d">
    <sync:ChromelessWindow.Resources>
        <converter:DarkModeConverter x:Key="darkConverter" />
    </sync:ChromelessWindow.Resources>
    <win:DialogHost Identifier="{x:Static const:AppCommonConsts.RootIdentifier}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition MaxWidth="240" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <Border
                x:Name="HeaderBorder"
                Grid.ColumnSpan="2"
                Opacity="0.5"
                Style="{DynamicResource HeaderBorderStyle}" />
            <Border Grid.Row="1" Style="{DynamicResource HeaderBorderStyle}" />

            <!--  顶部标题  -->
            <StackPanel
                Grid.ColumnSpan="2"
                Margin="20,25"
                HorizontalAlignment="Left"
                VerticalAlignment="Center"
                Orientation="Horizontal">
                <Image
                    Width="20"
                    Height="20"
                    Source="/Assets/Images/logo.ico" />
                <TextBlock
                    Margin="5,0,2,0"
                    FontWeight="Bold"
                    Foreground="{DynamicResource PrimaryBackground}"
                    Text="APP" />
                <TextBlock Text="FRAMEWORK" />
            </StackPanel>

            <!--  顶部按钮功能 主题/最小化/最大化/退出系统  -->
            <StackPanel
                Grid.Column="1"
                Margin="5"
                HorizontalAlignment="Right"
                VerticalAlignment="Top"
                Orientation="Horizontal">
                <sync:DropDownButtonAdv
                    Width="50"
                    Margin="5,0"
                    Padding="0,2"
                    Background="Transparent"
                    BorderThickness="0"
                    Label=""
                    SmallIcon="/Assets/Images/color.png">
                    <ItemsControl ItemsSource="{Binding themeService.ThemeItems}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Button
                                    Padding="5"
                                    Background="Transparent"
                                    BorderThickness="0"
                                    Command="{Binding DataContext.SetThemeCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"
                                    CommandParameter="{Binding}"
                                    Content="{Binding DisplayName}" />
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </sync:DropDownButtonAdv>
                <Button
                    Background="Transparent"
                    Command="{Binding SetThemeModeCommand}"
                    Content="{Binding themeService.IsDarkTheme, Converter={StaticResource darkConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                    Style="{DynamicResource IconButtonStyle}" />


                <Button
                    VerticalAlignment="Center"
                    Background="Transparent"
                    Command="{Binding LogOutCommand}"
                    Content=" &#xe652;"
                    Style="{DynamicResource IconButtonStyle}" />
                <Button
                    x:Name="BtnMin"
                    VerticalAlignment="Center"
                    Background="Transparent"
                    Content="&#xe729;"
                    Style="{DynamicResource IconButtonStyle}" />
                <Button
                    x:Name="BtnMax"
                    Margin="5,0"
                    VerticalAlignment="Center"
                    Background="Transparent"
                    Content="&#xe67b;"
                    Style="{DynamicResource IconButtonStyle}" />
                <Button
                    x:Name="BtnClose"
                    VerticalAlignment="Center"
                    Background="Transparent"
                    Content="&#xe63a;"
                    Style="{DynamicResource IconButtonStyle}" />
            </StackPanel>

            <!--  左侧系统菜单  -->
            <ListBox
                x:Name="ListMenuBox"
                Grid.Row="1"
                Margin="10"
                ItemsSource="{Binding appService.NavigationItems}">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Padding" Value="10,3" />
                        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <Grid>
                                        <Border
                                            x:Name="htborder"
                                            HorizontalAlignment="Left"
                                            Panel.ZIndex="1"
                                            Background="{DynamicResource PrimaryBackground}"
                                            CornerRadius="2"
                                            Opacity="1"
                                            Style="{DynamicResource BorderStyle}" />
                                        <Border
                                            x:Name="hdborder"
                                            Margin="0,2"
                                            Style="{DynamicResource BorderStyle}" />
                                        <Border
                                            x:Name="border"
                                            Margin="0,2"
                                            Padding="{TemplateBinding Padding}"
                                            CornerRadius="3">
                                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                        </Border>
                                    </Grid>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsSelected" Value="True">
                                            <Setter Property="Foreground" Value="{DynamicResource PrimaryBackground}" />
                                            <Setter TargetName="hdborder" Property="Opacity" Value="1" />
                                            <Setter TargetName="htborder" Property="Width" Value="3" />
                                            <Trigger.EnterActions>
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <ThicknessAnimation
                                                            Storyboard.TargetName="htborder"
                                                            Storyboard.TargetProperty="Margin"
                                                            From="5"
                                                            To="5,10"
                                                            Duration="0:0:.2" />
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </Trigger.EnterActions>
                                        </Trigger>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="Foreground" Value="{DynamicResource PrimaryBackground}" />
                                            <Setter TargetName="hdborder" Property="Opacity" Value="1" />
                                        </Trigger>
                                        <Trigger Property="IsSelected" Value="False">
                                            <Setter TargetName="hdborder" Property="Opacity" Value="0" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="5" Orientation="Horizontal">
                            <TextBlock
                                VerticalAlignment="Center"
                                FontFamily="/Assets/Fonts/#iconfont"
                                FontSize="18"
                                Style="{x:Null}"
                                Text="{Binding Icon}"
                                ToolTip="{Binding Title}" />
                            <TextBlock
                                Margin="10,0,0,0"
                                VerticalAlignment="Center"
                                FontSize="14"
                                Style="{x:Null}"
                                Text="{Binding Title}" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <i:InvokeCommandAction Command="{Binding NavigateCommand}" CommandParameter="{Binding ElementName=ListMenuBox, Path=SelectedItem}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </ListBox>

            <!--  显示页  -->
            <ContentControl
                Grid.Row="1"
                Grid.Column="1"
                prism:RegionManager.RegionName="{x:Static region:AppRegionManager.Main}" />
        </Grid>
    </win:DialogHost>
</sync:ChromelessWindow>