Browse Source

compdfkit(win) - 移除密码

weixiangjie 1 year ago
parent
commit
c13ceae1a0

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Common/HomePage/FeaturesListControl.xaml.cs

@@ -106,7 +106,7 @@ namespace Compdfkit_Tools.PDFControl
             var listBox = sender as ListBox;
             if (listBox != null && listBox.SelectedIndex != -1)
             {
-                SelectionChanged?.Invoke(sender, Items[listBox.SelectedIndex]);
+                SelectionChanged?.Invoke(sender, Items[HorizontalItemNumber*VerticalItemNumber*(CurrentIndex-1) + listBox.SelectedIndex]);
                 listBox.SelectedIndex = -1;
             }
         }

+ 12 - 1
Demo/Examples/Compdfkit_Tools/Common/HomePage/HomePageControl.xaml.cs

@@ -1,4 +1,5 @@
-using System;
+using Compdfkit_Tools.Encryption;
+using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
@@ -60,6 +61,16 @@ namespace Compdfkit_Tools.PDFControl
                 case "Watermark":
                     MessageBox.Show(e.TitleText + " is under development.");
                     break;
+                case "Security":
+                    {
+                        var parentWindow = Window.GetWindow(this);
+                        SecurityOperationTypeDialog securityOperationTypeDialog = new SecurityOperationTypeDialog()
+                        {
+                            Owner = parentWindow
+                        };
+                        securityOperationTypeDialog.ShowDialog();
+                        break;
+                    }
                 default:
                     MessageBox.Show(e.TitleText + " is under development.");
                     break;

+ 8 - 0
Demo/Examples/Compdfkit_Tools/Compdfkit_Tools.csproj

@@ -321,12 +321,18 @@
     <Compile Include="Common\BarControl\FormBarControl.xaml.cs">
       <DependentUpon>FormBarControl.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Encryption\DecryptionDialog.xaml.cs">
+      <DependentUpon>DecryptionDialog.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Encryption\EncryptionDialog.xaml.cs">
       <DependentUpon>EncryptionDialog.xaml</DependentUpon>
     </Compile>
     <Compile Include="Encryption\FileGridListControl.xaml.cs">
       <DependentUpon>FileGridListControl.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Encryption\SecurityOperationTypeDialog.xaml.cs">
+      <DependentUpon>SecurityOperationTypeDialog.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Encryption\SetEncryptionControl.xaml.cs">
       <DependentUpon>SetEncryptionControl.xaml</DependentUpon>
     </Compile>
@@ -827,8 +833,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Encryption\DecryptionDialog.xaml" />
     <Page Include="Encryption\EncryptionDialog.xaml" />
     <Page Include="Encryption\FileGridListControl.xaml" />
+    <Page Include="Encryption\SecurityOperationTypeDialog.xaml" />
     <Page Include="Encryption\SetEncryptionControl.xaml" />
     <Page Include="Form\FormControl\FormControl.xaml">
       <SubType>Designer</SubType>

+ 31 - 0
Demo/Examples/Compdfkit_Tools/Encryption/DecryptionDialog.xaml

@@ -0,0 +1,31 @@
+<Window x:Class="Compdfkit_Tools.PDFControl.DecryptionDialog"
+        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:Compdfkit_Tools.PDFControl"
+        mc:Ignorable="d"
+        ResizeMode="NoResize"
+        ShowInTaskbar="False"
+        Title="DecryptionDialog" Height="600" Width="522">
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="Auto"/>
+        </Grid.RowDefinitions>
+        <local:FileGridListControl x:Name="FileListControl" Width="496" Height="420"/>
+        
+        <StackPanel Grid.Row="1" Margin="20,20,20,0">
+            <TextBlock FontFamily="Segoe UI" FontSize="12" TextWrapping="Wrap" 
+                       Text="PDF Password Remover is an easy-to-use PDF security remover,which helps users decrypt PDF protections and remove restrictions on printing,editing and copying."></TextBlock>
+            <TextBlock FontFamily="Segoe UI" FontSize="12" TextWrapping="Wrap" Margin="0,10,0,10"
+                       Text="If open password is required,you need to enter the right password first and then remove protections from PDF files."></TextBlock>
+        </StackPanel>
+        
+        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
+            <Button Width="112" Height="32" FontFamily="Segoe UI" FontSize="14" Content="Remove" Click="Remove_Click" IsEnabled="{Binding CanRemove}"></Button>
+            <Button Width="112" Height="32" FontFamily="Segoe UI" FontSize="14" Content="Cancel" Margin="10,0,10,0" Click="Cancel_Click"></Button>
+        </StackPanel>
+    </Grid>
+</Window>

+ 44 - 0
Demo/Examples/Compdfkit_Tools/Encryption/DecryptionDialog.xaml.cs

@@ -0,0 +1,44 @@
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Windows;
+using ComPDFKit.PDFDocument;
+
+namespace Compdfkit_Tools.PDFControl
+{
+    public partial class DecryptionDialog : Window, INotifyPropertyChanged
+    {
+        private CPDFDocument document;
+        public bool CanRemove => FileListControl.FileNum > 0;
+
+        
+        public event PropertyChangedEventHandler PropertyChanged;
+        public DecryptionDialog()
+        {
+            InitializeComponent();
+            DataContext = this;
+            FileListControl.FileNumChanged += (sender, args) =>
+            {
+                OnPropertyChanged(nameof(CanRemove));
+            };
+        }
+
+        private void Cancel_Click(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
+
+        private void Remove_Click(object sender, RoutedEventArgs e)
+        {
+            
+        }
+
+        
+
+        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+        }
+        
+    }
+}

+ 1 - 0
Demo/Examples/Compdfkit_Tools/Encryption/EncryptionDialog.xaml

@@ -7,6 +7,7 @@
         xmlns:common="clr-namespace:Compdfkit_Tools.Common"
         mc:Ignorable="d"
         ResizeMode="NoResize"
+        ShowInTaskbar="False"
         Title="Batch Encryption" Height="504" Width="1052">
     <Grid>
         <Grid>

+ 2 - 2
Demo/Examples/Compdfkit_Tools/Encryption/FileGridListControl.xaml

@@ -40,9 +40,9 @@
                     <RowDefinition Height="*"></RowDefinition>
                     <RowDefinition Height="50"></RowDefinition>
                 </Grid.RowDefinitions>
-                 <Grid Grid.Row="0">
+                 <Grid Grid.Row="0" VerticalAlignment="Stretch">
                      <DataGrid Background="White" BorderBrush="#E6E6E6" x:Name="FileDataGrid" HeadersVisibility="Column"
-                               IsReadOnly="True" AutoGenerateColumns="False" FontSize="14" SelectionMode="Extended" Height="270"
+                               IsReadOnly="True" AutoGenerateColumns="False" FontSize="14" SelectionMode="Extended"
                                ScrollViewer.CanContentScroll="False" HorizontalScrollBarVisibility="Auto" MouseLeftButtonDown="FileDataGrid_OnMouseLeftButtonUp" SelectionChanged="FileDataGrid_SelectionChanged">
                          <DataGrid.Columns>
                              <DataGridTextColumn Header="File" Width="*" Binding="{Binding FileName}" />

+ 35 - 0
Demo/Examples/Compdfkit_Tools/Encryption/SecurityOperationTypeDialog.xaml

@@ -0,0 +1,35 @@
+<Window x:Class="Compdfkit_Tools.Encryption.SecurityOperationTypeDialog"
+        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:Compdfkit_Tools.Encryption"
+        mc:Ignorable="d"
+        ResizeMode="NoResize"
+        ShowInTaskbar="False"
+        Title="Operation Type" Height="214" Width="432">
+    <Grid Margin="10,20,5,0">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="104"></RowDefinition>
+            <RowDefinition Height="40"></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Background="White" Margin="20,0,0,0"  Panel.ZIndex="1" Height="20" HorizontalAlignment="Left" VerticalAlignment="Top">
+            <TextBlock Foreground="#001A4E" FontFamily="Segoe UI" Text="Password Type" FontWeight="DemiBold" FontSize="14"></TextBlock>
+        </Grid>
+        <Border Margin="0,10,7,12" BorderBrush="#33000000" BorderThickness="1">
+            <Grid Margin="10" VerticalAlignment="Center" Height="{Binding Path=ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Border}}}">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="*"></RowDefinition>
+                    <RowDefinition Height="*"></RowDefinition>
+                </Grid.RowDefinitions>
+                <RadioButton x:Name="RdoAddPassword" IsChecked="True" VerticalAlignment="Center" FontFamily="Segoe UI" FontSize="14" Content="Add Password">
+                </RadioButton>
+                <RadioButton Grid.Row="1" x:Name="RdoRemovePassword" VerticalAlignment="Center" FontFamily="Segoe UI" FontSize="14" Content="Remove Password"></RadioButton>
+            </Grid>
+        </Border>
+        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
+            <Button Content="Cancel" Width="112" Height="32" FontFamily="Segoe UI" FontSize="14" Click="Cancel_Click"></Button>
+            <Button Content="OK" Width="112" Height="32" FontFamily="Segoe UI" FontSize="14" Margin="10,0,10,0" Click="Confirm_Click"></Button>
+        </StackPanel>
+    </Grid>
+</Window>

+ 44 - 0
Demo/Examples/Compdfkit_Tools/Encryption/SecurityOperationTypeDialog.xaml.cs

@@ -0,0 +1,44 @@
+using System.Linq;
+using System.Windows;
+using Compdfkit_Tools.PDFControl;
+
+namespace Compdfkit_Tools.Encryption
+{
+    public partial class SecurityOperationTypeDialog : Window
+    {
+        public SecurityOperationTypeDialog()
+        {
+            InitializeComponent();
+        }
+
+        private void Confirm_Click(object sender, RoutedEventArgs e)
+        {
+            if (RdoAddPassword.IsChecked == true)
+            {
+                EncryptionDialog dialog = new EncryptionDialog();
+                OpenNewDialog(dialog);
+            }
+            else if (RdoRemovePassword.IsChecked == true)
+            {
+                DecryptionDialog dialog = new DecryptionDialog();
+                OpenNewDialog(dialog);
+            }
+            else
+            {
+                MessageBox.Show("Please select an operation type.");
+            }
+        }
+
+        private void OpenNewDialog(Window newDialog)
+        {
+            newDialog.Owner = this.Owner;
+            this.Close();
+            newDialog.ShowDialog();
+        }
+
+        private void Cancel_Click(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
+    }
+}

+ 0 - 2
Demo/Examples/Viewer/MainWindow.xaml

@@ -166,8 +166,6 @@
 
                     <Line Margin="13,0,13,0" Stroke="#E0E0E0" X1="0" Y1="5" X2="0" Y2="35"></Line>
                     <cpdftools:CPDFScalingControl x:Name="CPDFSaclingControl"></cpdftools:CPDFScalingControl>
-                    
-                    <Button Width="30" Height="30" Content="test" Click="ButtonBase_OnClick"></Button>
                 </StackPanel>
  
                 <ComboBox Width="120" Height="26" Grid.Column="1" HorizontalAlignment="Center" FontSize="14" Foreground="#001A4E">

+ 0 - 6
Demo/Examples/Viewer/MainWindow.xaml.cs

@@ -734,11 +734,5 @@ namespace Viewer
             }
         }
         #endregion
-
-        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
-        {
-            EncryptionDialog dialog = new EncryptionDialog();
-            dialog.ShowDialog();
-        }
     }
 }