Browse Source

综合-添加页面编辑控件、调整部分辅助类文件位置

ZhouJieSheng 2 years ago
parent
commit
88dd56d718

+ 1 - 0
PDF Office/App.xaml

@@ -9,6 +9,7 @@
             <ResourceDictionary.MergedDictionaries>
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/TabControlStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ComboxStyle.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ListBoxStyle.xaml" />
             </ResourceDictionary.MergedDictionaries>
 
 

+ 3 - 0
PDF Office/App.xaml.cs

@@ -10,6 +10,7 @@ using System.Windows.Controls;
 using ComPDFKit.NativeMethod;
 using ComPDFKit_Conversion.Converter;
 using PDF_Office.CustomControl;
+using PDF_Office.CustomControl.SystemControl;
 using PDF_Office.ViewModels;
 using PDF_Office.Views;
 using PDF_Office.Views.BOTA;
@@ -19,6 +20,7 @@ using Prism.DryIoc;
 using Prism.Ioc;
 using Prism.Regions;
 using PDF_Office.Model;
+using PDF_Office.Views.PageEdit;
 
 namespace PDF_Office
 {
@@ -69,6 +71,7 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<HomeToolsContent>("Tools");
             containerRegistry.RegisterForNavigation<HomeGuidContent>("Guid");
             containerRegistry.RegisterForNavigation<BOTAContent>();
+            containerRegistry.RegisterForNavigation<PageEditContent>();
 
             //注册弹窗
             containerRegistry.RegisterDialog<VerifyPassWordDialog>(DialogNames.VerifyPassWordDialog);

+ 55 - 0
PDF Office/CustomControl/IconAndTextTabItem.cs

@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+namespace PDF_Office.CustomControl
+{
+    /// <summary>
+    /// 显示图标和选中文字颜色的TabItem
+    /// </summary>
+    public class IconAndTextTabItem:TabItem
+    {
+        public IconAndTextTabItem()
+        {
+
+        }
+
+        public override void OnApplyTemplate()
+        {
+
+            base.OnApplyTemplate();
+        }
+
+        public PathGeometry NormalPathIcon
+        {
+            get { return (PathGeometry)GetValue(NormalIconProperty); }
+            set { SetValue(NormalIconProperty, value); }
+        }
+
+        public static readonly DependencyProperty NormalIconProperty =
+           DependencyProperty.Register("NormalPathIcon", typeof(PathGeometry), typeof(IconAndTextTabItem), new PropertyMetadata(null));
+
+
+        public ImageSource SelectedIcon
+        {
+            get { return (ImageSource)GetValue(HoverIconProperty); }
+            set { SetValue(HoverIconProperty, value); }
+        }
+
+        public static readonly DependencyProperty HoverIconProperty =
+           DependencyProperty.Register("SelectedIcon", typeof(ImageSource), typeof(IconAndTextTabItem), new PropertyMetadata(null));
+
+        public SolidColorBrush SelectedForeground
+        {
+            get { return (SolidColorBrush)GetValue(SelectedForegroundProperty); }
+            set { SetValue(SelectedForegroundProperty, value); }
+        }
+        public static readonly DependencyProperty SelectedForegroundProperty =
+           DependencyProperty.Register("SelectedForeground", typeof(SolidColorBrush), typeof(IconAndTextTabItem), new PropertyMetadata(new SolidColorBrush(Colors.Black)));
+    }
+}

+ 73 - 0
PDF Office/CustomControl/SystemControl/CustomCommandAction .cs

@@ -0,0 +1,73 @@
+using Microsoft.Xaml.Behaviors;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+
+namespace PDF_Office.CustomControl.SystemControl
+{
+    /// <summary>
+    /// 自动传送事件参数的辅助类
+    /// </summary>
+    public sealed class CustomCommandAction : TriggerAction<DependencyObject>
+    {
+        public static readonly DependencyProperty CommandParameterProperty =
+            DependencyProperty.Register("CommandParameter", typeof(object), typeof(CustomCommandAction), null);
+
+        public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
+            "Command", typeof(ICommand), typeof(CustomCommandAction), null);
+
+        public ICommand Command
+        {
+            get
+            {
+                return (ICommand)this.GetValue(CommandProperty);
+            }
+            set
+            {
+                this.SetValue(CommandProperty, value);
+            }
+        }
+
+        public object CommandParameter
+        {
+            get
+            {
+                return this.GetValue(CommandParameterProperty);
+            }
+
+            set
+            {
+                this.SetValue(CommandParameterProperty, value);
+            }
+        }
+
+        protected override void Invoke(object parameter)
+        {
+            if (this.AssociatedObject != null)
+            {
+                ICommand command = this.Command;
+                if (command != null)
+                {
+                    if (this.CommandParameter != null)
+                    {
+                        if (command.CanExecute(this.CommandParameter))
+                        {
+                            command.Execute(this.CommandParameter);
+                        }
+                    }
+                    else
+                    {
+                        if (command.CanExecute(parameter))
+                        {
+                            command.Execute(parameter);
+                        }
+                    }
+                }
+            }
+        }
+    }
+}

+ 1 - 1
PDF Office/CustomControl/InterTabClient.cs

@@ -9,7 +9,7 @@ using PDF_Office.Views;
 using Prism.Ioc;
 using Prism.Regions;
 
-namespace PDF_Office.CustomControl
+namespace PDF_Office.CustomControl.SystemControl
 {
     public class InterTabClient : IInterTabClient
     {

+ 55 - 0
PDF Office/CustomControl/SystemControl/RoutedEventTrigger.cs

@@ -0,0 +1,55 @@
+using Microsoft.Xaml.Behaviors;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace PDF_Office.CustomControl.SystemControl
+{
+    /// <summary>
+    /// 用于辅助绑定ScrollChanged等不方便直接绑定command的系统
+    /// </summary>
+    public class RoutedEventTrigger : EventTriggerBase<DependencyObject>
+    {
+        RoutedEvent _routedEvent;
+
+        public RoutedEvent RoutedEvent
+        {
+            get { return _routedEvent; }
+            set { _routedEvent = value; }
+        }
+
+        public RoutedEventTrigger()
+        {
+        }
+
+        protected override void OnAttached()
+        {
+            Behavior behavior = base.AssociatedObject as Behavior;
+            FrameworkElement associatedElement = base.AssociatedObject as FrameworkElement;
+
+            if (behavior != null)
+            {
+                associatedElement = ((IAttachedObject)behavior).AssociatedObject as FrameworkElement;
+            }
+            if (associatedElement == null)
+            {
+                throw new ArgumentException("Routed Event trigger can only be associated to framework elements");
+            }
+            if (RoutedEvent != null)
+            {
+                associatedElement.AddHandler(RoutedEvent, new RoutedEventHandler(this.OnRoutedEvent));
+            }
+        }
+        void OnRoutedEvent(object sender, RoutedEventArgs args)
+        {
+            base.OnEvent(args);
+        }
+        protected override string GetEventName()
+        {
+            return RoutedEvent.Name;
+        }
+    }
+}

+ 1 - 1
PDF Office/CustomControl/TabablzRegionBehavior.cs

@@ -13,7 +13,7 @@ using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Input;
 
-namespace PDF_Office.CustomControl
+namespace PDF_Office.CustomControl.SystemControl
 {
     public class DragablzWindowBehavior : RegionBehavior
     {

+ 1 - 1
PDF Office/Model/DialogNames.cs

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
 namespace PDF_Office.Model
 {
     /// <summary>
-    /// 记录窗的名称
+    /// 记录窗的名称
     /// </summary>
     public static class DialogNames
     {

+ 102 - 0
PDF Office/Model/PageEdit/PageEditItem.cs

@@ -0,0 +1,102 @@
+using Prism.Commands;
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media.Imaging;
+
+namespace PDF_Office.Model.PageEdit
+{
+    public class PageEditItem:BindableBase
+    {
+
+        private int pageNumber;
+        /// <summary>
+        /// 页码
+        /// </summary>
+        public int PageNumber
+        {
+            get { return pageNumber; }
+            set
+            {
+                SetProperty(ref pageNumber, value);
+            }
+        }
+
+
+        private string pageSize = "";
+        /// <summary>
+        /// 页面尺寸
+        /// </summary>
+        public string PageSize
+        {
+            get { return pageSize; }
+            set
+            {
+                SetProperty(ref pageSize, value);
+            }
+        }
+
+        private BitmapSource image;
+        /// <summary>
+        /// 页面缩略图
+        /// </summary>
+        public BitmapSource Image
+        {
+            get { return image; }
+            set
+            {
+                SetProperty(ref image, value);
+            }
+        }
+
+        private bool showPageSize = false;
+        /// <summary>
+        /// 是否显示页码尺寸
+        /// </summary>
+        public bool ShowPageSize
+        {
+            get { return showPageSize; }
+            set
+            {
+                SetProperty(ref showPageSize, value);
+            }
+        }
+
+        private bool haveBookMark = false;
+        /// <summary>
+        /// 该页是否有书签标记
+        /// </summary>
+        public bool HaveBookMark
+        {
+            get { return haveBookMark; }
+            set
+            {
+                SetProperty(ref haveBookMark, value);
+            }
+        }
+
+        private Visibility visible = Visibility.Visible;
+        /// <summary>
+        /// 是否显示
+        /// </summary>
+        public Visibility Visible
+        {
+            get { return visible; }
+            set
+            {
+                SetProperty(ref visible, value);
+            }
+        }
+
+
+        /// <summary>
+        /// 此次打开中是否已经获取图片,避免重复拿图
+        /// </summary>
+        public bool IsGetImage = false;
+
+    }
+}

+ 2 - 0
PDF Office/Model/ParameterNames.cs

@@ -22,5 +22,7 @@ namespace PDF_Office.Model
         public static string AddTab = "AddTab";
 
         public static string MainViewModel = "MainViewModel";
+
+        public static string ViewContentViewModel = "ViewContentViewModel";
     }
 }

+ 23 - 2
PDF Office/PDF Office.csproj

@@ -94,6 +94,10 @@
     <Reference Include="System.Xaml">
       <RequiredTargetFramework>4.0</RequiredTargetFramework>
     </Reference>
+    <Reference Include="VirtualizingWrapPanel, Version=1.5.7.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>packages\VirtualizingWrapPanel.1.5.7\lib\net452\VirtualizingWrapPanel.dll</HintPath>
+    </Reference>
     <Reference Include="WindowsBase" />
     <Reference Include="PresentationCore" />
     <Reference Include="PresentationFramework" />
@@ -104,22 +108,27 @@
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     <Compile Include="CustomControl\CustomIconToggleBtn.cs" />
+    <Compile Include="CustomControl\IconAndTextTabItem.cs" />
+    <Compile Include="CustomControl\SystemControl\CustomCommandAction .cs" />
+    <Compile Include="CustomControl\SystemControl\RoutedEventTrigger.cs" />
     <Compile Include="CustomControl\ToastControl.xaml.cs">
       <DependentUpon>ToastControl.xaml</DependentUpon>
     </Compile>
     <Compile Include="Model\DialogNames.cs" />
-    <Compile Include="CustomControl\InterTabClient.cs" />
+    <Compile Include="CustomControl\SystemControl\InterTabClient.cs" />
     <Compile Include="CustomControl\LoadingControl.xaml.cs">
       <DependentUpon>LoadingControl.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Model\PageEdit\PageEditItem.cs" />
     <Compile Include="Model\ParameterNames.cs" />
     <Compile Include="Model\RegionNames.cs" />
-    <Compile Include="CustomControl\TabablzRegionBehavior.cs" />
+    <Compile Include="CustomControl\SystemControl\TabablzRegionBehavior.cs" />
     <Compile Include="DataConvert\BoolToVisible.cs" />
     <Compile Include="DataConvert\VisibleToBoolConvert.cs" />
     <Compile Include="EventAggregators\DragablzWindowEvent.cs" />
     <Compile Include="EventAggregators\OpenFileEvent.cs" />
     <Compile Include="Tools\CommomEvent.cs" />
+    <Compile Include="Tools\CommonHelper.cs" />
     <Compile Include="ViewModels\BOTA\BOTAContentViewModel.cs" />
     <Compile Include="ViewModels\BottomToolContentViewModel.cs" />
     <Compile Include="ViewModels\Dialog\FullScreenWindowViewModel.cs" />
@@ -128,6 +137,7 @@
     <Compile Include="ViewModels\HomePanel\HomeGuidContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\HomeToolsContentViewModel.cs" />
     <Compile Include="ViewModels\MainContentViewModel.cs" />
+    <Compile Include="ViewModels\PageEdit\PageEditContentViewModel.cs" />
     <Compile Include="Views\BOTA\BOTAContent.xaml.cs">
       <DependentUpon>BOTAContent.xaml</DependentUpon>
     </Compile>
@@ -170,6 +180,9 @@
     <Compile Include="Views\MainContent.xaml.cs">
       <DependentUpon>MainContent.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\PageEdit\PageEditContent.xaml.cs">
+      <DependentUpon>PageEditContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\ViewContent.xaml.cs">
       <DependentUpon>ViewContent.xaml</DependentUpon>
     </Compile>
@@ -193,6 +206,10 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="Styles\ListBoxStyle.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
     <Page Include="Styles\ListViewStyle.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -279,6 +296,10 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Page Include="Views\PageEdit\PageEditContent.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
     <Page Include="Views\ViewContent.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

+ 48 - 0
PDF Office/Styles/ListBoxStyle.xaml

@@ -0,0 +1,48 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <!--  用于页面编辑的Item样式  -->
+    <ControlTemplate x:Key="ListBoxItemControlTemplate" TargetType="{x:Type ListBoxItem}">
+        <Border
+            x:Name="Bd"
+            Padding="{TemplateBinding Padding}"
+            Background="{TemplateBinding Background}"
+            BorderBrush="{TemplateBinding BorderBrush}"
+            BorderThickness="{TemplateBinding BorderThickness}"
+            SnapsToDevicePixels="True">
+            <ContentPresenter
+                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                Content="{TemplateBinding Content}"
+                ContentStringFormat="{TemplateBinding ContentStringFormat}"
+                ContentTemplate="{TemplateBinding ContentTemplate}"
+                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
+        </Border>
+        <ControlTemplate.Triggers>
+            <MultiTrigger>
+                <MultiTrigger.Conditions>
+                    <Condition Property="IsMouseOver" Value="True" />
+                </MultiTrigger.Conditions>
+                <Setter TargetName="Bd" Property="Background" Value="#1A000000" />
+                <Setter TargetName="Bd" Property="BorderBrush" Value="Transparent" />
+            </MultiTrigger>
+            <MultiTrigger>
+                <MultiTrigger.Conditions>
+                    <Condition Property="Selector.IsSelectionActive" Value="False" />
+                    <Condition Property="IsSelected" Value="True" />
+                </MultiTrigger.Conditions>
+                <!--<Setter TargetName="Bd" Property="Background" Value="#1A477EDE" />
+                <Setter TargetName="Bd" Property="BorderBrush" Value="Transparent" />-->
+            </MultiTrigger>
+            <MultiTrigger>
+                <MultiTrigger.Conditions>
+                    <Condition Property="Selector.IsSelectionActive" Value="True" />
+                    <Condition Property="IsSelected" Value="True" />
+                </MultiTrigger.Conditions>
+                <!--<Setter TargetName="Bd" Property="Background" Value="#1A477EDE" />
+                <Setter TargetName="Bd" Property="BorderBrush" Value="Transparent" />-->
+            </MultiTrigger>
+            <Trigger Property="IsEnabled" Value="False">
+                <Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
+            </Trigger>
+        </ControlTemplate.Triggers>
+    </ControlTemplate>
+</ResourceDictionary>

+ 122 - 3
PDF Office/Styles/TabControlStyle.xaml

@@ -1,4 +1,7 @@
-<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+<ResourceDictionary
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:cus="clr-namespace:PDF_Office.CustomControl">
 
     <Style x:Key="TabControlWithUnderLineStyle" TargetType="{x:Type TabControl}">
         <Setter Property="Padding" Value="2" />
@@ -42,8 +45,8 @@
                             Margin="0,0,0,1"
                             VerticalAlignment="Bottom"
                             SnapsToDevicePixels="True"
-                            Stroke="Transparent"
-                            StrokeThickness="0.1"
+                            Stroke="#E7E9EC"
+                            StrokeThickness="0"
                             X1="0"
                             X2="{Binding ActualWidth, RelativeSource={RelativeSource Self}}" />
                         <Border
@@ -106,4 +109,120 @@
         <Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Cycle" />
         <Setter Property="KeyboardNavigation.TabNavigation" Value="Cycle" />
     </Style>
+
+    <Style x:Key="TabItem_WithUnderLineStyle" TargetType="{x:Type cus:IconAndTextTabItem}">
+        <Setter Property="Foreground" Value="Black" />
+        <Setter Property="Background" Value="White" />
+        <Setter Property="BorderBrush" Value="#FFACACAC" />
+        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
+        <Setter Property="VerticalContentAlignment" Value="Stretch" />
+        <Setter Property="AllowDrop" Value="True" />
+        <Setter Property="SelectedForeground" Value="Black" />
+        <Setter Property="FontSize" Value="14" />
+        <Setter Property="Height" Value="40" />
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type cus:IconAndTextTabItem}">
+                    <Grid
+                        x:Name="templateRoot"
+                        Margin="{TemplateBinding Padding}"
+                        Background="Transparent"
+                        SnapsToDevicePixels="True">
+                        <Border
+                            x:Name="_underline"
+                            HorizontalAlignment="Stretch"
+                            BorderBrush="#FF477EDE"
+                            BorderThickness="0" />
+                        <StackPanel Orientation="Horizontal">
+                            <Path
+                                x:Name="NormalPathIcon"
+                                MaxWidth="20"
+                                MaxHeight="20"
+                                Margin="0,0,4,0"
+                                Data="{Binding NormalPathIcon, RelativeSource={RelativeSource Mode=TemplatedParent}}"
+                                Fill="Black"
+                                Visibility="Visible" />
+                            <Image
+                                x:Name="SelectedIcon"
+                                MaxWidth="20"
+                                MaxHeight=" 20"
+                                Margin="0,0,4,0"
+                                Source="{Binding SelectedIcon, RelativeSource={RelativeSource Mode=TemplatedParent}}"
+                                Visibility="Collapsed" />
+                            <TextBlock
+                                x:Name="txt"
+                                Margin="0,0,4,0"
+                                HorizontalAlignment="Center"
+                                VerticalAlignment="Center"
+                                Foreground="{TemplateBinding Foreground}"
+                                Text="{TemplateBinding Header}"
+                                TextTrimming="CharacterEllipsis"
+                                ToolTip="{TemplateBinding Header}"
+                                Visibility="Visible" />
+                        </StackPanel>
+                    </Grid>
+                    <ControlTemplate.Triggers>
+                        <MultiDataTrigger>
+                            <MultiDataTrigger.Conditions>
+                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true" />
+                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type TabControl}}}" Value="Top" />
+                            </MultiDataTrigger.Conditions>
+                            <Setter TargetName="SelectedIcon" Property="Visibility" Value="Collapsed" />
+                            <Setter TargetName="NormalPathIcon" Property="Visibility" Value="Visible" />
+                            <Setter TargetName="txt" Property="Foreground" Value="#FF000000" />
+                        </MultiDataTrigger>
+                        <MultiDataTrigger>
+                            <MultiDataTrigger.Conditions>
+                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false" />
+                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type TabControl}}}" Value="Left" />
+                            </MultiDataTrigger.Conditions>
+                            <Setter TargetName="templateRoot" Property="Opacity" Value="0.56" />
+                        </MultiDataTrigger>
+                        <MultiDataTrigger>
+                            <MultiDataTrigger.Conditions>
+                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false" />
+                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type TabControl}}}" Value="Bottom" />
+                            </MultiDataTrigger.Conditions>
+                            <Setter TargetName="templateRoot" Property="Opacity" Value="0.56" />
+                        </MultiDataTrigger>
+                        <MultiDataTrigger>
+                            <MultiDataTrigger.Conditions>
+                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false" />
+                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type TabControl}}}" Value="Right" />
+                            </MultiDataTrigger.Conditions>
+                            <Setter TargetName="templateRoot" Property="Opacity" Value="0.56" />
+
+                        </MultiDataTrigger>
+                        <MultiDataTrigger>
+                            <MultiDataTrigger.Conditions>
+                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false" />
+                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type TabControl}}}" Value="Top" />
+                            </MultiDataTrigger.Conditions>
+                            <Setter TargetName="templateRoot" Property="Opacity" Value="0.56" />
+                        </MultiDataTrigger>
+
+                        <MultiDataTrigger>
+                            <MultiDataTrigger.Conditions>
+                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false" />
+                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type TabControl}}}" Value="Top" />
+                            </MultiDataTrigger.Conditions>
+                            <Setter TargetName="NormalPathIcon" Property="Opacity" Value="0.56" />
+                        </MultiDataTrigger>
+
+                        <MultiDataTrigger>
+                            <MultiDataTrigger.Conditions>
+                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true" />
+                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type TabControl}}}" Value="Top" />
+                            </MultiDataTrigger.Conditions>
+                            <Setter Property="Panel.ZIndex" Value="1" />
+                            <Setter TargetName="txt" Property="Foreground" Value="{Binding SelectedForeground, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
+                            <Setter TargetName="_underline" Property="BorderThickness" Value="0,0,0,2" />
+                            <Setter TargetName="SelectedIcon" Property="Visibility" Value="Collapsed" />
+                            <Setter TargetName="NormalPathIcon" Property="Visibility" Value="Visible" />
+                        </MultiDataTrigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
 </ResourceDictionary>

+ 63 - 0
PDF Office/Tools/CommonHelper.cs

@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+
+namespace PDF_Office.Tools
+{
+    public static class CommonHelper
+    {
+        /// <summary>
+        /// 查找对象目标类型的父类控件
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="obj"></param>
+        /// <returns></returns>
+        public static T FindVisualParent<T>(DependencyObject obj) where T : class
+        {
+            try
+            {
+                while (obj != null)
+                {
+                    if (obj is T)
+                        return obj as T;
+
+                    obj = VisualTreeHelper.GetParent(obj);
+                }
+                return null;
+            }
+            catch { return null; }
+        }
+
+        /// <summary>
+        /// 根据对象查找目标类型的子类
+        /// </summary>
+        /// <typeparam name="childItem"></typeparam>
+        /// <param name="obj"></param>
+        /// <returns></returns>
+        public static childItem FindVisualChild<childItem>(DependencyObject obj)
+             where childItem : DependencyObject
+        {
+            try
+            {
+                for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
+                {
+                    DependencyObject child = VisualTreeHelper.GetChild(obj, i);
+                    if (child != null && child is childItem)
+                        return (childItem)child;
+                    else
+                    {
+                        childItem childOfChild = FindVisualChild<childItem>(child);
+                        if (childOfChild != null)
+                            return childOfChild;
+                    }
+                }
+                return null;
+            }
+            catch { return null; }
+        }
+    }
+}

+ 1 - 1
PDF Office/ViewModels/MainWindowViewModel.cs

@@ -1,5 +1,5 @@
 using Microsoft.Win32;
-using PDF_Office.CustomControl;
+using PDF_Office.CustomControl.SystemControl;
 using PDF_Office.Model;
 using PDF_Office.EventAggregators;
 using PDF_Office.Views;

+ 355 - 0
PDF Office/ViewModels/PageEdit/PageEditContentViewModel.cs

@@ -0,0 +1,355 @@
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using System.Collections.ObjectModel;
+using PDF_Office.Model.PageEdit;
+using Prism.Commands;
+using System.Windows;
+using System.Windows.Media.Imaging;
+using System.Windows.Controls.Primitives;
+using System.Diagnostics;
+using System.Windows.Controls;
+using PDF_Office.Tools;
+using System.Windows.Threading;
+
+namespace PDF_Office.ViewModels.PageEdit
+{
+    public class PageEditContentViewModel : BindableBase, INavigationAware
+    {
+
+        private CPDFViewer PDFViewer;
+
+        private ViewContentViewModel viewContentViewModel;
+
+        private IDialogService dialogs;
+
+        /// <summary>
+        /// 是否正在初始化所有列表项,正在初始化时,不刷新图片
+        /// </summary>
+        private bool isInitaling = false;
+
+        private ScrollEventType scrollType = ScrollEventType.EndScroll;
+
+        /// <summary>
+        /// 辅助判断滚轮是否暂停滚动的计时器(暂时没有更好的方法来判断滚轮是否停止滚动)
+        /// 只要滚动就重新计时、通过计时开始0.3秒后没有刷新计时来粗略判断用户是否有暂停滚动
+        /// </summary>
+        private DispatcherTimer timer = new DispatcherTimer();
+
+        #region 属性
+        private Visibility isvisible;
+
+        public Visibility IsVisible
+        {
+            get { return isvisible; }
+            set
+            {
+                SetProperty(ref isvisible, value);
+            }
+        }
+
+
+        #endregion
+
+        #region 命令
+        /// <summary>
+        /// 是否显示  事件
+        /// </summary>
+        public DelegateCommand<object> IsVisibleChangedCommmand { get; set; }
+
+        public DelegateCommand<object> ScollChangedComamnd { get; set; }
+
+        public DelegateCommand<object> ScrollCommand { get; set; }
+
+        public DelegateCommand LoadCommand { get; set; }
+        #endregion
+
+        /// <summary>
+        /// 项数据集合
+        /// </summary>
+        public ObservableCollection<PageEditItem> PageEditItems { get; set; }
+
+        public PageEditContentViewModel(IDialogService dialogService)
+        {
+            dialogs = dialogService;
+            PageEditItems = new ObservableCollection<PageEditItem>();
+            timer.Interval = TimeSpan.FromSeconds(0.2);
+            timer.Tick += Timer_Tick;
+
+
+            IsVisibleChangedCommmand = new DelegateCommand<object>(IsVisibleChangedEvent);
+            ScollChangedComamnd = new DelegateCommand<object>(ScrollChanged);
+            ScrollCommand = new DelegateCommand<object>(ScrollEvent);
+            LoadCommand = new DelegateCommand(ControlLoad);
+        }
+
+
+        #region 事件
+        /// <summary>
+        /// 判断鼠标滚轮是否停止滚动的事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Timer_Tick(object sender, EventArgs e)
+        {
+            if (PDFViewer != null && PDFViewer.Document != null)
+            {
+                timer.Stop();
+            }
+        }
+
+        /// <summary>
+        /// 鼠标滚轮滚动时触发的事件
+        /// </summary>
+        /// <param name="e"></param>
+        private void ScrollChanged(object e)
+        {
+            var args = (ScrollChangedEventArgs)e;
+            var scrollviewer = args.OriginalSource as ScrollViewer;
+            if (scrollviewer == null)
+                return;
+            if (args != null && PDFViewer != null)
+            {
+                //确保第一次所有item添加完之后再刷新图片
+                //鼠标拖动过程中不拿图
+                if (!isInitaling&& scrollType== ScrollEventType.EndScroll)
+                {
+                    //size是拿的DataTemplate的宽高
+                    var range = GetRoughFromView(scrollviewer, new Size(208, 320), new Thickness(5, 10, 5, 10));
+                    RefreshItemImage(range.Item1, range.Item2 + 1);
+                    RefreshBookMarkList();
+                }
+                else//其余滚动的时候,只有滚动暂停后再刷图
+                {
+                    if (args.VerticalChange != 0)
+                    {
+                        timer.Start();
+                    }
+                }
+
+            }
+        }
+
+        /// <summary>
+        /// 拖动右侧滑块时触发的事件
+        /// </summary>
+        /// <param name="e"></param>
+        private void ScrollEvent(object e)
+        {
+            var args = (ScrollEventArgs)e;
+            scrollType = args.ScrollEventType;
+            var scroll = CommonHelper.FindVisualParent<ScrollViewer>(args.OriginalSource as ScrollBar);
+            if(args!=null&&PDFViewer!=null&&scroll!=null)
+            {
+                if(scrollType == ScrollEventType.EndScroll)
+                {
+                    //size是拿的DataTemplate的宽高
+                    var range = GetRoughFromView(scroll, new Size(208, 320), new Thickness(5, 10, 5, 10));
+                    RefreshItemImage(range.Item1, range.Item2+1);
+                
+                }
+            }
+        }
+
+        private void IsVisibleChangedEvent(object e)
+        {
+            var args = (DependencyPropertyChangedEventArgs)e;
+            if (args == null)
+                return;
+            if ((Visibility)args.NewValue == Visibility.Visible)
+            {
+                GetSourceItems();
+                RefreshBookMarkList();
+               
+            }
+        }
+
+        private void ControlLoad()
+        {
+
+        }
+
+
+        private void Load(object e)
+        {
+            Debug.Write("Loaded");
+        }
+        #endregion
+
+        /// <summary>
+        /// 从PDFView获取所有Items集合
+        /// </summary>
+        private void GetSourceItems()
+        {
+            PageEditItems.Clear();
+            isInitaling = true;
+            for (int i = 0; i < PDFViewer.Document.PageCount; i++)
+            {
+                PageEditItem item = new PageEditItem();
+                item.PageNumber = i + 1;
+                var pagesize = PDFViewer.Document.GetPageSize(i);
+
+                item.PageSize = $"{pagesize.Width}mm*{pagesize.Height} mm";
+                RefreshItemImage(i,i);
+                PageEditItems.Add(item);
+            }
+            isInitaling = false;
+        }
+
+        /// <summary>
+        /// 刷新书签列表
+        /// </summary>
+        public void RefreshBookMarkList()
+        {
+            if (PDFViewer != null)
+            {
+                var booklist = PDFViewer.Document.GetBookmarkList();
+                if (booklist == null)
+                { 
+                    return; 
+                }
+                //获取所有书签的Index集合
+                List<int> marks = new List<int>();
+                for (int i = 0; i < booklist.Count; i++)
+                {
+                    marks.Add(booklist[i].PageIndex);
+                }
+
+                //不能只遍历marks集合,考虑书签集合元素删除的情况
+                for (int k = 0; k < PageEditItems.Count; k++)
+                {
+                    if (marks.Contains(k))
+                        PageEditItems[k].HaveBookMark = true;
+                    else
+                        PageEditItems[k].HaveBookMark = false;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 刷新指定范围的图片
+        /// </summary>
+        /// <param name="startIndex"></param>
+        /// <param name="endIndex"></param>
+        private async void RefreshItemImage(int startIndex,int endIndex)
+        {
+            for (int i = startIndex; i <=endIndex;i++)
+            {
+                if (i <= PDFViewer.Document.PageCount - 1&&i>=0)
+                {
+                    //宽高为样式中图片控件宽高
+                    await PDFViewer.GetThumbnail(i, 208, 294);
+                }
+            }
+        }
+
+
+        #region Navigate
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+           
+
+        }
+
+        /// <summary>
+        /// 从其他页面导航过来的时候会触发
+        /// </summary>
+        /// <param name="navigationContext"></param>
+        public async void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if (PDFViewer != null)
+            {
+                PDFViewer.OnThumbnailGenerated += PDFViewer_OnThumbnailGenerated;
+                //每次进入前 更新item项,刷新书签列表
+                await Task.Run(() =>
+                {
+                    App.Current.Dispatcher.Invoke(() =>
+                    {
+                        GetSourceItems();
+                    });
+                });
+                RefreshBookMarkList();
+            }
+        }
+        #endregion
+
+        /// <summary>
+        /// 获取滑轨的垂直偏移量,结合item总数和Item尺寸以及间隔,来估算实际展示的item范围
+        /// 返回值为页面范围  从1开始
+        /// </summary>
+        /// <param name="scrollViewer"></param>
+        /// <param name="itemSize"></param>
+        /// <param name="itemMargin"></param>
+        /// <returns></returns>
+        private Tuple<int, int, int> GetRoughFromView(ScrollViewer scrollViewer, Size itemSize, Thickness itemMargin)
+        {
+            if (PDFViewer == null || PDFViewer.Document == null || scrollViewer == null || scrollViewer.ActualHeight == 0 || scrollViewer.ActualWidth == 0|| scrollViewer.ExtentHeight==0)//视图展开
+                return new Tuple<int, int, int>(0, 0, 0);
+            try
+            {
+                var currentHeight = scrollViewer.ActualHeight;
+                var currentWidth = scrollViewer.ActualWidth;
+                //计算当前窗口大小能显示的行数和列数
+                var columnCount = (int)(currentWidth / (itemSize.Width + itemMargin.Left));
+                var rowCount = (int)Math.Ceiling(currentHeight / (itemSize.Height + itemMargin.Bottom));
+
+                var preItemCount = (int)((scrollViewer.VerticalOffset / scrollViewer.ExtentHeight) * ((PDFViewer.Document.PageCount + columnCount - 1) / columnCount));//滑动百分比*行数 = 大概的垂直位置
+                preItemCount = preItemCount * columnCount;
+                var preEnd = (int)(((scrollViewer.VerticalOffset + scrollViewer.ActualHeight) / scrollViewer.ExtentHeight) * ((PDFViewer.Document.PageCount + columnCount - 1) / columnCount));
+                preEnd = preEnd * columnCount + columnCount - 1;
+
+                var middle = (int)Math.Ceiling(preItemCount + preEnd / 2d);
+
+                return new Tuple<int, int, int>(
+                    Math.Max(preItemCount, 0),
+                    Math.Min(PageEditItems.Count, preEnd),
+                    middle);
+            }
+            catch (Exception ex)
+            {
+
+            }
+            return new Tuple<int, int, int>(0, 0, 0);
+        }
+
+        /// <summary>
+        /// 从底层库获取对应页面的图片
+        /// </summary>
+        /// <param name="pageIndex"></param>
+        /// <param name="thumb"></param>
+        /// <param name="w"></param>
+        /// <param name="h"></param>
+        private void PDFViewer_OnThumbnailGenerated(int pageIndex, byte[] thumb, int w, int h)
+        {
+            try
+            {
+                if (PageEditItems.Count >= pageIndex + 1&&!PageEditItems[pageIndex].IsGetImage)
+                {
+                    PixelFormat fmt = PixelFormats.Bgra32;
+                    BitmapSource bps = BitmapSource.Create(w, h, 96.0, 96.0, fmt, null, thumb, (w * fmt.BitsPerPixel + 7) / 8);
+                    PageEditItems[pageIndex].Image = bps;
+                    PageEditItems[pageIndex].IsGetImage = true;
+                }
+            }
+            catch
+            {
+              
+            }
+        }
+    }
+}

+ 128 - 6
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -14,16 +14,14 @@ using Prism.Services.Dialogs;
 using PDF_Office.CustomControl;
 using PDF_Office.Model;
 using PDF_Office.Tools;
+using System.Windows;
+using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels
 {
 
     public class ViewContentViewModel : BindableBase, INavigationAware
     {
-        public DelegateCommand LoadFile { get; set; }
-
-        public DelegateCommand Load { get; set; }
-
         private CPDFViewer PDFViewer { get; set; }
 
         private MainContentViewModel mainViewModel { get; set; }
@@ -38,6 +36,56 @@ namespace PDF_Office.ViewModels
 
         public string PropertyRegionName { get; set; }
 
+        public string ToolContentRegionName { get; set; }
+
+        public DelegateCommand LoadFile { get; set; }
+
+        public DelegateCommand Load { get; set; }
+
+        public DelegateCommand<object> TabControlSelectionChangedCommand { get; set; }
+
+
+        private int gridToolRow = 1;
+        /// <summary>
+        /// 控制ToolContent的Row
+        /// </summary>
+        public int GridToolRow
+        {
+            get { return gridToolRow; }
+            set
+            {
+                SetProperty(ref gridToolRow, value);
+            }
+        }
+
+        private int gridToolRowSpan = 3;
+        /// <summary>
+        /// 控制ToolContent的RowSpan
+        /// </summary>
+        public int GridToolRowSpan
+        {
+            get { return gridToolRowSpan; }
+            set
+            {
+                SetProperty(ref gridToolRowSpan, value);
+            }
+        }
+
+        private Visibility toolContentVisible = Visibility.Visible;
+        /// <summary>
+        /// 控制Content的显示
+        /// 留意:显示前需要先注入内容、设置好行和跨行数
+        /// </summary>
+        public Visibility ToolContentVisible
+        {
+            get { return toolContentVisible; }
+            set
+            {
+                SetProperty(ref toolContentVisible, value);
+            }
+        }
+
+
         private bool isOpenFile = false;
 
         /// <summary>
@@ -52,12 +100,16 @@ namespace PDF_Office.ViewModels
 
             LoadFile = new DelegateCommand(loadFile);
             Load = new DelegateCommand(LoadControl);
+            TabControlSelectionChangedCommand = new DelegateCommand<object>(TabControlSelectonChangedEvent);
 
             ViwerRegionName = Guid.NewGuid().ToString();
             BOTARegionName = Guid.NewGuid().ToString();
             PropertyRegionName = Guid.NewGuid().ToString();
+            ToolContentVisible = Visibility.Visible;
+            ToolContentRegionName = Guid.NewGuid().ToString();
+            ToolContentVisible = Visibility.Collapsed;
+
 
- 
         }
 
         private void LoadControl()
@@ -71,7 +123,7 @@ namespace PDF_Office.ViewModels
         }
 
         /// <summary>
-        /// 将PDFViwer
+        /// 将PDFViwer添加到Region
         /// </summary>
         private void loadFile()
         {
@@ -79,6 +131,23 @@ namespace PDF_Office.ViewModels
             region.AddToRegion(ViwerRegionName, PDFViewer);
         }
 
+        private void TabControlSelectonChangedEvent(object e)
+        {
+            var args = e as SelectionChangedEventArgs;
+            if(args!=null)
+            {
+                var item = args.AddedItems[0] as TabItem;
+                if(item.Name=="TabItemPageEdit")
+                {
+                    EnterPageEdit();
+                }
+                else
+                {
+                    ExitPageEdit();
+                }
+            }
+        }
+
         #region PDFViewer鼠标滚轮缩放事件
         public void PdfViewer_MouseWheelZoomHandler(object sender, bool e)
         {
@@ -116,6 +185,7 @@ namespace PDF_Office.ViewModels
         }
         #endregion
 
+        #region Navigate
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             if (isOpenFile)
@@ -146,5 +216,57 @@ namespace PDF_Office.ViewModels
         {
 
         }
+        #endregion
+
+        /// <summary>
+        /// 显示前添加内容到Region
+        /// </summary>
+        /// <param name="isPageEdit"></param>
+        private void ShowToolContent(bool isPageEdit = true)
+        {
+            //显示页面编辑
+            if(isPageEdit)
+            {
+                if(GridToolRow!=1)
+                {
+                    GridToolRow = 1;
+                }
+
+                if(GridToolRowSpan!=3)
+                {
+                    GridToolRowSpan = 3;
+                }
+         
+            }
+            else
+            {
+                //显示其他工具模式 如密文、水印等
+                GridToolRow = 0;
+                GridToolRowSpan = 4;
+            }
+            ToolContentVisible = Visibility.Visible;
+        }
+
+        /// <summary>
+        /// 进入页面编辑模式
+        /// </summary>
+        private void EnterPageEdit()
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add(ParameterNames.ViewContentViewModel,this);
+            region.RequestNavigate(ToolContentRegionName, "PageEditContent" , param);
+            ShowToolContent();
+         
+        }
+
+        /// <summary>
+        /// 退出页面编辑模式,隐藏ToolContent
+        /// </summary>
+
+        public void ExitPageEdit()
+        {
+            ToolContentVisible = Visibility.Collapsed;
+        }
     }
 }

+ 1 - 1
PDF Office/Views/BOTA/BOTAContent.xaml

@@ -68,7 +68,7 @@
             Style="{StaticResource TabControlWithUnderLineStyle}"
             TabStripPlacement="Left">
             <!--  建立一个空的标头占位  -->
-            <TabItem />
+            <TabItem Height="0" />
             <TabItem
                 Name="TabItemThumbnail"
                 Width="48"

+ 7 - 0
PDF Office/Views/MainContent.xaml.cs

@@ -23,9 +23,16 @@ namespace PDF_Office.Views
     /// </summary>
     public partial class MainContent : UserControl
     {
+
+        /// <summary>
+        /// 用来区分每个页签的唯一识别码,避免聚合事件重复订阅
+        /// </summary>
+        public string Unicode { get; set; }
+
         public MainContent()
         {
             InitializeComponent();
+            Unicode = Guid.NewGuid().ToString();
         }
     }
 }

+ 143 - 0
PDF Office/Views/PageEdit/PageEditContent.xaml

@@ -0,0 +1,143 @@
+<UserControl
+    x:Class="PDF_Office.Views.PageEdit.PageEditContent"
+    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:cussys="clr-namespace:PDF_Office.CustomControl.SystemControl"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+    xmlns:local="clr-namespace:PDF_Office.Views.PageEdit"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:pageedit="clr-namespace:PDF_Office.Model.PageEdit"
+    xmlns:pageedit1="clr-namespace:PDF_Office.ViewModels.PageEdit"
+    xmlns:prism="http://prismlibrary.com/"
+    xmlns:wpftk="clr-namespace:WpfToolkit.Controls;assembly=VirtualizingWrapPanel"
+    Name="PageEdit"
+    d:DataContext="{d:DesignInstance Type=pageedit1:PageEditContentViewModel}"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    prism:ViewModelLocator.AutoWireViewModel="True"
+    Visibility="{Binding IsVisible, Mode=TwoWay}"
+    mc:Ignorable="d">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <convert:BoolToVisible x:Key="BoolToVisibleConvert" />
+
+            <DataTemplate x:Key="PageEditListBoxItemTemplate" DataType="{x:Type pageedit:PageEditItem}">
+                <Grid Height="320">
+                    <Border
+                        Name="BdBorder"
+                        Height="auto"
+                        VerticalAlignment="Top"
+                        BorderBrush="Blue"
+                        BorderThickness="0"
+                        CornerRadius="0">
+                        <Grid
+                            Width="208"
+                            Height="294"
+                            Margin="1">
+                            <Image Source="{Binding Image}" />
+                            <Border
+                                Width="10"
+                                Height="10"
+                                Margin="0,10,10,0"
+                                HorizontalAlignment="Right"
+                                VerticalAlignment="Top"
+                                Background="Yellow"
+                                Visibility="{Binding HaveBookMark, Converter={StaticResource BoolToVisibleConvert}}" />
+                        </Grid>
+                    </Border>
+                    <Border
+                        Name="BdPageNum"
+                        Margin="0,4,0,0"
+                        VerticalAlignment="Bottom"
+                        Background="Transparent">
+                        <StackPanel
+                            Name="StkpnlButtom"
+                            Width="auto"
+                            MinWidth="116"
+                            HorizontalAlignment="Center"
+                            Background="Transparent">
+                            <TextBlock
+                                Width="auto"
+                                Height="22"
+                                HorizontalAlignment="Center"
+                                FontSize="14"
+                                Text="{Binding PageNumber}" />
+                            <TextBlock
+                                Width="auto"
+                                Height="22"
+                                HorizontalAlignment="Center"
+                                FontSize="14"
+                                Text="{Binding PageSize}"
+                                Visibility="{Binding ShowPageSize, Converter={StaticResource BoolToVisibleConvert}}" />
+                        </StackPanel>
+                    </Border>
+                </Grid>
+
+                <DataTemplate.Triggers>
+                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
+                        <Setter TargetName="BdBorder" Property="BorderThickness" Value="1" />
+                        <Setter TargetName="BdBorder" Property="CornerRadius" Value="4" />
+                        <Setter TargetName="BdPageNum" Property="Background" Value="Blue" />
+                        <Setter TargetName="BdPageNum" Property="CornerRadius" Value="4" />
+                    </DataTrigger>
+                </DataTemplate.Triggers>
+            </DataTemplate>
+        </ResourceDictionary>
+    </UserControl.Resources>
+
+    <Border
+        BorderBrush="#F2F2F2"
+        BorderThickness="0,1,0,0"
+        Visibility="{Binding IsVisible, Mode=TwoWay}">
+        <Grid>
+            <Grid.RowDefinitions>
+                <RowDefinition Height="40" />
+                <RowDefinition />
+            </Grid.RowDefinitions>
+            <Grid Background="#FFFFFF">
+                <StackPanel Name="StkpnlCenter" />
+                <StackPanel Name="StkpnlRight" />
+            </Grid>
+            <ListBox
+                Grid.Row="1"
+                Padding="0"
+                AllowDrop="True"
+                ItemTemplate="{StaticResource PageEditListBoxItemTemplate}"
+                ItemsSource="{Binding PageEditItems}"
+                ScrollViewer.CanContentScroll="True"
+                SelectionMode="Extended"
+                VirtualizingPanel.CacheLength="1"
+                VirtualizingPanel.CacheLengthUnit="Page"
+                VirtualizingPanel.ScrollUnit="Pixel"
+                VirtualizingPanel.VirtualizationMode="Standard">
+                <ListBox.ItemContainerStyle>
+                    <Style TargetType="{x:Type ListBoxItem}">
+                        <Setter Property="Template" Value="{StaticResource ListBoxItemControlTemplate}" />
+                        <Setter Property="Margin" Value="0,10" />
+                        <Setter Property="Visibility" Value="{Binding Visible}" />
+                    </Style>
+                </ListBox.ItemContainerStyle>
+                <ListBox.ItemsPanel>
+                    <ItemsPanelTemplate>
+                        <wpftk:VirtualizingWrapPanel />
+                    </ItemsPanelTemplate>
+                </ListBox.ItemsPanel>
+                <i:Interaction.Triggers>
+                    <cussys:RoutedEventTrigger RoutedEvent="ScrollViewer.ScrollChanged">
+                        <i:InvokeCommandAction Command="{Binding ScollChangedComamnd}" PassEventArgsToCommand="True" />
+                    </cussys:RoutedEventTrigger>
+                    <cussys:RoutedEventTrigger RoutedEvent="ScrollBar.Scroll">
+                        <i:InvokeCommandAction Command="{Binding ScrollCommand}" PassEventArgsToCommand="True" />
+                    </cussys:RoutedEventTrigger>
+                </i:Interaction.Triggers>
+            </ListBox>
+        </Grid>
+        <i:Interaction.Triggers>
+            <i:EventTrigger EventName="Loaded">
+                <i:InvokeCommandAction Command="{Binding LoadCommand}" />
+            </i:EventTrigger>
+        </i:Interaction.Triggers>
+    </Border>
+</UserControl>

+ 46 - 0
PDF Office/Views/PageEdit/PageEditContent.xaml.cs

@@ -0,0 +1,46 @@
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.Views.PageEdit
+{
+    /// <summary>
+    /// PageEditContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class PageEditContent : UserControl
+    {
+        public PageEditContent()
+        {
+            InitializeComponent();
+        }
+
+
+        public PageEditContent(IEventAggregator eventAggregator) :this()
+        {
+
+        }
+
+
+        /// <summary>
+        /// 每次显示的时候就触发事件,刷新所有图片
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void PageEdit_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
+        {
+
+        }
+    }
+}

+ 57 - 21
PDF Office/Views/ViewContent.xaml

@@ -3,18 +3,21 @@
     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}"/>
+            <prism:InvokeCommandAction Command="{Binding Load}" />
         </i:EventTrigger>
     </i:Interaction.Triggers>
     <UserControl.Resources>
@@ -42,7 +45,7 @@
             <Button
                 Width="16"
                 Height="16"
-                Margin="8" 
+                Margin="8"
                 ToolTip="Undo" />
             <Button
                 Width="16"
@@ -76,26 +79,59 @@
             VerticalAlignment="Top"
             BorderThickness="0"
             Style="{StaticResource TabControlWithUnderLineStyle}">
-            <TabItem Height="40" Header="注释">
+            <cus:IconAndTextTabItem
+                x:Name="TabItemAnnotation"
+                Header="注释"
+                Style="{StaticResource TabItem_WithUnderLineStyle}">
                 <Grid Grid.Row="1" Height="40" />
-            </TabItem>
-            <TabItem Header="页面" />
-            <TabItem Header="转换" />
-            <TabItem Header="扫描和OCR">
+            </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" />
-            </TabItem>
-            <TabItem Height="40" Header="编辑">
+            </cus:IconAndTextTabItem>
+            <cus:IconAndTextTabItem
+                x:Name="TabItemEdit"
+                Height="40"
+                Header="编辑"
+                Style="{StaticResource TabItem_WithUnderLineStyle}">
                 <Grid Grid.Row="1" Height="40" />
-            </TabItem>
-            <TabItem Height="40" Header="表单">
+            </cus:IconAndTextTabItem>
+            <cus:IconAndTextTabItem
+                x:Name="TabItemForm"
+                Height="40"
+                Header="表单"
+                Style="{StaticResource TabItem_WithUnderLineStyle}">
                 <Grid Grid.Row="1" Height="40" />
-            </TabItem>
-            <TabItem Height="40" Header="填写与签名">
+            </cus:IconAndTextTabItem>
+            <cus:IconAndTextTabItem
+                x:Name="TabItemFill"
+                Height="40"
+                Header="填写与签名"
+                Style="{StaticResource TabItem_WithUnderLineStyle}">
                 <Grid Grid.Row="1" Height="40" />
-            </TabItem>
-            <TabItem Height="40" Header="工具">
+            </cus:IconAndTextTabItem>
+            <cus:IconAndTextTabItem
+                x:Name="TabItemTool"
+                Height="40"
+                Header="工具"
+                Style="{StaticResource TabItem_WithUnderLineStyle}">
                 <Grid Grid.Row="1" Height="40" />
-            </TabItem>
+            </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>
@@ -130,10 +166,10 @@
         <local:BottomToolContent Grid.Row="3" />
 
         <ContentControl
-            Grid.Row="2"
-            Grid.RowSpan="2"
-            Visibility="Collapsed">
-            <Grid Background="Red" />
-        </ContentControl>
+            Name="ContentTool"
+            Grid.Row="{Binding GridToolRow}"
+            Grid.RowSpan="{Binding GridToolRowSpan}"
+            prism:RegionManager.RegionName="{Binding ToolContentRegionName}"
+            Visibility="{Binding ToolContentVisible}" />
     </Grid>
 </UserControl>

+ 1 - 0
PDF Office/packages.config

@@ -6,4 +6,5 @@
   <package id="Prism.DryIoc" version="8.1.97" targetFramework="net462" />
   <package id="Prism.Wpf" version="8.1.97" targetFramework="net462" />
   <package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
+  <package id="VirtualizingWrapPanel" version="1.5.7" targetFramework="net462" />
 </packages>