Forráskód Böngészése

Merge branch 'practice2' into dev

ZhouJieSheng 2 éve
szülő
commit
9df7899269
29 módosított fájl, 2765 hozzáadás és 1006 törlés
  1. 1 0
      PDF Office/App.xaml.cs
  2. 1 1
      PDF Office/CustomControl/TextBoxWithTip.xaml
  3. 4 20
      PDF Office/CustomControl/TextBoxWithTip.xaml.cs
  4. 39 5
      PDF Office/Helper/CommonHelper.cs
  5. 15 0
      PDF Office/Model/BOTA/AnnotationSortOrder.cs
  6. 28 0
      PDF Office/Model/BOTA/AuthorItem.cs
  7. 49 46
      PDF Office/Model/ParameterNames.cs
  8. 2 1
      PDF Office/PDF Office.csproj
  9. BIN
      PDF Office/Resources/BOTA/empty_annotation.png
  10. 37 28
      PDF Office/Styles/ContextMenuStyle.xaml
  11. 149 117
      PDF Office/Styles/ContextMenuTextEditStyle.xaml
  12. 15 15
      PDF Office/Styles/ListBoxStyle.xaml
  13. 39 22
      PDF Office/Styles/OutLineItemStyle.xaml
  14. 89 54
      PDF Office/Styles/RadioButtonStyle.xaml
  15. 519 17
      PDF Office/ViewModels/BOTA/AnnotationContentViewModel.cs
  16. 0 171
      PDF Office/ViewModels/BOTA/AnnotationListItemViewModel.cs
  17. 405 86
      PDF Office/ViewModels/Dialog/BOTA/ScreenAnnotationDialogViewModel.cs
  18. 343 3
      PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs
  19. 76 32
      PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs
  20. 18 23
      PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs
  21. 3 2
      PDF Office/ViewModels/ViewContentViewModel.cs
  22. 136 126
      PDF Office/Views/BOTA/AnnotationContent.xaml
  23. 4 0
      PDF Office/Views/BOTA/AnnotationContent.xaml.cs
  24. 86 62
      PDF Office/Views/BOTA/AnnotationListItem.xaml
  25. 22 22
      PDF Office/Views/BOTA/AnnotationListItem.xaml.cs
  26. 200 36
      PDF Office/Views/Dialog/BOTA/ScreenAnnotationDialog.xaml
  27. 3 2
      PDF Office/Views/Dialog/BOTA/ScreenAnnotationDialog.xaml.cs
  28. 443 113
      PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml
  29. 39 2
      PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml.cs

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

@@ -252,6 +252,7 @@ namespace PDF_Office
             containerRegistry.RegisterDialog<ConverterExcelDialog>(DialogNames.ConverterExcelDialog);
             containerRegistry.RegisterDialog<ConverterProgressBarDialog>(DialogNames.ConverterProgressBarDialog);
             containerRegistry.RegisterDialog<ScreenAnnotationDialog>(DialogNames.ScreenAnnotationDialog);
+            containerRegistry.RegisterDialog<AddBookmarkDialog>(DialogNames.AddBookmarkDialog);
 
             #endregion 注册弹窗
         }

+ 1 - 1
PDF Office/CustomControl/TextBoxWithTip.xaml

@@ -43,4 +43,4 @@
             </Setter>
         </Style>
     </UserControl.Style>
-</UserControl>
+</UserControl>

+ 4 - 20
PDF Office/CustomControl/TextBoxWithTip.xaml.cs

@@ -26,8 +26,6 @@ namespace PDF_Office.CustomControl
             InitializeComponent();
         }
 
-
-
         public string TipText
         {
             get { return (string)GetValue(TipTextProperty); }
@@ -38,8 +36,6 @@ namespace PDF_Office.CustomControl
         public static readonly DependencyProperty TipTextProperty =
             DependencyProperty.Register("TipText", typeof(string), typeof(TextBoxWithTip), new PropertyMetadata(""));
 
-
-
         public Visibility ShowTip
         {
             get { return (Visibility)GetValue(ShowTipProperty); }
@@ -50,9 +46,6 @@ namespace PDF_Office.CustomControl
         public static readonly DependencyProperty ShowTipProperty =
             DependencyProperty.Register("ShowTip", typeof(Visibility), typeof(TextBoxWithTip), new PropertyMetadata(Visibility.Hidden));
 
-
-
-
         public string Text
         {
             get { return (string)GetValue(TextProperty); }
@@ -63,19 +56,15 @@ namespace PDF_Office.CustomControl
         public static readonly DependencyProperty TextProperty =
             DependencyProperty.Register("Text", typeof(string), typeof(TextBoxWithTip), new PropertyMetadata(""));
 
-
-
-        public string  PlaceHoldText
+        public string PlaceHoldText
         {
-            get { return (string )GetValue(PlaceHoldTextProperty); }
+            get { return (string)GetValue(PlaceHoldTextProperty); }
             set { SetValue(PlaceHoldTextProperty, value); }
         }
 
         // Using a DependencyProperty as the backing store for PlaceHoldText.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty PlaceHoldTextProperty =
-            DependencyProperty.Register("PlaceHoldText", typeof(string ), typeof(TextBoxWithTip), new PropertyMetadata(""));
-
-
+            DependencyProperty.Register("PlaceHoldText", typeof(string), typeof(TextBoxWithTip), new PropertyMetadata(""));
 
         public bool IsError
         {
@@ -86,10 +75,5 @@ namespace PDF_Office.CustomControl
         // Using a DependencyProperty as the backing store for IsError.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty IsErrorProperty =
             DependencyProperty.Register("IsError", typeof(bool), typeof(TextBoxWithTip), new PropertyMetadata(false));
-
-
-
-
-
     }
-}
+}

+ 39 - 5
PDF Office/Helper/CommonHelper.cs

@@ -1,4 +1,5 @@
 using PDF_Office.Model.PageEdit;
+using PDF_Office.ViewModels.Dialog.BOTA;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
@@ -12,6 +13,26 @@ using System.Windows.Media;
 
 namespace PDF_Office.Helper
 {
+    public class Compare<T, C> : IEqualityComparer<T>
+    {
+        private Func<T, C> _getField;
+
+        public Compare(Func<T, C> getfield)
+        {
+            this._getField = getfield;
+        }
+
+        public bool Equals(T x, T y)
+        {
+            return EqualityComparer<C>.Default.Equals(_getField(x), _getField(y));
+        }
+
+        public int GetHashCode(T obj)
+        {
+            return EqualityComparer<C>.Default.GetHashCode(this._getField(obj));
+        }
+    }
+
     /// <summary>
     /// 1 FindVisualParent 查找目标类型的父类控件
     /// 2 FindVisualChild  查找目标类型的子类控件
@@ -25,6 +46,19 @@ namespace PDF_Office.Helper
     /// </summary>
     public static class CommonHelper
     {
+        /// <summary>
+        /// 自定义Distinct扩展方法
+        /// </summary>
+        /// <typeparam name="T">要去重的对象类</typeparam>
+        /// <typeparam name="C">自定义去重的字段类型</typeparam>
+        /// <param name="source">要去重的对象</param>
+        /// <param name="getfield">获取自定义去重字段的委托</param>
+        /// <returns></returns>
+        public static IEnumerable<T> DistinctHelper<T, C>(this IEnumerable<T> source, Func<T, C> getfield)
+        {
+            return source.Distinct(new Compare<T, C>(getfield));
+        }
+
         /// <summary>
         /// 查找对象目标类型的父类控件
         /// </summary>
@@ -207,9 +241,9 @@ namespace PDF_Office.Helper
         /// 显示系统文件浏览器
         /// </summary>
         /// <param name="selectedFile">要选中的文件路径</param>
-        public static void ShowFileBrowser(string selectedFile=null)
+        public static void ShowFileBrowser(string selectedFile = null)
         {
-            if(string.IsNullOrEmpty(selectedFile))
+            if (string.IsNullOrEmpty(selectedFile))
             {
                 Process.Start(@"explorer.exe");
             }
@@ -217,7 +251,7 @@ namespace PDF_Office.Helper
             {
                 Process.Start(@"explorer.exe", "/select,\"" + selectedFile + "\"");
             }
-    
+
         }
 
 
@@ -288,7 +322,7 @@ namespace PDF_Office.Helper
         /// <param name="size"></param>
         /// <param name="unit"></param>
         /// <returns></returns>
-        public static double GetUnitsFromPageSize(double size,PageItemUnits unit = PageItemUnits.MM)
+        public static double GetUnitsFromPageSize(double size, PageItemUnits unit = PageItemUnits.MM)
         {
             double sizeWithUnit = 0;
             switch (unit)
@@ -297,7 +331,7 @@ namespace PDF_Office.Helper
                     sizeWithUnit = (size * 96 / 72.0) / GetDpi() * 25.4;
                     break;
                 case PageItemUnits.CM:
-                    sizeWithUnit = (size * 96 / 72.0) / GetDpi() * 25.4/10.0;
+                    sizeWithUnit = (size * 96 / 72.0) / GetDpi() * 25.4 / 10.0;
                     break;
                 case PageItemUnits.IN:
                     sizeWithUnit = (size * 96 / 72.0) / GetDpi();

+ 15 - 0
PDF Office/Model/BOTA/AnnotationSortOrder.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.BOTA
+{
+    public enum AnnotationSortOrder
+    {
+        TimeAscending,
+        TimeDescending,
+        PageIndexAscending,
+    }
+}

+ 28 - 0
PDF Office/Model/BOTA/AuthorItem.cs

@@ -0,0 +1,28 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.BOTA
+{
+    public class AuthorItem : BindableBase
+    {
+        private string name;
+
+        public string Name
+        {
+            get { return name; }
+            set
+            {
+                SetProperty(ref name, value);
+            }
+        }
+
+        public AuthorItem(string name)
+        {
+            Name = name;
+        }
+    }
+}

+ 49 - 46
PDF Office/Model/ParameterNames.cs

@@ -5,72 +5,75 @@ using System.Text;
 using System.Threading.Tasks;
 
 namespace PDF_Office.Model
-{
+{
     /// <summary>
     /// 记录常用的参数的Key名称,防止String写错
     /// </summary>
-    public static class ParameterNames
-    {
+    public static class ParameterNames
+    {
         #region ViewModelName
 
-        public static string MainViewModel = "MainViewModel";
-
-        public static string ViewContentViewModel = "ViewContentViewModel";
-
+        public static string MainViewModel = "MainViewModel";
+
+        public static string ViewContentViewModel = "ViewContentViewModel";
+
         public static string PropertyPanelContentViewModel = "PropertyPanelContentViewModel";
-
+
         #endregion ViewModelName
-
-        public static string PDFViewer = "PDFViewer";
-
-        public static string FilePath = "FilePath";
-
-        public static string PassWord = "PassWord";
-
-        public static string PDFDocument = "PDFDocument";
-
-        public static string AddTab = "AddTab";
-
-        public static string InsertType_File = "Insert_File";
-
-        public static string InsertType_Blank = "Insert_Blank";
-
-        public static string InsertType_Custom = "Insert_Custom";
-
-        public static string BatchProcessing_Name = "BatchProcessing_Name";
-
+
+        public static string PDFViewer = "PDFViewer";
+
+        public static string FilePath = "FilePath";
+
+        public static string PassWord = "PassWord";
+
+        public static string PDFDocument = "PDFDocument";
+
+        public static string AddTab = "AddTab";
+
+        public static string InsertType_File = "Insert_File";
+
+        public static string InsertType_Blank = "Insert_Blank";
+
+        public static string InsertType_Custom = "Insert_Custom";
+
+        public static string BatchProcessing_Name = "BatchProcessing_Name";
+
         /// <summary>
         /// 书签
         /// </summary>
-        public static string Bookmark = "Bookmark";
-
-        public static string Title = "Title";
-
-        public static string BookmarkInfo = "BookmarkInfo";
-
-        /// <summary>
-        /// 注释列表
+        public static string Bookmark = "Bookmark";
+
+        public static string Title = "Title";
+
+        public static string BookmarkInfo = "BookmarkInfo";
+
+        /// <summary>
+        /// 注释列表
         /// </summary>
-
-        public static string Annotation = "Annotation";
-        public static string AnnotEvent = "AnnotEvent";
-        public static string AnnotationList = "AnnotationList";
 
+        public static string Annotation = "Annotation";
+        public static string AnnotEvent = "AnnotEvent";
+        public static string AnnotationList = "AnnotationList";
+        public static string AnnotArgsTypes = "AnnotArgsTypes";
+        public static string AnnotationColors = "AnnotationColors";
+        public static string AnnotationAuthor = "AnnotationAuthor";
+        public static string AnnotationCleanState = "AnnotationCleanState";
         /// <summary>
         /// 底部工具栏
         /// </summary>
-        public static string BottomToolContentViewModel = "BottomToolContentViewModel";
-
+        public static string BottomToolContentViewModel = "BottomToolContentViewModel";
+
         /// <summary>
         /// BOTA缩略图
         /// </summary>
-        public static string BOTAThumb = "Thumbnail";
-
+        public static string BOTAThumb = "Thumbnail";
+
         /// <summary>
         /// 用于弹窗传参的数据模型
         /// </summary>
-        public static string DataModel = "Model";
-
+        public static string DataModel = "Model";
+
         /// <summary>
         /// 转换类型
         /// </summary>
@@ -79,6 +82,6 @@ namespace PDF_Office.Model
         /// <summary>
         /// 用于转换数据模型
         /// </summary>
-        public static string ConverterTypeModel = "ConverterTypeModel";
+        public static string ConverterTypeModel = "ConverterTypeModel";
     }
 }

+ 2 - 1
PDF Office/PDF Office.csproj

@@ -275,6 +275,8 @@
     <Compile Include="Model\AnnotPanel\Signature.cs" />
     <Compile Include="Model\BOTA\AnnotationHandlerEventArgs.cs" />
     <Compile Include="Model\AnnotPanel\Stamp.cs" />
+    <Compile Include="Model\BOTA\AnnotationSortOrder.cs" />
+    <Compile Include="Model\BOTA\AuthorItem.cs" />
     <Compile Include="Model\BOTA\OutlineNode.cs" />
     <Compile Include="Model\CloudDrive\CloudDriveItem.cs" />
     <Compile Include="Model\CloudDrive\CloudFiles.cs" />
@@ -345,7 +347,6 @@
     <Compile Include="ViewModels\EditTools\Bates\BatesDocumentContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Bates\BatesTemplateListContentViewModel.cs" />
     <Compile Include="ViewModels\BOTA\AnnotationContentViewModel.cs" />
-    <Compile Include="ViewModels\BOTA\AnnotationListItemViewModel.cs" />
     <Compile Include="ViewModels\BOTA\BookmarkContentViewModel.cs" />
     <Compile Include="ViewModels\Dialog\BOTA\AddAnnotationDialogViewModel.cs" />
     <Compile Include="ViewModels\BOTA\OutLineControlViewModel.cs" />

BIN
PDF Office/Resources/BOTA/empty_annotation.png


+ 37 - 28
PDF Office/Styles/ContextMenuStyle.xaml

@@ -1,19 +1,20 @@
-<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">
+    <!--  快捷工具展开收缩  -->
     <ContextMenu x:Key="ExpendToolsContextMenu" FontSize="14">
         <ContextMenu.ItemContainerStyle>
             <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7"/>
-                <Setter Property="VerticalContentAlignment" Value="Center"/>
+                <Setter Property="Padding" Value="0,7,0,7" />
+                <Setter Property="VerticalContentAlignment" Value="Center" />
             </Style>
         </ContextMenu.ItemContainerStyle>
-        <MenuItem Name="ExpendMenuItem" Header="展开" IsEnabled="True">
+        <MenuItem
+            Name="ExpendMenuItem"
+            Header="展开"
+            IsEnabled="True">
             <MenuItem.Icon>
-                <Path Fill="Black"
-                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
                     <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0"/>
+                        <TranslateTransform X="3.0000" Y="0" />
                     </Path.RenderTransform>
                 </Path>
             </MenuItem.Icon>
@@ -24,53 +25,61 @@
     <ContextMenu x:Key="SelectAnnotContextMenu" FontSize="14">
         <ContextMenu.ItemContainerStyle>
             <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7"/>
-                <Setter Property="VerticalContentAlignment" Value="Center"/>
+                <Setter Property="Padding" Value="0,7,0,7" />
+                <Setter Property="VerticalContentAlignment" Value="Center" />
             </Style>
         </ContextMenu.ItemContainerStyle>
-        <MenuItem Name="CutAnnotMenuItem" Header="剪切" IsEnabled="True">
+        <MenuItem
+            Name="CutAnnotMenuItem"
+            Header="剪切"
+            IsEnabled="True">
             <MenuItem.Icon>
-                <Path Fill="Black"
-                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
                     <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0"/>
+                        <TranslateTransform X="3.0000" Y="0" />
                     </Path.RenderTransform>
                 </Path>
             </MenuItem.Icon>
         </MenuItem>
 
-        <MenuItem Name="CopyAnnotMenuItem" Header="复制" IsEnabled="True">
+        <MenuItem
+            Name="CopyAnnotMenuItem"
+            Header="复制"
+            IsEnabled="True">
             <MenuItem.Icon>
-                <Path Fill="Black"
-                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
                     <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0"/>
+                        <TranslateTransform X="3.0000" Y="0" />
                     </Path.RenderTransform>
                 </Path>
             </MenuItem.Icon>
         </MenuItem>
 
-        <MenuItem Name="DeleteAnnotMenuItem" Header="删除" IsEnabled="True">
+        <MenuItem
+            Name="DeleteAnnotMenuItem"
+            Header="删除"
+            IsEnabled="True">
             <MenuItem.Icon>
-                <Path Fill="Black"
-                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
                     <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0"/>
+                        <TranslateTransform X="3.0000" Y="0" />
                     </Path.RenderTransform>
                 </Path>
             </MenuItem.Icon>
         </MenuItem>
 
-        <MenuItem Name="NoteAnnotMenuItem" Header="笔记" IsEnabled="True">
+        <MenuItem
+            Name="NoteAnnotMenuItem"
+            Header="笔记"
+            IsEnabled="True">
             <MenuItem.Icon>
-                <Path Fill="Black"
-                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
                     <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0"/>
+                        <TranslateTransform X="3.0000" Y="0" />
                     </Path.RenderTransform>
                 </Path>
             </MenuItem.Icon>
         </MenuItem>
     </ContextMenu>
-    
+
 </ResourceDictionary>

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 149 - 117
PDF Office/Styles/ContextMenuTextEditStyle.xaml


+ 15 - 15
PDF Office/Styles/ListBoxStyle.xaml

@@ -49,39 +49,39 @@
     </ControlTemplate>
 
     <ControlTemplate x:Key="EditToolsItemControlTemplate" TargetType="{x:Type ListBoxItem}">
-        <Border x:Name="EditToolsBorder"  
+        <Border
+            x:Name="EditToolsBorder"
+            Width="{TemplateBinding Width}"
+            Height="{TemplateBinding Height}"
             Padding="{TemplateBinding Padding}"
             Background="{TemplateBinding Background}"
             BorderBrush="{TemplateBinding BorderBrush}"
             BorderThickness="{TemplateBinding BorderThickness}"
-            Height="{TemplateBinding Height}"
-            Width="{TemplateBinding Width}"
-            SnapsToDevicePixels="True"
-               >
-            <ContentPresenter   
+            SnapsToDevicePixels="True">
+            <ContentPresenter
                 Content="{TemplateBinding Content}"
                 ContentStringFormat="{TemplateBinding ContentStringFormat}"
                 ContentTemplate="{TemplateBinding ContentTemplate}"
-                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
+                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
         </Border>
         <ControlTemplate.Triggers>
             <MultiTrigger>
                 <MultiTrigger.Conditions>
-                    <Condition Property="IsMouseOver" Value="True"></Condition>
+                    <Condition Property="IsMouseOver" Value="True" />
                 </MultiTrigger.Conditions>
-                <Setter Property="Background" TargetName="EditToolsBorder" Value="#1A477EDE"/>
-                <Setter Property="BorderBrush" TargetName="EditToolsBorder" Value="Black"/>
+                <Setter TargetName="EditToolsBorder" Property="Background" Value="#1A477EDE" />
+                <Setter TargetName="EditToolsBorder" Property="BorderBrush" Value="Black" />
             </MultiTrigger>
             <MultiTrigger>
                 <MultiTrigger.Conditions>
-                    <Condition Property="Selector.IsSelectionActive" Value="True"/>
-                    <Condition Property="IsSelected" Value="True"/>
+                    <Condition Property="Selector.IsSelectionActive" Value="True" />
+                    <Condition Property="IsSelected" Value="True" />
                 </MultiTrigger.Conditions>
-                <Setter Property="Background" TargetName="EditToolsBorder" Value="#1A477EDE"/>
-                <Setter Property="BorderBrush" TargetName="EditToolsBorder" Value="Black"/>
+                <Setter TargetName="EditToolsBorder" Property="Background" Value="#1A477EDE" />
+                <Setter TargetName="EditToolsBorder" Property="BorderBrush" Value="Black" />
             </MultiTrigger>
             <Trigger Property="IsEnabled" Value="False">
-                <Setter Property="TextElement.Foreground" TargetName="EditToolsBorder" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
+                <Setter TargetName="EditToolsBorder" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
             </Trigger>
 
         </ControlTemplate.Triggers>

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 39 - 22
PDF Office/Styles/OutLineItemStyle.xaml


+ 89 - 54
PDF Office/Styles/RadioButtonStyle.xaml

@@ -186,72 +186,98 @@
         </Setter>
     </Style>
 
-    <!--最近列表列表模式单选按钮-->
+    <!--  最近列表列表模式单选按钮  -->
     <Style x:Key="ListModeRadioBtnStyle" TargetType="{x:Type RadioButton}">
-        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
-        <Setter Property="Background" Value="{StaticResource RadioButton.Static.Background}"/>
-        <Setter Property="BorderBrush" Value="{StaticResource RadioButton.Static.Border}"/>
-        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
+        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
+        <Setter Property="Background" Value="{StaticResource RadioButton.Static.Background}" />
+        <Setter Property="BorderBrush" Value="{StaticResource RadioButton.Static.Border}" />
+        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
         <Setter Property="Template">
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type RadioButton}">
-                    <Border CornerRadius="4" x:Name="root" Background="#EEF2F3">
-                   
-                        <Grid x:Name="templateRoot" SnapsToDevicePixels="True" VerticalAlignment="Center" HorizontalAlignment="Center">
+                    <Border
+                        x:Name="root"
+                        Background="#EEF2F3"
+                        CornerRadius="4">
+
+                        <Grid
+                            x:Name="templateRoot"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center"
+                            SnapsToDevicePixels="True">
 
                             <Grid.ColumnDefinitions>
-                                <ColumnDefinition Width="Auto"/>
-                                <ColumnDefinition Width="*"/>
+                                <ColumnDefinition Width="Auto" />
+                                <ColumnDefinition Width="*" />
                             </Grid.ColumnDefinitions>
-                            <Border x:Name="radioButtonBorder" Visibility="Collapsed" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="100" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1,1,2,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
+                            <Border
+                                x:Name="radioButtonBorder"
+                                Margin="1,1,2,1"
+                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                                Background="{TemplateBinding Background}"
+                                BorderBrush="{TemplateBinding BorderBrush}"
+                                BorderThickness="{TemplateBinding BorderThickness}"
+                                CornerRadius="100"
+                                Visibility="Collapsed">
                                 <Grid x:Name="markGrid" Margin="2">
-                                    <Ellipse x:Name="optionMark" Fill="{StaticResource RadioButton.Static.Glyph}" MinWidth="6" MinHeight="6" Opacity="0"/>
+                                    <Ellipse
+                                        x:Name="optionMark"
+                                        MinWidth="6"
+                                        MinHeight="6"
+                                        Fill="{StaticResource RadioButton.Static.Glyph}"
+                                        Opacity="0" />
                                 </Grid>
                             </Border>
 
-                            <ContentPresenter x:Name="contentPresenter" Grid.Column="1" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
-                            </ContentPresenter>
+                            <ContentPresenter
+                                x:Name="contentPresenter"
+                                Grid.Column="1"
+                                Margin="{TemplateBinding Padding}"
+                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                                Focusable="False"
+                                RecognizesAccessKey="True"
+                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                         </Grid>
 
                     </Border>
 
                     <ControlTemplate.Triggers>
                         <Trigger Property="HasContent" Value="true">
-                            <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}"/>
-                            <Setter Property="Padding" Value="4,-1,0,0"/>
+                            <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}" />
+                            <Setter Property="Padding" Value="4,-1,0,0" />
                         </Trigger>
                         <Trigger Property="IsMouseOver" Value="true">
-                            <Setter Property="Background" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.MouseOver.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.MouseOver.Border}"/>
-                            <Setter Property="Fill" TargetName="optionMark" Value="{StaticResource RadioButton.MouseOver.Glyph}"/>
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.MouseOver.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.MouseOver.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.MouseOver.Glyph}" />
                         </Trigger>
                         <Trigger Property="IsEnabled" Value="false">
-                            <Setter Property="Background" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Disabled.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Disabled.Border}"/>
-                            <Setter Property="Fill" TargetName="optionMark" Value="{StaticResource RadioButton.Disabled.Glyph}"/>
-                            <Setter Property="Border.Background" TargetName="root">
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Disabled.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Disabled.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Disabled.Glyph}" />
+                            <Setter TargetName="root" Property="Border.Background">
                                 <Setter.Value>
-                                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
-                                        <GradientStop Color="White" Offset="0.0" />
-                                        <GradientStop Color="#CFCFCF" Offset="0.5" />
-                                        <GradientStop Color="White" Offset="0.0" />
+                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
+                                        <GradientStop Offset="0.0" Color="White" />
+                                        <GradientStop Offset="0.5" Color="#CFCFCF" />
+                                        <GradientStop Offset="0.0" Color="White" />
                                     </LinearGradientBrush>
                                 </Setter.Value>
                             </Setter>
                         </Trigger>
                         <Trigger Property="IsPressed" Value="true">
-                            <Setter Property="Background" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Pressed.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Pressed.Border}"/>
-                            <Setter Property="Fill" TargetName="optionMark" Value="{StaticResource RadioButton.Pressed.Glyph}"/>
+                            <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Pressed.Background}" />
+                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Pressed.Border}" />
+                            <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Pressed.Glyph}" />
                         </Trigger>
                         <Trigger Property="IsChecked" Value="true">
-                            <Setter Property="Opacity" TargetName="optionMark" Value="1"/>
-                            <Setter Property="Border.Background" TargetName="root" Value="White">
-                              
-                            </Setter>
+                            <Setter TargetName="optionMark" Property="Opacity" Value="1" />
+                            <Setter TargetName="root" Property="Border.Background" Value="White" />
                         </Trigger>
                         <Trigger Property="IsChecked" Value="{x:Null}">
-                            <Setter Property="Opacity" TargetName="optionMark" Value="0.56"/>
+                            <Setter TargetName="optionMark" Property="Opacity" Value="0.56" />
 
                         </Trigger>
                     </ControlTemplate.Triggers>
@@ -260,45 +286,54 @@
         </Setter>
     </Style>
 
-    <!--悬浮灰色背景单选按钮-->
+    <!--  悬浮灰色背景单选按钮  -->
     <Style x:Key="GreyBgRadioBtnStyle" TargetType="{x:Type RadioButton}">
-        <Setter Property="BorderThickness" Value="1"/>
-        <Setter Property="Foreground" Value="#252629"/>
+        <Setter Property="BorderThickness" Value="1" />
+        <Setter Property="Foreground" Value="#252629" />
         <Setter Property="Template">
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type RadioButton}">
-                    <Border x:Name="templateRoot" Background="{TemplateBinding Background}"  CornerRadius="4" SnapsToDevicePixels="True">
+                    <Border
+                        x:Name="templateRoot"
+                        Background="{TemplateBinding Background}"
+                        CornerRadius="4"
+                        SnapsToDevicePixels="True">
 
-                            <ContentPresenter x:Name="contentPresenter" Grid.Column="1" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+                        <ContentPresenter
+                            x:Name="contentPresenter"
+                            Grid.Column="1"
+                            Margin="{TemplateBinding Padding}"
+                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                            Focusable="False"
+                            RecognizesAccessKey="True"
+                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
 
                     </Border>
                     <ControlTemplate.Triggers>
                         <Trigger Property="HasContent" Value="true">
-                            <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}"/>
-                            <Setter Property="Padding" Value="4,-1,0,0"/>
+                            <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}" />
+                            <Setter Property="Padding" Value="4,-1,0,0" />
                         </Trigger>
                         <Trigger Property="IsMouseOver" Value="true">
-                            <Setter Property="Background" TargetName="templateRoot" Value="#EDEEF0"/>
+                            <Setter TargetName="templateRoot" Property="Background" Value="#EDEEF0" />
 
                         </Trigger>
                         <Trigger Property="IsEnabled" Value="false">
-                            <Setter Property="Opacity" TargetName="templateRoot" Value="0.5"/>
-                        </Trigger>
-                        <Trigger Property="IsPressed" Value="true">
-
+                            <Setter TargetName="templateRoot" Property="Opacity" Value="0.5" />
                         </Trigger>
+                        <Trigger Property="IsPressed" Value="true" />
                         <Trigger Property="IsChecked" Value="true">
-                            <Setter Property="Background" TargetName="templateRoot">
+                            <Setter TargetName="templateRoot" Property="Background">
                                 <Setter.Value>
-                                    <SolidColorBrush Color="#CED0D4" Opacity="0.6"/>
+                                    <SolidColorBrush Opacity="0.6" Color="#CED0D4" />
                                 </Setter.Value>
                             </Setter>
-                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="#CED0D4"/>
-                            <Setter Property="Foreground" Value="#616469"/>
-                            <Setter Property="BorderThickness" TargetName="templateRoot" Value="1"/>
-                        </Trigger>
-                        <Trigger Property="IsChecked" Value="{x:Null}">
+                            <Setter TargetName="templateRoot" Property="BorderBrush" Value="#CED0D4" />
+                            <Setter Property="Foreground" Value="#616469" />
+                            <Setter TargetName="templateRoot" Property="BorderThickness" Value="1" />
                         </Trigger>
+                        <Trigger Property="IsChecked" Value="{x:Null}" />
                     </ControlTemplate.Triggers>
                 </ControlTemplate>
             </Setter.Value>

+ 519 - 17
PDF Office/ViewModels/BOTA/AnnotationContentViewModel.cs

@@ -7,12 +7,14 @@ using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using DryIoc;
 using Microsoft.Office.Interop.Excel;
+using Microsoft.Office.Interop.PowerPoint;
 using Microsoft.Office.Interop.Word;
 using PDF_Office.CustomControl;
 using PDF_Office.DataConvert;
 using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Model.BOTA;
+using PDF_Office.Views.BOTA;
 using PDF_Office.Views.PropertyPanel.AnnotPanel;
 using Prism.Commands;
 using Prism.Mvvm;
@@ -23,10 +25,12 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.ComponentModel;
 using System.Configuration;
+using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
+using System.Windows.Annotations.Storage;
 using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Forms;
@@ -35,8 +39,10 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Shapes;
 using static Dropbox.Api.Files.SearchMatchType;
+using static Dropbox.Api.TeamLog.SpaceCapsType;
 using static System.Net.Mime.MediaTypeNames;
 using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolBar;
 using Border = System.Windows.Controls.Border;
 using ListBox = System.Windows.Controls.ListBox;
 using Task = System.Threading.Tasks.Task;
@@ -65,6 +71,15 @@ namespace PDF_Office.ViewModels.BOTA
             }
         }
 
+        private ObservableCollection<AnnotationHandlerEventArgs> currentAnnotationArgs = new ObservableCollection<AnnotationHandlerEventArgs>();
+        private AnnotationSortOrder annotationSortOrder = AnnotationSortOrder.PageIndexAscending;
+
+        public AnnotationSortOrder AnnotationSortOrder
+        {
+            get { return annotationSortOrder; }
+            set { annotationSortOrder = value; }
+        }
+
         private ObservableCollection<AnnotationHandlerEventArgs> annotationListItems;
 
         public ObservableCollection<AnnotationHandlerEventArgs> AnnotationListItems
@@ -76,15 +91,24 @@ namespace PDF_Office.ViewModels.BOTA
             }
         }
 
+        private List<string> colors = new List<string>();
+        private List<string> authors = new List<string>();
+        private List<AnnotArgsType> annotArgsTypes = new List<AnnotArgsType>();
         public DelegateCommand<object> LoadedCommand { get; set; }
         public DelegateCommand<object> ListBoxItemPreviewMouseLeftButtonDown { get; set; }
         public DelegateCommand<object> AddNotesCommand { get; set; }
         public DelegateCommand<object> ScreenCommand { get; set; }
         public DelegateCommand<object> ExportCommentsCommand { get; set; }
+        public DelegateCommand<object> ImportCommentsCommand { get; set; }
         public DelegateCommand<object> DeleteCommand { get; set; }
 
         public DelegateCommand DeleteAllCommand { get; set; }
 
+        public DelegateCommand PageSortCommand { get; set; }
+
+        public DelegateCommand TimeAscendingCommand { get; set; }
+        public DelegateCommand TimeDescendingCommand { get; set; }
+
         public AnnotationContentViewModel(IRegionManager regionManager, IDialogService dialogService)
         {
             region = regionManager;
@@ -94,8 +118,92 @@ namespace PDF_Office.ViewModels.BOTA
             AddNotesCommand = new DelegateCommand<object>(AddNotesEvent);
             ScreenCommand = new DelegateCommand<object>(ScreenEvent);
             ExportCommentsCommand = new DelegateCommand<object>(ExportCommentsEvent);
+            ImportCommentsCommand = new DelegateCommand<object>(ImportCommentsEvent);
             DeleteCommand = new DelegateCommand<object>(DelegateEvent);
             DeleteAllCommand = new DelegateCommand(DeleteAllEvent);
+            PageSortCommand = new DelegateCommand(PageSortEvent);
+            TimeAscendingCommand = new DelegateCommand(TimeAscendingEvent);
+            TimeDescendingCommand = new DelegateCommand(TimeDescendingEvent);
+        }
+
+        /// <summary>
+        /// 导入注释
+        /// </summary>
+        /// <param name="obj"></param>
+        private async void ImportCommentsEvent(object obj)
+        {
+            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
+            dlg.Filter = "PDF|*.xfdf";
+            dlg.DefaultExt = ".xfdf";
+            if (dlg.ShowDialog() == true)
+            {
+                string fileName = dlg.FileName;
+                await Task.Delay(5);
+                var result = PdfViewer.ImportAnnotationFromXFDFPath(fileName);
+                if (result == false)
+                {
+                    //MessageBoxEx.Show("导入失败", "", Winform.MessageBoxButtons.OK, Winform.MessageBoxIcon.Error);
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.Show("提示", "导入失败!", "OK");
+                    return;
+                }
+                PdfViewer.ReloadVisibleAnnots();
+                //提取出来的注释文件 时间为空  则显示未系统当前时间
+                currentAnnotationArgs = GetDocumentAnnotionList();
+
+                AnnotationListItems.Clear();
+                AnnotationListItems.AddRange(currentAnnotationArgs);
+                await Task.Delay(5);
+                RefreshAnnotationListItems(null);
+
+                PdfViewer.UndoManager.CanSave = true;
+            }
+        }
+
+        /// <summary>
+        /// 时间倒序
+        /// </summary>
+        private void TimeDescendingEvent()
+        {
+            ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
+            CreateTimeToDate createTimeToDate = new CreateTimeToDate();
+            v.GroupDescriptions.Clear();
+            v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.CreateTime), createTimeToDate));
+            v.SortDescriptions.Clear();
+            v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.CreateTime), ListSortDirection.Descending));
+            v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Descending));
+            AnnotationSortOrder = AnnotationSortOrder.TimeDescending;
+        }
+
+        /// <summary>
+        /// 时间正序
+        /// </summary>
+        private void TimeAscendingEvent()
+        {
+            ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
+            CreateTimeToDate createTimeToDate = new CreateTimeToDate();
+            v.GroupDescriptions.Clear();
+            v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.CreateTime), createTimeToDate));
+
+            v.SortDescriptions.Clear();
+            v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.CreateTime), ListSortDirection.Ascending));
+            v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
+            AnnotationSortOrder = AnnotationSortOrder.TimeAscending;
+        }
+
+        /// <summary>
+        /// 页面排序
+        /// </summary>
+        private void PageSortEvent()
+        {
+            ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
+            v.GroupDescriptions.Clear();
+            v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.PageIndex)));
+
+            v.SortDescriptions.Clear();
+            v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
+            v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
+            AnnotationSortOrder = AnnotationSortOrder.PageIndexAscending;
         }
 
         /// <summary>
@@ -105,9 +213,9 @@ namespace PDF_Office.ViewModels.BOTA
         {
             //调用集中删除的接口  方便一次性undo
             Dictionary<int, List<int>> deleteLists = new Dictionary<int, List<int>>();
-            for (int i = 0; i < annotationListItems.Count; i++)
+            for (int i = 0; i < AnnotationListItems.Count; i++)
             {
-                AnnotationHandlerEventArgs item = annotationListItems[i] as AnnotationHandlerEventArgs;
+                AnnotationHandlerEventArgs item = AnnotationListItems[i] as AnnotationHandlerEventArgs;
                 if (!deleteLists.ContainsKey(item.PageIndex))
                 {
                     deleteLists.Add(item.PageIndex, new List<int>() { item.AnnotIndex });
@@ -119,7 +227,8 @@ namespace PDF_Office.ViewModels.BOTA
                 }
             }
             PdfViewer.RemovePageAnnot(deleteLists);
-            annotationListItems.Clear();
+            AnnotationListItems.Clear();
+            currentAnnotationArgs.Clear();
             PdfViewer.UndoManager.CanSave = true;
         }
 
@@ -137,6 +246,7 @@ namespace PDF_Office.ViewModels.BOTA
                     if (result)
                     {
                         AnnotationListItems.Remove(annotation);
+                        currentAnnotationArgs.Remove(annotation);
                         //记录是删除了哪些页面的注释,然后更新对应页面的注释即可
                         UpdateAnnotListAfterDelete(annotation.PageIndex, annotation.AnnotIndex);
                         PdfViewer.UndoManager.CanSave = true;
@@ -145,6 +255,11 @@ namespace PDF_Office.ViewModels.BOTA
             }
         }
 
+        /// <summary>
+        /// 删除之后,更新
+        /// </summary>
+        /// <param name="pageIndex"></param>
+        /// <param name="annoteIndex"></param>
         private void UpdateAnnotListAfterDelete(int pageIndex, int annoteIndex)
         {
             var items = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
@@ -156,12 +271,12 @@ namespace PDF_Office.ViewModels.BOTA
                     {
                         //相当于将后面的索引-1
                         if (AnnotationListItems[k].PageIndex == pageIndex &&
-                            AnnotationListItems[k].AnnotIndex == (items[j].AnnotIndex + 1) &&
-                            string.Equals(AnnotationListItems[k].MarkupContent, items[j].MarkupContent) &&
-                            string.Equals(AnnotationListItems[k].Content, items[j].Content) &&
-                            string.Equals(AnnotationListItems[k].CreateTime, items[j].CreateTime) &&
-                            string.Equals(AnnotationListItems[k].Author, items[j].Author)
-                            )
+                        AnnotationListItems[k].AnnotIndex == (items[j].AnnotIndex + 1) &&
+                        string.Equals(AnnotationListItems[k].MarkupContent, items[j].MarkupContent) &&
+                        string.Equals(AnnotationListItems[k].Content, items[j].Content) &&
+                        string.Equals(AnnotationListItems[k].CreateTime, items[j].CreateTime) &&
+                        string.Equals(AnnotationListItems[k].Author, items[j].Author)
+                        )
                         {
                             AnnotationListItems[k].AnnotHandlerEventArgs = items[j];
                             AnnotationListItems[k].PageIndex = items[j].PageIndex;
@@ -182,6 +297,10 @@ namespace PDF_Office.ViewModels.BOTA
             }
         }
 
+        /// <summary>
+        /// 导出注释
+        /// </summary>
+        /// <param name="obj"></param>
         private void ExportCommentsEvent(object obj)
         {
             if (ViewContentViewModel.CanSave)
@@ -198,24 +317,392 @@ namespace PDF_Office.ViewModels.BOTA
                 var result = PdfViewer.ExportAnnotationToXFDFPath(fileName);
                 if (result)
                 {
-                    MessageBoxEx.Show("导出成功", "", Winform.MessageBoxButtons.OK);
+                    //MessageBoxEx.Show("导出成功", "", Winform.MessageBoxButtons.OK);
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.Show("提示", "导出成功!", "OK");
                 }
                 else
                 {
-                    MessageBoxEx.Show("导出失败", "", Winform.MessageBoxButtons.OK, Winform.MessageBoxIcon.Error);
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.Show("提示", "导出失败!", "OK");
+                    //MessageBoxEx.Show("导出失败", "", Winform.MessageBoxButtons.OK, Winform.MessageBoxIcon.Error);
                 }
             }
         }
 
+        /// <summary>
+        /// 筛选注释
+        /// </summary>
+        /// <param name="obj"></param>
         private void ScreenEvent(object obj)
         {
-            DialogParameters value = new DialogParameters();
-            value.Add(ParameterNames.AnnotationList, AnnotationListItems);
-            dialogs.ShowDialog(DialogNames.ScreenAnnotationDialog, value, e =>
+            if (obj is System.Windows.Controls.Button button)
             {
-            });
+                DialogParameters value = new DialogParameters();
+                value.Add(ParameterNames.AnnotationList, currentAnnotationArgs);
+                value.Add(ParameterNames.AnnotArgsTypes, annotArgsTypes);
+                value.Add(ParameterNames.AnnotationColors, colors);
+                value.Add(ParameterNames.AnnotationAuthor, authors);
+                dialogs.ShowDialog(DialogNames.ScreenAnnotationDialog, value, e =>
+                {
+                    if (e.Result == ButtonResult.OK && e.Parameters != null)
+                    {
+                        bool cleanState = false;
+                        if (e.Parameters.ContainsKey(ParameterNames.AnnotationCleanState))
+                        {
+                            cleanState = e.Parameters.GetValue<bool>(ParameterNames.AnnotationCleanState);
+                            if (cleanState)
+                            {
+                                colors.Clear();
+                                authors.Clear();
+                                annotArgsTypes.Clear();
+                                AnnotationListItems.Clear();
+                                AnnotationListItems.AddRange(currentAnnotationArgs);
+                                RefreshAnnotationListItems(button);
+                            }
+                            else
+                            {
+                                if (e.Parameters.ContainsKey(ParameterNames.AnnotArgsTypes))
+                                {
+                                    annotArgsTypes = e.Parameters.GetValue<List<AnnotArgsType>>(ParameterNames.AnnotArgsTypes);
+                                }
+                                if (e.Parameters.ContainsKey(ParameterNames.AnnotationColors))
+                                {
+                                    colors = e.Parameters.GetValue<List<string>>(ParameterNames.AnnotationColors);
+                                }
+                                if (e.Parameters.ContainsKey(ParameterNames.AnnotationAuthor))
+                                {
+                                    authors = e.Parameters.GetValue<List<string>>(ParameterNames.AnnotationAuthor);
+                                }
+
+                                ObservableCollection<AnnotationHandlerEventArgs> screenAnnotationArgs = SelectAnnotationListItems(annotArgsTypes, colors, authors);
+                                AnnotationListItems.Clear();
+                                AnnotationListItems.AddRange(screenAnnotationArgs);
+
+                                RefreshAnnotationListItems(button);
+                            }
+                        }
+                    }
+                    else if (e.Result == ButtonResult.Cancel && e.Parameters != null)
+                    {
+                        colors.Clear();
+                        authors.Clear();
+                        annotArgsTypes.Clear();
+                        AnnotationListItems.Clear();
+                        AnnotationListItems.AddRange(currentAnnotationArgs);
+
+                        RefreshAnnotationListItems(button);
+                    }
+                });
+            }
+        }
+
+        /// <summary>
+        /// 刷新列表数据
+        /// </summary>
+        /// <param name="button"></param>
+        private async void RefreshAnnotationListItems(System.Windows.Controls.Button button)
+        {
+            switch (AnnotationSortOrder)
+            {
+                case AnnotationSortOrder.TimeAscending:
+                    TimeAscendingEvent();
+                    break;
+
+                case AnnotationSortOrder.TimeDescending:
+                    TimeDescendingEvent();
+                    break;
+
+                case AnnotationSortOrder.PageIndexAscending:
+                    PageSortEvent();
+                    break;
+
+                default:
+                    break;
+            }
+            if (AnnotationListItems.Count > 0)
+            {
+                IsEmptyPanelVisibility = Visibility.Collapsed;
+                await Task.Delay(10);
+                //展开数据
+                ExpandGroupHeader(AnnotationListItems, listBox);
+            }
+            else
+            {
+                if (button != null)
+                {
+                    button.IsEnabled = true;
+                }
+                IsEmptyPanelVisibility = Visibility.Visible;
+                //AnnotationListItems.AddRange(currentAnnotationArgs);
+                //RefreshAnnotationListItems();
+            }
         }
 
+        /// <summary>
+        /// 根据条件筛选列表数据
+        /// </summary>
+        /// <param name="annotArgsTypes"></param>
+        /// <param name="colors"></param>
+        /// <param name="authors"></param>
+        /// <returns></returns>
+        private ObservableCollection<AnnotationHandlerEventArgs> SelectAnnotationListItems(List<AnnotArgsType> annotArgsTypes, List<string> colors, List<string> authors)
+        {
+            ObservableCollection<AnnotationHandlerEventArgs> annotationArgs = new ObservableCollection<AnnotationHandlerEventArgs>();
+
+            #region 类型 颜色 作者
+
+            if (annotArgsTypes.Count > 0 && colors.Count > 0 && authors.Count > 0)
+            {
+                foreach (var item in currentAnnotationArgs)
+                {
+                    foreach (var type in annotArgsTypes)
+                    {
+                        foreach (var color in colors)
+                        {
+                            foreach (var author in authors)
+                            {
+                                if (item.EventType == type && item.Author == author)
+                                {
+                                    SelectAnnotationColors(item, color, annotationArgs);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+
+            #endregion 类型 颜色 作者
+
+            #region 颜色 作者
+
+            else if (colors.Count > 0 && authors.Count > 0)
+            {
+                foreach (var item in currentAnnotationArgs)
+                {
+                    foreach (var color in colors)
+                    {
+                        foreach (var author in authors)
+                        {
+                            if (item.Author == author)
+                            {
+                                SelectAnnotationColors(item, color, annotationArgs);
+                            }
+                        }
+                    }
+                }
+            }
+
+            #endregion 颜色 作者
+
+            #region 类型 作者
+
+            else if (annotArgsTypes.Count > 0 && authors.Count > 0)
+            {
+                foreach (var item in currentAnnotationArgs)
+                {
+                    foreach (var type in annotArgsTypes)
+                    {
+                        foreach (var author in authors)
+                        {
+                            if (item.EventType == type && item.Author == author)
+                            {
+                                annotationArgs.Add(item);
+                            }
+                        }
+                    }
+                }
+            }
+
+            #endregion 类型 作者
+
+            #region 类型 颜色
+
+            else if (annotArgsTypes.Count > 0 && colors.Count > 0)
+            {
+                foreach (var item in currentAnnotationArgs)
+                {
+                    foreach (var type in annotArgsTypes)
+                    {
+                        foreach (var color in colors)
+                        {
+                            if (item.EventType == type)
+                            {
+                                SelectAnnotationColors(item, color, annotationArgs);
+                            }
+                        }
+                    }
+                }
+            }
+
+            #endregion 类型 颜色
+
+            #region 类型
+
+            else if (annotArgsTypes.Count > 0)
+            {
+                foreach (var item in currentAnnotationArgs)
+                {
+                    foreach (var type in annotArgsTypes)
+                    {
+                        if (item.EventType == type)
+                        {
+                            annotationArgs.Add(item);
+                        }
+                    }
+                }
+            }
+
+            #endregion 类型
+
+            #region 颜色
+
+            else if (colors.Count > 0)
+            {
+                foreach (var item in currentAnnotationArgs)
+                {
+                    foreach (var color in colors)
+                    {
+                        SelectAnnotationColors(item, color, annotationArgs);
+                    }
+                }
+            }
+
+            #endregion 颜色
+
+            #region 作者
+
+            else if (authors.Count > 0)
+            {
+                foreach (var item in currentAnnotationArgs)
+                {
+                    foreach (var author in authors)
+                    {
+                        if (item.Author == author)
+                        {
+                            annotationArgs.Add(item);
+                        }
+                    }
+                }
+            }
+
+            #endregion 作者
+
+            return annotationArgs;
+        }
+
+        /// <summary>
+        /// 根据颜色筛选注释
+        /// </summary>
+        /// <param name="item"></param>
+        /// <param name="color"></param>
+        /// <param name="annotationArgs"></param>
+        private void SelectAnnotationColors(AnnotationHandlerEventArgs item, string color, ObservableCollection<AnnotationHandlerEventArgs> annotationArgs)
+        {
+            AnnotHandlerEventArgs data = item.AnnotHandlerEventArgs;
+
+            switch (item.EventType)
+            {
+                case AnnotArgsType.AnnotFreeText://文本
+                    if (data is FreeTextAnnotArgs textAnnotArgs)
+                    {
+                        AddScreenAnnotationArgs(textAnnotArgs.FontColor, color, item, annotationArgs);
+                    }
+                    break;
+
+                case AnnotArgsType.AnnotHighlight://高亮
+                    if (data is TextHighlightAnnotArgs highlightAnnotArgs)
+                    {
+                        AddScreenAnnotationArgs(highlightAnnotArgs.Color, color, item, annotationArgs);
+                    }
+                    break;
+
+                case AnnotArgsType.AnnotFreehand://手绘
+                    if (data is FreehandAnnotArgs freehandAnnotArgs)
+                    {
+                        AddScreenAnnotationArgs(freehandAnnotArgs.InkColor, color, item, annotationArgs);
+                    }
+                    break;
+
+                case AnnotArgsType.AnnotSquiggly://波浪线
+                    break;
+
+                case AnnotArgsType.AnnotStamp://图章
+                    break;
+
+                case AnnotArgsType.AnnotStrikeout://删除线
+                    if (data is TextStrikeoutAnnotArgs textStrikeoutAnnotArgs)
+                    {
+                        AddScreenAnnotationArgs(textStrikeoutAnnotArgs.Color, color, item, annotationArgs);
+                    }
+                    break;
+
+                case AnnotArgsType.AnnotSticky://便签
+                    if (data is StickyAnnotArgs stickyAnnotArgs)
+                    {
+                        AddScreenAnnotationArgs(stickyAnnotArgs.Color, color, item, annotationArgs);
+                    }
+                    break;
+
+                case AnnotArgsType.AnnotUnderline://下划线
+                    if (data is TextUnderlineAnnotArgs textUnderlineAnnotArgs)
+                    {
+                        AddScreenAnnotationArgs(textUnderlineAnnotArgs.Color, color, item, annotationArgs);
+                    }
+                    break;
+
+                case AnnotArgsType.AnnotLine:
+                    //if ((item.AnnotHandlerEventArgs as LineAnnotArgs).HeadLineType >= (C_LINE_TYPE)1 || (item.AnnotHandlerEventArgs as LineAnnotArgs).TailLineType >= (C_LINE_TYPE)1)
+                    //{
+                    //    //箭头
+                    //}
+                    //else
+                    //{
+                    //    //线
+                    //}
+                    if (data is LineAnnotArgs lineAnnotArgs)
+                    {
+                        AddScreenAnnotationArgs(lineAnnotArgs.LineColor, color, item, annotationArgs);
+                    }
+                    break;
+
+                case AnnotArgsType.AnnotSquare://矩形
+                    if (data is SquareAnnotArgs squareAnnotArgs)
+                    {
+                        AddScreenAnnotationArgs(squareAnnotArgs.LineColor, color, item, annotationArgs);
+                        AddScreenAnnotationArgs(squareAnnotArgs.BgColor, color, item, annotationArgs);
+                    }
+                    break;
+
+                case AnnotArgsType.AnnotCircle://圆
+                    if (data is CircleAnnotArgs circleAnnotArgs)
+                    {
+                        AddScreenAnnotationArgs(circleAnnotArgs.LineColor, color, item, annotationArgs);
+                        AddScreenAnnotationArgs(circleAnnotArgs.BgColor, color, item, annotationArgs);
+                    }
+                    break;
+            }
+        }
+
+        /// <summary>
+        /// 对比颜色
+        /// </summary>
+        /// <param name="color1"></param>
+        /// <param name="color"></param>
+        /// <param name="item"></param>
+        /// <param name="annotationArgs"></param>
+        private void AddScreenAnnotationArgs(System.Windows.Media.Color color1, string color, AnnotationHandlerEventArgs item, ObservableCollection<AnnotationHandlerEventArgs> annotationArgs)
+        {
+            if (color1.ToString() == color)
+            {
+                annotationArgs.Add(item);
+            }
+        }
+
+        /// <summary>
+        /// 添加附注的注释
+        /// </summary>
+        /// <param name="obj"></param>
         private void AddNotesEvent(object obj)
         {
             if (obj is AnnotationHandlerEventArgs data)
@@ -307,16 +794,20 @@ namespace PDF_Office.ViewModels.BOTA
                 ViewContentViewModel = viewContentViewModel;
                 PdfViewer = pdfview;
                 AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>();
-                AnnotationListItems = GetDocumentAnnotionList();
                 AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
+                AnnotationListItems = GetDocumentAnnotionList();
+                currentAnnotationArgs.AddRange(AnnotationListItems);
             }
         }
 
+        /// <summary>
+        /// 默认按照PageIndex,分组 排序
+        /// </summary>
+        /// <param name="listBox"></param>
         private async void SetGroupHeader(ListBox listBox)
         {
             //按照PageIndex,分组 排序
             ICollectionView iCollectionView = CollectionViewSource.GetDefaultView(AnnotationListItems);
-            CreateTimeToDate createTimeToDate = new CreateTimeToDate();
             iCollectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotationHandlerEventArgs.PageIndex)));
             iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
             iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
@@ -381,6 +872,10 @@ namespace PDF_Office.ViewModels.BOTA
             return null;
         }
 
+        /// <summary>
+        /// 获取listbox绑定数据
+        /// </summary>
+        /// <returns></returns>
         private ObservableCollection<AnnotationHandlerEventArgs> GetDocumentAnnotionList()
         {
             ObservableCollection<AnnotationHandlerEventArgs> list = new ObservableCollection<AnnotationHandlerEventArgs>();
@@ -460,11 +955,18 @@ namespace PDF_Office.ViewModels.BOTA
             return null;
         }
 
+        /// <summary>
+        /// listbox的itemsource发生变化时
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
         private void AnnotationListItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
         {
             ObservableCollection<AnnotationHandlerEventArgs> obsSender = sender as ObservableCollection<AnnotationHandlerEventArgs>;
             if (obsSender != null)
             {
+                currentAnnotationArgs.Clear();
+                currentAnnotationArgs.AddRange(obsSender);
                 if (obsSender.Count < 1)
                 {
                     IsEmptyPanelVisibility = Visibility.Visible;

+ 0 - 171
PDF Office/ViewModels/BOTA/AnnotationListItemViewModel.cs

@@ -1,171 +0,0 @@
-using ComPDFKitViewer.AnnotEvent;
-using PDF_Office.Helper;
-using Prism.Commands;
-using Prism.Mvvm;
-using Prism.Regions;
-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.ViewModels.BOTA
-{
-    internal class AnnotationListItemViewModel : BindableBase
-    {
-        private Visibility pathTxtIcoVisibility = Visibility.Collapsed;
-
-        public Visibility PathTxtIcoVisibility
-        {
-            get { return pathTxtIcoVisibility; }
-            set
-            {
-                SetProperty(ref pathTxtIcoVisibility, value);
-            }
-        }
-
-        public DelegateCommand<object> GridIcoLoadedCommand { get; set; }
-
-        public AnnotationListItemViewModel()
-        {
-            GridIcoLoadedCommand = new DelegateCommand<object>(GridIcoLoaded);
-        }
-
-        private void GridIcoLoaded(object obj)
-        {
-            if (obj is CompositeCommandParameter commandParameter)
-            {
-                if (commandParameter.EventArgs is RoutedEventArgs eventArgs && commandParameter.Parameter is object[] parameters)
-                {
-                    if ((eventArgs.Source as Grid).DataContext is AnnotHandlerEventArgs data)
-                    {
-                        TextBlock txbContext = parameters[0] as TextBlock;
-                        TextBlock txbMarkUpContent = parameters[1] as TextBlock;
-                        Grid grid = parameters[2] as Grid;
-
-                        switch (data.EventType)
-                        {
-                            case AnnotArgsType.AnnotFreeText:
-                                PathTxtIcoVisibility = Visibility.Visible;
-                                txbMarkUpContent.Foreground = new SolidColorBrush((data as FreeTextAnnotArgs).FontColor);
-                                //txtContext.FontSize = (data as FreeTextAnnotArgs).FontSize;
-                                //txtContext.FontFamily = (data as FreeTextAnnotArgs).Family;
-                                if ((data as FreeTextAnnotArgs).HasBgColor)
-                                {
-                                    txbContext.Background = new SolidColorBrush((data as FreeTextAnnotArgs).BgColor);
-                                }
-                                break;
-
-                            //case AnnotArgsType.AnnotHighlight:
-                            //    highlight.Visibility = Visibility.Visible;
-                            //    highlightcolor.Fill = new SolidColorBrush((data as TextHighlightAnnotArgs).Color);
-                            //    txtContext.Text = data.Content;
-                            //    // txtContext.Background = new SolidColorBrush((data as TextHighlightAnnotArgs).HighlightColor);
-                            //    break;
-
-                            //case AnnotArgsType.AnnotFreehand:
-                            //    freehand.Visibility = Visibility.Visible;
-                            //    freehandcolor.Fill = new SolidColorBrush((data as FreehandAnnotArgs).InkColor);
-                            //    break;
-
-                            //case AnnotArgsType.AnnotLine:
-                            //    if ((data as LineAnnotArgs).HeadLineType >= (C_LINE_TYPE)1 || (data as LineAnnotArgs).TailLineType >= (C_LINE_TYPE)1)
-                            //    {
-                            //        arrow.Visibility = Visibility.Visible;
-                            //        arrow.Fill = new SolidColorBrush((data as LineAnnotArgs).LineColor);
-                            //    }
-                            //    else
-                            //    {
-                            //        line.Stroke = new SolidColorBrush((data as LineAnnotArgs).LineColor);
-                            //        line.Visibility = Visibility.Visible;
-                            //    }
-                            //    break;
-
-                            //case AnnotArgsType.AnnotSquiggly://波浪线
-                            //    AnnotSquiggly.Visibility = Visibility.Visible;
-                            //    AnnotSquigglycolor.Stroke = new SolidColorBrush((data as TextSquigglyAnnotArgs).Color);
-                            //    txtContext.Text = data.Content;
-                            //    TextDecoration mySquiggly = new TextDecoration();
-                            //    Pen myPen = new Pen();
-                            //    myPen.Brush = new SolidColorBrush((data as TextSquigglyAnnotArgs).Color);
-                            //    myPen.Brush.Opacity = 0.8;
-                            //    myPen.Thickness = 2;
-                            //    myPen.DashStyle = DashStyles.Dash;
-                            //    mySquiggly.Pen = myPen;
-                            //    mySquiggly.PenThicknessUnit = TextDecorationUnit.FontRecommended;
-
-                            //    TextDecorationCollection myCollection = new TextDecorationCollection();
-                            //    myCollection.Add(mySquiggly);
-                            //    //txtContext.TextDecorations = myCollection;
-                            //    break;
-
-                            //case AnnotArgsType.AnnotStamp:
-                            //    stamp.Visibility = Visibility.Visible;
-                            //    break;
-
-                            //case AnnotArgsType.AnnotStrikeout://删除线
-                            //    AnnotStrikeout.Visibility = Visibility.Visible;
-                            //    AnnotStrikeoutycolor.Stroke = new SolidColorBrush((data as TextStrikeoutAnnotArgs).Color);
-                            //    AnnotStrikeoutycolor.VerticalAlignment = VerticalAlignment.Center;
-                            //    txtContext.Text = data.Content;
-
-                            //    TextDecoration myStrikeout = new TextDecoration();
-                            //    Pen myPen2 = new Pen();
-                            //    myPen2.Brush = new SolidColorBrush((data as TextStrikeoutAnnotArgs).Color);
-                            //    myPen2.Brush.Opacity = 0.8;
-                            //    myPen2.Thickness = 1;
-                            //    myStrikeout.Pen = myPen2;
-                            //    myStrikeout.PenOffset = -3;
-                            //    myStrikeout.PenThicknessUnit = TextDecorationUnit.FontRecommended;
-                            //    TextDecorationCollection myCollection2 = new TextDecorationCollection();
-                            //    myCollection2.Add(myStrikeout);
-                            //    //因为波浪线无法实现 暂时只显示文字 不显示下划线,删除线等
-                            //    //txtContext.TextDecorations = myCollection2;
-                            //    break;
-
-                            //case AnnotArgsType.AnnotSticky://便签
-                            //    sticky.Visibility = Visibility;
-                            //    sticky.Fill = new SolidColorBrush((data as StickyAnnotArgs).Color);
-                            //    break;
-
-                            //case AnnotArgsType.AnnotUnderline:
-                            //    AnnotStrikeout.Visibility = Visibility.Visible;
-                            //    AnnotStrikeoutycolor.VerticalAlignment = VerticalAlignment.Bottom;
-                            //    txtContext.Text = data.Content;
-                            //    AnnotStrikeoutycolor.Stroke = new SolidColorBrush((data as TextUnderlineAnnotArgs).Color);
-                            //    TextDecoration myUnderline = new TextDecoration();
-                            //    Pen myPen1 = new Pen();
-                            //    myPen1.Brush = new SolidColorBrush((data as TextUnderlineAnnotArgs).Color);
-                            //    myPen1.Brush.Opacity = 0.8;
-                            //    myPen1.Thickness = 2;
-                            //    myUnderline.Pen = myPen1;
-                            //    myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
-                            //    TextDecorationCollection myCollection1 = new TextDecorationCollection();
-                            //    myCollection1.Add(myUnderline);
-                            //    //txtContext.TextDecorations = myCollection1;
-                            //    break;
-
-                            //case AnnotArgsType.AnnotSquare:
-                            //    rect.Visibility = Visibility.Visible;
-                            //    rect.Stroke = new SolidColorBrush((data as SquareAnnotArgs).LineColor);
-                            //    rect.Fill = new SolidColorBrush((data as SquareAnnotArgs).BgColor);
-                            //    break;
-
-                            //case AnnotArgsType.AnnotCircle:
-                            //    circle.Visibility = Visibility.Visible;
-                            //    circle.Stroke = new SolidColorBrush((data as CircleAnnotArgs).LineColor);
-                            //    circle.Fill = new SolidColorBrush((data as CircleAnnotArgs).BgColor);
-                            //    break;
-
-                            default:
-                                break;
-                        }
-                    }
-                }
-            }
-        }
-    }
-}

+ 405 - 86
PDF Office/ViewModels/Dialog/BOTA/ScreenAnnotationDialogViewModel.cs

@@ -4,7 +4,9 @@ using Dropbox.Api.Users;
 using DryIoc;
 using ImTools;
 using Microsoft.Office.Interop.Word;
+using PDF_Office.CustomControl;
 using PDF_Office.CustomControl.CompositeControl;
+using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Model.BOTA;
 using Prism.Commands;
@@ -16,69 +18,20 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Drawing;
 using System.Linq;
+using System.Runtime.CompilerServices;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Annotations;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Forms;
 using System.Windows.Media;
+using DialogResult = Prism.Services.Dialogs.DialogResult;
+using ListBox = System.Windows.Controls.ListBox;
 
 namespace PDF_Office.ViewModels.Dialog.BOTA
 {
-    public class AuthorItem : BindableBase
-    {
-        private string name;
-
-        public string Name
-        {
-            get { return name; }
-            set
-            {
-                SetProperty(ref name, value);
-            }
-        }
-
-        public AuthorItem(string name)
-        {
-            Name = name;
-        }
-    }
-
-    public class Compare<T, C> : IEqualityComparer<T>
-    {
-        private Func<T, C> _getField;
-
-        public Compare(Func<T, C> getfield)
-        {
-            this._getField = getfield;
-        }
-
-        public bool Equals(T x, T y)
-        {
-            return EqualityComparer<C>.Default.Equals(_getField(x), _getField(y));
-        }
-
-        public int GetHashCode(T obj)
-        {
-            return EqualityComparer<C>.Default.GetHashCode(this._getField(obj));
-        }
-    }
-
-    public static class CommonHelper
-    {
-        /// <summary>
-        /// 自定义Distinct扩展方法
-        /// </summary>
-        /// <typeparam name="T">要去重的对象类</typeparam>
-        /// <typeparam name="C">自定义去重的字段类型</typeparam>
-        /// <param name="source">要去重的对象</param>
-        /// <param name="getfield">获取自定义去重字段的委托</param>
-        /// <returns></returns>
-        public static IEnumerable<T> MyDistinct<T, C>(this IEnumerable<T> source, Func<T, C> getfield)
-        {
-            return source.Distinct(new Compare<T, C>(getfield));
-        }
-    }
-
     internal class ScreenAnnotationDialogViewModel : BindableBase, IDialogAware
     {
         public string Title => "";
@@ -245,8 +198,10 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
 
         public DelegateCommand CancelCommand { get; set; }
 
-        public DelegateCommand CreateCommnad { get; set; }
+        public DelegateCommand<Object> OkCommnad { get; set; }
 
+        public DelegateCommand<Object> CleanCommand { get; set; }
+        public DelegateCommand<object> LoadedCommand { get; set; }
         public ObservableCollection<AnnotationHandlerEventArgs> AnnotationListItems { get; set; }
 
         private ObservableCollection<ColorItem> annotationColors = new ObservableCollection<ColorItem>();
@@ -271,20 +226,367 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
             }
         }
 
-        //private List<System.Windows.Media.Color> annotationColors = new List<System.Windows.Media.Color>();
-        //private List<string> annotationAuthor = new List<string>();
+        private CustomIconToggleBtn btnHighlight = null;
+        private CustomIconToggleBtn btnFreeHand = null;
+        private CustomIconToggleBtn btnAnnotSticky = null;
+        private CustomIconToggleBtn btnAnnotStamp = null;
+        private CustomIconToggleBtn btnSharpLine = null;
+        private CustomIconToggleBtn btnSharpArrow = null;
+        private CustomIconToggleBtn btnAnnotCircle = null;
+        private CustomIconToggleBtn btnAnnotSquare = null;
+        private CustomIconToggleBtn btnAnnotFreeText = null;
+        private CustomIconToggleBtn btnAnnotStrikeout = null;
+        private CustomIconToggleBtn btnUnderLine = null;
+        private ListBox _ListColor = null;
+        private ListBox _ListAuthor = null;
+
+        private List<string> colors = new List<string>();
+        private List<string> authors = new List<string>();
+        private List<AnnotArgsType> annotArgsTypes = new List<AnnotArgsType>();
+
+        public List<string> Colors { get => colors; set => colors = value; }
+        public List<string> Authors { get => authors; set => authors = value; }
+        public List<AnnotArgsType> AnnotArgsTypes { get => annotArgsTypes; set => annotArgsTypes = value; }
 
         public ScreenAnnotationDialogViewModel()
         {
+            LoadedCommand = new DelegateCommand<object>(Loaded);
             CancelCommand = new DelegateCommand(CancelEvent);
-            CreateCommnad = new DelegateCommand(CreateEvent);
+            OkCommnad = new DelegateCommand<Object>(OkEvent);
+            CleanCommand = new DelegateCommand<Object>(CleanEvent);
         }
 
-        private void CreateEvent()
+        private void Loaded(object obj)
         {
-            DialogParameters valuePairs = new DialogParameters();
-            //valuePairs.Add(ParameterNames.Bookmark, Bookmark);
-            RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
+            if (obj is CompositeCommandParameter composite)
+            {
+                if (composite.Parameter is Object[] arrys)
+                {
+                    btnHighlight = arrys[0] as CustomIconToggleBtn;
+                    btnFreeHand = arrys[1] as CustomIconToggleBtn;
+                    btnAnnotSticky = arrys[2] as CustomIconToggleBtn;
+                    btnAnnotStamp = arrys[3] as CustomIconToggleBtn;
+                    btnSharpLine = arrys[4] as CustomIconToggleBtn;
+                    btnSharpArrow = arrys[5] as CustomIconToggleBtn;
+                    btnAnnotCircle = arrys[6] as CustomIconToggleBtn;
+                    btnAnnotSquare = arrys[7] as CustomIconToggleBtn;
+                    btnAnnotFreeText = arrys[8] as CustomIconToggleBtn;
+                    btnAnnotStrikeout = arrys[9] as CustomIconToggleBtn;
+                    btnUnderLine = arrys[10] as CustomIconToggleBtn;
+                    SetBtnSelectedState(arrys);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 记录设置按钮状态
+        /// </summary>
+        /// <param name="arrys"></param>
+        private void SetBtnSelectedState(object[] arrys)
+        {
+            if (AnnotArgsTypes.Count > 0)
+            {
+                foreach (var item in AnnotArgsTypes)
+                {
+                    switch (item)
+                    {
+                        case AnnotArgsType.AnnotNone:
+                            break;
+
+                        case AnnotArgsType.AnnotSquare:
+
+                            SetBtnType(btnAnnotSquare, false);
+                            break;
+
+                        case AnnotArgsType.AnnotCircle:
+
+                            SetBtnType(btnAnnotCircle, false);
+                            break;
+
+                        case AnnotArgsType.AnnotSticky:
+
+                            SetBtnType(btnAnnotSticky, false);
+                            break;
+
+                        case AnnotArgsType.AnnotLine:
+                            foreach (var annoitem in AnnotationListItems)
+                            {
+                                if ((annoitem.AnnotHandlerEventArgs as LineAnnotArgs).HeadLineType >= (C_LINE_TYPE)1 || (annoitem.AnnotHandlerEventArgs as LineAnnotArgs).TailLineType >= (C_LINE_TYPE)1)
+                                {
+                                    //箭头
+                                    SetBtnType(btnSharpArrow, false);
+                                    break;
+                                }
+                                else
+                                {
+                                    //线
+                                    SetBtnType(btnSharpLine, false);
+                                    break;
+                                }
+                            }
+
+                            break;
+
+                        case AnnotArgsType.AnnotFreehand:
+                            SetBtnType(btnFreeHand, false);
+                            break;
+
+                        case AnnotArgsType.AnnotErase:
+                            break;
+
+                        case AnnotArgsType.AnnotFreeText:
+                            SetBtnType(btnAnnotFreeText, false);
+                            break;
+
+                        case AnnotArgsType.AnnotStamp:
+                            SetBtnType(btnAnnotStamp, false);
+                            break;
+
+                        case AnnotArgsType.AnnotHighlight:
+                            SetBtnType(btnHighlight, false);
+                            break;
+
+                        case AnnotArgsType.AnnotUnderline:
+                            SetBtnType(btnUnderLine, false);
+                            break;
+
+                        case AnnotArgsType.AnnotStrikeout:
+                            SetBtnType(btnAnnotStrikeout, false);
+                            break;
+
+                        case AnnotArgsType.AnnotSquiggly:
+                            SetBtnType(btnAnnotSquare, false);
+                            break;
+
+                        case AnnotArgsType.AnnotLink:
+                            break;
+
+                        case AnnotArgsType.AnnotSelectTool:
+                            break;
+
+                        case AnnotArgsType.SnapshotTool:
+                            break;
+
+                        case AnnotArgsType.SnapshotWithEditTool:
+                            break;
+
+                        case AnnotArgsType.WidgetViewForm:
+                            break;
+
+                        case AnnotArgsType.AnnotSound:
+                            break;
+
+                        case AnnotArgsType.AnnotMedia:
+                            break;
+
+                        case AnnotArgsType.AnnotRedaction:
+                            break;
+
+                        default:
+                            break;
+                    }
+                }
+            }
+
+            if (arrys[11] is System.Windows.Controls.ListBox listColor)
+            {
+                this._ListColor = listColor;
+
+                if (Colors.Count > 0)
+                {
+                    listColor.ItemsSource = AnnotationColors;
+                    foreach (var item in AnnotationColors)
+                    {
+                        foreach (var color in Colors)
+                        {
+                            if (item.Color.ToString() == color)
+                            {
+                                ListBoxItem myListBoxItem = (ListBoxItem)(listColor.ItemContainerGenerator.ContainerFromItem(item));
+                                myListBoxItem.IsSelected = true;
+                            }
+                        }
+                    }
+                }
+            }
+            if (arrys[12] is System.Windows.Controls.ListBox listAuthor)
+            {
+                this._ListAuthor = listAuthor;
+
+                if (Authors.Count > 0)
+                {
+                    listAuthor.ItemsSource = AnnotationAuthor;
+                    foreach (var item in AnnotationAuthor)
+                    {
+                        foreach (var author in Authors)
+                        {
+                            if (item.Name == author)
+                            {
+                                ListBoxItem myListBoxItem = (ListBoxItem)(listAuthor.ItemContainerGenerator.ContainerFromItem(item));
+                                myListBoxItem.IsSelected = true;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 清除筛选项
+        /// </summary>
+        /// <param name="obj"></param>
+        private void CleanEvent(Object obj)
+        {
+            if (obj is Object[] arrys)
+            {
+                //CustomIconToggleBtn btnHighlight = arrys[0] as CustomIconToggleBtn;
+                //CustomIconToggleBtn btnFreeHand = arrys[1] as CustomIconToggleBtn;
+                //CustomIconToggleBtn btnAnnotSticky = arrys[2] as CustomIconToggleBtn;
+                //CustomIconToggleBtn btnAnnotStamp = arrys[3] as CustomIconToggleBtn;
+                //CustomIconToggleBtn btnSharpLine = arrys[4] as CustomIconToggleBtn;
+                //CustomIconToggleBtn btnSharpArrow = arrys[5] as CustomIconToggleBtn;
+                //CustomIconToggleBtn btnAnnotCircle = arrys[6] as CustomIconToggleBtn;
+                //CustomIconToggleBtn btnAnnotSquare = arrys[7] as CustomIconToggleBtn;
+                //CustomIconToggleBtn btnAnnotFreeText = arrys[8] as CustomIconToggleBtn;
+                //CustomIconToggleBtn btnAnnotStrikeout = arrys[9] as CustomIconToggleBtn;
+                //CustomIconToggleBtn btnUnderLine = arrys[10] as CustomIconToggleBtn;
+
+                SetBtnType(btnHighlight, true);
+                SetBtnType(btnFreeHand, true);
+                SetBtnType(btnAnnotSticky, true);
+                SetBtnType(btnAnnotStamp, true);
+                SetBtnType(btnSharpLine, true);
+                SetBtnType(btnSharpArrow, true);
+                SetBtnType(btnAnnotCircle, true);
+                SetBtnType(btnAnnotSquare, true);
+                SetBtnType(btnAnnotFreeText, true);
+                SetBtnType(btnAnnotStrikeout, true);
+                SetBtnType(btnUnderLine, true);
+
+                if (this._ListColor != null)
+                {
+                    this._ListColor.SelectedItems.Clear();
+                }
+                if (this._ListAuthor != null)
+                {
+                    this._ListAuthor.SelectedItems.Clear();
+                }
+                DialogParameters valuePairs = new DialogParameters();
+                valuePairs.Add(ParameterNames.AnnotationCleanState, true);
+                RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
+            }
+        }
+
+        /// <summary>
+        /// 设置类型按钮状态
+        /// </summary>
+        /// <param name="btn"></param>
+        private void SetBtnType(CustomIconToggleBtn btn, bool flag)
+        {
+            if (btn != null)
+            {
+                if (btn.IsChecked == flag)
+                {
+                    btn.IsChecked = !flag;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 确认
+        /// </summary>
+        /// <param name="obj"></param>
+        private void OkEvent(Object obj)
+        {
+            if (obj is Object[] arrys)
+            {
+                List<AnnotArgsType> styleDic = GetAnnotArgsType(arrys);
+                //ListBox listColor = arrys[11] as ListBox;
+                //ListBox listAuthor = arrys[12] as ListBox;
+                List<string> colors = new List<string>();
+                List<string> authors = new List<string>();
+                if (this._ListColor != null)
+                {
+                    if (this._ListColor.SelectedItems.Count > 0)
+                    {
+                        foreach (var item in this._ListColor.SelectedItems)
+                        {
+                            ColorItem color = item as ColorItem;
+                            colors.Add(color.Color.ToString());
+                        }
+                    }
+                }
+                if (this._ListAuthor != null)
+                {
+                    if (this._ListAuthor.SelectedItems.Count > 0)
+                    {
+                        foreach (var item in this._ListAuthor.SelectedItems)
+                        {
+                            AuthorItem author = item as AuthorItem;
+                            authors.Add(author.Name);
+                        }
+                    }
+                }
+
+                DialogParameters valuePairs = new DialogParameters();
+                valuePairs.Add(ParameterNames.AnnotArgsTypes, styleDic);
+                valuePairs.Add(ParameterNames.AnnotationColors, colors);
+                valuePairs.Add(ParameterNames.AnnotationAuthor, authors);
+                valuePairs.Add(ParameterNames.AnnotationCleanState, false);
+                RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
+            }
+        }
+
+        /// <summary>
+        /// 获取类型按钮状态
+        /// </summary>
+        /// <param name="arrys"></param>
+        /// <returns></returns>
+        private List<AnnotArgsType> GetAnnotArgsType(object[] arrys)
+        {
+            List<AnnotArgsType> styleDic = new List<AnnotArgsType>();
+            //CustomIconToggleBtn btnHighlight = arrys[0] as CustomIconToggleBtn;
+            //CustomIconToggleBtn btnFreeHand = arrys[1] as CustomIconToggleBtn;
+            //CustomIconToggleBtn btnAnnotSticky = arrys[2] as CustomIconToggleBtn;
+            //CustomIconToggleBtn btnAnnotStamp = arrys[3] as CustomIconToggleBtn;
+            //CustomIconToggleBtn btnSharpLine = arrys[4] as CustomIconToggleBtn;
+            //CustomIconToggleBtn btnSharpArrow = arrys[5] as CustomIconToggleBtn;
+            //CustomIconToggleBtn btnAnnotCircle = arrys[6] as CustomIconToggleBtn;
+            //CustomIconToggleBtn btnAnnotSquare = arrys[7] as CustomIconToggleBtn;
+            //CustomIconToggleBtn btnAnnotFreeText = arrys[8] as CustomIconToggleBtn;
+            //CustomIconToggleBtn btnAnnotStrikeout = arrys[9] as CustomIconToggleBtn;
+            //CustomIconToggleBtn btnUnderLine = arrys[10] as CustomIconToggleBtn;
+            GetBtnAnnotArgsTypeState(btnHighlight, styleDic, AnnotArgsType.AnnotHighlight);
+            GetBtnAnnotArgsTypeState(btnFreeHand, styleDic, AnnotArgsType.AnnotFreehand);
+            GetBtnAnnotArgsTypeState(btnAnnotSticky, styleDic, AnnotArgsType.AnnotSticky);
+            GetBtnAnnotArgsTypeState(btnAnnotStamp, styleDic, AnnotArgsType.AnnotStamp);
+            GetBtnAnnotArgsTypeState(btnSharpLine, styleDic, AnnotArgsType.AnnotLine);
+            GetBtnAnnotArgsTypeState(btnSharpArrow, styleDic, AnnotArgsType.AnnotLine);
+            GetBtnAnnotArgsTypeState(btnAnnotCircle, styleDic, AnnotArgsType.AnnotCircle);
+            GetBtnAnnotArgsTypeState(btnAnnotSquare, styleDic, AnnotArgsType.AnnotSquare);
+            GetBtnAnnotArgsTypeState(btnAnnotFreeText, styleDic, AnnotArgsType.AnnotFreeText);
+            GetBtnAnnotArgsTypeState(btnAnnotStrikeout, styleDic, AnnotArgsType.AnnotStrikeout);
+            GetBtnAnnotArgsTypeState(btnUnderLine, styleDic, AnnotArgsType.AnnotUnderline);
+            return styleDic;
+        }
+
+        /// <summary>
+        /// 添加被选中的类型按钮到集合
+        /// </summary>
+        /// <param name="btnType"></param>
+        /// <param name="styleDic"></param>
+        /// <param name="annotArgsType"></param>
+        private void GetBtnAnnotArgsTypeState(CustomIconToggleBtn btnType, List<AnnotArgsType> styleDic, AnnotArgsType annotArgsType)
+        {
+            if (btnType != null)
+            {
+                if (btnType.IsChecked == true)
+                {
+                    if (styleDic.IndexOf(annotArgsType) == -1)
+                    {
+                        styleDic.Add(annotArgsType);
+                    }
+                }
+            }
         }
 
         private void CancelEvent()
@@ -301,7 +603,11 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
         {
         }
 
-        private void SetColor(System.Windows.Media.Color color)
+        /// <summary>
+        /// 添加筛选颜色
+        /// </summary>
+        /// <param name="color"></param>
+        private void GetAnnotationColors(System.Windows.Media.Color color)
         {
             if (AnnotationColors.Count > 0)
             {
@@ -309,18 +615,13 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                 {
                     System.Windows.Media.Color color1 = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(AnnotationColors[i].Color.ToString());
                     if (color1.R == color.R && color1.G == color.G && color1.B == color.B
-                        && color1.A == color.A)
+                    && color1.A == color.A)
                     {
                         AnnotationColors.Remove(AnnotationColors[i]);
                     }
                 }
             }
             AnnotationColors.Add(new ColorItem(color));
-            //var bFind = AnnotationColors.All<ColorItem>(p => p.Color == new SolidColorBrush(color));
-            //if (bFind)
-            //{
-            //    AnnotationColors.Add(new ColorItem(color));
-            //}
         }
 
         public void OnDialogOpened(IDialogParameters parameters)
@@ -328,7 +629,28 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
             ObservableCollection<AnnotationHandlerEventArgs> list;
             parameters.TryGetValue<ObservableCollection<AnnotationHandlerEventArgs>>(ParameterNames.AnnotationList, out list);
             AnnotationListItems = list;
-
+            List<string> colors = new List<string>();
+            List<string> authors = new List<string>();
+            List<AnnotArgsType> annotArgsTypes = new List<AnnotArgsType>();
+            parameters.TryGetValue<List<string>>(ParameterNames.AnnotationColors, out colors);
+            parameters.TryGetValue<List<string>>(ParameterNames.AnnotationAuthor, out authors);
+            parameters.TryGetValue<List<AnnotArgsType>>(ParameterNames.AnnotArgsTypes, out annotArgsTypes);
+            if (colors != null)
+            {
+                this.Colors = colors;
+            }
+            if (authors != null)
+            {
+                this.Authors = authors;
+            }
+            if (annotArgsTypes != null)
+            {
+                this.AnnotArgsTypes = annotArgsTypes;
+            }
+            if (AnnotationListItems.Count <= 0)
+            {
+                return;
+            }
             foreach (var item in AnnotationListItems)
             {
                 AnnotationAuthor.Add(new AuthorItem(item.Author));
@@ -340,7 +662,7 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                     case AnnotArgsType.AnnotFreeText://文本
                         if (data is FreeTextAnnotArgs textAnnotArgs)
                         {
-                            SetColor(textAnnotArgs.FontColor);
+                            GetAnnotationColors(textAnnotArgs.FontColor);
                         }
                         AnnotFreeTextVisibility = Visibility.Visible;
                         break;
@@ -348,7 +670,7 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                     case AnnotArgsType.AnnotHighlight://高亮
                         if (data is TextHighlightAnnotArgs highlightAnnotArgs)
                         {
-                            SetColor(highlightAnnotArgs.Color);
+                            GetAnnotationColors(highlightAnnotArgs.Color);
                         }
                         HighlightVisibility = Visibility.Visible;
                         break;
@@ -356,7 +678,7 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                     case AnnotArgsType.AnnotFreehand://手绘
                         if (data is FreehandAnnotArgs freehandAnnotArgs)
                         {
-                            SetColor(freehandAnnotArgs.InkColor);
+                            GetAnnotationColors(freehandAnnotArgs.InkColor);
                         }
                         FreeHandVisibility = Visibility.Visible;
                         break;
@@ -372,7 +694,7 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                     case AnnotArgsType.AnnotStrikeout://删除线
                         if (data is TextStrikeoutAnnotArgs textStrikeoutAnnotArgs)
                         {
-                            SetColor(textStrikeoutAnnotArgs.Color);
+                            GetAnnotationColors(textStrikeoutAnnotArgs.Color);
                         }
                         AnnotStickyVisibility = Visibility.Visible;
                         break;
@@ -380,7 +702,7 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                     case AnnotArgsType.AnnotSticky://便签
                         if (data is StickyAnnotArgs stickyAnnotArgs)
                         {
-                            SetColor(stickyAnnotArgs.Color);
+                            GetAnnotationColors(stickyAnnotArgs.Color);
                         }
                         AnnotStickyVisibility = Visibility.Visible;
                         break;
@@ -388,7 +710,7 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                     case AnnotArgsType.AnnotUnderline://下划线
                         if (data is TextUnderlineAnnotArgs textUnderlineAnnotArgs)
                         {
-                            SetColor(textUnderlineAnnotArgs.Color);
+                            GetAnnotationColors(textUnderlineAnnotArgs.Color);
                         }
                         UnderLineVisibility = Visibility.Visible;
                         break;
@@ -404,15 +726,15 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                             //线
                             SharpLineVisibility = Visibility.Visible;
                         }
-                        SetColor((item.AnnotHandlerEventArgs as LineAnnotArgs).LineColor);
+                        GetAnnotationColors((item.AnnotHandlerEventArgs as LineAnnotArgs).LineColor);
 
                         break;
 
                     case AnnotArgsType.AnnotSquare://矩形
                         if (data is SquareAnnotArgs squareAnnotArgs)
                         {
-                            SetColor(squareAnnotArgs.BgColor);
-                            SetColor(squareAnnotArgs.LineColor);
+                            GetAnnotationColors(squareAnnotArgs.BgColor);
+                            GetAnnotationColors(squareAnnotArgs.LineColor);
                         }
                         AnnotSquareVisibility = Visibility.Visible;
                         break;
@@ -420,18 +742,15 @@ namespace PDF_Office.ViewModels.Dialog.BOTA
                     case AnnotArgsType.AnnotCircle://圆
                         if (data is CircleAnnotArgs circleAnnotArgs)
                         {
-                            SetColor(circleAnnotArgs.BgColor);
-                            SetColor(circleAnnotArgs.LineColor);
+                            GetAnnotationColors(circleAnnotArgs.BgColor);
+                            GetAnnotationColors(circleAnnotArgs.LineColor);
                         }
                         AnnotCircleVisibility = Visibility.Visible;
                         break;
                 }
             }
-            //AnnotationAuthor = AnnotationAuthor.MyDistinct(s => s.Name) as ObservableCollection<AuthorItem>;
-            //AnnotationColors = AnnotationColors.MyDistinct(s => s.Color) as ObservableCollection<ColorItem>;
 
-            AnnotationAuthor = new ObservableCollection<AuthorItem>(AnnotationAuthor.MyDistinct(s => s.Name));
-            //AnnotationColors = new ObservableCollection<ColorItem>(AnnotationColors.MyDistinct(s => s.Color));
+            AnnotationAuthor = new ObservableCollection<AuthorItem>(AnnotationAuthor.DistinctHelper(s => s.Name));
         }
     }
 }

+ 343 - 3
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -1,12 +1,352 @@
-using System;
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using PDF_Office.ViewModels.Tools;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
 using System.Collections.Generic;
+using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Media;
+using System.Windows;
+using System.Windows.Media.Imaging;
+using Prism.Commands;
+using PDF_Office.Helper;
+using Microsoft.Office.Interop.Word;
+using static Dropbox.Api.Files.FileCategory;
+using PDF_Office.Views.PropertyPanel.AnnotPanel;
+using System.Windows.Controls;
+using PDF_Office.CustomControl;
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
-    internal class LinkAnnotPropertyViewModel
+    internal class LinkAnnotPropertyViewModel : BindableBase, INavigationAware
     {
+        public AnnotAttribEvent AnnotAttribEvent { get; set; }
+        private int totalPage = 0;
+        private AnnotPropertyPanel PropertyPanel;
+        private AnnotArgsType annotType;
+
+        private LinkAnnotArgs _annotArgs;
+
+        public LinkAnnotArgs AnnotArgs
+        {
+            get
+            {
+                return _annotArgs;
+            }
+            set
+            {
+                if (_annotArgs != null)
+                {
+                    _annotArgs.LinkDrawFinished -= _annotArgs_LinkDrawFinished;
+                }
+                _annotArgs = value;
+
+                if (_annotArgs != null)
+                {
+                    _annotArgs.LinkDrawFinished += _annotArgs_LinkDrawFinished;
+                }
+            }
+        }
+
+        public AnnotArgsType AnnotType
+        {
+            get { return annotType; }
+            set
+            {
+                SetProperty(ref annotType, value);
+            }
+        }
+
+        private string pageNumTextContent = "Enter target page";
+
+        public string PageNumTextContent
+        {
+            get
+            {
+                return pageNumTextContent;
+            }
+            set
+            {
+                SetProperty(ref pageNumTextContent, value);
+            }
+        }
+
+        private WriteableBitmap previewImage;
+
+        public WriteableBitmap PreviewImage
+        {
+            get { return previewImage; }
+            set
+            {
+                SetProperty(ref previewImage, value);
+            }
+        }
+
+        private Visibility imagePreviewVisibility = Visibility.Collapsed;
+
+        public Visibility ImagePreviewVisibility
+        {
+            get { return imagePreviewVisibility; }
+            set
+            {
+                SetProperty(ref imagePreviewVisibility, value);
+            }
+        }
+
+        private Visibility btnGOorBackVisibility = Visibility.Collapsed;
+
+        public Visibility BtnGOorBackVisibility
+        {
+            get { return btnGOorBackVisibility; }
+            set
+            {
+                SetProperty(ref btnGOorBackVisibility, value);
+            }
+        }
+
+        private Visibility errorNumTipsVisibility = Visibility.Collapsed;
+
+        public Visibility ErrorNumTipsVisibility
+        {
+            get { return errorNumTipsVisibility; }
+            set
+            {
+                SetProperty(ref errorNumTipsVisibility, value);
+            }
+        }
+
+        private Visibility errorRangeTipsVisibility = Visibility.Collapsed;
+
+        public Visibility ErrorRangeTipsVisibility
+        {
+            get { return errorRangeTipsVisibility; }
+            set
+            {
+                SetProperty(ref errorRangeTipsVisibility, value);
+            }
+        }
+
+        private CPDFViewer pdfViewer;
+        private CPDFDocument document;
+        private LinkAnnotProperty linkAnnot;
+        public DelegateCommand<object> LoadedCommand { get; set; }
+        public DelegateCommand<object> PageNumTextChangedCommand { get; set; }
+        public DelegateCommand<object> ToggleButtonTabCommand { get; set; }
+
+        public LinkAnnotPropertyViewModel()
+        {
+            LoadedCommand = new DelegateCommand<object>(Loaded);
+            PageNumTextChangedCommand = new DelegateCommand<object>(PageNumTextChanged);
+            ToggleButtonTabCommand = new DelegateCommand<object>(ToggleButtonTabSelected);
+        }
+
+        private void ToggleButtonTabSelected(object obj)
+        {
+            if (obj is object[] array)
+            {
+            }
+        }
+
+        private void PageNumTextChanged(object obj)
+        {
+            if (obj is TextChangedEventArgs textChangedEventArgs)
+            {
+                if (textChangedEventArgs.Source is TextBoxWithTip textBox)
+                {
+                    int pageNum = -1;
+                    if (CheckPageNumVaild(out pageNum, textBox))
+                    {
+                        if (AnnotArgs != null)
+                        {
+                            AnnotArgs.DestIndex = pageNum - 1;
+                            SetImagePreview();
+                        }
+                    }
+                }
+            }
+        }
+
+        private bool CheckPageNumVaild(out int pageNum, TextBoxWithTip textBox)
+        {
+            pageNum = -1;
+            ErrorNumTipsVisibility = Visibility.Collapsed;
+            ErrorRangeTipsVisibility = Visibility.Collapsed;
+            BtnGOorBackVisibility = Visibility.Collapsed;
+            if (string.IsNullOrEmpty(textBox.Text))
+            {
+                return false;
+            }
+            if (textBox.Text.Trim() != string.Empty)
+            {
+                if (!int.TryParse(textBox.Text.Trim(), out pageNum))
+                {
+                    //ErrorNumTipsVisibility = Visibility.Visible;
+                    //ErrorRangeTipsVisibility = Visibility.Collapsed;
+                    textBox.IsError = true;
+                    textBox.ShowTip = Visibility.Visible;
+                    textBox.TipText = " Page number error.";
+                    return false;
+                }
+            }
+            if (pageNum < 1 || pageNum > totalPage)
+            {
+                //ErrorNumTipsVisibility = Visibility.Collapsed;
+                //ErrorRangeTipsVisibility = Visibility.Visible;
+                textBox.IsError = true;
+                textBox.ShowTip = Visibility.Visible;
+                textBox.TipText = "  Page number out of range.";
+                return false;
+            }
+            else
+            {
+                textBox.IsError = false;
+                textBox.ShowTip = Visibility.Collapsed;
+            }
+            BtnGOorBackVisibility = Visibility.Visible;
+            return true;
+        }
+
+        private void SetImagePreview()
+        {
+            ImagePreviewVisibility = Visibility.Visible;
+            BtnGOorBackVisibility = Visibility.Visible;
+
+            int dpiHeight = (int)linkAnnot.ImagePreview.Height;
+            int dpiWidth = (int)linkAnnot.ImagePreview.Width;
+            if (dpiHeight <= 0 || dpiWidth <= 0)
+            {
+                return;
+            }
+
+            int pageIndex = AnnotArgs.DestIndex;
+            Rect MediaRect = GetPageRect(document, pageIndex, CPDFDisplayBox.MediaBox);
+
+            System.Windows.Size pageSize = GetPageSize(document, pageIndex);
+            double scale = Math.Min(dpiWidth / MediaRect.Width, dpiHeight / MediaRect.Height);
+            scale = Math.Min(scale, 1);
+
+            int cropWidth = (int)(scale * pageSize.Width);
+            int cropHeight = (int)(scale * pageSize.Height);
+
+            byte[] imageDatas = RenderPDFPageToArray(document, pageIndex, new Rect(0, 0, cropWidth, cropHeight), scale, true, true);
+
+            WriteableBitmap WirteBitmap = new WriteableBitmap(cropWidth, cropHeight, 96, 96, PixelFormats.Bgra32, null);
+            WirteBitmap.WritePixels(new Int32Rect(0, 0, cropWidth, cropHeight), imageDatas, WirteBitmap.BackBufferStride, 0);
+
+            PreviewImage = WirteBitmap;
+        }
+
+        private void _annotArgs_LinkDrawFinished(object sender, bool e)
+        {
+            linkAnnot.SetTextBoxEnableOrNot(e, totalPage);
+            //AnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
+        }
+
+        private void Loaded(object obj)
+        {
+            if (obj is CompositeCommandParameter composite)
+            {
+                if (composite.Parameter is LinkAnnotProperty linkAnnotProperty)
+                {
+                    linkAnnot = linkAnnotProperty;
+                }
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
+
+            if (PropertyPanel != null && pdfViewer != null)
+            {
+                AnnotAttribEvent = PropertyPanel.AnnotEvent;
+                AnnotType = PropertyPanel.annot.EventType;
+
+                document = pdfViewer.Document;
+                totalPage = pdfViewer.Document.PageCount;
+                if (linkAnnot != null)
+                {
+                    if (pdfViewer != null && pdfViewer.ToolManager != null && pdfViewer.ToolManager.CurrentAnnotArgs?.EventType == AnnotArgsType.AnnotLink)
+                    {
+                        if (AnnotAttribEvent.IsAnnotCreateReset)
+                        {
+                            AnnotArgs = pdfViewer.ToolManager.CurrentAnnotArgs as LinkAnnotArgs;
+                        }
+                    }
+                    linkAnnot.SetTextBoxEnableOrNot(!AnnotAttribEvent.IsAnnotCreateReset, totalPage);
+                }
+                else
+                {
+                    AnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
+                }
+            }
+        }
+
+        public byte[] RenderPDFPageToArray(CPDFDocument document, int pageIndex, Rect renderRect, double currentZoom, bool renderAnnot = false, bool renderForm = false)
+        {
+            if (renderRect.Width <= 0 || renderRect.Height <= 0 || document == null)
+            {
+                return null;
+            }
+            try
+            {
+                byte[] bmpData = new byte[(int)renderRect.Width * (int)renderRect.Height * 4];
+                currentZoom = currentZoom * 96 / 72;
+                int flag = 0;
+                if (renderAnnot)
+                {
+                    flag = 1;
+                }
+                uint bgColor = 0xFFFFFFFF;
+                CPDFPage page = document.PageAtIndex(pageIndex);
+                if (page.IsValid())
+                {
+                    page.RenderPageBitmapWithMatrix((float)currentZoom, renderRect, bgColor, bmpData, flag, renderForm);
+                }
+                return bmpData;
+            }
+            catch (Exception ex)
+            {
+                return null;
+            }
+        }
+
+        private Rect GetPageRect(CPDFDocument document, int pageIndex, CPDFDisplayBox displayBox)
+        {
+            CPDFPage currentPage = document.PageAtIndex(pageIndex);
+            Rect boundBox = currentPage.GetBoundsForBox(displayBox);
+
+            Rect boundRect = new Rect((int)(boundBox.Left / 72.0 * 96.0), (int)(boundBox.Top / 72.0 * 96.0),
+            (int)(boundBox.Width / 72.0 * 96.0), (int)(boundBox.Height / 72.0 * 96.0));
+
+            return boundRect;
+        }
+
+        private System.Windows.Size GetPageSize(CPDFDocument document, int pageIndex)
+        {
+            System.Windows.Size pageSize = document.GetPageSize(pageIndex);
+            pageSize.Width = pageSize.Width / 72.0 * 96;
+            pageSize.Height = pageSize.Height / 72.0 * 96;
+
+            return pageSize;
+        }
     }
-}
+}

+ 76 - 32
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -1,10 +1,12 @@
 using ComPDFKit.PDFAnnotation;
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
 using Microsoft.Win32;
 using PDF_Office.CustomControl;
 using PDF_Office.Helper;
 using PDF_Office.Properties;
+using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
 using PDFSettings;
 using Prism.Mvvm;
 using Prism.Regions;
@@ -21,6 +23,7 @@ namespace PDF_Office.ViewModels.Tools
     public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
     {
         #region 初始化
+
         private void BindingEvent()
         {
             propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
@@ -30,7 +33,6 @@ namespace PDF_Office.ViewModels.Tools
 
         private void InitDefaultValue()
         {
-
             InitAnnotHighlight();
             InitAnnotUnderline();
             InitAnnotSquiggly();
@@ -56,7 +58,6 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
-
         private void InitAnnotUnderline()
         {
             DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotUnderline);
@@ -114,8 +115,7 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
-        #endregion
-
+        #endregion 初始化
 
         #region 注释工具
 
@@ -128,7 +128,7 @@ namespace PDF_Office.ViewModels.Tools
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             TextHighlightAnnotArgs highlightArgs = null;
 
-            if(selectedhighlightArgs == null)
+            if (selectedhighlightArgs == null)
             {
                 highlightArgs = new TextHighlightAnnotArgs();
                 highlightArgs.Color = Color.FromRgb(0xFF, 0xBB, 0x00);
@@ -154,6 +154,47 @@ namespace PDF_Office.ViewModels.Tools
             return highlightArgs;
         }
 
+        private AnnotHandlerEventArgs GetLink(LinkAnnotArgs selectedfreetextArgs = null, AnnotAttribEvent annotAttribEvent = null)
+        {
+            Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
+            LinkAnnotArgs linkArgs = new LinkAnnotArgs();
+            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotLink);
+            if (annotProperty != null)
+            {
+            }
+
+            if (selectedfreetextArgs != null)
+            {
+                linkArgs.URI = selectedfreetextArgs.URI;
+                linkArgs.LinkType = selectedfreetextArgs.LinkType;
+                linkArgs.DestIndex = selectedfreetextArgs.DestIndex;
+            }
+            else
+            {
+                linkArgs.URI = string.Empty;
+                linkArgs.LinkType = LINK_TYPE.GOTO;
+                linkArgs.DestIndex = -1;
+            }
+
+            //if (viewCtrl.PdfViewer.Document != null)
+            //{
+            //    linkProperty.SetTotalPage(viewCtrl.PdfViewer.Document.PageCount);
+            //}
+            //linkProperty.SetLinkPageNum(linkArgs.DestIndex);
+            //linkProperty.SetLinkUrl(linkArgs.URI);
+            //linkProperty.SetLinkEmail(string.Empty);
+            //linkProperty.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(linkArgs, annotAttribsList);
+            //linkProperty.AnnotArgs = linkArgs;
+            //propertyPanel = linkProperty;
+            //annotArgs = linkArgs;
+            //viewCtrl.ShowPropertyPanel();
+            annotAttribsList[AnnotAttrib.LinkType] = linkArgs.LinkType;
+            annotAttribsList[AnnotAttrib.LinkUri] = linkArgs.URI;
+            annotAttribsList[AnnotAttrib.LinkDestIndx] = linkArgs.DestIndex;
+            AddToPropertyPanel("LinkAnnotProperty", "Link", linkArgs, annotAttribsList, annotAttribEvent);
+            return linkArgs;
+        }
+
         private AnnotHandlerEventArgs GetUnderLine(TextUnderlineAnnotArgs selectedunderlineArgs = null)
         {
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
@@ -180,8 +221,8 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Color] = underlineArgs.Color;
             annotAttribsList[AnnotAttrib.Transparency] = underlineArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
-          
-            AddToPropertyPanel("TextAnnotProperty", "UnderLine", underlineArgs,  annotAttribsList);
+
+            AddToPropertyPanel("TextAnnotProperty", "UnderLine", underlineArgs, annotAttribsList);
             return underlineArgs;
         }
 
@@ -212,7 +253,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Transparency] = squigglyArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
 
-            AddToPropertyPanel("TextAnnotProperty", "Squiggly", squigglyArgs,  annotAttribsList);
+            AddToPropertyPanel("TextAnnotProperty", "Squiggly", squigglyArgs, annotAttribsList);
             return squigglyArgs;
         }
 
@@ -221,7 +262,7 @@ namespace PDF_Office.ViewModels.Tools
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             TextStrikeoutAnnotArgs strikeoutArgs = null;
 
-            if(selectedstrikeoutArgs == null)
+            if (selectedstrikeoutArgs == null)
             {
                 strikeoutArgs = new TextStrikeoutAnnotArgs();
                 strikeoutArgs.Color = Color.FromRgb(0xFF, 0x3B, 0x30);
@@ -238,7 +279,7 @@ namespace PDF_Office.ViewModels.Tools
             {
                 strikeoutArgs = selectedstrikeoutArgs;
             }
-           
+
             annotAttribsList[AnnotAttrib.Color] = strikeoutArgs.Color;
             annotAttribsList[AnnotAttrib.Transparency] = strikeoutArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
@@ -252,7 +293,7 @@ namespace PDF_Office.ViewModels.Tools
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             FreehandAnnotArgs freehandArgs = null;
 
-            if(selectedfreehandArgs == null)
+            if (selectedfreehandArgs == null)
             {
                 freehandArgs = new FreehandAnnotArgs();
                 freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
@@ -266,13 +307,12 @@ namespace PDF_Office.ViewModels.Tools
                     freehandArgs.LineWidth = annotProperty.Thickness;
                     freehandArgs.Content = annotProperty.NoteText;
                 }
-
             }
             else
             {
                 freehandArgs = selectedfreehandArgs;
             }
-            
+
             annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
             annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
             annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
@@ -325,7 +365,6 @@ namespace PDF_Office.ViewModels.Tools
                     textAlignment = TextAlignment.Center;
                 else
                     textAlignment = TextAlignment.Right;
-
             }
             else
             {
@@ -333,7 +372,6 @@ namespace PDF_Office.ViewModels.Tools
                 textAlignment = freetextArgs.Align;
             }
 
-          
             annotAttribsList[AnnotAttrib.Color] = freetextArgs.LineColor;
             annotAttribsList[AnnotAttrib.FillColor] = freetextArgs.BgColor;
             annotAttribsList[AnnotAttrib.Thickness] = freetextArgs.LineWidth;
@@ -378,7 +416,7 @@ namespace PDF_Office.ViewModels.Tools
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             SquareAnnotArgs squareArgs = null;
 
-            if(selectedsquareArgs == null)
+            if (selectedsquareArgs == null)
             {
                 squareArgs = new SquareAnnotArgs();
 
@@ -416,7 +454,7 @@ namespace PDF_Office.ViewModels.Tools
             {
                 squareArgs = selectedsquareArgs;
             }
-            
+
             annotAttribsList[AnnotAttrib.Color] = squareArgs.LineColor;
             annotAttribsList[AnnotAttrib.FillColor] = squareArgs.BgColor;
             annotAttribsList[AnnotAttrib.LineStyle] = squareArgs.LineDash;
@@ -433,7 +471,7 @@ namespace PDF_Office.ViewModels.Tools
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             CircleAnnotArgs circleAnnotArgs = null;
 
-            if(selectedcircleAnnotArgs == null)
+            if (selectedcircleAnnotArgs == null)
             {
                 circleAnnotArgs = new CircleAnnotArgs();
                 circleAnnotArgs.LineColor = Colors.Red;
@@ -469,7 +507,7 @@ namespace PDF_Office.ViewModels.Tools
             {
                 circleAnnotArgs = selectedcircleAnnotArgs;
             }
-            
+
             annotAttribsList[AnnotAttrib.Color] = circleAnnotArgs.LineColor;
             annotAttribsList[AnnotAttrib.FillColor] = circleAnnotArgs.BgColor;
             annotAttribsList[AnnotAttrib.LineStyle] = circleAnnotArgs.LineDash;
@@ -481,14 +519,13 @@ namespace PDF_Office.ViewModels.Tools
             return circleAnnotArgs;
         }
 
-        private AnnotHandlerEventArgs GetArrowLine(string TagStr,LineAnnotArgs selectedLineAnnotArgs = null)
+        private AnnotHandlerEventArgs GetArrowLine(string TagStr, LineAnnotArgs selectedLineAnnotArgs = null)
         {
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             LineAnnotArgs lineArgs = new LineAnnotArgs();
 
-            if(selectedLineAnnotArgs == null)
+            if (selectedLineAnnotArgs == null)
             {
-
                 lineArgs.LineColor = Colors.Red;
                 lineArgs.HeadLineType = C_LINE_TYPE.LINETYPE_NONE;
                 if (TagStr == "Line")
@@ -576,8 +613,6 @@ namespace PDF_Office.ViewModels.Tools
             if (openFileDialog.ShowDialog() == true)
             {
                 stampArgs.ImagePath = openFileDialog.FileName;
-
-              
             }
 
             AddToPropertyPanel("ImageAnnotProperty", null, stampArgs, annotAttribsList);
@@ -591,7 +626,7 @@ namespace PDF_Office.ViewModels.Tools
         /// <param name="toolTag">导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线</param>
         /// <param name="annot">注释</param>
         /// <param name="annotAttribsList">更改注释属性的键值对,更改值后会自动记录undoRedo容器里</param>
-        private void AddToPropertyPanel(string viewContent, string toolTag = null, AnnotHandlerEventArgs annot = null, Dictionary<AnnotAttrib, object> annotAttribsList = null)
+        private void AddToPropertyPanel(string viewContent, string toolTag = null, AnnotHandlerEventArgs annot = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null)
         {
             if (string.IsNullOrEmpty(toolTag) == false)
             {
@@ -605,16 +640,25 @@ namespace PDF_Office.ViewModels.Tools
                 propertyPanel.annot = annot;
 
             if (annotAttribsList != null)
-                propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
+            {
+                if (annot is LinkAnnotArgs && annotAttribEvent != null)
+                {
+                    propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
+                    if (annotAttribEvent.IsAnnotCreateReset)
+                    {
+                        propertyPanel.AnnotEvent.IsAnnotCreateReset = true;
+                    }
+                }
+                else
+                {
+                    propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
+                }
+            }
 
             if (string.IsNullOrEmpty(viewContent) == false)
                 viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
-
         }
 
-
-        #endregion
-
-
+        #endregion 注释工具
     }
-}
+}

+ 18 - 23
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -26,10 +26,8 @@ using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.Tools
 {
-
     public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
     {
-
         public AnnotToolContentViewModel(IRegionManager regionManager)
         {
             region = regionManager;
@@ -40,8 +38,8 @@ namespace PDF_Office.ViewModels.Tools
             InitDefaultValue();
         }
 
-
         private Dictionary<string, bool> ToolExpandDict = new Dictionary<string, bool>();
+
         public void BtnMyTools_Click(CustomIconToggleBtn annotBtn)
         {
             //不创建注释,属于注释模板
@@ -50,7 +48,6 @@ namespace PDF_Office.ViewModels.Tools
 
             if (annotBtn.IsChecked == true)
             {
-
                 switch (annotBtn.Tag.ToString())
                 {
                     case "SnapshotEdit":
@@ -112,8 +109,8 @@ namespace PDF_Office.ViewModels.Tools
                         break;
 
                     case "Link":
+                        annotArgs = GetLink();
                         break;
-
                 }
 
                 if (annotArgs != null)
@@ -122,23 +119,20 @@ namespace PDF_Office.ViewModels.Tools
                     PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
                     PDFViewer.SetToolParam(annotArgs);
                 }
-
             }
 
             //当不是注释模板,且无创建注释时,属性面板显示为空内容
-            if(isTemplateAnnot == false && annotArgs == null)
+            if (isTemplateAnnot == false && annotArgs == null)
             {
                 PDFViewer.SetMouseMode(MouseModes.PanTool);
                 viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
             }
 
             ShowPropertyPanel((bool)annotBtn.IsChecked);
-
         }
 
         private void AnnotProperty_DefaultStored(object sender, object e)
         {
-
         }
 
         private void AnnotPropertyPanel_AnnotTypeChanged(object sender, Dictionary<AnnotArgsType, object> e)
@@ -162,21 +156,18 @@ namespace PDF_Office.ViewModels.Tools
                             var LineTag = e[argsType] as string;
                             annotArgs = GetArrowLine(LineTag);
                             break;
-
                     }
                     if (annotArgs != null)
                     {
                         annotArgs.Author = Settings.Default.AppProperties.Description.Author;
                         PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
                         PDFViewer.SetToolParam(annotArgs);
-
                     }
                     ShowPropertyPanel();
                 }
             }
         }
 
-
         private void AnnotPropertyPanel_DataChanged(object sender, Dictionary<AnnotArgsType, object> e)
         {
             if (e != null)
@@ -239,6 +230,7 @@ namespace PDF_Office.ViewModels.Tools
                                 //  FreehandPath.Opacity = (double)e[argsType];
                             }
                             break;
+
                         case AnnotArgsType.AnnotErase:
                             if (e[argsType] is ToggleButton)
                             {
@@ -360,18 +352,15 @@ namespace PDF_Office.ViewModels.Tools
 
                 PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
                 PDFViewer.WidgetClickHander += PDFViewer_WidgetClickHander;
-
             }
         }
 
         private void PDFViewer_WidgetClickHander(object sender, WidgetArgs e)
         {
-
         }
 
         private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
         {
-
         }
 
         private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
@@ -384,29 +373,38 @@ namespace PDF_Office.ViewModels.Tools
                     switch (annot.EventType)
                     {
                         case AnnotArgsType.AnnotHighlight:
+                            e.IsAnnotCreateReset = false;
                             GetHighLight(annot as TextHighlightAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotUnderline:
                             GetUnderLine(annot as TextUnderlineAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotStrikeout:
                             GetStrikeout(annot as TextStrikeoutAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotSquiggly:
                             GetSquiggly(annot as TextSquigglyAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotFreehand:
                             GetFreehand(annot as FreehandAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotFreeText:
                             GetFreetext(annot as FreeTextAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotSquare:
                             GetRect(annot as SquareAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotCircle:
                             GetCircle(annot as CircleAnnotArgs);
                             break;
+
                         case AnnotArgsType.AnnotLine:
                             bool isLine = true;
                             if (e.Attribs.ContainsKey(AnnotAttrib.LineStart))
@@ -430,6 +428,10 @@ namespace PDF_Office.ViewModels.Tools
                                 GetArrowLine("Arrow", annot as LineAnnotArgs);
 
                             break;
+
+                        case AnnotArgsType.AnnotLink:
+                            GetLink(annot as LinkAnnotArgs, e);
+                            break;
                     }
 
                     ShowPropertyPanel();
@@ -440,12 +442,10 @@ namespace PDF_Office.ViewModels.Tools
                 // PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
                 //  viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
             }
-
         }
 
         private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
         {
-
             if (e.AnnotEventArgsList == null)
                 return;
 
@@ -468,14 +468,12 @@ namespace PDF_Office.ViewModels.Tools
                         {
                             e.Handle = true;
                         }
-
                     }
 
                     break;
             }
         }
 
-
         private ContextMenu SelectAnnotContextMenu(object sender)
         {
             var popMenu = App.Current.FindResource("SelectAnnotContextMenu") as ContextMenu;
@@ -498,7 +496,6 @@ namespace PDF_Office.ViewModels.Tools
                 //menuItem = popMenu.Items[2] as MenuItem;
                 //menuItem.CommandTarget = (UIElement)sender;
                 //menuItem.Command = ApplicationCommands.no;
-
             }
             return popMenu;
         }
@@ -527,7 +524,5 @@ namespace PDF_Office.ViewModels.Tools
         {
             viewContentViewModel.IsPropertyOpen = show;
         }
-
     }
-
-}
+}

+ 3 - 2
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -471,7 +471,7 @@ namespace PDF_Office.ViewModels
             ToolsBarContentVisible = Visibility.Collapsed;
             ConverterBarContentVisible = Visibility.Collapsed;
             TextEditToolContentVisible = Visibility.Collapsed;
-        
+
             switch (currentBar)
             {
                 case "TabItemAnnotation":
@@ -508,7 +508,7 @@ namespace PDF_Office.ViewModels
 
         private void PDFEditMode(string currentBar)
         {
-            if(currentBar == "TabItemEdit")
+            if (currentBar == "TabItemEdit")
             {
                 if (PDFViewer != null)
                 {
@@ -772,6 +772,7 @@ namespace PDF_Office.ViewModels
                 //传其他参数:文档类,空注释面板;
                 parameters.Add(ParameterNames.PDFViewer, PDFViewer);
                 parameters.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
+
                 region.RequestNavigate(PropertyRegionName, Content, parameters);
             }
          ));

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 136 - 126
PDF Office/Views/BOTA/AnnotationContent.xaml


+ 4 - 0
PDF Office/Views/BOTA/AnnotationContent.xaml.cs

@@ -38,6 +38,10 @@ namespace PDF_Office.Views.BOTA
         {
             InitializeComponent();
             viewModel = this.DataContext as AnnotationContentViewModel;
+            if (AnnotationList.Items.Count < 0)
+            {
+                MenuExpandAll.IsEnabled = false;
+            }
         }
 
         private void ListBoxItem_PreviewMouseDown(object sender, MouseButtonEventArgs e)

+ 86 - 62
PDF Office/Views/BOTA/AnnotationListItem.xaml

@@ -44,12 +44,13 @@
             <Grid.RowDefinitions>
                 <RowDefinition />
                 <RowDefinition />
+                <RowDefinition />
             </Grid.RowDefinitions>
 
             <Grid>
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="40" />
-                    <ColumnDefinition Width="85*" />
+                    <ColumnDefinition Width="95*" />
                 </Grid.ColumnDefinitions>
                 <Grid
                     Name="GridIco"
@@ -65,16 +66,43 @@
                         Tag="HighLight"
                         Visibility="Collapsed">
                         <Grid>
-                            <Polygon
-                                Name="PathHighlight"
-                                VerticalAlignment="Center"
-                                Fill="Black"
-                                Points="0,20,3,0,20,0,17,20" />
+
+                            <!--<Border
+                            x:Name="PathHighlight"
+                            Width="20"
+                            Height="20"
+                            BorderThickness="1"
+                            CornerRadius="3"
+                            Opacity="1">
+                            <Path
+                            Margin="-5,-5,0,0"
+                            Data="M7.5 7H20.5C20.7761 7 21 7.22386 21 7.5V20.5C21 20.7761 20.7761 21 20.5 21H7.5C7.22386 21 7 20.7761 7 20.5V7.5C7 7.22386 7.22386 7 7.5 7ZM5 7.5C5 6.11929 6.11929 5 7.5 5H20.5C21.8807 5 23 6.11929 23 7.5V20.5C23 21.8807 21.8807 23 20.5 23H7.5C6.11929 23 5 21.8807 5 20.5V7.5ZM12.1015 17.75H9.84564L12.6874 9.29492H15.3183L18.1601 17.75H15.9042L15.3828 15.8926H12.623L12.1015 17.75ZM14.0585 11.1582H13.9472L13.0566 14.3457H14.9492L14.0585 11.1582Z"
+                            Fill="#273C62" />
+                            </Border>-->
+
+                            <Border
+                                x:Name="PathHighlight"
+                                Width="20"
+                                Height="20"
+                                BorderThickness="1"
+                                CornerRadius="3"
+                                Opacity="1">
+
+                                <Path
+                                    Margin="4.85,4.29,0,0"
+                                    Data="M0.845703 8.75H3.10156L3.62305 6.89258H6.38281L6.9043 8.75H9.16016L6.31836 0.294922H3.6875L0.845703 8.75ZM4.94727 2.1582H5.05859L5.94922 5.3457H4.05664L4.94727 2.1582Z"
+                                    Fill="#273C62" />
+                            </Border>
+                            <!--<Polygon
+                            Name="PathHighlight"
+                            VerticalAlignment="Center"
+                            Fill="Black"
+                            Points="0,20,3,0,20,0,17,20" />
                             <Image
-                                Width="18"
-                                Height="18"
-                                Source="pack://application:,,,/Resources/BOTA/Annotation/Highlight.png"
-                                Stretch="UniformToFill" />
+                            Width="18"
+                            Height="18"
+                            Source="pack://application:,,,/Resources/BOTA/Annotation/Highlight.png"
+                            Stretch="UniformToFill" />-->
                         </Grid>
                     </customControl:CustomIconToggleBtn>
                     <!--  手绘  -->
@@ -238,7 +266,7 @@
                                 Grid.Row="1"
                                 Width="20"
                                 Height="2"
-                                Margin="0,4,0,0"
+                                Margin="0,5,0,0"
                                 Fill="#FF8200CC"
                                 Opacity="1" />
                         </Grid>
@@ -256,7 +284,10 @@
                                 <RowDefinition Height="Auto" />
                                 <RowDefinition />
                             </Grid.RowDefinitions>
-                            <Path Data="M3.41699 16H5.82666L7.16992 12.001H12.8301L14.1631 16H16.583L11.2407 1.20361H8.75928L3.41699 16ZM9.90771 3.79785H10.082L12.2148 10.1553H7.78516L9.90771 3.79785Z" Fill="#273C62" />
+                            <Path
+                                Name="UnderlinePath"
+                                Data="M3.41699 16H5.82666L7.16992 12.001H12.8301L14.1631 16H16.583L11.2407 1.20361H8.75928L3.41699 16ZM9.90771 3.79785H10.082L12.2148 10.1553H7.78516L9.90771 3.79785Z"
+                                Fill="#273C62" />
                             <Rectangle
                                 Name="RectangleUnderline"
                                 Grid.Row="1"
@@ -265,12 +296,44 @@
                                 Margin="0,1,0,0"
                                 Fill="#FF8200CC"
                                 Opacity="1" />
+                            <!--<Path Data="M3.41699 16H5.82666L7.16992 12.001H12.8301L14.1631 16H16.583L11.2407 1.20361H8.75928L3.41699 16ZM9.90771 3.79785H10.082L12.2148 10.1553H7.78516L9.90771 3.79785Z" Fill="#273C62" />
+                            <Rectangle
+                            Name="RectangleUnderline"
+                            Grid.Row="1"
+                            Width="18"
+                            Height="2"
+                            Margin="0,1,0,0"
+                            Fill="#FF8200CC"
+                            Opacity="1" />-->
                         </Grid>
                     </customControl:CustomIconToggleBtn>
                 </Grid>
-                <!--<TextBox
-                Name="TxtContext"
-                Grid.Column="1"
+                <WrapPanel Grid.Column="1" Orientation="Horizontal">
+                    <TextBlock
+                        Name="txtAuthor"
+                        Margin="5,0,0,0"
+                        VerticalAlignment="Top"
+                        FontFamily="Segoe UI"
+                        FontSize="10"
+                        Foreground="#666666"
+                        Text="{Binding Author}"
+                        TextAlignment="Left" />
+                    <TextBlock
+                        Name="txtDate"
+                        Margin="5,0,0,0"
+                        HorizontalAlignment="Left"
+                        VerticalAlignment="Top"
+                        FontFamily="Segoe UI"
+                        FontSize="10"
+                        Foreground="#666666"
+                        Text="{Binding CreateTime, Converter={StaticResource StringToDateConvert}}"
+                        TextAlignment="Left"
+                        TextWrapping="Wrap" />
+                </WrapPanel>
+            </Grid>
+            <TextBlock
+                Name="TxbContext"
+                Grid.Row="1"
                 Padding="5,0"
                 FontFamily="Segoe UI"
                 FontSize="14"
@@ -278,29 +341,16 @@
                 Foreground="#FF333333"
                 Text="{Binding Content}"
                 TextAlignment="Left"
-                TextWrapping="Wrap"
-                Visibility="Collapsed" />-->
-                <TextBlock
-                    Name="TxbContext"
-                    Grid.Column="1"
-                    Padding="5,0"
-                    FontFamily="Segoe UI"
-                    FontSize="14"
-                    FontWeight="SemiBold"
-                    Foreground="#FF333333"
-                    Text="{Binding Content}"
-                    TextAlignment="Left"
-                    TextTrimming="CharacterEllipsis"
-                    TextWrapping="Wrap" />
+                TextTrimming="CharacterEllipsis"
+                TextWrapping="Wrap" />
 
-                <Image
-                    Name="ImageContext"
-                    Grid.Column="1"
-                    Source="{Binding WriteableBitmap}" />
-            </Grid>
+            <Image
+                Name="ImageContext"
+                Grid.Row="1"
+                Source="{Binding WriteableBitmap}" />
             <TextBlock
                 Name="TxbMarkUpContent"
-                Grid.Row="1"
+                Grid.Row="2"
                 Margin="5,10"
                 FontFamily="Segoe UI"
                 FontSize="12"
@@ -310,33 +360,7 @@
                 TextWrapping="Wrap"
                 Visibility="{Binding ElementName=TxbMarkUpContent, Path=Text, Converter={StaticResource StringToVisibleConvert}}" />
         </Grid>
-        <Grid Grid.Row="1">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition />
-                <ColumnDefinition />
-            </Grid.ColumnDefinitions>
-            <TextBlock
-                Name="txtAuthor"
-                Margin="4,0,0,0"
-                VerticalAlignment="Bottom"
-                FontFamily="Segoe UI"
-                FontSize="10"
-                Foreground="#666666"
-                Text="{Binding Author}"
-                TextAlignment="Left" />
-            <TextBlock
-                Name="txtDate"
-                Grid.Column="1"
-                Margin="0,0,5,0"
-                Padding="0,10,0,0"
-                HorizontalAlignment="Right"
-                VerticalAlignment="Bottom"
-                FontFamily="Segoe UI"
-                FontSize="10"
-                Foreground="#666666"
-                Text="{Binding CreateTime, Converter={StaticResource StringToDateConvert}}"
-                TextAlignment="Right" />
-        </Grid>
+
         <Separator
             x:Name="MenuSeparator2"
             Grid.Row="1"

+ 22 - 22
PDF Office/Views/BOTA/AnnotationListItem.xaml.cs

@@ -56,7 +56,7 @@ namespace PDF_Office.Views.BOTA
 
                 case AnnotArgsType.AnnotHighlight:
                     BtnHighlight.Visibility = Visibility.Visible;
-                    PathHighlight.Fill = new SolidColorBrush((data as TextHighlightAnnotArgs).Color);
+                    PathHighlight.Background = new SolidColorBrush((data as TextHighlightAnnotArgs).Color);
                     //TxbContext.Text = data.Content;
                     if (!string.IsNullOrEmpty(TxbContext.Text))
                     {
@@ -114,18 +114,18 @@ namespace PDF_Office.Views.BOTA
 
                     #region to do
 
-                    //TextDecoration myStrikeout = new TextDecoration();
-                    //Pen myPen2 = new Pen();
-                    //myPen2.Brush = new SolidColorBrush((data as TextStrikeoutAnnotArgs).Color);
-                    //myPen2.Brush.Opacity = 0.8;
-                    //myPen2.Thickness = 1;
-                    //myStrikeout.Pen = myPen2;
-                    //myStrikeout.PenOffset = -3;
-                    //myStrikeout.PenThicknessUnit = TextDecorationUnit.FontRecommended;
-                    //TextDecorationCollection myCollection2 = new TextDecorationCollection();
-                    //myCollection2.Add(myStrikeout);
+                    TextDecoration myStrikeout = new TextDecoration();
+                    Pen myPen2 = new Pen();
+                    myPen2.Brush = new SolidColorBrush((data as TextStrikeoutAnnotArgs).Color);
+                    myPen2.Brush.Opacity = 0.8;
+                    myPen2.Thickness = 2;
+                    myStrikeout.Pen = myPen2;
+                    myStrikeout.PenOffset = -4;
+                    myStrikeout.PenThicknessUnit = TextDecorationUnit.FontRecommended;
+                    TextDecorationCollection myCollection2 = new TextDecorationCollection();
+                    myCollection2.Add(myStrikeout);
                     //因为波浪线无法实现 暂时只显示文字 不显示下划线,删除线等
-                    //TxbContext.TextDecorations = myCollection2;
+                    TxbContext.TextDecorations = myCollection2;
 
                     #endregion to do
 
@@ -142,16 +142,16 @@ namespace PDF_Office.Views.BOTA
 
                     #region TO DO
 
-                    //TextDecoration myUnderline = new TextDecoration();
-                    //Pen myPen1 = new Pen();
-                    //myPen1.Brush = new SolidColorBrush((data as TextUnderlineAnnotArgs).Color);
-                    //myPen1.Brush.Opacity = 0.8;
-                    //myPen1.Thickness = 2;
-                    //myUnderline.Pen = myPen1;
-                    //myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
-                    //TextDecorationCollection myCollection1 = new TextDecorationCollection();
-                    //myCollection1.Add(myUnderline);
-                    //TxbContext.TextDecorations = myCollection1;
+                    TextDecoration myUnderline = new TextDecoration();
+                    Pen myPen1 = new Pen();
+                    myPen1.Brush = new SolidColorBrush((data as TextUnderlineAnnotArgs).Color);
+                    myPen1.Brush.Opacity = 0.8;
+                    myPen1.Thickness = 2;
+                    myUnderline.Pen = myPen1;
+                    myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
+                    TextDecorationCollection myCollection1 = new TextDecorationCollection();
+                    myCollection1.Add(myUnderline);
+                    TxbContext.TextDecorations = myCollection1;
 
                     #endregion TO DO
 

+ 200 - 36
PDF Office/Views/Dialog/BOTA/ScreenAnnotationDialog.xaml

@@ -2,6 +2,7 @@
     x:Class="PDF_Office.Views.Dialog.BOTA.ScreenAnnotationDialog"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:DataConvert="clr-namespace:PDF_Office.DataConvert"
     xmlns:customControl="clr-namespace:PDF_Office.CustomControl"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:dialogBOTA="clr-namespace:PDF_Office.ViewModels.Dialog.BOTA"
@@ -22,28 +23,28 @@
                 <ResourceDictionary Source="pack://application:,,,/Styles/ListViewStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/Styles/CustomBtnStyle.xaml" />
             </ResourceDictionary.MergedDictionaries>
-
+            <DataConvert:ObjectConvert x:Key="ObjectConvert" />
             <SolidColorBrush x:Key="path.fill" Color="#273C62" />
             <DataTemplate x:Key="ListColorData">
                 <Border
-                Width="20"
-                Height="20"
-                Margin="6">
-                    <Ellipse
-                    Name="EllipseColor"
                     Width="20"
                     Height="20"
-                    Fill="{Binding Color}" />
+                    Margin="6">
+                    <Ellipse
+                        Name="EllipseColor"
+                        Width="20"
+                        Height="20"
+                        Fill="{Binding Color}" />
                 </Border>
             </DataTemplate>
             <DataTemplate x:Key="ListAuthorData">
                 <TextBlock
-                Name="TxbAuthor"
-                Margin="6,0"
-                HorizontalAlignment="Center"
-                VerticalAlignment="Center"
-                FontSize="12"
-                Text="{Binding Name}" />
+                    Name="TxbAuthor"
+                    Margin="6,0"
+                    HorizontalAlignment="Center"
+                    VerticalAlignment="Center"
+                    FontSize="12"
+                    Text="{Binding Name}" />
             </DataTemplate>
             <Style x:Key="ListboxItemStyle" TargetType="{x:Type ListBoxItem}">
                 <Setter Property="HorizontalAlignment" Value="Center" />
@@ -55,12 +56,12 @@
                     <Setter.Value>
                         <ControlTemplate TargetType="{x:Type ContentControl}">
                             <Border
-                            x:Name="border"
-                            Width="40"
-                            Height="40"
-                            HorizontalAlignment="Center"
-                            Background="{TemplateBinding Background}"
-                            CornerRadius="4">
+                                x:Name="border"
+                                Width="40"
+                                Height="40"
+                                HorizontalAlignment="Center"
+                                Background="{TemplateBinding Background}"
+                                CornerRadius="4">
                                 <ContentPresenter />
                             </Border>
                         </ControlTemplate>
@@ -88,12 +89,12 @@
                     <Setter.Value>
                         <ControlTemplate TargetType="{x:Type ContentControl}">
                             <Border
-                            x:Name="border"
-                            Height="40"
-                            HorizontalAlignment="Center"
-                            VerticalAlignment="Center"
-                            Background="{TemplateBinding Background}"
-                            CornerRadius="4">
+                                x:Name="border"
+                                Height="40"
+                                HorizontalAlignment="Center"
+                                VerticalAlignment="Center"
+                                Background="{TemplateBinding Background}"
+                                CornerRadius="4">
                                 <ContentPresenter />
                             </Border>
                         </ControlTemplate>
@@ -112,6 +113,78 @@
                     </Trigger>
                 </Style.Triggers>
             </Style>
+            <Style x:Key="FocusVisual">
+                <Setter Property="Control.Template">
+                    <Setter.Value>
+                        <ControlTemplate>
+                            <Rectangle
+                                Margin="2"
+                                SnapsToDevicePixels="true"
+                                Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
+                                StrokeDashArray="1 2"
+                                StrokeThickness="1" />
+                        </ControlTemplate>
+                    </Setter.Value>
+                </Setter>
+            </Style>
+            <SolidColorBrush x:Key="Button.Static.Background" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Static.Border" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.MouseOver.Background" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.MouseOver.Border" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Pressed.Background" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Pressed.Border" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Disabled.Background" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Disabled.Border" Color="Transparent" />
+            <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="Transparent" />
+            <Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
+                <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
+                <Setter Property="Background" Value="{StaticResource Button.Static.Background}" />
+                <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}" />
+                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
+                <Setter Property="BorderThickness" Value="1" />
+                <Setter Property="HorizontalContentAlignment" Value="Center" />
+                <Setter Property="VerticalContentAlignment" Value="Center" />
+                <Setter Property="Padding" Value="1" />
+                <Setter Property="Template">
+                    <Setter.Value>
+                        <ControlTemplate TargetType="{x:Type Button}">
+                            <Border
+                                x:Name="border"
+                                Background="{TemplateBinding Background}"
+                                BorderBrush="{TemplateBinding BorderBrush}"
+                                BorderThickness="{TemplateBinding BorderThickness}"
+                                SnapsToDevicePixels="true">
+                                <ContentPresenter
+                                    x:Name="contentPresenter"
+                                    Margin="{TemplateBinding Padding}"
+                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                                    Focusable="False"
+                                    RecognizesAccessKey="True"
+                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
+                            </Border>
+                            <ControlTemplate.Triggers>
+                                <Trigger Property="IsDefaulted" Value="true">
+                                    <Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
+                                </Trigger>
+                                <Trigger Property="IsMouseOver" Value="true">
+                                    <Setter TargetName="border" Property="Background" Value="{StaticResource Button.MouseOver.Background}" />
+                                    <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.MouseOver.Border}" />
+                                </Trigger>
+                                <Trigger Property="IsPressed" Value="true">
+                                    <Setter TargetName="border" Property="Background" Value="{StaticResource Button.Pressed.Background}" />
+                                    <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Pressed.Border}" />
+                                </Trigger>
+                                <Trigger Property="IsEnabled" Value="false">
+                                    <Setter TargetName="border" Property="Background" Value="{StaticResource Button.Disabled.Background}" />
+                                    <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Disabled.Border}" />
+                                    <Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{StaticResource Button.Disabled.Foreground}" />
+                                </Trigger>
+                            </ControlTemplate.Triggers>
+                        </ControlTemplate>
+                    </Setter.Value>
+                </Setter>
+            </Style>
         </ResourceDictionary>
     </UserControl.Resources>
     <customControl:DialogContent Header="{Binding Title}">
@@ -154,7 +227,7 @@
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Style="{StaticResource ToggleBtnScreenAnnotationStyle}"
-                        Tag="HighLight"
+                        Tag="AnnotArgsType.AnnotHighlight"
                         Visibility="{Binding HighlightVisibility}">
                         <Grid>
                             <Path
@@ -170,7 +243,7 @@
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Style="{StaticResource ToggleBtnScreenAnnotationStyle}"
-                        Tag="Freehand"
+                        Tag="AnnotArgsType.AnnotFreehand"
                         Visibility="{Binding FreeHandVisibility}">
                         <Grid>
                             <Image
@@ -216,6 +289,7 @@
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Style="{StaticResource ToggleBtnScreenAnnotationStyle}"
+                        Tag="AnnotArgsType.AnnotSticky"
                         Visibility="{Binding AnnotStickyVisibility}">
                         <Path
                             Name="PathSticky"
@@ -230,6 +304,7 @@
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Style="{StaticResource ToggleBtnScreenAnnotationStyle}"
+                        Tag="AnnotArgsType.AnnotStamp"
                         Visibility="{Binding AnnotStampVisibility}">
                         <Path
                             Name="PathStamp"
@@ -244,6 +319,7 @@
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Style="{StaticResource ToggleBtnScreenAnnotationStyle}"
+                        Tag="AnnotArgsType.AnnotLine"
                         Visibility="{Binding SharpLineVisibility}">
                         <Path
                             x:Name="PathSharpLine"
@@ -262,6 +338,7 @@
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Style="{StaticResource ToggleBtnScreenAnnotationStyle}"
+                        Tag="AnnotArgsType.AnnotLine"
                         Visibility="{Binding SharpArrowVisibility}">
                         <Path
                             x:Name="PathArrow"
@@ -280,6 +357,7 @@
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Style="{StaticResource ToggleBtnScreenAnnotationStyle}"
+                        Tag="AnnotArgsType.AnnotCircle"
                         Visibility="{Binding AnnotCircleVisibility}">
                         <Path
                             x:Name="PathCircle"
@@ -303,6 +381,7 @@
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Style="{StaticResource ToggleBtnScreenAnnotationStyle}"
+                        Tag="AnnotArgsType.AnnotSquare"
                         Visibility="{Binding AnnotSquareVisibility}">
                         <!--<Path Name="RectAnnotSquare" Fill="{StaticResource path.fill}"  Data="M18.75,3.25 L1.25,3.25 L1.25,16.75 L18.75,16.75 L18.75,3.25 Z M17.25,4.75 L17.25,15.25 L2.75,15.25 L2.75,4.75 L17.25,4.75 Z" />-->
                         <Rectangle
@@ -320,6 +399,7 @@
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Style="{StaticResource ToggleBtnScreenAnnotationStyle}"
+                        Tag="AnnotArgsType.AnnotFreeText"
                         Visibility="{Binding AnnotFreeTextVisibility}">
                         <Path
                             Name="FreeTextPath"
@@ -332,6 +412,7 @@
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Style="{StaticResource ToggleBtnScreenAnnotationStyle}"
+                        Tag="AnnotArgsType.AnnotStrikeout"
                         Visibility="{Binding AnnotStrikeoutVisibility}">
                         <Grid Width="20" Height="20">
                             <Path
@@ -353,7 +434,7 @@
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Style="{StaticResource ToggleBtnScreenAnnotationStyle}"
-                        Tag="UnderLine"
+                        Tag="AnnotArgsType.AnnotUnderline"
                         Visibility="{Binding UnderLineVisibility}">
                         <Grid Width="20" Height="20">
                             <Grid.RowDefinitions>
@@ -382,7 +463,8 @@
                     ItemTemplate="{StaticResource ListColorData}"
                     ItemsSource="{Binding AnnotationColors}"
                     ScrollViewer.HorizontalScrollBarVisibility="Disabled"
-                    ScrollViewer.VerticalScrollBarVisibility="Auto">
+                    ScrollViewer.VerticalScrollBarVisibility="Auto"
+                    SelectionMode="Multiple">
                     <ListBox.ItemsPanel>
                         <ItemsPanelTemplate>
                             <WrapPanel
@@ -402,7 +484,8 @@
                     ItemTemplate="{StaticResource ListAuthorData}"
                     ItemsSource="{Binding AnnotationAuthor}"
                     ScrollViewer.HorizontalScrollBarVisibility="Disabled"
-                    ScrollViewer.VerticalScrollBarVisibility="Auto">
+                    ScrollViewer.VerticalScrollBarVisibility="Auto"
+                    SelectionMode="Multiple">
                     <ListBox.ItemsPanel>
                         <ItemsPanelTemplate>
                             <WrapPanel
@@ -425,24 +508,105 @@
                     Height="32"
                     Margin="25,0,0,0"
                     HorizontalAlignment="Left"
-                    Content="清除" />
+                    Background="Transparent"
+                    BorderBrush="Transparent"
+                    Content="清除"
+                    FontFamily="Segoe UI"
+                    FontSize="14"
+                    Foreground=" #1770F4"
+                    Style="{DynamicResource ButtonStyle1}"
+                    Name="BtnClean"
+                    Command="{Binding CleanCommand}">
+                    <Button.CommandParameter>
+                        <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
+                            <MultiBinding.Bindings>
+                                <Binding ElementName="BtnHighlight" />
+                                <Binding ElementName="BtnFreeHand" />
+                                <Binding ElementName="BtnAnnotSticky" />
+                                <Binding ElementName="BtnAnnotStamp" />
+                                <Binding ElementName="BtnSharpLine" />
+                                <Binding ElementName="BtnSharpArrow" />
+                                <Binding ElementName="BtnAnnotCircle" />
+                                <Binding ElementName="BtnAnnotSquare" />
+                                <Binding ElementName="BtnAnnotFreeText" />
+                                <Binding ElementName="BtnAnnotStrikeout" />
+                                <Binding ElementName="BtnUnderLine" />
+                                <Binding ElementName="ListColor" />
+                                <Binding ElementName="ListAuthor" />
+                            </MultiBinding.Bindings>
+                        </MultiBinding>
+                    </Button.CommandParameter>
+                </Button>
                 <StackPanel Grid.Column="1" Orientation="Horizontal">
                     <Button
                         Width="80"
                         Height="32"
-                        Margin="10,0,0,0"
+                        Margin="20,0,0,0"
                         HorizontalAlignment="Left"
-                        Command="{Binding CreateCommnad}"
-                        Content="确定" />
+                        Command="{Binding OkCommnad}"
+                        Content="确定"
+                        FontFamily="Segoe UI"
+                        FontSize="14"
+                        Style="{StaticResource Btn.cta}">
+                        <Button.CommandParameter>
+                            <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
+                                <MultiBinding.Bindings>
+                                    <Binding ElementName="BtnHighlight" />
+                                    <Binding ElementName="BtnFreeHand" />
+                                    <Binding ElementName="BtnAnnotSticky" />
+                                    <Binding ElementName="BtnAnnotStamp" />
+                                    <Binding ElementName="BtnSharpLine" />
+                                    <Binding ElementName="BtnSharpArrow" />
+                                    <Binding ElementName="BtnAnnotCircle" />
+                                    <Binding ElementName="BtnAnnotSquare" />
+                                    <Binding ElementName="BtnAnnotFreeText" />
+                                    <Binding ElementName="BtnAnnotStrikeout" />
+                                    <Binding ElementName="BtnUnderLine" />
+                                    <Binding ElementName="ListColor" />
+                                    <Binding ElementName="ListAuthor" />
+                                </MultiBinding.Bindings>
+                            </MultiBinding>
+                        </Button.CommandParameter>
+                    </Button>
                     <Button
                         Width="80"
                         Height="32"
-                        Margin="20,0,0,0"
+                        Margin="30,0,0,0"
                         HorizontalAlignment="Right"
                         Command="{Binding CancelCommand}"
-                        Content="取消" />
+                        Content="取消"
+                        FontFamily="Segoe UI"
+                        FontSize="14"
+                        Style="{StaticResource Btn.cta}" />
                 </StackPanel>
             </Grid>
         </customControl:DialogContent.BottmBar>
     </customControl:DialogContent>
+    <i:Interaction.Triggers>
+        <i:EventTrigger EventName="Loaded">
+            <helper:AdvancedInvokeCommandAction
+                            Command="{Binding LoadedCommand}"
+                            PassEventArgsToCommand="True">
+                <helper:AdvancedInvokeCommandAction.CommandParameter>
+                    <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
+                        <MultiBinding.Bindings>
+                            <Binding ElementName="BtnHighlight" />
+                            <Binding ElementName="BtnFreeHand" />
+                            <Binding ElementName="BtnAnnotSticky" />
+                            <Binding ElementName="BtnAnnotStamp" />
+                            <Binding ElementName="BtnSharpLine" />
+                            <Binding ElementName="BtnSharpArrow" />
+                            <Binding ElementName="BtnAnnotCircle" />
+                            <Binding ElementName="BtnAnnotSquare" />
+                            <Binding ElementName="BtnAnnotFreeText" />
+                            <Binding ElementName="BtnAnnotStrikeout" />
+                            <Binding ElementName="BtnUnderLine" />
+                            <Binding ElementName="ListColor" />
+                            <Binding ElementName="ListAuthor" />
+                        </MultiBinding.Bindings>
+                    </MultiBinding>
+                </helper:AdvancedInvokeCommandAction.CommandParameter>
+            </helper:AdvancedInvokeCommandAction>
+        </i:EventTrigger>
+    </i:Interaction.Triggers>
 </UserControl>

+ 3 - 2
PDF Office/Views/Dialog/BOTA/ScreenAnnotationDialog.xaml.cs

@@ -1,4 +1,5 @@
-using System;
+using PDF_Office.CustomControl;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -25,4 +26,4 @@ namespace PDF_Office.Views.Dialog.BOTA
             InitializeComponent();
         }
     }
-}
+}

+ 443 - 113
PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml

@@ -1,172 +1,502 @@
-<UserControl x:Class="PDF_Office.Views.PropertyPanel.AnnotPanel.LinkAnnotProperty"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.AnnotPanel"
-             xmlns:Convert="clr-namespace:PDF_Office.DataConvert"
-             mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800">
+<UserControl
+    x:Class="PDF_Office.Views.PropertyPanel.AnnotPanel.LinkAnnotProperty"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:AnnotPanel="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
+    xmlns:Convert="clr-namespace:PDF_Office.DataConvert"
+    xmlns:CustomControl="clr-namespace:PDF_Office.CustomControl"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:data="clr-namespace:ComPDFKit.PDFDocument;assembly=ComPDFKit.Desk"
+    xmlns:helper="clr-namespace:PDF_Office.Helper"
+    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+    xmlns:local="clr-namespace:PDF_Office.Views.BOTA"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:prism="http://prismlibrary.com/"
+    xmlns:property="clr-namespace:PDF_Office.Properties"
+    Name="LinkAnnotPropertyContent"
+    d:DataContext="{d:DesignInstance Type=AnnotPanel:LinkAnnotPropertyViewModel}"
+    d:DesignHeight="680"
+    d:DesignWidth="260"
+    prism:ViewModelLocator.AutoWireViewModel="True"
+    mc:Ignorable="d">
     <UserControl.Resources>
         <ResourceDictionary>
-            <!--<ResourceDictionary.MergedDictionaries>
-                <ResourceDictionary Source="../Resources/Style/ToggleButtonStyle.xaml"/>
-            </ResourceDictionary.MergedDictionaries>-->
-            <Convert:StringToVisibleConvert x:Key="StringToVisibleConvert"/>
-            <Convert:StringToUnVisibleConvert x:Key="StringToUnVisibleConvert"></Convert:StringToUnVisibleConvert>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="pack://application:,,,/Styles/RadioButtonStyle.xaml" />
+            </ResourceDictionary.MergedDictionaries>
+            <Convert:ObjectConvert x:Key="ObjectConvert" />
+            <Convert:StringToVisibleConvert x:Key="StringToVisibleConvert" />
+            <Convert:StringToUnVisibleConvert x:Key="StringToUnVisibleConvert" />
+            <Convert:BoolToVisible x:Key="BoolToVisible" />
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid>
-        <StackPanel>
-            <TextBlock Name="AnnotTypeTitle" FontFamily="Segoe UI" FontWeight="Bold" FontSize="18" LineHeight="24" HorizontalAlignment="Center" Margin="0,12,0,12">Hyperlink</TextBlock>
-            <StackPanel Orientation="Horizontal" Margin="12,0,0,0">
-                <ToggleButton Name="LinkPageBtn" Width="72" Height="80"  VerticalContentAlignment="Center" Tag="Page" Background="Transparent" BorderThickness="0" IsChecked="True">
-                    <StackPanel  VerticalAlignment="Center">
-                        <Path Margin="8 8 8 8" Fill="#000000" HorizontalAlignment="Center">
+        <StackPanel Background="White" Orientation="Vertical">
+            <TextBlock
+                Name="AnnotTypeTitle"
+                Margin="0,12,0,12"
+                HorizontalAlignment="Left"
+                FontFamily="Segoe UI"
+                FontSize="18"
+                FontWeight="Bold"
+                LineHeight="24">
+                Link
+            </TextBlock>
+            <StackPanel
+                Name="ToggleButtonTab"
+                Margin="12,0,0,0"
+                Orientation="Horizontal">
+                <RadioButton
+                    Name="LinkPageBtn"
+                    Width="75"
+                    Height="28"
+                    VerticalContentAlignment="Center"
+                    Command="{Binding ToggleButtonTabCommand}"
+                    GroupName="LinkTab"
+                    IsChecked="True"
+                    Style="{StaticResource PageViewRadioBtn}"
+                    Tag="Page">
+                    <!--<ToggleButton.CommandParameter>
+                    <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
+                    <MultiBinding.Bindings>
+                    <Binding ElementName="LinkPageBtn" />
+                    -->
+                    <!--<Binding ElementName="LinkWebBtn" />
+                    <Binding ElementName="LinkMailBtn" />-->
+                    <!--
+                    </MultiBinding.Bindings>
+                    </MultiBinding>
+                    </ToggleButton.CommandParameter>-->
+                    <StackPanel>
+                        <Path
+                            Margin="8,8,8,8"
+                            HorizontalAlignment="Center"
+                            Fill="#252629">
                             <Path.Data>
-                                M10.7071068,0 L15,4.29289322 L15,16 L1,16 L1,0 L10.7071068,0 Z M10.293,1 L2,1 L2,15 L14,15 L14,4.707 L10.293,1 Z M12,11 L12,12 L4,
-                        12 L4,11 L12,11 Z M12,9 L12,10 L4,10 L4,9 L12,9 Z M12,7 L12,8 L4,8 L4,7 L12,7 Z M8,5 L8,6 L4,6 L4,5 L8,5 Z
+                                M12.8335 14.5V5.33432L9.70479 1.5H3.8335V14.5H12.8335ZM3.3335
+                                0C2.78121 0 2.3335 0.447715 2.3335 1V15C2.3335 15.5523 2.78121 16 3.3335
+                                16H13.3335C13.8858 16 14.3335 15.5523 14.3335 15V5.15622C14.3335 4.92583
+                                14.2539 4.70251 14.1083 4.524L10.7169 0.367788C10.527 0.135042 10.2425
+                                0 9.94214 0H3.3335ZM9.8335 7.25H4.8335V5.75H9.8335V7.25ZM4.8335
+                                10.25H11.8335V8.75H4.8335V10.25Z
                             </Path.Data>
                         </Path>
-                        <TextBlock x:Name="LinkPageText" Width="36" TextWrapping="Wrap" FontSize="12" FontFamily="Segoe UI" LineHeight="16" TextAlignment="Center"/>
+                        <TextBlock
+                            x:Name="LinkPageText"
+                            Width="36"
+                            FontFamily="Segoe UI"
+                            FontSize="12"
+                            LineHeight="16"
+                            TextAlignment="Center"
+                            TextWrapping="Wrap" />
                     </StackPanel>
-                </ToggleButton>
+                </RadioButton>
 
-                <ToggleButton Name="LinkWebBtn" Width="72" Height="80" VerticalContentAlignment="Center"  Tag="Web" Background="Transparent" BorderThickness="0">
-                    <StackPanel  Grid.Column="1" >
-                        <Path Margin="8 8 8 8" Fill="#000000" HorizontalAlignment="Center">
+                <RadioButton
+                    Name="LinkWebBtn"
+                    Width="75"
+                    Height="28"
+                    VerticalContentAlignment="Center"
+                    Background="Transparent"
+                    Command="{Binding ToggleButtonTabCommand}"
+                    GroupName="LinkTab"
+                    IsChecked="False"
+                    Style="{StaticResource PageViewRadioBtn}"
+                    Tag="Web">
+                    <StackPanel>
+                        <Path
+                            Margin="8,8,8,8"
+                            HorizontalAlignment="Center"
+                            Fill="#252629">
                             <Path.Data>
-                                M8,0 C12.418278,0 16,3.581722 16,8 C16,12.418278 12.418278,16 8,16 C3.581722,16 0,12.418278 0,8 C0,
-                        3.581722 3.581722,0 8,0 Z M10.015957,11.4996518 L5.98404305,11.4996518 C6.28228653,12.6171156 6.71860376,
-                        13.7718221 7.29369179,14.9638748 C7.52703012,14.9881352 7.76212948,15 8,15 C8.23787052,15 8.47296988,14.9881352 8.70473856,14.9649652 L8.5527864,
-                        15.2763932 C9.20429615,13.9733737 9.69172111,12.7145042 10.015957,11.4996518 Z M4.95140445,11.5005273 L1.93671038,11.5004062 C2.83671487,
-                        13.0560047 4.31818608,14.2331131 6.08391456,14.7345218 C5.59233631,13.6294852 5.2144726,12.5517364 4.95140445,11.5005273 Z M14.0632896,
-                        11.5004062 L11.0485955,11.5005273 C10.7855274,12.5517364 10.4076637,13.6294852 9.91549498,14.733701 C11.6818139,14.2331131 13.1632851,
-                        13.0560047 14.0632896,11.5004062 Z M4.73409625,5.50071837 L1.45951741,5.5002913 C1.16263785,6.27661068 1,7.11931229 1,
-                        8 C1,8.88106408 1.16277689,9.72410957 1.4598981,10.5007039 L4.73428007,10.5002845 C4.5781846,9.64883923 4.5,8.81539751 4.5,8 C4.5,
-                        7.18492263 4.57812322,6.35181522 4.73409625,5.50071837 Z M10.2481144,5.50109727 L5.7518856,5.50109727 C5.583851,
-                        6.3567708 5.5,7.18972192 5.5,8 C5.5,8.81059324 5.58391624,9.64387716 5.75208172,10.4999012 L10.2479183,10.4999012 C10.4160838,9.64387716 10.5,
-                        8.81059324 10.5,8 C10.5,7.18972192 10.416149,6.3567708 10.2481144,5.50109727 Z M14.5404826,5.5002913 L11.2659038,5.50071837 C11.4218768,6.35181522 11.5,
-                        7.18492263 11.5,8 C11.5,8.81539751 11.4218154,9.64883923 11.2657199,10.5002845 L14.5401019,10.5007039 C14.8372231,9.72410957 15,8.88106408 15,8 C15,
-                        7.11931229 14.8373622,6.27661068 14.5404826,5.5002913 Z M6.08450502,1.26629895 L5.91841413,1.31470614 C4.22534161,1.84130637 2.80783045,2.99335133 1.93613744,
-                        4.50058424 L4.95115335,4.5004762 C5.21423213,3.44894951 5.5921797,2.37086613 6.08450502,1.26629895 Z M8,1 C7.76212948,1 7.52703012,1.01186476 7.29526144,
-                        1.03503476 L7.4472136,0.723606798 C6.79552511,2.02698377 6.30801146,3.28618649 5.98377622,4.50134805 L10.0162238,4.50134805 C9.73005017,3.42883299 9.31668229,
-                        2.32200977 8.77550381,1.18078687 L8.70473856,1.03503476 C8.47296988,1.01186476 8.23787052,1 8,1 Z M9.91608544,1.26547815 L10.1069462,1.70819247 C10.50689,
-                        2.65884847 10.8209632,3.58962551 11.0488466,4.5004762 L14.0638626,4.50058424 C13.1639139,2.94449491 11.6821887,1.76699331 9.91608544,1.26547815 Z
+                                M8.66618 14.4663C8.44716 14.4886 8.22491 14.5 8 14.5C7.85803
+                                14.5 7.71712 14.4954 7.57741 14.4865C7.10001 13.5646 6.74754
+                                12.6476 6.49725 11.75H9.73591C9.48745 12.6411 9.13829 13.5512 8.66618
+                                14.4663ZM10.5459 13.9825C11.6619 13.507 12.6176 12.7283 13.3098
+                                11.75H11.2887C11.1051 12.4836 10.8609 13.2299 10.5459 13.9825ZM11.5858
+                                10.25H14.1C14.3587 9.5489 14.5 8.79095 14.5 8C14.5 7.20905 14.3587 6.4511
+                                14.1 5.75H11.5922C11.7855 7.11458 11.8224 8.63886 11.5858 10.25ZM10.0763
+                                5.75H6.15683C5.94754 7.09263 5.90154 8.62363 6.16683 10.25H10.0663C10.3316
+                                8.62363 10.2856 7.09263 10.0763 5.75ZM9.76021 4.25H6.47294C6.78297 3.09108
+                                7.1942 2.14973 7.56609 1.51425C7.7095 1.5048 7.85419 1.5 8 1.5C8.22937 1.5
+                                8.45596 1.51188 8.67919 1.53506C9.04787 2.17019 9.45355 3.10366 9.76021
+                                4.25ZM11.3063 4.25H13.3098C12.6268 3.28462 11.6871 2.5137 10.5902
+                                2.03658C10.8556 2.67393 11.1063 3.4192 11.3063 4.25ZM4.94441
+                                11.75C5.13712 12.5199 5.39657 13.3038 5.73452 14.0943C4.49822 13.6345
+                                3.43967 12.8093 2.69016 11.75H4.94441ZM4.64733 10.25C4.41071 8.63886
+                                4.44762 7.11458 4.64092 5.75H1.89996C1.64127 6.4511 1.5 7.20905 1.5 8C1.5 8.79095 1.64127 9.5489
+                                1.89996 10.25H4.64733ZM4.92683 4.25C5.13895 3.36886 5.40812 2.58393 5.69137 1.92192C4.47359 2.38472
+                                3.43094 3.203 2.69016 4.25H4.92683ZM16 8C16 12.4183 12.4183 16 8 16C3.58172 16 0 12.4183 0 8C0
+                                3.58172 3.58172 0 8 0C12.4183 0 16 3.58172 16 8Z
                             </Path.Data>
                         </Path>
-                        <TextBlock x:Name="URLText" Width="52" TextWrapping="Wrap" FontSize="12" FontFamily="Segoe UI" LineHeight="16" TextAlignment="Center">Open web Page</TextBlock>
                     </StackPanel>
-                </ToggleButton>
+                </RadioButton>
 
-                <ToggleButton Name="LinkMailBtn" Width="72" Height="80" VerticalContentAlignment="Center" Tag="Mail" Background="Transparent" BorderThickness="0">
-                    <StackPanel  Grid.Column="2">
-                        <Path Margin="8 8 8 8"  Fill="#000000" HorizontalAlignment="Center">
+                <RadioButton
+                    Name="LinkMailBtn"
+                    Width="75"
+                    Height="28"
+                    VerticalContentAlignment="Center"
+                    Background="Transparent"
+                    Command="{Binding ToggleButtonTabCommand}"
+                    GroupName="LinkTab"
+                    IsChecked="False"
+                    Style="{StaticResource PageViewRadioBtn}"
+                    Tag="Mail">
+                    <StackPanel>
+                        <Path
+                            Margin="8,8,8,8"
+                            HorizontalAlignment="Center"
+                            Fill="#252629">
                             <Path.Data>
-                                M16,2 L16,14 L0,14 L0,2 L16,2 Z M5.792,7.628 L1.533,13 L14.465,13 L10.203,7.631 L8,9.100925 L5.792,7.628 Z M15,4.434 L11.038,
-                        7.075 L15,12.067 L15,4.434 Z M1,4.435 L1,12.064 L4.957,7.072 L1,4.435 Z M15,3 L1,3 L1,3.232 L8,7.898 L15,3.231 L15,3 Z
+                                M1.5 2.27882V10.5H14.5V2.27882L8.43593 6.6103C8.17516 6.79657
+                                7.82484 6.79657 7.56407 6.6103L1.5 2.27882ZM13.0097
+                                1.5H2.99035L8 5.07832L13.0097 1.5ZM0 1C0 0.447715
+                                0.447715 0 1 0H15C15.5523 0 16 0.447715 16 1V11C16 11.5523 15.5523 12 15 12H1C0.447715 12 0 11.5523 0 11V1Z
                             </Path.Data>
                         </Path>
-                        <TextBlock x:Name="EmailText"  TextWrapping="Wrap" FontSize="12" FontFamily="Segoe UI" LineHeight="16" TextAlignment="Center">Email</TextBlock>
                     </StackPanel>
-                </ToggleButton>
-
+                </RadioButton>
             </StackPanel>
-            <Line Margin="0,4,0,0" Stroke="#1A000000" StrokeThickness="1" Width="232" HorizontalAlignment="Center" X1="0" X2="232" Y1="0" Y2="0"></Line>
-            <Grid Height="100">
-                <StackPanel Name="LinkPagePanel">
-                    <TextBlock x:Name="PageNumberText" Margin="12,12,0,4" FontSize="14" FontFamily="Segoe UI" LineHeight="20" Height="20">Control header</TextBlock>
+            <Line
+                Width="232"
+                Margin="0,4,0,0"
+                HorizontalAlignment="Center"
+                Stroke="#1A000000"
+                StrokeThickness="1"
+                X1="0"
+                X2="232"
+                Y1="0"
+                Y2="0" />
+            <Grid MinWidth="260">
+                <StackPanel Name="LinkPagePanel" Visibility="{Binding ElementName=LinkPageBtn, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
+                    <TextBlock
+                        x:Name="TxtPage"
+                        Height="20"
+                        Margin="16,12,0,4"
+                        FontFamily="Segoe UI"
+                        FontSize="12"
+                        Foreground="#616469"
+                        LineHeight="20"
+                        Text="Page" />
                     <StackPanel Orientation="Horizontal">
                         <Grid>
-                            <TextBox Name="PageNumText" Margin="12,0,0,0" Width="199" Height="32" BorderBrush="#FFE2E3E6" Padding="12,0,0,0" Background="Gray" MaxLength="7"
-                         VerticalContentAlignment="Center"  IsEnabled="False"></TextBox>
-                            <Button Tag="PageNumText" HorizontalAlignment="Right" Margin="0,8,8,8" VerticalAlignment="Center" Width="16" Height="16" Background="Transparent"
-                            >
-                                <Button.Content>
-                                    <Path Fill="#333333">
-                                        <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.RenderTransform>
-                                            <TransformGroup>
-                                                <TranslateTransform X="-8"/>
-                                                <RotateTransform Angle="45"/>
-                                                <TranslateTransform X="13"/>
-                                            </TransformGroup>
-                                        </Path.RenderTransform>
-                                    </Path>
-                                </Button.Content>
-                            </Button>
+                            <!--<CustomControl:TextBoxEx
+                            x:Name="PageNumText"
+                            Width="228"
+                            Height="32"
+                            Margin="16,0"
+                            VerticalContentAlignment="Center"
+                            IsEnabled="False"
+                            PlaceholderText="Enter target page">
+                            <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="TextChanged">
+                            <i:InvokeCommandAction Command="{Binding PageNumTextChangedCommand}" PassEventArgsToCommand="True" />
+                            </i:EventTrigger>
+                            </i:Interaction.Triggers>
+                            </CustomControl:TextBoxEx>-->
+                            <CustomControl:TextBoxWithTip
+                                x:Name="PageNumText"
+                                Width="228"
+                                Margin="16,0"
+                                VerticalContentAlignment="Center"
+                                IsEnabled="False"
+                                ShowTip="Collapsed"
+                                Text="Enter target page"
+                                TipText=" Page number error.">
+                                <i:Interaction.Triggers>
+                                    <i:EventTrigger EventName="TextChanged">
+                                        <i:InvokeCommandAction Command="{Binding PageNumTextChangedCommand}" PassEventArgsToCommand="True" />
+                                    </i:EventTrigger>
+                                </i:Interaction.Triggers>
+                            </CustomControl:TextBoxWithTip>
+                            <!--<Border
+                            Name="BorderPageNumText"
+                            Width="228"
+                            Height="32"
+                            Margin="16,0"
+                            Background="LightGray"
+                            BorderBrush="#1770F4"
+                            BorderThickness="1"
+                            CornerRadius="4">
+                            <TextBox
+                            Name="PageNumText"
+                            VerticalContentAlignment="Center"
+                            Background="Transparent"
+                            BorderThickness="0"
+                            IsEnabled="False">
+                            <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="TextChanged">
+                            <i:InvokeCommandAction Command="{Binding PageNumTextChangedCommand}" PassEventArgsToCommand="True" />
+                            </i:EventTrigger>
+                            </i:Interaction.Triggers>
+                            </TextBox>
+                            </Border>
+                            <TextBlock
+                            x:Name="defaultPageNumText"
+                            Margin="25,0,0,0"
+                            VerticalAlignment="Center"
+                            FontSize="14"
+                            Foreground="Gray"
+                            IsHitTestVisible="False"
+                            Visibility="{Binding ElementName=PageNumText, Path=Text, Converter={StaticResource StringToUnVisibleConvert}, Mode=OneWay}">
+                            Enter target page
+                            </TextBlock>
+                            <Button
+                            Width="18"
+                            Height="18"
+                            Margin="0,0,18,0"
+                            HorizontalAlignment="Right"
+                            VerticalAlignment="Center"
+                            Background="Transparent"
+                            Tag="PageNumText"
+                            Visibility="{Binding ElementName=PageNumText, Path=Text, Converter={StaticResource StringToVisibleConvert}}">
+                            <Button.Content>
+                            <Path Fill="#333333">
+                            <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.RenderTransform>
+                            <TransformGroup>
+                            <TranslateTransform X="-8" />
+                            <RotateTransform Angle="45" />
+                            <TranslateTransform X="13" />
+                            </TransformGroup>
+                            </Path.RenderTransform>
+                            </Path>
+                            </Button.Content>
+                            </Button>-->
                         </Grid>
 
-                        <TextBlock Name="PageNumBlock" Margin="8,0,0,0" Height="20" FontSize="14" FontFamily="Segoe UI" LineHeight="20" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
+                        <!--<TextBlock
+                        Name="PageNumBlock"
+                        Height="20"
+                        Margin="8,0,0,0"
+                        VerticalAlignment="Center"
+                        FontFamily="Segoe UI"
+                        FontSize="14"
+                        LineHeight="20"
+                        TextAlignment="Center" />-->
                     </StackPanel>
-                    <TextBlock Name="ErrorNumTips" Foreground="Red" Margin="12,0,0,0" Visibility="Collapsed">Page number error.</TextBlock>
-                    <TextBlock Name="ErrorRangeTips" Foreground="Red" Margin="12,0,0,0" Visibility="Collapsed">Page number out of range.</TextBlock>
+                    <!--<TextBlock
+                    Name="ErrorNumTips"
+                    Margin="12,0,0,0"
+                    Foreground="Red"
+                    Visibility="{Binding ErrorNumTipsVisibility}">
+                    Page number error.
+                    </TextBlock>
+                    <TextBlock
+                    Name="ErrorRangeTips"
+                    Margin="12,0,0,0"
+                    Foreground="Red"
+                    Visibility="{Binding ErrorRangeTipsVisibility}">
+                    Page number out of range.
+                    </TextBlock>-->
+                    <Button
+                        Name="BtnLocation"
+                        Width="228"
+                        Height="32"
+                        Margin="16,16,16,0"
+                        IsEnabled="False"
+                        Style="{StaticResource Btn.cta}">
+                        <Button.Content>
+                            <StackPanel Orientation="Horizontal">
+                                <Path
+                                    Name="PathLocation"
+                                    HorizontalAlignment="Left"
+                                    VerticalAlignment="Center"
+                                    Data="M15.064 6.88052L13.5661 6.49468L9.57748 11.6857L10.2156 13.8898C10.3593 14.3863 9.74722 14.7479 9.38174 14.3824L6.59721 11.5979L0.0145727 15.9711L4.38786 9.38851L1.60356 6.60421C1.23807 6.23873 1.59967 5.62665 2.09615 5.77038L4.30107 6.40871L9.49166 2.42039L9.10576 0.92227C8.97879 0.42937 9.58359 0.0840825 9.9435 0.443993L15.5423 6.04277C15.9022 6.40268 15.5569 7.00748 15.064 6.88052Z"
+                                    Fill="White" />
+                                <TextBlock Margin="10,0" Text="Locate the target page" />
+                            </StackPanel>
+                        </Button.Content>
+                    </Button>
+                    <Image
+                        Name="ImagePreview"
+                        Width="196"
+                        Height="254"
+                        Margin="32"
+                        Source="{Binding PreviewImage}"
+                        Visibility="{Binding ImagePreviewVisibility}" />
                 </StackPanel>
-                <StackPanel Name="LinkWebPanel" Visibility="Collapsed">
-                    <TextBlock Margin="12,12,0,4" FontSize="14" FontFamily="Segoe UI" LineHeight="20" Height="20">URL</TextBlock>
+                <StackPanel Name="LinkWebPanel" Visibility="{Binding ElementName=LinkWebBtn, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
+                    <TextBlock
+                        Height="20"
+                        Margin="16,12,0,4"
+                        FontFamily="Segoe UI"
+                        FontSize="12"
+                        Foreground="#616469"
+                        LineHeight="20"
+                        Text="URL" />
                     <Grid>
-                        <TextBox Name="PageWebText" Margin="12,0,12,0" Width="232" Height="32" BorderBrush="#FFE2E3E6" HorizontalAlignment="Left" Padding="12,0,25,0" VerticalContentAlignment="Center"
-                      IsEnabled="False" Background="Gray"></TextBox>
-                        <TextBlock x:Name="defaultPageWebText" IsHitTestVisible="False" Margin="25,0,0,0" VerticalAlignment="Center" Foreground="Gray" FontSize="14"
-                          
-                                   >https://www.pdfreaderpro.com</TextBlock>
-                        <Button Tag="PageWebText" HorizontalAlignment="Right" Margin="0,8,18,8" VerticalAlignment="Center" Width="16" Height="16" Background="Transparent"
-                    >
+                        <Border
+                            Name="BorderPageWebText"
+                            Width="228"
+                            Height="32"
+                            Margin="16,0"
+                            Background="#FFFFFF"
+                            BorderBrush="#1770F4"
+                            BorderThickness="1"
+                            CornerRadius="4">
+                            <TextBox
+                                Name="PageWebText"
+                                VerticalContentAlignment="Center"
+                                Background="Transparent"
+                                BorderThickness="0"
+                                IsEnabled="True" />
+                        </Border>
+                        <TextBlock
+                            x:Name="defaultPageWebText"
+                            Margin="25,0,0,0"
+                            VerticalAlignment="Center"
+                            FontSize="14"
+                            Foreground="Gray"
+                            IsHitTestVisible="False"
+                            Visibility="{Binding ElementName=PageWebText, Path=Text, Converter={StaticResource StringToUnVisibleConvert}, Mode=OneWay}">
+                            https://www.pdfreaderpro.com
+                        </TextBlock>
+                        <Button
+                            Width="18"
+                            Height="18"
+                            Margin="0,0,18,0"
+                            HorizontalAlignment="Right"
+                            VerticalAlignment="Center"
+                            Background="Transparent"
+                            Tag="PageWebText"
+                            Visibility="{Binding ElementName=PageWebText, Path=Text, Converter={StaticResource StringToVisibleConvert}}">
                             <Button.Content>
                                 <Path Fill="#333333">
                                     <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
+                                        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.RenderTransform>
                                         <TransformGroup>
-                                            <TranslateTransform X="-8"/>
-                                            <RotateTransform Angle="45"/>
-                                            <TranslateTransform X="13"/>
+                                            <TranslateTransform X="-8" />
+                                            <RotateTransform Angle="45" />
+                                            <TranslateTransform X="13" />
                                         </TransformGroup>
                                     </Path.RenderTransform>
                                 </Path>
                             </Button.Content>
                         </Button>
                     </Grid>
-                    <TextBlock Name="ErrorUrlTips" Foreground="Red" Margin="12,0,0,0" Visibility="Collapsed">Invalid link.</TextBlock>
+                    <TextBlock
+                        Name="ErrorUrlTips"
+                        Margin="12,0,0,0"
+                        Foreground="Red"
+                        Visibility="Collapsed">
+                        Invalid link.
+                    </TextBlock>
                 </StackPanel>
-                <StackPanel Name="LinkMailPanel" Visibility="Collapsed">
-                    <TextBlock Margin="12,12,0,4" FontSize="14" FontFamily="Segoe UI" LineHeight="20" Height="20">Email</TextBlock>
+                <StackPanel Name="LinkMailPanel" Visibility="{Binding ElementName=LinkMailBtn, Path=IsChecked, Converter={StaticResource BoolToVisible}, Mode=OneWay}">
+                    <TextBlock
+                        Height="20"
+                        Margin="12,12,0,4"
+                        FontFamily="Segoe UI"
+                        FontSize="14"
+                        LineHeight="20">
+                        Email
+                    </TextBlock>
                     <Grid>
-                        <TextBox Name="PageMailText" Margin="12,0,12,0" Width="232" Height="32" BorderBrush="#FFE2E3E6" HorizontalAlignment="Left" Background="Gray"
-                     Padding="12,0,0,0" VerticalContentAlignment="Center"  IsEnabled="False"></TextBox>
-                        <TextBlock x:Name="defaultPageMailText" IsHitTestVisible="False" Margin="25,0,0,0" VerticalAlignment="Center" Foreground="Gray" FontSize="14"
-                           
-                                   >support@pdfreaderpro.com</TextBlock>
-                        <Button Tag="PageMailText" HorizontalAlignment="Right" Margin="0,8,18,8" VerticalAlignment="Center" Width="16" Height="16" Background="Transparent"
-                   >
+                        <Border
+                            Name="BorderPageMailText"
+                            Width="228"
+                            Height="32"
+                            Margin="16,0"
+                            Background="#FFFFFF"
+                            BorderBrush="#1770F4"
+                            BorderThickness="1"
+                            CornerRadius="4">
+                            <TextBox
+                                Name="PageMailText"
+                                Width="232"
+                                Height="32"
+                                HorizontalAlignment="Left"
+                                VerticalContentAlignment="Center"
+                                Background="Transparent"
+                                BorderBrush="Transparent"
+                                IsEnabled="False" />
+                        </Border>
+                        <TextBlock
+                            x:Name="defaultPageMailText"
+                            Margin="25,0,0,0"
+                            VerticalAlignment="Center"
+                            FontSize="14"
+                            Foreground="Gray"
+                            IsHitTestVisible="False"
+                            Visibility="{Binding ElementName=PageMailText, Path=Text, Converter={StaticResource StringToUnVisibleConvert}, Mode=OneWay}">
+                            support@pdfreaderpro.com
+                        </TextBlock>
+                        <Button
+                            Width="18"
+                            Height="18"
+                            Margin="0,0,18,0"
+                            HorizontalAlignment="Right"
+                            VerticalAlignment="Center"
+                            Background="Transparent"
+                            Tag="PageMailText"
+                            Visibility="{Binding ElementName=PageMailText, Path=Text, Converter={StaticResource StringToVisibleConvert}}">
                             <Button.Content>
                                 <Path Fill="#333333">
                                     <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
+                                        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.RenderTransform>
                                         <TransformGroup>
-                                            <TranslateTransform X="-8"/>
-                                            <RotateTransform Angle="45"/>
-                                            <TranslateTransform X="13"/>
+                                            <TranslateTransform X="-8" />
+                                            <RotateTransform Angle="45" />
+                                            <TranslateTransform X="13" />
                                         </TransformGroup>
                                     </Path.RenderTransform>
                                 </Path>
                             </Button.Content>
                         </Button>
                     </Grid>
-                    <TextBlock Name="ErrorMailTips" Foreground="Red" Margin="12,0,0,0" TextWrapping="Wrap" Visibility="Collapsed">The email is invalid.Please enter a valid email address.</TextBlock>
+                    <TextBlock
+                        Name="ErrorMailTips"
+                        Margin="12,0,0,0"
+                        Foreground="Red"
+                        TextWrapping="Wrap"
+                        Visibility="Collapsed">
+                        The email is invalid.Please enter a valid email address.
+                    </TextBlock>
                 </StackPanel>
             </Grid>
-            <Button Name="SaveBtn" Width="120" Height="32" Tag="go" FontSize="16" Foreground="White" BorderThickness="0"  Background="#273C62" IsEnabled="False">
-                <!--<TextBlock x:Name="GoText" Foreground="White">Go</TextBlock>-->
-            </Button>
+            <Button
+                x:Name="BtnGOorBack"
+                Background="Transparent"
+                BorderThickness="0"
+                Content="GO"
+                FontSize="16"
+                Foreground="#1770F4"
+                Style="{StaticResource Btn.cta}"
+                Visibility="{Binding BtnGOorBackVisibility}" />
         </StackPanel>
     </Grid>
-</UserControl>
+    <i:Interaction.Triggers>
+        <i:EventTrigger EventName="Loaded">
+            <helper:AdvancedInvokeCommandAction
+                Command="{Binding LoadedCommand}"
+                CommandParameter="{Binding ElementName=LinkAnnotPropertyContent}"
+                PassEventArgsToCommand="True">
+                <!--<helper:AdvancedInvokeCommandAction.CommandParameter>
+                <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
+                <MultiBinding.Bindings>
+                <Binding ElementName="ImagePreview" />
+                <Binding ElementName="LinkPagePanel" />
+                <Binding ElementName="LinkWebPanel" />
+                <Binding ElementName="LinkMailPanel" />
+                <Binding ElementName="LinkPagePanel" />
+                <Binding ElementName="LinkPagePanel" />
+                <Binding ElementName="LinkPagePanel" />
+                </MultiBinding.Bindings>
+                </MultiBinding>
+                </helper:AdvancedInvokeCommandAction.CommandParameter>-->
+            </helper:AdvancedInvokeCommandAction>
+        </i:EventTrigger>
+    </i:Interaction.Triggers>
+</UserControl>

+ 39 - 2
PDF Office/Views/PropertyPanel/AnnotPanel/LinkAnnotProperty.xaml.cs

@@ -1,4 +1,5 @@
-using System;
+using ComPDFKitViewer.AnnotEvent;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -20,9 +21,45 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
     /// </summary>
     public partial class LinkAnnotProperty : UserControl
     {
+        public int TotalPage { get; set; }
+
         public LinkAnnotProperty()
         {
             InitializeComponent();
         }
+
+        internal void SetTextBoxEnableOrNot(bool enable, int totalPage)
+        {
+            TotalPage = totalPage;
+
+            PageNumText.Text = string.Empty;
+            PageWebText.Text = string.Empty;
+            PageMailText.Text = string.Empty;
+
+            PageNumText.IsEnabled = enable;
+            if (PageNumText.IsEnabled == true)
+            {
+                //defaultPageNumText.Text = string.Format($"1-{totalPage}页");
+                //PageNumText.PlaceholderText = string.Format($"1-{totalPage}页");
+                PageNumText.PlaceHoldText = string.Format($"1-{totalPage}页");
+            }
+            else
+            {
+                //defaultPageNumText.Text = "Enter target page";
+                //PageNumText.PlaceholderText = "Enter target page";
+                PageNumText.PlaceHoldText = "Enter target page";
+            }
+            PageNumText.IsError = false;
+            //BorderPageNumText.Background = enable ? Brushes.White : Brushes.LightGray;
+
+            PageWebText.IsEnabled = enable;
+            BorderPageWebText.Background = enable ? Brushes.White : Brushes.LightGray;
+
+            PageMailText.IsEnabled = enable;
+            BorderPageMailText.Background = enable ? Brushes.White : Brushes.LightGray;
+
+            BtnGOorBack.IsEnabled = false;
+            BtnLocation.IsEnabled = enable;
+        }
     }
-}
+}