<Window x:Class="PDFViewer.MainWindow"
        x:Name="Window"
        
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:PDFViewer"
        mc:Ignorable="d"
        SnapsToDevicePixels="True" 
        xmlns:cpdfcommon="clr-namespace:Compdfkit_Tools.Common;assembly=Compdfkit_Tools"
        xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
        BorderThickness="{Binding RelativeSource={RelativeSource Mode=Self},Path=WindowState,Converter={StaticResource WindowStateToThicknessConverter}}"
        Title="ComPDFKit V1.10.0" Height="720" Width="1080" >
    <WindowChrome.WindowChrome>
        <WindowChrome 
            CornerRadius="8"
            NonClientFrameEdges="Left,Bottom,Right"
            UseAeroCaptionButtons="False"
            ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}">
            <WindowChrome.CaptionHeight>
                <MultiBinding Converter="{StaticResource CaptionHeightConverter}">
                    <Binding ElementName="TitleBarGrid" Path="ActualHeight"/>
                    <Binding ElementName="Window" Path="BorderThickness.Top"/>
                </MultiBinding>
            </WindowChrome.CaptionHeight>
        </WindowChrome>
    </WindowChrome.WindowChrome>

    <Window.Resources>
        <ControlTemplate x:Key="CloseFileButton" TargetType="{x:Type ButtonBase}">
            <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
                                BorderBrush="{TemplateBinding Border.BorderBrush}"
                                Background="{TemplateBinding Panel.Background}"
                                Name="border"
                                SnapsToDevicePixels="True">
                <Path Name="content" VerticalAlignment="Center" HorizontalAlignment="Center" Fill="#666666">
                    <Path.RenderTransform>
                        <TransformGroup>
                            <TranslateTransform X="8" Y="-8"/>
                            <RotateTransform Angle="45"/>
                            <TranslateTransform X="-4" Y="-5"/>
                        </TransformGroup>
                    </Path.RenderTransform>
                    <Path.Data>
                        M9.48528137,2.98528137 L9.48428137,8.48428137 L14.9852814,8.48528137 L14.9852814,9.48528137 L9.48428137,9.48428137 L9.48528137,14.9852814 L8.48528137,14.9852814 
                        L8.48428137,9.48428137 L2.98528137,9.48528137 L2.98528137,8.48528137 L8.48428137,8.48428137 L8.48528137,2.98528137 L9.48528137,2.98528137 Z
                    </Path.Data>
                </Path>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="Button.IsDefaulted" Value="True">
                    <Setter Property="Path.Fill"  TargetName="content" Value="#666666" />
                </Trigger>
                <Trigger Property="UIElement.IsMouseOver"  Value="True">
                    <Setter Property="Path.Fill" TargetName="content" Value="#333333" />
                </Trigger>
                <Trigger Property="ButtonBase.IsPressed" Value="True">
                    <Setter Property="Path.Fill" TargetName="content"  Value="#000000" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

        <ControlTemplate x:Key="AddFileButton" TargetType="{x:Type ButtonBase}">
            <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
                                BorderBrush="{TemplateBinding Border.BorderBrush}"
                                Background="{TemplateBinding Panel.Background}"
                                Name="border"
                                SnapsToDevicePixels="True">
                <Path Name="content" VerticalAlignment="Center" HorizontalAlignment="Center" Fill="#FFFFFF">
                    <Path.RenderTransform>
                        <TransformGroup>
                            <TranslateTransform X="-2" Y="-2"/>
                        </TransformGroup>
                    </Path.RenderTransform>
                    <Path.Data>
                        M9.48528137,2.98528137 L9.48428137,8.48428137 L14.9852814,8.48528137 L14.9852814,9.48528137 L9.48428137,9.48428137 L9.48528137,14.9852814 L8.48528137,14.9852814 
                        L8.48428137,9.48428137 L2.98528137,9.48528137 L2.98528137,8.48528137 L8.48428137,8.48428137 L8.48528137,2.98528137 L9.48528137,2.98528137 Z
                    </Path.Data>
                </Path>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="Button.IsDefaulted" Value="True">
                    <Setter Property="Path.Fill" TargetName="content" Value="#666666" />
                </Trigger>
                <Trigger Property="UIElement.IsMouseOver"  Value="True">
                    <Setter Property="Path.Fill" TargetName="content" Value="#333333" />
                </Trigger>
                <Trigger Property="ButtonBase.IsPressed" Value="True">
                    <Setter Property="Path.Fill" TargetName="content" Value="#000000" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

        <Style x:Key="DragablzItemStyle" TargetType="{x:Type dragablz:DragablzItem}">
            <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="32"  Margin="10,4,0,0" BorderBrush="#A0A2AE" BorderThickness="1,1,1,0" CornerRadius="3,3,0,0">
                                <Grid Background="Transparent">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="auto" />
                                        <ColumnDefinition Width="*" MinWidth="10" />
                                        <ColumnDefinition Width="auto" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock  x:Name="TextTitle"  MaxWidth="145"  Margin="8,4,0,4"  FontFamily="Segoe UI,Microsoft YaHei"  Text="{Binding FileName}"  TextTrimming="WordEllipsis" />
                                    <Thumb  x:Name="PART_Thumb"  Grid.ColumnSpan="2"  HorizontalAlignment="Stretch"  VerticalContentAlignment="Stretch" Background="Transparent"  FontFamily="Segoe UI,Microsoft YaHei"  ToolTip="{Binding 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" IsHitTestVisible="False"  Text="*" Visibility="{Binding FileChanged}" />

                                    <Button x:Name="CloseFileButton" Grid.Column="2"  Width="16" Height="16"  Margin="0,4,8,4" Background="Transparent"  BorderThickness="0" Template="{StaticResource CloseFileButton}"  Click="CloseFileButton_Click"></Button>
                                </Grid>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter TargetName="Title" Property="Background" Value="#FFFFFF" />
                                <Setter TargetName="Title" Property="BorderThickness" Value="1,1,1,0" />
                                <Setter TargetName="TextTitle" Property="Foreground" Value="Black" />
                                <Setter TargetName="ChangeIcon" Property="Foreground" Value="Black" />
                            </Trigger>
                            <Trigger Property="IsSelected" Value="False">
                                <Setter TargetName="Title" Property="Background" Value="TransParent" />
                                <Setter TargetName="Title" Property="BorderThickness" Value="1,1,1,0" />
                                <Setter TargetName="TextTitle" Property="Foreground" Value="White" />
                                <Setter TargetName="ChangeIcon" Property="Foreground" Value="white" />
                            </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 TargetName="TextTitle" Property="Foreground" Value="black" />
                                <Setter TargetName="ChangeIcon" Property="Foreground" Value="black" />
                            </MultiDataTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="TitleBarButtonStyle" TargetType="Button">
            <Setter Property="Foreground" Value="#FFFFFF" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="Margin" Value="0" />
            <Setter Property="VerticalAlignment" Value="Top" />
            <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
            <Setter Property="IsTabStop" Value="False" />
            <Setter Property="Width" Value="36" />
            <Setter Property="Height" Value="30" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border x:Name="border"
                                Background="Transparent"
                                BorderThickness="0"
                                SnapsToDevicePixels="True">
                            <ContentPresenter x:Name="contentPresenter"
                                Margin="0"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Focusable="False"
                                RecognizesAccessKey="True" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="border" Property="Background" Value="#1AE9E9E9" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter TargetName="border" Property="Background" Value="#1AEDEDED" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="TitleBarCloseButtonStyle" BasedOn="{StaticResource TitleBarButtonStyle}" TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border x:Name="border"
                                Background="Transparent"
                                BorderThickness="0"
                                SnapsToDevicePixels="True">
                            <ContentPresenter x:Name="contentPresenter"
                                Margin="0"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Focusable="False"
                                RecognizesAccessKey="True" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="border" Property="Background" Value="#C42B1C" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter TargetName="border" Property="Background" Value="#C84031" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid Background="#273C62" Margin="0,-1,0,0">
            <dragablz:TabablzControl Name="TabControl" ItemContainerStyle="{StaticResource DragablzItemStyle}" WindowChrome.IsHitTestVisibleInChrome="True">
                <dragablz:TabablzControl.InterTabController>
                    <dragablz:InterTabController />
                </dragablz:TabablzControl.InterTabController>
                <dragablz:TabablzControl.HeaderSuffixContent>
                    <Grid Name="TitleBarGrid" MinHeight="32">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"></ColumnDefinition>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                            <ColumnDefinition Width="auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button  x:Name="addBtn" Width="16"  Height="16"  Margin="9,7,0,5"  HorizontalAlignment="Left" Background="Transparent"  BorderThickness="0" 
                             Click="DefaultAddButton_Click"  Template="{StaticResource AddFileButton}"></Button>
                        <Grid Grid.Column="2" HorizontalAlignment="Right">
                            <StackPanel Orientation="Horizontal" Margin="0,-2,0,0">
                                <Button x:Name="MinimizeButton" Style="{StaticResource TitleBarButtonStyle}" Width="36" Height="32" Click="MinimizeButton_Click">
                                    <Path Width="36" Height="32"
                                        Data="M 13,15 H 23"
                                        Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
                                        StrokeThickness="1" />
                                </Button>
                                <Button x:Name="MaximizeRestoreButton" Style="{StaticResource TitleBarButtonStyle}" Width="36" Height="32" Click="MaximizeRestoreButton_Click">
                                    <Path Width="36" Height="32"
                      Data="{Binding ElementName=Window, Path=WindowState, Converter={StaticResource WindowStateToPathConverter}}"
                      Stroke="{Binding Path=Foreground,RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
                      StrokeThickness="1" />
                                </Button>
                                <Button x:Name="CloseButton" Style="{StaticResource TitleBarCloseButtonStyle}" Width="36" Height="32" Click="CloseButton_Click">
                                    <Path Width="36" Height="32"
                                        Data="M 13,11 22,20 M 13,20 22,11"
                                        Stroke="{Binding Path=Foreground,RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
                                        StrokeThickness="1" />
                                </Button>
                            </StackPanel>
                        </Grid>
                    </Grid>
                </dragablz:TabablzControl.HeaderSuffixContent>

            </dragablz:TabablzControl>
        </Grid>

        <Border Name="PopupBorder" Background="#A0000000" Visibility="Collapsed">
            <cpdfcommon:PasswordDialog x:Name="PasswordUI" Visibility="Collapsed"></cpdfcommon:PasswordDialog>
        </Border>
    </Grid>

</Window>
