Browse Source

PDFView(Windows) - 补充大纲跳转;修改显示模式按钮错误

liyuxuan 1 year ago
parent
commit
0552c1df9c

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-assets/Styles/ButtonStyle.xaml

@@ -122,7 +122,7 @@
                     </Trigger>
                     </Trigger>
                     <Trigger Property="IsMouseOver" Value="true">
                     <Trigger Property="IsMouseOver" Value="true">
                             <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
                             <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
-                            <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
+                            <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
                         </Trigger>
                         </Trigger>
                     <Trigger Property="IsPressed" Value="true">
                     <Trigger Property="IsPressed" Value="true">
                         <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
                         <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>

+ 4 - 4
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFDisplaySettings/PDFDisplaySettingsUI/CPDFViewModeUI.xaml

@@ -50,8 +50,8 @@
                     
                     
                     <StackPanel Orientation="Horizontal" Grid.Row="1">
                     <StackPanel Orientation="Horizontal" Grid.Row="1">
                         <!--水平视图-->
                         <!--水平视图-->
-                        <ToggleButton Name="HorizonBtn" Width="50" Height="36" BorderThickness="0" Style="{StaticResource RoundToggleButtonStyle}" 
-                                      Background="Transparent" Click="HorizonBtn_Click">
+                        <ToggleButton Name="VerticalBtn" Width="50" Height="36" BorderThickness="0" Style="{StaticResource RoundToggleButtonStyle}" 
+                                      Background="Transparent" Click="VerticalBtn_Click">
                             <ToggleButton.Content>
                             <ToggleButton.Content>
                                 <Path Name="HorizonPath" Fill="#999999" >
                                 <Path Name="HorizonPath" Fill="#999999" >
                                     <Path.Data>
                                     <Path.Data>
@@ -66,8 +66,8 @@
                         </ToggleButton>
                         </ToggleButton>
 
 
                         <!--垂直视图-->
                         <!--垂直视图-->
-                        <ToggleButton Name="VerticalBtn" Width="50" Height="36" BorderThickness="0" Margin="5,0,0,0" Style="{StaticResource RoundToggleButtonStyle}" 
-                                      Background="Transparent" Click="VerticalBtn_Click">
+                        <ToggleButton Name="HorizonBtn" Width="50" Height="36" BorderThickness="0" Margin="5,0,0,0" Style="{StaticResource RoundToggleButtonStyle}" 
+                                      Background="Transparent" Click="HorizonBtn_Click">
                             <ToggleButton.Content>
                             <ToggleButton.Content>
                                 <Path Name="VerticalPath" Fill="#999999">
                                 <Path Name="VerticalPath" Fill="#999999">
                                     <Path.Data>
                                     <Path.Data>

+ 35 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFOutline/PDFOutlineControl/CPDFOutlineControl.xaml.cs

@@ -1,4 +1,5 @@
 using ComPDFKit.PDFDocument;
 using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFDocument.Action;
 using compdfkit_tools.PDFControlUI;
 using compdfkit_tools.PDFControlUI;
 using compdfkit_tools.PDFView.PDFOutline.PDFOutlineData;
 using compdfkit_tools.PDFView.PDFOutline.PDFOutlineData;
 using ComPDFKitViewer.PdfViewer;
 using ComPDFKitViewer.PdfViewer;
@@ -26,7 +27,6 @@ namespace compdfkit_tools.PDFControl
     public partial class CPDFOutlineControl : UserControl
     public partial class CPDFOutlineControl : UserControl
     {
     {
         CPDFViewer pdfViewer;
         CPDFViewer pdfViewer;
-        private CPDFOutline CurrentCPDFOutline { set; get; }
         public ObservableCollection<CPDFOutlineNode> OutlineList
         public ObservableCollection<CPDFOutlineNode> OutlineList
         {
         {
             set; get;
             set; get;
@@ -34,6 +34,40 @@ namespace compdfkit_tools.PDFControl
         public CPDFOutlineControl()
         public CPDFOutlineControl()
         {
         {
             InitializeComponent();
             InitializeComponent();
+            Loaded += CPDFOutlineControl_Loaded;
+        }
+
+        private void CPDFOutlineControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            CPDFOutlineUI.OutlineSelectionChanged -= CPDFOutlineUI_OutlineSelectionChanged;
+            CPDFOutlineUI.OutlineSelectionChanged += CPDFOutlineUI_OutlineSelectionChanged;
+        }
+
+        private void CPDFOutlineUI_OutlineSelectionChanged(object sender, object e)
+        {
+            try
+            {
+                TreeViewItem new_item = (TreeViewItem)e;
+                CPDFOutline outline = (CPDFOutline)new_item.Tag;
+
+                CPDFAction action = outline.GetAction();
+                if (action != null && action.ActionType != C_ACTION_TYPE.ACTION_TYPE_UNKNOWN)
+                {
+                    pdfViewer.ProcessAction(action);
+                }
+                else
+                {
+                    CPDFDestination dest = outline.GetDestination(pdfViewer.Document);
+                    if (dest != null)
+                    {
+                        pdfViewer.GoToPage(dest.PageIndex);
+                    }
+                }
+            }
+            catch(Exception ex)
+            {
+
+            }
         }
         }
 
 
         private int GetIndexFromParent(List<CPDFOutline> parentlist, CPDFOutline outline)
         private int GetIndexFromParent(List<CPDFOutline> parentlist, CPDFOutline outline)

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFOutline/PDFOutlineUI/CPDFOutlineUI.xaml

@@ -24,7 +24,7 @@
         </Border>
         </Border>
 
 
         <Grid Grid.Row="1">
         <Grid Grid.Row="1">
-            <TreeView Name="OutlineTree" BorderThickness="0" Background="#FAFCFF" FontSize="14" Margin="8,0,0,0">
+            <TreeView Name="OutlineTree" BorderThickness="0" Background="#FAFCFF" FontSize="14" Margin="8,0,0,0" SelectedItemChanged="OutlineTree_SelectedItemChanged">
                 <TreeView.Resources>
                 <TreeView.Resources>
                     <Style TargetType="TreeViewItem" BasedOn="{StaticResource TreeViewItemStyle}"/>
                     <Style TargetType="TreeViewItem" BasedOn="{StaticResource TreeViewItemStyle}"/>
                 </TreeView.Resources>
                 </TreeView.Resources>

+ 12 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/PDFView/PDFOutline/PDFOutlineUI/CPDFOutlineUI.xaml.cs

@@ -1,4 +1,5 @@
 using ComPDFKit.PDFDocument;
 using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFDocument.Action;
 using compdfkit_tools.PDFControl;
 using compdfkit_tools.PDFControl;
 using compdfkit_tools.PDFView.PDFOutline.PDFOutlineData;
 using compdfkit_tools.PDFView.PDFOutline.PDFOutlineData;
 using ComPDFKitViewer.PdfViewer;
 using ComPDFKitViewer.PdfViewer;
@@ -77,6 +78,8 @@ namespace compdfkit_tools.PDFControlUI
 
 
         public ObservableCollection<CPDFOutlineNode> OutlineList { get; set; } = new ObservableCollection<CPDFOutlineNode>();
         public ObservableCollection<CPDFOutlineNode> OutlineList { get; set; } = new ObservableCollection<CPDFOutlineNode>();
 
 
+        public event EventHandler<object> OutlineSelectionChanged;
+
         public CPDFOutlineUI()
         public CPDFOutlineUI()
         {
         {
             InitializeComponent();
             InitializeComponent();
@@ -105,7 +108,6 @@ namespace compdfkit_tools.PDFControlUI
             this.OutlineList.Clear();
             this.OutlineList.Clear();
             if (!OutlineTree.HasItems)
             if (!OutlineTree.HasItems)
             {
             {
-                //OutlineTree.FontSize = 14;
                 if (outlineList != null && outlineList.Count > 0)
                 if (outlineList != null && outlineList.Count > 0)
                 {
                 {
                     OutlineTree.BeginInit();
                     OutlineTree.BeginInit();
@@ -123,7 +125,15 @@ namespace compdfkit_tools.PDFControlUI
                 NoResultText.Visibility= Visibility.Collapsed;
                 NoResultText.Visibility= Visibility.Collapsed;
             }
             }
         }
         }
-    }
 
 
+        private void OutlineTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
+        {
+            if (e.NewValue == null)
+            {
+                return;
+            }
 
 
+            OutlineSelectionChanged?.Invoke(this, e.NewValue);
+        }
+    }
 }
 }