<Window
    x:Class="PDF_Office.Views.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:convert="clr-namespace:PDF_Office.DataConvert"
    xmlns:cus="clr-namespace:PDF_Office.CustomControl"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz"
    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
    xmlns:local="clr-namespace:PDF_Office"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="http://prismlibrary.com/"
    xmlns:viewmodels="clr-namespace:PDF_Office.ViewModels"
    Width="1280"
    Height="800"
    MinWidth="540"
    MinHeight="460"
    prism:ViewModelLocator.AutoWireViewModel="True"
    Activated="Window_Activated"
    Closed="Window_Closed"
    Style="{StaticResource WindowStyle}"
    UseLayoutRounding="True"
    WindowStartupLocation="CenterScreen"
    mc:Ignorable="d">
    <Window.Resources>
        <ResourceDictionary>
            <Style x:Key="DragablzItemStyle" TargetType="{x:Type dragablz:DragablzItem}">
                <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
                <Setter Property="Foreground" Value="{StaticResource color.sys.text.neutral.lv2}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="dragablz:DragablzItem">
                            <Grid x:Name="templateRoot">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="auto" />
                                </Grid.ColumnDefinitions>
                                <Border
                                    x:Name="Title"
                                    Width="184"
                                    Height="34"
                                    Margin="4,6,0,2"
                                    BorderBrush="{StaticResource color.sys.border.neutral.lv3}"
                                    BorderThickness="0"
                                    CornerRadius="4,4,0,0"
                                    WindowChrome.IsHitTestVisibleInChrome="True">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="auto" />
                                            <ColumnDefinition Width="*" MinWidth="10" />
                                            <ColumnDefinition Width="auto" />
                                        </Grid.ColumnDefinitions>
                                        <StackPanel Orientation="Horizontal">
                                            <Path
                                                Name="Ico_Home"
                                                Width="20"
                                                Height="20"
                                                Margin="8,7,0,7"
                                                Data="M3.8655 5.79659C3.32363 6.16983 3 6.78571 3 7.44369V15.0001C3 16.1046 3.89543 17.0001 5 17.0001H9V12.1786H11V17.0001H15C16.1046 17.0001 17 16.1046 17 15.0001V7.44369C17 6.78571 16.6764 6.16983 16.1345 5.79659L11.1345 2.35266C10.4514 1.88212 9.54865 1.88212 8.8655 2.35266L3.8655 5.79659Z"
                                                Fill="{TemplateBinding Foreground}"
                                                Visibility="Collapsed" />
                                            <TextBlock
                                                x:Name="TextTitle"
                                                MaxWidth="145"
                                                Margin="8,7"
                                                VerticalAlignment="Center"
                                                FontFamily="Segoe UI,Microsoft YaHei"
                                                Foreground="{TemplateBinding Foreground}"
                                                Text="{Binding DataContext.FileName}"
                                                TextTrimming="WordEllipsis" />
                                        </StackPanel>
                                        <Thumb
                                            x:Name="PART_Thumb"
                                            Grid.ColumnSpan="2"
                                            HorizontalAlignment="Stretch"
                                            VerticalContentAlignment="Stretch"
                                            Background="Transparent"
                                            FontFamily="Segoe UI,Microsoft YaHei"
                                            ToolTip="{Binding DataContext.FileName}">
                                            <Thumb.Template>
                                                <ControlTemplate>
                                                    <Grid Background="Transparent" />
                                                </ControlTemplate>
                                            </Thumb.Template>
                                        </Thumb>
                                        <TextBlock
                                            x:Name="ChangeIcon"
                                            Grid.Column="1"
                                            Width="5"
                                            Margin="3,4,2,0"
                                            HorizontalAlignment="Left"
                                            VerticalAlignment="Top"
                                            Foreground="{TemplateBinding Foreground}"
                                            IsHitTestVisible="False"
                                            Text="*"
                                            Visibility="{Binding DataContext.FileChanged}" />
                                        <Button
                                            Grid.Column="2"
                                            Width="16"
                                            Height="16"
                                            Margin="0,4,8,4"
                                            Background="Transparent"
                                            BorderThickness="0"
                                            Command="{Binding DataContext.CloseTab}"
                                            CommandParameter="{Binding}">
                                            <Path Data="M6.50006 7.06072L9.96973 10.5304L11.0304 9.46973L7.56072 6.00006L11.0304 2.53039L9.96973 1.46973L6.50006 4.9394L3.03039 1.46973L1.96973 2.53039L5.4394 6.00006L1.96973 9.46973L3.03039 10.5304L6.50006 7.06072Z" Fill="{StaticResource color.icon.base.neutral.norm.lv2}" />
                                        </Button>
                                    </Grid>
                                </Border>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter TargetName="Title" Property="Background" Value="{StaticResource color.sys.layout.mg}" />
                                    <Setter Property="Foreground" Value="{StaticResource color.sys.text.neutral.lv1}" />
                                    <Setter TargetName="Title" Property="BorderThickness" Value="0,0,0,1" />
                                </Trigger>
                                <Trigger Property="IsSelected" Value="False">
                                    <Setter TargetName="Title" Property="Background" Value="TransParent" />
                                </Trigger>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="Title" Property="Background" Value="{StaticResource color.item-state.hov.bg}" />
                                </Trigger>
                                <Trigger SourceName="TextTitle" Property="Text" Value="Home">
                                    <Setter TargetName="Ico_Home" Property="Visibility" Value="Visible" />
                                </Trigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false" />
                                        <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true" />
                                    </MultiDataTrigger.Conditions>
                                    <Setter TargetName="Title" Property="Background" Value="#0D000000" />
                                    <Setter Property="Foreground" Value="{StaticResource color.sys.text.neutral.lv1}" />
                                    <!--<Setter TargetName="btnPath" Property="Path.Fill" Value="Black"/>-->
                                </MultiDataTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <convert:UnVisivleConvert x:Key="UnvisibleConvert" />
        </ResourceDictionary>
    </Window.Resources>
    <Border>
        <Grid Background="{StaticResource color.sys.layout.bg.tabbar}">
            <Grid.RowDefinitions>
                <RowDefinition Height="40" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <dragablz:TabablzControl
                Name="TabablzControl"
                Grid.RowSpan="3"
                BorderThickness="0"
                ItemContainerStyle="{StaticResource DragablzItemStyle}"
                SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                <dragablz:TabablzControl.InterTabController>
                    <dragablz:InterTabController InterTabClient="{Binding InterTabClient}" />
                </dragablz:TabablzControl.InterTabController>
                <dragablz:TabablzControl.HeaderSuffixContent>
                    <Button
                        x:Name="BtnAdd"
                        Width="20"
                        Height="20"
                        Margin="9,13,0,7"
                        Padding="0"
                        HorizontalAlignment="Left"
                        Background="Transparent"
                        BorderThickness="0"
                        Command="{Binding AddTab}"
                        WindowChrome.IsHitTestVisibleInChrome="True">
                        <Path
                            Width="20"
                            Height="20"
                            Data="M9 11V16H11V11H16V9H11V4H9V9H4L4 11H9Z"
                            Fill="{StaticResource color.icon.base.neutral.norm.lv1}" />
                    </Button>
                </dragablz:TabablzControl.HeaderSuffixContent>
                <dragablz:TabablzControl.HeaderPrefixContent>
                    <Grid
                        Width="16"
                        Height="38"
                        Margin="0,0,0,0"
                        Background="Transparent" />
                </dragablz:TabablzControl.HeaderPrefixContent>
            </dragablz:TabablzControl>
            <!--  标题栏右侧栏，关闭按钮，会员，试用等  -->
            <StackPanel
                HorizontalAlignment="Right"
                Orientation="Horizontal"
                WindowChrome.IsHitTestVisibleInChrome="True">
                <Button
                    Name="BtnMiniSize"
                    Width="40"
                    Height="40"
                    Background="Transparent"
                    BorderThickness="0"
                    Click="BtnMiniSize_Click"
                    Style="{StaticResource TitleBarBtn}">
                    <Polygon Fill="{StaticResource color.btn.sec.text.def}" Points="14 7 14 8 2 8 2 7">
                        <Polygon.RenderTransform>
                            <TransformGroup>
                                <TranslateTransform Y="-3" />
                            </TransformGroup>
                        </Polygon.RenderTransform>
                    </Polygon>
                </Button>
                <Button
                    Name="BtnReStore"
                    Width="40"
                    Height="40"
                    Background="Transparent"
                    BorderThickness="0"
                    Click="BtnReStore_Click"
                    Style="{StaticResource TitleBarBtn}">
                    <Grid>
                        <Path
                            x:Name="ico_max"
                            Data="M14,2 L14,14 L2,14 L2,2 L14,2 Z M13,3 L3,3 L3,13 L13,13 L13,3 Z"
                            Fill="{StaticResource color.btn.sec.text.def}"
                            Visibility="Collapsed" />
                        <Grid x:Name="ico_mini" Visibility="{Binding ElementName=ico_max, Path=Visibility, Converter={StaticResource UnvisibleConvert}}">
                            <Path Data="M11,5 L11,14 L2,14 L2,5 L11,5 Z M10,6 L3,6 L3,13 L10,13 L10,6 Z" Fill="{StaticResource color.btn.sec.text.def}" />
                            <Polygon Fill="{StaticResource color.btn.sec.text.def}" Points="14 2 14 11 11 11 11 10 13 10 13 3 6 3 6 5 5 5 5 2" />
                        </Grid>
                    </Grid>
                </Button>
                <Button
                    Name="BtnClose"
                    Width="40"
                    Height="40"
                    Background="Transparent"
                    BorderThickness="0"
                    Click="BtnClose_Click"
                    Style="{StaticResource CloseBtn}">
                    <Polygon Fill="{StaticResource color.btn.sec.text.def}" Points="11.2919922 12 12 11.2919922 6.70800781 6 12 0.708007813 11.2919922 0 6 5.29199219 0.708007812 9.76996262e-15 -2.27456942e-13 0.708007813 5.29199219 6 0 11.2919922 0.708007812 12 6 6.70800781" />
                </Button>
            </StackPanel>
        </Grid>
    </Border>
</Window>
