Bladeren bron

ComPDFKit.Demo(win) - 注释列表支持缩放和展开

TangJinZhou 7 maanden geleden
bovenliggende
commit
e1ef8eec3c

+ 12 - 2
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListControl/CPDFAnnotationListControl.xaml

@@ -52,10 +52,20 @@
                         </Canvas>
                     </MenuItem.Header>
                     <MenuItem Header="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Menu_ExpandAllAnnot}" Style="{StaticResource Sub_MenuItem}">
-
+                        <MenuItem.Command>
+                            <cpdftools:ExpandAnnotListCommand/>
+                        </MenuItem.Command>
+                        <MenuItem.CommandParameter>
+                            <Binding Path="." RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type cpdftools:CPDFAnnotationListControl}}"/>
+                        </MenuItem.CommandParameter>
                     </MenuItem>
                     <MenuItem Header="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Menu_FoldAllAnnot}" Style="{StaticResource Sub_MenuItem}">
-
+                        <MenuItem.Command>
+                            <cpdftools:FoldAnnotListCommand/>
+                        </MenuItem.Command>
+                        <MenuItem.CommandParameter>
+                            <Binding Path="." RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type cpdftools:CPDFAnnotationListControl}}"/>
+                        </MenuItem.CommandParameter>
                     </MenuItem>
                     <MenuItem Header="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Menu_ExpandAllReply}" Style="{StaticResource Sub_MenuItem}">
                         <MenuItem.Command>

+ 37 - 0
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListControl/CPDFAnnotationListControl.xaml.cs

@@ -349,4 +349,41 @@ namespace ComPDFKit.Controls.PDFControl
             }
         }
     }
+
+    public class ExpandAnnotListCommand : ICommand
+    {
+        public event EventHandler CanExecuteChanged;
+
+        public bool CanExecute(object parameter)
+        {
+            return true;
+        }
+
+        public void Execute(object parameter)
+        {
+            if (parameter is CPDFAnnotationListControl annotationListControl)
+            {
+                annotationListControl.AnnotationList.ExpandAnnotList(true);
+            }
+        }
+    }
+
+    public class FoldAnnotListCommand : ICommand
+    {
+        public event EventHandler CanExecuteChanged;
+
+        public bool CanExecute(object parameter)
+        {
+            return true;
+        }
+
+        public void Execute(object parameter)
+        {
+            if (parameter is CPDFAnnotationListControl annotationListControl)
+            {
+                annotationListControl.AnnotationList.ExpandAnnotList(false);
+            }
+        }
+    }
+
 }

+ 2 - 2
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnotationListUI.xaml

@@ -43,14 +43,14 @@
 
             <ListView.ItemsPanel>
                 <ItemsPanelTemplate>
-                    <VirtualizingStackPanel Background="#FAFCFF" Margin="-5,0,5,0" HorizontalAlignment="Stretch"
+                    <VirtualizingStackPanel Background="#FAFCFF" Margin="-5,0,5,0" HorizontalAlignment="Stretch" 
                                             Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}, Converter={StaticResource SubtractionConverter}, ConverterParameter=5}"></VirtualizingStackPanel>
                 </ItemsPanelTemplate>
             </ListView.ItemsPanel>
 
             <ListView.ItemTemplate>
                 <ItemContainerTemplate>
-                    <Grid Margin="0,0,5,5">
+                    <Grid Margin="0,0,5,5" Visibility = "{Binding BindProperty.IsAnnotListVisible}">
                         <Grid.RowDefinitions>
                             <RowDefinition></RowDefinition>
                             <RowDefinition Height="Auto"></RowDefinition>

+ 23 - 3
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnotationListUI.xaml.cs

@@ -164,7 +164,7 @@ namespace ComPDFKit.Controls.PDFControlUI
     public partial class CPDFAnnotationListUI : UserControl
     {
         public event EventHandler<CPDFAnnotationState> ReplyStatusChanged;
-          
+
         public class ReplyData
         {
             public CPDFAnnotation ReplyAnnotation { get; set; }
@@ -243,6 +243,17 @@ namespace ComPDFKit.Controls.PDFControlUI
                 OnPropertyChanged(nameof(ReplyCount));
             }
 
+            private Visibility _isAnnotListVisible = Visibility.Visible;
+            public Visibility IsAnnotListVisible
+            {
+                get { return _isAnnotListVisible; }
+                set
+                {
+                    _isAnnotListVisible = value;
+                    OnPropertyChanged(nameof(IsAnnotListVisible));
+                }
+            }
+
             public int PageIndex { get; set; }
 
             public int AnnotIndex { get => annotationData.AnnotIndex; }
@@ -386,7 +397,6 @@ namespace ComPDFKit.Controls.PDFControlUI
         private ContextMenu popContextMenu;
         private bool enableSelectEvent = true;
 
-
         public CPDFAnnotationListUI()
         {
             InitializeComponent();
@@ -449,7 +459,6 @@ namespace ComPDFKit.Controls.PDFControlUI
             AnnotationList.ContextMenu = popContextMenu;
         }
 
-
         public void DeleteAllAnnot()
         {
             try
@@ -502,6 +511,17 @@ namespace ComPDFKit.Controls.PDFControlUI
             }
         }
 
+        public void ExpandAnnotList(bool isExpand)
+        {
+            foreach (AnnotationBindData data in annotationList)
+            {
+                if (isExpand)
+                    data.BindProperty.IsAnnotListVisible = Visibility.Visible;
+                else
+                    data.BindProperty.IsAnnotListVisible = Visibility.Collapsed;
+            }
+        }
+
         private void DeleteAllMenu_Click(object sender, RoutedEventArgs e)
         {
             try

+ 8 - 10
Demo/Examples/Compdfkit.Controls/Common/Convert/LanguageResourceConverter.cs

@@ -6,8 +6,6 @@ using ComPDFKit.Controls.Helper;
 
 namespace ComPDFKit.Controls.Common
 {
-
-
     public class BotaResourceConverter : IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@@ -22,7 +20,7 @@ namespace ComPDFKit.Controls.Common
 
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
-            throw new NotSupportedException();
+            return null;
         }
     }
 
@@ -40,7 +38,7 @@ namespace ComPDFKit.Controls.Common
 
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
-            throw new NotSupportedException();
+            return null;
         }
     }
 
@@ -58,7 +56,7 @@ namespace ComPDFKit.Controls.Common
 
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
-            throw new NotSupportedException();
+            return null;
         }
     }
 
@@ -76,7 +74,7 @@ namespace ComPDFKit.Controls.Common
 
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
-            throw new NotSupportedException();
+            return null;
         }
     }
 
@@ -94,7 +92,7 @@ namespace ComPDFKit.Controls.Common
 
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
-            throw new NotSupportedException();
+            return null;
         }
     }
     
@@ -112,7 +110,7 @@ namespace ComPDFKit.Controls.Common
 
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
-            throw new NotSupportedException();
+            return null;
         }
     }
     
@@ -130,7 +128,7 @@ namespace ComPDFKit.Controls.Common
 
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
-            throw new NotSupportedException();
+            return null;
         }
     }
     
@@ -148,7 +146,7 @@ namespace ComPDFKit.Controls.Common
 
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
-            throw new NotSupportedException();
+            return null;
         }
     }
 }