Browse Source

compdfkit(win) - 创建证书开始

liuaoran 1 year ago
parent
commit
b3943a4952

+ 50 - 0
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCertificationControl.xaml

@@ -0,0 +1,50 @@
+<Window x:Class="Compdfkit_Tools.DigitalSignature.AddCertificationControl.AddCertificationControl"
+             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.DigitalSignature.AddCertificationControl"
+             mc:Ignorable="d"
+             d:DesignHeight="474" d:DesignWidth="462">
+    <Grid Margin="10,10,10,10">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto" />
+            <RowDefinition Height="Auto" />
+            <RowDefinition Height="Auto" />
+            <RowDefinition Height="Auto" />
+            <RowDefinition Height="Auto" />
+        </Grid.RowDefinitions>
+        <Label Grid.Row="0" Content="Select the type of Digital ID:" FontSize="14" FontFamily="Segoe UI" FontWeight="600" Padding="0,4,0,4" Width="187" HorizontalAlignment="Left"></Label>
+        <StackPanel Grid.Row="1" Orientation="Horizontal">
+            <RadioButton FontSize="16" BorderThickness="1" Margin="0,2,0,0" BorderBrush="#43474D" GroupName="ChooseCertification" VerticalAlignment="Center"></RadioButton>
+            <StackPanel Orientation="Horizontal" Width="386" Height="80">
+                <Image  Width="32" Height="32" Margin="0,0,0,0" VerticalAlignment="Center"></Image>
+                <StackPanel Orientation="Vertical" Margin="10,0,0,0" VerticalAlignment="Center">
+                    <Label Content="Use a Digital ID from a file" FontSize="14" FontFamily="Segoe UI" FontWeight="600" Padding="0,4,0,4" Width="168" HorizontalAlignment="Left" VerticalAlignment="Top"></Label>
+                    <Label Content="Import an existing Digital ID that you have obtained as a file" FontSize="12" FontFamily="Segoe UI" FontWeight="400" Padding="0,4,0,4" Width="318" HorizontalAlignment="Left" VerticalAlignment="Bottom"></Label>
+                </StackPanel>
+            </StackPanel>
+        </StackPanel>
+        <StackPanel Grid.Row="2" Orientation="Horizontal">
+            <RadioButton FontSize="16" BorderThickness="1" Margin="0,2,0,0" BorderBrush="#43474D" GroupName="ChooseCertification" VerticalAlignment="Center"></RadioButton>
+            <StackPanel Orientation="Horizontal" Width="386" Height="80">
+                <Image  Width="32" Height="32" Margin="0,0,0,0" VerticalAlignment="Center"></Image>
+                <StackPanel Orientation="Vertical" Margin="10,0,0,0" VerticalAlignment="Center">
+                    <Label Content="Use a Digital ID from a file" FontSize="14" FontFamily="Segoe UI" FontWeight="600" Padding="0,4,0,4" Width="168" HorizontalAlignment="Left" VerticalAlignment="Top"></Label>
+                    <Label Content="Create your self-signed Digital ID" FontSize="12" FontFamily="Segoe UI" FontWeight="400" Padding="0,4,0,4" Width="318" HorizontalAlignment="Left" VerticalAlignment="Bottom"></Label>
+                </StackPanel>
+            </StackPanel>
+        </StackPanel>
+        <StackPanel Grid.Row="3" Margin="10,10,10,10">
+                <TextBlock FontWeight="400" FontSize="12" FontFamily="Segoe UI" Foreground="#43474D" TextWrapping="Wrap" Background="#F2F2F2" Padding="12,10,12,10"
+                           Text="A Digital ID is required to create a digital signature. The most secure Digital ID are issued by trusted Certificate authorities and are based on secure devices like smart card or token. Some are based on files."/>
+                <TextBlock FontWeight="400" FontSize="12" FontFamily="Segoe UI" Foreground="#43474D" TextWrapping="Wrap" Background="#F2F2F2"/>
+                <TextBlock FontWeight="400" FontSize="12" FontFamily="Segoe UI" Foreground="#43474D" TextWrapping="Wrap" Background="#F2F2F2" Padding="12,10,12,10"
+                           Text="You can also create a new Digital ID, but they provide a low level of identity assurance."/>
+        </StackPanel>
+        <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Right">
+            <Button Content="Cancel" Width="112" Height="32" BorderThickness="1" Margin="0,0,10,0"></Button>
+            <Button Content="Continue" Width="112" Height="32" BorderThickness="1"></Button>
+        </StackPanel>
+    </Grid>
+</Window>

+ 11 - 10
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCertificationDialog.xaml

@@ -6,8 +6,9 @@
              xmlns:local="clr-namespace:Compdfkit_Tools.DigitalSignature.AddCertificationControl"
              ShowInTaskbar="False"
              mc:Ignorable="d"
-             d:DesignHeight="474" d:DesignWidth="462">
-    <Grid Margin="10,10,10,10">
+             Height="500"
+             Width="462">
+    <Grid Margin="10,10,10,0">
         <Grid.RowDefinitions>
             <RowDefinition Height="Auto" />
             <RowDefinition Height="Auto" />
@@ -21,13 +22,13 @@
                 <ControlTemplate TargetType="RadioButton">
                     <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                         <RadioButton IsChecked="{TemplateBinding IsChecked}" VerticalAlignment="Center" Margin="10,0,10,0"/>
-                        
+
                         <Border BorderThickness="1" BorderBrush="Black" Width="386" Height="80">
                             <StackPanel Orientation="Horizontal">
                                 <Image Width="32" Height="32" VerticalAlignment="Center" Margin="10,0,10,0"/>
                                 <StackPanel Orientation="Vertical" VerticalAlignment="Center">
-                                <Label Content="Use a Digital ID from a file" FontSize="14" FontFamily="Segoe UI" FontWeight="Bold" Padding="0,4,0,4"/>
-                                <Label Content="Import an existing Digital ID that you have obtained as a file" FontSize="12" FontFamily="Segoe UI"  Padding="0,4,0,4"/>
+                                    <Label Content="Use a Digital ID from a file" FontSize="14" FontFamily="Segoe UI" FontWeight="Bold" Padding="0,4,0,4"/>
+                                    <Label Content="Import an existing Digital ID that you have obtained as a file" FontSize="12" FontFamily="Segoe UI"  Padding="0,4,0,4"/>
                                 </StackPanel>
                             </StackPanel>
                         </Border>
@@ -40,7 +41,7 @@
                 <ControlTemplate TargetType="RadioButton">
                     <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                         <RadioButton IsChecked="{TemplateBinding IsChecked}" VerticalAlignment="Center" Margin="10,0,10,0"/>
-                        
+
                         <Border BorderThickness="1" BorderBrush="Black" Width="386" Height="80">
                             <StackPanel Orientation="Horizontal">
                                 <Image Width="32" Height="32" VerticalAlignment="Center" Margin="10,0,10,0"/>
@@ -55,12 +56,12 @@
             </RadioButton.Template>
         </RadioButton>
 
-        
+
         <StackPanel Grid.Row="3" Margin="10,20,10,20" Width="407">
-                <TextBlock  FontSize="12" FontFamily="Segoe UI" Foreground="#43474D" TextWrapping="Wrap" Background="#F2F2F2" Padding="12,10,12,10"
+            <TextBlock  FontSize="12" FontFamily="Segoe UI" Foreground="#43474D" TextWrapping="Wrap" Background="#F2F2F2" Padding="12,10,12,10"
                            Text="A Digital ID is required to create a digital signature. The most secure Digital ID are issued by trusted Certificate authorities and are based on secure devices like smart card or token. Some are based on files."/>
-                <TextBlock  FontSize="12" FontFamily="Segoe UI" Foreground="#43474D" TextWrapping="Wrap" Background="#F2F2F2"/>
-                <TextBlock  FontSize="12" FontFamily="Segoe UI" Foreground="#43474D" TextWrapping="Wrap" Background="#F2F2F2" Padding="12,10,12,10"
+            <TextBlock  FontSize="12" FontFamily="Segoe UI" Foreground="#43474D" TextWrapping="Wrap" Background="#F2F2F2"/>
+            <TextBlock  FontSize="12" FontFamily="Segoe UI" Foreground="#43474D" TextWrapping="Wrap" Background="#F2F2F2" Padding="12,10,12,10"
                            Text="You can also create a new Digital ID, but they provide a low level of identity assurance."/>
         </StackPanel>
         <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Right">

+ 16 - 12
Demo/Examples/Compdfkit_Tools/DigitalSignature/DigitalSignatureControl/DigitalSignatureControl.xaml.cs

@@ -20,10 +20,7 @@ using System.Windows.Navigation;
 using System.Windows.Shapes;
 
 namespace Compdfkit_Tools.PDFControl
-{
-    /// <summary>
-    /// DigitalSignatureControl.xaml 的交互逻辑
-    /// </summary>
+{ 
     public partial class DigitalSignatureControl : UserControl, INotifyPropertyChanged
     {
         private bool isFirstLoad = true;
@@ -107,15 +104,20 @@ namespace Compdfkit_Tools.PDFControl
             DigitalSignatureBarControl.DigitalSignatureActionChanged -= DigitalSignatureBarControl_DigitalSignatureActionChanged;
             DigitalSignatureBarControl.DigitalSignatureActionChanged += DigitalSignatureBarControl_DigitalSignatureActionChanged;
 
-            PDFViewControl.PDFView.PDFEditActiveHandler -= PDFView_PDFEditActiveHandler;
-            PDFViewControl.PDFView.PDFEditActiveHandler += PDFView_PDFEditActiveHandler;
+            PDFViewControl.PDFView.WidgetClickHandler -= PDFView_WidgetClickHandler;
+            PDFViewControl.PDFView.WidgetClickHandler += PDFView_WidgetClickHandler; ;
+
         }
 
-        private void PDFView_PDFEditActiveHandler(object sender, ComPDFKitViewer.PDFEditEvent e)
+        private void PDFView_WidgetClickHandler(object sender, WidgetArgs e)
         {
-            
+            Window parentWindow = Window.GetWindow((DependencyObject)sender);
+            AddCertificationDialog addCertificationControl = new AddCertificationDialog();
+            addCertificationControl.Owner = parentWindow;
+            addCertificationControl.ShowDialog();
         }
 
+
         private void DigitalSignatureBarControl_DigitalSignatureActionChanged(object sender, Common.CPDFDigitalSignatureBarControl.DigitalSignatureAction e)
         {
             if (e == Common.CPDFDigitalSignatureBarControl.DigitalSignatureAction.AddSignatrueField)
@@ -141,10 +143,12 @@ namespace Compdfkit_Tools.PDFControl
         private void CreateSign()
         {
             PDFViewControl.PDFView.SetMouseMode(MouseModes.FormEditTool);
-            WidgetSignArgs signArgs = new WidgetSignArgs();
-            signArgs.LineWidth = 1;
-            signArgs.LineColor = Colors.Black;
-            signArgs.FieldName = "Signature" + GetTime();
+            WidgetSignArgs signArgs = new WidgetSignArgs
+            {
+                LineWidth = 1,
+                LineColor = Colors.Black,
+                FieldName = "Signature" + GetTime()
+            };
             PDFViewControl.PDFView.SetToolParam(signArgs);
         }
 

+ 5 - 0
Demo/Examples/Compdfkit_Tools/PDFView/PDFViewControl/PDFViewControl.xaml.cs

@@ -36,6 +36,11 @@ namespace Compdfkit_Tools.PDFControl
             PDFView.WidgetClickHandler += PDFView_WidgetClickHandler;
         }
 
+        /// <summary>
+        /// set CustomSignhandle = ture if dont need this default function. 
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
         private void PDFView_WidgetClickHandler(object sender, WidgetArgs e)
         {
             if ((e is WidgetSignArgs) && CustomSignHandle == false)

+ 1 - 0
Demo/Examples/DigitalSignature/MainWindow.xaml.cs

@@ -173,6 +173,7 @@ namespace DigitalSignature
             pdfViewer.PDFView.InfoChanged += PdfViewer_InfoChanged;
 
             pdfViewer.PDFView.SetFormFieldHighlight(true);
+            pdfViewer.CustomSignHandle = true;
 
             PasswordUI.Closed -= PasswordUI_Closed;
             PasswordUI.Canceled -= PasswordUI_Canceled;