Ver código fonte

ComPDFKit(win) - 注释回复菜单和文案

weixiangjie 6 meses atrás
pai
commit
eb85338ab4

Diferenças do arquivo suprimidas por serem muito extensas
+ 54 - 0
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationList/PDFAnnotationListControl/CPDFAnnotationListControl.xaml


+ 76 - 0
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationList/PDFAnnotationListControl/CPDFAnnotationListControl.xaml.cs

@@ -13,6 +13,7 @@ using System.IO;
 using System.Windows;
 using System.Windows.Annotations;
 using System.Windows.Controls;
+using System.Windows.Input;
 using Compdfkit_Tools.Helper;
 using Compdfkit_Tools.PDFControlUI;
 using static Compdfkit_Tools.PDFControlUI.CPDFAnnotationListUI;
@@ -278,4 +279,79 @@ namespace Compdfkit_Tools.PDFControl
             }
         }
     }
+    
+    public class ExpandAllReplyCommand : ICommand
+    {
+        public event EventHandler CanExecuteChanged;
+
+        public bool CanExecute(object parameter)
+        {
+            return true;
+        }
+
+        public void Execute(object parameter)
+        {
+            if (parameter is CPDFAnnotationListControl annotationListControl)
+            {
+                annotationListControl.AnnotationList.ExpandAllReply(true);
+            }
+        }
+    }
+    
+    public class FoldAllReplyCommand : ICommand
+    {
+        public event EventHandler CanExecuteChanged;
+
+        public bool CanExecute(object parameter)
+        {
+            return true;
+        }
+
+        public void Execute(object parameter)
+        {
+            if (parameter is CPDFAnnotationListControl annotationListControl)
+            {
+                annotationListControl.AnnotationList.ExpandAllReply(false);
+            }
+        }
+    }
+    
+    public class DeleteAllAnnotCommand : ICommand
+    {
+        public event EventHandler CanExecuteChanged;
+
+        public bool CanExecute(object parameter)
+        {
+            return true;
+        }
+
+        public void Execute(object parameter)
+        {
+            if (parameter is CPDFAnnotationListControl annotationListControl)
+            {
+                annotationListControl.AnnotationList.DeleteAllReply();
+                annotationListControl.LoadAnnotationList();
+                annotationListControl.AnnotationList.DeleteAllAnnot();
+            }
+        }
+    }
+    
+    public class DeleteAllReplyCommand : ICommand
+    {
+        public event EventHandler CanExecuteChanged;
+
+        public bool CanExecute(object parameter)
+        {
+            return true;
+        }
+
+        public void Execute(object parameter)
+        {
+            if (parameter is CPDFAnnotationListControl annotationListControl)
+            {
+                annotationListControl.AnnotationList.DeleteAllReply();
+                annotationListControl.LoadAnnotationList();
+            }
+        }
+    }
 }

+ 6 - 5
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationList/PDFAnnotationListUI/AnnotationReplyListControl.xaml

@@ -15,6 +15,7 @@
             <common:TextLengthToVisibilityConverter x:Key="TextLengthToVisibilityConverter"></common:TextLengthToVisibilityConverter>
             <pdfControlUi:SubtractionConverter x:Key="SubtractionConverter"/>
             <pdfControlUi:AntiVisibilityConverter x:Key="AntiVisibilityConverter"></pdfControlUi:AntiVisibilityConverter>
+            <common:BotaResourceConverter x:Key="BotaResourceConverter"></common:BotaResourceConverter>
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid x:Name="ReplyGrid" Margin="5">
@@ -26,13 +27,13 @@
         
         <Grid Grid.Row="0">
             <TextBox x:Name="InputTxb" Height="30" VerticalContentAlignment="Center"></TextBox>
-            <TextBlock Text="Reply or add thoughts" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="#A0A0A0" IsHitTestVisible="False"
+            <TextBlock Text="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Holder_Reply}" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="#A0A0A0" IsHitTestVisible="False"
                        Visibility="{Binding ElementName=InputTxb, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}"></TextBlock>
         </Grid>
         
         <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,5,0,0">
-            <Button Content="Cancel" Background="Transparent" BorderThickness="0" Margin="0,0,5,0" Width="56" Height="30" Click="ButtonCancel_Click"></Button>
-            <Button Content="Reply" Width="56" Height="30" Foreground="White" Background="#1460F3" BorderThickness="0" Click="ReplyButton_Click"></Button>
+            <Button Content="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Button_Cancel}" Background="Transparent" BorderThickness="0" Margin="0,0,5,0" Width="56" Height="30" Click="ButtonCancel_Click"></Button>
+            <Button Content="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Button_Reply}" Width="56" Height="30" Foreground="White" Background="#1460F3" BorderThickness="0" Click="ReplyButton_Click"></Button>
         </StackPanel>
         
         <ListView Grid.Row="2" x:Name="ReplyList" Margin="0,5,0,0" VirtualizingPanel.IsVirtualizingWhenGrouping="True" 
@@ -71,7 +72,7 @@
                                               Fill="#43474D"/>
                                     </Canvas>
                                 </MenuItem.Header>
-                                <MenuItem Header="Edit" Style="{StaticResource Sub_MenuItem}">
+                                <MenuItem Header="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Menu_Edit}" Style="{StaticResource Sub_MenuItem}">
                                     <MenuItem.Command>
                                         <pdfControlUi:ShowContentBoxCommand/>
                                     </MenuItem.Command>
@@ -80,7 +81,7 @@
                                     </MenuItem.CommandParameter>
                                 </MenuItem>
                                 
-                                <MenuItem Header="Delete" Style="{StaticResource Sub_MenuItem}">
+                                <MenuItem Header="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Menu_Delete}" Style="{StaticResource Sub_MenuItem}">
                                     <MenuItem.Command>
                                         <pdfControlUi:DeleteReplyCommand/>
                                     </MenuItem.Command>

+ 76 - 1
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnotationListUI.xaml.cs

@@ -268,20 +268,69 @@ namespace Compdfkit_Tools.PDFControlUI
             InitializeComponent();
             ICollectionView groupView = CollectionViewSource.GetDefaultView(annotationList);
             groupView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotationBindData.ShowPageIndex)));
+            AnnotationList.PreviewMouseRightButtonUp += ((sender, args) => { SetContextMenu(); });
+        }
+
+        private void SetContextMenu()
+        {
+            if(AnnotationList.SelectedIndex == -1)
+            {
+                return;
+            }
             popContextMenu = new ContextMenu();
+            AnnotationBindData data = annotationList[AnnotationList.SelectedIndex];
+            
             MenuItem deleteMenu = new MenuItem();
             deleteMenu.Header = LanguageHelper.BotaManager.GetString("Menu_Delete");
             deleteMenu.Click -= DeleteMenu_Click;
             deleteMenu.Click += DeleteMenu_Click;
             popContextMenu.Items.Add(deleteMenu);
+            
             MenuItem deleteAllMenu = new MenuItem();
             deleteAllMenu.Header = LanguageHelper.BotaManager.GetString("Menu_DeleteAll");
             deleteAllMenu.Click -= DeleteAllMenu_Click;
             deleteAllMenu.Click += DeleteAllMenu_Click;
             popContextMenu.Items.Add(deleteAllMenu);
+            
+            MenuItem replyMenu = new MenuItem();
+            replyMenu.Header = LanguageHelper.BotaManager.GetString("Menu_AddReply");
+            replyMenu.Click += (sender, e) =>
+            {
+                if (AnnotationList != null && AnnotationList.SelectedIndex >= 0)
+                {
+                    data.IsReplyInputVisible = true;
+                }
+            };
+            popContextMenu.Items.Add(replyMenu);
+            
+            MenuItem showReplyMenu = new MenuItem();
+            
+            if(data.IsReplyListVisible)
+            {
+                showReplyMenu.Header = LanguageHelper.BotaManager.GetString("Menu_FoldReply");
+            }
+            else
+            {
+                showReplyMenu.Header = LanguageHelper.BotaManager.GetString("Menu_ExpandReply");
+            }
+            showReplyMenu.Click += (sender, e) =>
+            {
+                if (AnnotationList != null && AnnotationList.SelectedIndex >= 0)
+                {
+                    data.IsReplyListVisible = !data.IsReplyListVisible;
+                }
+            };
+            popContextMenu.Items.Add(showReplyMenu);
+            
+            AnnotationList.ContextMenu = popContextMenu;
         }
 
         private void DeleteAllMenu_Click(object sender, RoutedEventArgs e)
+        {
+            DeleteAllAnnot();
+        }
+
+        public void DeleteAllAnnot()
         {
             try
             {
@@ -303,7 +352,25 @@ namespace Compdfkit_Tools.PDFControlUI
             }
             catch (Exception ex)
             {
-
+                return;
+            }
+        }
+        
+        public void DeleteAllReply()
+        {
+            try
+            {
+                foreach (var data in annotationList)
+                {
+                    foreach (var replyData in data.BindProperty.ReplyList)
+                    {
+                        replyData.ReplyAnnotation.RemoveAnnot();
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                return;
             }
         }
 
@@ -440,6 +507,14 @@ namespace Compdfkit_Tools.PDFControlUI
         {
             ReplyStatusChanged?.Invoke(sender, CPDFAnnotationState.C_ANNOTATION_UNMARKED);
         }
+
+        public void ExpandAllReply(bool isExpand)
+        {
+            foreach (AnnotationBindData data in annotationList)
+            {
+                data.IsReplyListVisible = isExpand;
+            }
+        }
     }
     
     public class SubtractionConverter : IValueConverter

+ 189 - 1
Demo/Examples/Compdfkit_Tools/Strings/Bota.Designer.cs

@@ -1,7 +1,6 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:4.0.30319.42000
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -132,6 +131,15 @@ namespace Compdfkit_Tools.Strings {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Reply.
+        /// </summary>
+        internal static string Button_Reply {
+            get {
+                return ResourceManager.GetString("Button_Reply", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to Search.
         /// </summary>
@@ -186,6 +194,15 @@ namespace Compdfkit_Tools.Strings {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Reply or add thoughts.
+        /// </summary>
+        internal static string Holder_Reply {
+            get {
+                return ResourceManager.GetString("Holder_Reply", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to Search.
         /// </summary>
@@ -195,6 +212,15 @@ namespace Compdfkit_Tools.Strings {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Add a new reply.
+        /// </summary>
+        internal static string Menu_AddReply {
+            get {
+                return ResourceManager.GetString("Menu_AddReply", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to Certification Details.
         /// </summary>
@@ -204,6 +230,33 @@ namespace Compdfkit_Tools.Strings {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Delete all annotations.
+        /// </summary>
+        internal static string Menu_DelAllAnnot {
+            get {
+                return ResourceManager.GetString("Menu_DelAllAnnot", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Delete all replies.
+        /// </summary>
+        internal static string Menu_DelAllReply {
+            get {
+                return ResourceManager.GetString("Menu_DelAllReply", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Delete annotation.
+        /// </summary>
+        internal static string Menu_DelAnnot {
+            get {
+                return ResourceManager.GetString("Menu_DelAnnot", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to Delete.
         /// </summary>
@@ -222,6 +275,69 @@ namespace Compdfkit_Tools.Strings {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Edit.
+        /// </summary>
+        internal static string Menu_Edit {
+            get {
+                return ResourceManager.GetString("Menu_Edit", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Expand all annotations.
+        /// </summary>
+        internal static string Menu_ExpandAllAnnot {
+            get {
+                return ResourceManager.GetString("Menu_ExpandAllAnnot", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Expand all replies.
+        /// </summary>
+        internal static string Menu_ExpandAllReply {
+            get {
+                return ResourceManager.GetString("Menu_ExpandAllReply", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Expand replies.
+        /// </summary>
+        internal static string Menu_ExpandReply {
+            get {
+                return ResourceManager.GetString("Menu_ExpandReply", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Fold all annotations.
+        /// </summary>
+        internal static string Menu_FoldAllAnnot {
+            get {
+                return ResourceManager.GetString("Menu_FoldAllAnnot", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Fold all replies.
+        /// </summary>
+        internal static string Menu_FoldAllReply {
+            get {
+                return ResourceManager.GetString("Menu_FoldAllReply", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Fold replies.
+        /// </summary>
+        internal static string Menu_FoldReply {
+            get {
+                return ResourceManager.GetString("Menu_FoldReply", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to Signature Details.
         /// </summary>
@@ -231,6 +347,69 @@ namespace Compdfkit_Tools.Strings {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Accepted.
+        /// </summary>
+        internal static string Status_Accepted {
+            get {
+                return ResourceManager.GetString("Status_Accepted", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Cancelled.
+        /// </summary>
+        internal static string Status_Cancelled {
+            get {
+                return ResourceManager.GetString("Status_Cancelled", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Completed.
+        /// </summary>
+        internal static string Status_Completed {
+            get {
+                return ResourceManager.GetString("Status_Completed", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Marked.
+        /// </summary>
+        internal static string Status_Marked {
+            get {
+                return ResourceManager.GetString("Status_Marked", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to None.
+        /// </summary>
+        internal static string Status_None {
+            get {
+                return ResourceManager.GetString("Status_None", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Rejected.
+        /// </summary>
+        internal static string Status_Rejected {
+            get {
+                return ResourceManager.GetString("Status_Rejected", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Unmarked.
+        /// </summary>
+        internal static string Status_Unmarked {
+            get {
+                return ResourceManager.GetString("Status_Unmarked", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to No Annotations.
         /// </summary>
@@ -411,6 +590,15 @@ namespace Compdfkit_Tools.Strings {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to More.
+        /// </summary>
+        internal static string Tooltip_More {
+            get {
+                return ResourceManager.GetString("Tooltip_More", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to View Outlines.
         /// </summary>

+ 63 - 0
Demo/Examples/Compdfkit_Tools/Strings/Bota.resx

@@ -249,4 +249,67 @@
   <data name="Button_Search" xml:space="preserve">
     <value>Search</value>
   </data>
+  <data name="Tooltip_More" xml:space="preserve">
+    <value>More</value>
+  </data>
+  <data name="Menu_ExpandAllAnnot" xml:space="preserve">
+    <value>Expand all annotations</value>
+  </data>
+  <data name="Menu_FoldAllAnnot" xml:space="preserve">
+    <value>Fold all annotations</value>
+  </data>
+  <data name="Menu_ExpandAllReply" xml:space="preserve">
+    <value>Expand all replies</value>
+  </data>
+  <data name="Menu_FoldAllReply" xml:space="preserve">
+    <value>Fold all replies</value>
+  </data>
+  <data name="Menu_DelAllAnnot" xml:space="preserve">
+    <value>Delete all annotations</value>
+  </data>
+  <data name="Menu_DelAllReply" xml:space="preserve">
+    <value>Delete all replies</value>
+  </data>
+  <data name="Menu_Edit" xml:space="preserve">
+    <value>Edit</value>
+  </data>
+  <data name="Button_Reply" xml:space="preserve">
+    <value>Reply</value>
+  </data>
+  <data name="Holder_Reply" xml:space="preserve">
+    <value>Reply or add thoughts</value>
+  </data>
+  <data name="Menu_AddReply" xml:space="preserve">
+    <value>Add a new reply</value>
+  </data>
+  <data name="Menu_ExpandReply" xml:space="preserve">
+    <value>Expand replies</value>
+  </data>
+  <data name="Menu_FoldReply" xml:space="preserve">
+    <value>Fold replies</value>
+  </data>
+  <data name="Menu_DelAnnot" xml:space="preserve">
+    <value>Delete annotation</value>
+  </data>
+  <data name="Status_Marked" xml:space="preserve">
+    <value>Marked</value>
+  </data>
+  <data name="Status_Unmarked" xml:space="preserve">
+    <value>Unmarked</value>
+  </data>
+  <data name="Status_Accepted" xml:space="preserve">
+    <value>Accepted</value>
+  </data>
+  <data name="Status_Rejected" xml:space="preserve">
+    <value>Rejected</value>
+  </data>
+  <data name="Status_Cancelled" xml:space="preserve">
+    <value>Cancelled</value>
+  </data>
+  <data name="Status_Completed" xml:space="preserve">
+    <value>Completed</value>
+  </data>
+  <data name="Status_None" xml:space="preserve">
+    <value>None</value>
+  </data>
 </root>

+ 63 - 0
Demo/Examples/Compdfkit_Tools/Strings/Bota.zh.resx

@@ -249,4 +249,67 @@
   <data name="Button_Search" xml:space="preserve">
     <value>搜索</value>
   </data>
+  <data name="Tooltip_More" xml:space="preserve">
+    <value>更多</value>
+  </data>
+  <data name="Menu_ExpandAllAnnot" xml:space="preserve">
+    <value>展开所有注释</value>
+  </data>
+  <data name="Menu_FoldAllAnnot" xml:space="preserve">
+    <value>收起所有注释</value>
+  </data>
+  <data name="Menu_ExpandAllReply" xml:space="preserve">
+    <value>展开所有回复</value>
+  </data>
+  <data name="Menu_FoldAllReply" xml:space="preserve">
+    <value>收起所有回复</value>
+  </data>
+  <data name="Menu_DelAllAnnot" xml:space="preserve">
+    <value>删除所有注释</value>
+  </data>
+  <data name="Menu_DelAllReply" xml:space="preserve">
+    <value>删除所有回复</value>
+  </data>
+  <data name="Menu_Edit" xml:space="preserve">
+    <value>编辑</value>
+  </data>
+  <data name="Button_Reply" xml:space="preserve">
+    <value>保存</value>
+  </data>
+  <data name="Holder_Reply" xml:space="preserve">
+    <value>请输入回复内容</value>
+  </data>
+  <data name="Menu_AddReply" xml:space="preserve">
+    <value>新增回复</value>
+  </data>
+  <data name="Menu_ExpandReply" xml:space="preserve">
+    <value>展开回复</value>
+  </data>
+  <data name="Menu_FoldReply" xml:space="preserve">
+    <value>收起回复</value>
+  </data>
+  <data name="Menu_DelAnnot" xml:space="preserve">
+    <value>删除注释</value>
+  </data>
+  <data name="Status_Accepted" xml:space="preserve">
+    <value>已接受</value>
+  </data>
+  <data name="Status_Cancelled" xml:space="preserve">
+    <value>已取消</value>
+  </data>
+  <data name="Status_Completed" xml:space="preserve">
+    <value>已完成</value>
+  </data>
+  <data name="Status_Marked" xml:space="preserve">
+    <value>已标记</value>
+  </data>
+  <data name="Status_None" xml:space="preserve">
+    <value>五</value>
+  </data>
+  <data name="Status_Rejected" xml:space="preserve">
+    <value>已拒绝</value>
+  </data>
+  <data name="Status_Unmarked" xml:space="preserve">
+    <value>未标记</value>
+  </data>
 </root>