<UserControl
    x:Class="PDF_Office.Views.ViewContent"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Viewer="clr-namespace:ComPDFKitViewer.PdfViewer;assembly=ComPDFKit.Viewer"
    xmlns:cus="clr-namespace:PDF_Office.CustomControl"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
    xmlns:local="clr-namespace:PDF_Office.Views"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="http://prismlibrary.com/"
    xmlns:viewmodels="clr-namespace:PDF_Office.ViewModels"
    d:DataContext="{d:DesignInstance Type=viewmodels:ViewContentViewModel}"
    d:DesignHeight="450"
    d:DesignWidth="800"
    prism:ViewModelLocator.AutoWireViewModel="True"
    mc:Ignorable="d">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <prism:InvokeCommandAction Command="{Binding Load}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <UserControl.Resources>
        <ResourceDictionary>
            <Style x:Key="MenuButtonStyle" TargetType="{x:Type Button}">
                <Setter Property="Width" Value="20" />
                <Setter Property="Height" Value="20" />
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Name="HeadRow" Height="40" />
            <RowDefinition Name="ToolRow" Height="40" />
            <RowDefinition Height="*" />
            <RowDefinition Height="32" />
        </Grid.RowDefinitions>
        <!--  左边菜单按钮  -->
        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
            <Button
                Margin="8"
                Style="{StaticResource MenuButtonStyle}"
                ToolTip="File">
                <Path Data="M12.6172 12L15.8906 5.44531C15.9635 5.29948 16 5.14844 16 4.99219C16 4.85677 15.974 4.72917 15.9219 4.60938C15.8698 4.48958 15.7982 4.38411 15.707 4.29297C15.6159 4.20182 15.5091 4.13021 15.3867 4.07812C15.2643 4.02604 15.1354 4 15 4H13V2C13 1.85938 12.974 1.72917 12.9219 1.60938C12.8698 1.48958 12.7982 1.38411 12.707 1.29297C12.6159 1.20182 12.5104 1.13021 12.3906 1.07812C12.2708 1.02604 12.1406 1 12 1H6.25C6.08854 1 5.94661 0.97526 5.82422 0.925781C5.70182 0.876302 5.58724 0.815104 5.48047 0.742188C5.3737 0.669271 5.26823 0.588542 5.16406 0.5C5.0599 0.411458 4.94141 0.330729 4.80859 0.257812C4.67578 0.184896 4.52474 0.123698 4.35547 0.0742188C4.1862 0.0247396 3.98438 0 3.75 0H1C0.859375 0 0.729167 0.0260417 0.609375 0.078125C0.489583 0.130208 0.384115 0.201823 0.292969 0.292969C0.201823 0.384115 0.130208 0.489583 0.078125 0.609375C0.0260417 0.729167 0 0.859375 0 1V12H12.6172ZM1 9.38281V1H3.75C3.91146 1 4.05339 1.02474 4.17578 1.07422C4.29818 1.1237 4.41276 1.1849 4.51953 1.25781C4.6263 1.33073 4.73177 1.41146 4.83594 1.5C4.9401 1.58854 5.05859 1.66927 5.19141 1.74219C5.32422 1.8151 5.47526 1.8763 5.64453 1.92578C5.8138 1.97526 6.01562 2 6.25 2H12V4H4.3125C4.11979 4 3.94401 4.04948 3.78516 4.14844C3.6263 4.2474 3.5026 4.38281 3.41406 4.55469L1 9.38281ZM1.3125 11H12L15 5H4.3125L1.3125 11Z" Fill="#333333" />
            </Button>
            <Button
                Margin="8"
                Command="{Binding SaveFile}"
                IsEnabled="{Binding CanSave}"
                Style="{StaticResource MenuButtonStyle}"
                ToolTip="Save">
                <Path Data="M0 0H10.7071L14 3.29289V14H0V0ZM13 3.707L10.293 1H1V13H3V7H11V13H13V3.707ZM10 13H4V8H10V13ZM6 5V4H3V5H6Z" Fill="#333333" />
            </Button>
            <Button
                Margin="8"
                Command="{Binding UndoCommand}"
                IsEnabled="{Binding CanUndo}"
                Style="{StaticResource MenuButtonStyle}"
                ToolTip="Undo">
                <Path Data="M3.02773 1.12105L2 1.1197L2.00703 6.05868L7.14571 6.06544L7.1443 5.07764L3.95607 5.07345L5.96547 3.14214L6.1139 3.0063C7.72531 1.60263 10.2166 1.64791 11.7713 3.14214C13.3745 4.68306 13.3745 7.18139 11.7713 8.72231L5.96547 14.3025L6.69119 15L12.497 9.41983L12.651 9.26532C14.4996 7.33014 14.4483 4.32008 12.497 2.44461C10.4929 0.518462 7.24377 0.518462 5.23974 2.44461L3.03264 4.56595L3.02773 1.12105Z" Fill="#333333" />
            </Button>
            <Button
                Margin="8"
                Command="{Binding RedoCommand}"
                IsEnabled="{Binding CanRedo}"
                Style="{StaticResource MenuButtonStyle}"
                ToolTip="Redo">
                <Path Data="M10.9737 0.118216L12 0.116865L11.993 5.05009L6.86172 5.05685L6.86312 4.0702L10.0425 4.06602L8.03792 2.13876L7.88969 2.00309C6.28039 0.601253 3.78921 0.649819 2.23256 2.1464C0.627259 3.68974 0.623702 6.18858 2.22461 7.72771L8.02203 13.3014L7.29536 14L1.49795 8.42633L1.34413 8.27199C-0.501568 6.33885 -0.445937 3.3281 1.50788 1.44969C3.51451 -0.479494 6.76344 -0.483769 8.76458 1.44014L10.9688 3.55934L10.9737 0.118216Z" Fill="#333333" />
            </Button>
        </StackPanel>
        <!--  右边菜单按钮  -->
        <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
            <Button
                Margin="8"
                Style="{StaticResource MenuButtonStyle}"
                ToolTip="Print">
                <Path Data="M12 6V0H4V6H1.5L1.35554 6.00687C0.594888 6.07955 0 6.7203 0 7.5V14H4V16H12V14H16V7.5L15.9931 7.35554C15.9204 6.59489 15.2797 6 14.5 6H12ZM4 10V13H1V7.5L1.00806 7.41012C1.05039 7.17688 1.25454 7 1.5 7H14.5L14.5899 7.00806C14.8231 7.05039 15 7.25454 15 7.5V13H12V10H4ZM11 6V1H5V6H11ZM11 11H5V15H11V11ZM3 8H2V9H3V8Z" Fill="#333333" />
            </Button>
            <Button
                Margin="8"
                Style="{StaticResource MenuButtonStyle}"
                ToolTip="Share">
                <Path Data="M10 11L15.5 5.5L10 0V3C9.35417 3 8.73307 3.08333 8.13672 3.25C7.54036 3.41667 6.98307 3.65234 6.46484 3.95703C5.94661 4.26172 5.47526 4.6263 5.05078 5.05078C4.6263 5.47526 4.26172 5.94661 3.95703 6.46484C3.65234 6.98307 3.41667 7.54036 3.25 8.13672C3.08333 8.73307 3 9.35417 3 10V11C3.45833 10.526 3.95703 10.1029 4.49609 9.73047C5.03516 9.35807 5.60156 9.04297 6.19531 8.78516C6.78906 8.52734 7.40495 8.33203 8.04297 8.19922C8.68099 8.06641 9.33333 8 10 8V11ZM4.125 8.76562C4.22396 8.28646 4.37891 7.82943 4.58984 7.39453C4.80078 6.95964 5.05859 6.55599 5.36328 6.18359C5.66797 5.8112 6.01432 5.47917 6.40234 5.1875C6.79036 4.89583 7.21094 4.65625 7.66406 4.46875C7.96094 4.34375 8.24219 4.2487 8.50781 4.18359C8.77344 4.11849 9.03776 4.07292 9.30078 4.04688C9.5638 4.02083 9.72396 4.00651 10 4.00391C10.276 4.0013 10.6823 4 11 4V2.41406L14 5.5L11 8.5V7H10C8.94792 7 7.92448 7.14844 6.92969 7.44531C5.9349 7.74219 5 8.18229 4.125 8.76562ZM1 14V4H0V15H16V12H15V14H1Z" Fill="#333333" />
            </Button>
            <Button
                Margin="8"
                Style="{StaticResource MenuButtonStyle}"
                ToolTip="Property" />
        </StackPanel>
        <TabControl
            x:Name="ToolTabControl"
            Grid.Row="0"
            Grid.RowSpan="2"
            HorizontalAlignment="Center"
            VerticalAlignment="Top"
            BorderThickness="0"
            Style="{StaticResource TabControlWithUnderLineStyle}">
            <cus:IconAndTextTabItem
                x:Name="TabItemAnnotation"
                Header="注释"
                Style="{StaticResource TabItem_WithUnderLineStyle}">
                <Grid Grid.Row="1" Height="40" />
            </cus:IconAndTextTabItem>
            <cus:IconAndTextTabItem
                x:Name="TabItemPageEdit"
                Header="页面"
                Style="{StaticResource TabItem_WithUnderLineStyle}" />
            <cus:IconAndTextTabItem
                x:Name="TabItemConvert"
                Header="转换"
                Style="{StaticResource TabItem_WithUnderLineStyle}" />
            <cus:IconAndTextTabItem
                x:Name="TabItemScan"
                Header="扫描和OCR"
                Style="{StaticResource TabItem_WithUnderLineStyle}">
                <Grid Grid.Row="1" Height="40" />
            </cus:IconAndTextTabItem>
            <cus:IconAndTextTabItem
                x:Name="TabItemEdit"
                Height="40"
                Header="编辑"
                Style="{StaticResource TabItem_WithUnderLineStyle}">
                <Grid Grid.Row="1" Height="40" />
            </cus:IconAndTextTabItem>
            <cus:IconAndTextTabItem
                x:Name="TabItemForm"
                Height="40"
                Header="表单"
                Style="{StaticResource TabItem_WithUnderLineStyle}">
                <Grid Grid.Row="1" Height="40" />
            </cus:IconAndTextTabItem>
            <cus:IconAndTextTabItem
                x:Name="TabItemFill"
                Height="40"
                Header="填写与签名"
                Style="{StaticResource TabItem_WithUnderLineStyle}">
                <Grid Grid.Row="1" Height="40" />
            </cus:IconAndTextTabItem>
            <cus:IconAndTextTabItem
                x:Name="TabItemTool"
                Height="40"
                Header="工具"
                Style="{StaticResource TabItem_WithUnderLineStyle}">
                <Grid Grid.Row="1" Height="40" />
            </cus:IconAndTextTabItem>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <i:InvokeCommandAction Command="{Binding TabControlSelectionChangedCommand}" PassEventArgsToCommand="True" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </TabControl>
        <Grid Name="DocumentView" Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition
                    x:Name="BOTACloumn"
                    Width="48"
                    MinWidth="48"
                    MaxWidth="400" />
                <ColumnDefinition Width="12" />
                <ColumnDefinition
                    Name="ViewerColumn"
                    Width="*"
                    MinWidth="200" />
                <ColumnDefinition Width="12" />
                <ColumnDefinition Name="PropertyColumn" Width="0" />
            </Grid.ColumnDefinitions>
            <ContentControl prism:RegionManager.RegionName="{Binding BOTARegionName}" />
            <GridSplitter
                Grid.Column="1"
                Width="12"
                FocusVisualStyle="{x:Null}"
                ResizeBehavior="PreviousAndNext"
                ShowsPreview="True" />
            <ContentControl
                x:Name="PDFViewerContent"
                Grid.Column="2"
                HorizontalAlignment="Stretch"
                prism:RegionManager.RegionName="{Binding ViwerRegionName}" />
            <Button Grid.Column="3" />
            <ContentControl Grid.Column="4" prism:RegionManager.RegionName="{Binding PropertyRegionName}" />
        </Grid>
        <local:BottomToolContent Grid.Row="3" />

        <!--  用于显示页面编辑、水印、背景、标记密文等功能的区域  -->
        <ContentControl
            Name="ContentTool"
            Grid.Row="{Binding GridToolRow}"
            Grid.RowSpan="{Binding GridToolRowSpan}"
            prism:RegionManager.RegionName="{Binding ToolContentRegionName}"
            Visibility="{Binding ToolContentVisible}" />

        <cus:LoadingControl Grid.RowSpan="3" Visibility="{Binding IsLoading}" />

        <ContentControl
            Name="ContentToolsBar"
            Grid.Row="{Binding GridToolRow}"
            prism:RegionManager.RegionName="{Binding ToolsBarContentRegionName}"
            Visibility="{Binding ToolsBarContentVisible}" />
    </Grid>
</UserControl>
