瀏覽代碼

compdfkit(win) - 文案修改,添加证书自动信任

weixiangjie 1 年之前
父節點
當前提交
06948f466a
共有 13 個文件被更改,包括 90 次插入42 次删除
  1. 1 1
      Demo/Examples/Compdfkit_Tools/Common/BarControl/CPDFDigitalSignatureBarControl.xaml.cs
  2. 4 4
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCertificationControl.xaml
  3. 11 8
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddExistedCertificationControl.xaml
  4. 48 12
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddExistedCertificationControl.xaml.cs
  5. 3 3
      Demo/Examples/Compdfkit_Tools/DigitalSignature/CPDFSignatureListControl/CPDFSignatureListControl.xaml.cs
  6. 3 3
      Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureControl.xaml
  7. 1 0
      Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureControl.xaml.cs
  8. 3 3
      Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/CertificateDetailControl.xaml
  9. 1 1
      Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/ConfidenceControl.xaml
  10. 1 1
      Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/ConfidenceControl.xaml.cs
  11. 2 2
      Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/SummaryControl.xaml
  12. 7 4
      Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/ViewCertificateDialog.xaml
  13. 5 0
      Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/ViewCertificateDialog.xaml.cs

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Common/BarControl/CPDFDigitalSignatureBarControl.xaml.cs

@@ -137,7 +137,7 @@ namespace Compdfkit_Tools.Common
                 button.Click += VerifySignatureBtn_Click;
             }
             DigitalSignBarGrid.ColumnDefinitions.Add(new ColumnDefinition());
-            DigitalSignBarGrid.Width += 150;
+            DigitalSignBarGrid.Width += 180;
             Grid.SetColumn(button, counter++);
             DigitalSignBarGrid.Children.Add(button);
         }

File diff suppressed because it is too large
+ 4 - 4
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCertificationControl.xaml


+ 11 - 8
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddExistedCertificationControl.xaml

@@ -18,27 +18,30 @@
             <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
         <TextBlock TextWrapping="Wrap" FontSize="14" Foreground="#000000" Margin="10,20,10,20" Height="40"
-                   Text="Browse digital ID files. Digital ID files are password protected. If you do not know its password, you cannot access the digital ID card.">
+                   Text="Browse a digital ID file. Digital ID cards are password-protected. If you do not know the password, you cannot obtain a digital ID card.">
         </TextBlock>
-        <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="10,0,0,8">
-            <TextBlock Text="Files" Foreground="#43474D" FontSize="14" VerticalAlignment="Center" Margin="10,0,10,0" HorizontalAlignment="Left" Width="58" FontFamily="Segoe UI"></TextBlock>
+        <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="10,0,10,8">
+            <TextBlock Text="Certificate File" Foreground="#43474D" FontSize="14" VerticalAlignment="Center" Margin="10,0,10,0" HorizontalAlignment="Left" Width="88" FontFamily="Segoe UI"></TextBlock>
             <Grid IsEnabled="{Binding InputEnable}">
-                <TextBox Width="258" Height="28"  x:Name="FileNameTxt" VerticalContentAlignment="Center" VerticalAlignment="Center" IsReadOnly="True"/>
+                <TextBox Width="238" Height="28"  x:Name="FileNameTxt" VerticalContentAlignment="Center" VerticalAlignment="Center" IsReadOnly="True" TextChanged="FileNameTxt_OnTextChanged"/>
                 <TextBlock Text="Select a file" Margin="8" VerticalAlignment="Center"   Visibility="{Binding ElementName=FileNameTxt, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
             </Grid>
-            <Button x:Name="SelectFileBtn" Content="Select File" Width="90" Height="28" FontSize="14" FontFamily="Segoe UI" Margin="8,0,0,0" Click="SelectFileBtn_Click"></Button>
+            <Button x:Name="SelectFileBtn" Content="Upload" Width="90" Height="28" FontSize="14" FontFamily="Segoe UI" Margin="8,0,0,0" Click="SelectFileBtn_Click"></Button>
         </StackPanel>
         <StackPanel Grid.Row="2" Orientation="Horizontal"  Margin="10,0,0,8">
-            <TextBlock Foreground="#43474D" Width="58" FontSize="14" FontFamily="Segoe UI" Text="Password" VerticalAlignment="Top" Margin="10,5,10,0"></TextBlock>
+            <TextBlock Foreground="#43474D" Width="88" FontSize="14" FontFamily="Segoe UI" Text="Password" VerticalAlignment="Top" Margin="10,5,10,0"></TextBlock>
             <StackPanel  Margin="0,0,0,0">
-                <PasswordBox Name="PasswordBoxTxt" Padding="5,0,0,0" Width="258" Height="28"  VerticalContentAlignment="Center" VerticalAlignment="Center"></PasswordBox>
+                <Grid>
+                    <PasswordBox Name="PasswordBoxTxt" Padding="5,0,0,0" Width="238" Height="28"  VerticalContentAlignment="Center" VerticalAlignment="Center" PasswordChanged="PasswordBoxTxt_OnPasswordChanged"></PasswordBox>
+                    <TextBlock x:Name="PasswordTextBlock" Text="Please enter your password" Margin="8" VerticalAlignment="Center" IsHitTestVisible="False" Foreground="#BBB"></TextBlock>
+                </Grid>
                 <TextBlock Name="ErrorTipsText" Foreground="Red" Margin="0,4,0,0"></TextBlock>
             </StackPanel>
         </StackPanel>
         <Grid Grid.Row="4">
             <StackPanel  Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="24"> 
                 <Button x:Name="CancelBtn" Content="Cancel"  Margin="0,0,10,0" Width="112" Height="32" BorderThickness="1" Click="CancelBtn_Click"></Button>
-                <Button x:Name="DoneBtn" Content="Done" Width="112" Height="32" BorderThickness="1" Click="DoneBtn_Click"></Button>
+                <Button x:Name="DoneBtn" Content="OK" Width="112" Height="32" BorderThickness="1" IsEnabled="{Binding CanContinue}" Click="DoneBtn_Click"></Button>
             </StackPanel>
         </Grid> 
     </Grid>

+ 48 - 12
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddExistedCertificationControl.xaml.cs

@@ -1,19 +1,31 @@
 using ComPDFKit.DigitalSign;
 using Compdfkit_Tools.Helper;
 using System;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
 using System.Windows;
 using System.Windows.Controls;
 
 namespace Compdfkit_Tools.PDFControl
 {
-    public partial class AddExistedCertificationControl : UserControl
+    public partial class AddExistedCertificationControl : UserControl,INotifyPropertyChanged
     {
         public event EventHandler SaveEvent;
         public event EventHandler CancelEvent;
         public event EventHandler<CertificateAccess> FillSignatureEvent;
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        private bool _canContinue;
+        public bool CanContinue
+        {
+            get => _canContinue;
+            set => UpdateProper(ref _canContinue, value);
+        }
+
         public AddExistedCertificationControl()
         {
             InitializeComponent();
+            DataContext = this;
         }
 
         private void CancelBtn_Click(object sender, System.Windows.RoutedEventArgs e)
@@ -23,19 +35,9 @@ namespace Compdfkit_Tools.PDFControl
 
         private void DoneBtn_Click(object sender, System.Windows.RoutedEventArgs e)
         {
-            if (FileNameTxt.Text == string.Empty)
-            {
-                ErrorTipsText.Text = "Please select a file.";
-                return;
-            }
-            if (PasswordBoxTxt.Password == string.Empty)
-            {
-                ErrorTipsText.Text = "Please input password.";
-                return;
-            }
             if (!CPDFPKCS12CertHelper.CheckPKCS12Password(FileNameTxt.Text, PasswordBoxTxt.Password))
             {
-                ErrorTipsText.Text = "Password is incorrect.";
+                ErrorTipsText.Text = "Invalid Password.";
                 return;
             }
 
@@ -51,5 +53,39 @@ namespace Compdfkit_Tools.PDFControl
                 FileNameTxt.Text = filePath;
             }
         }
+
+        private void PasswordBoxTxt_OnPasswordChanged(object sender, RoutedEventArgs e)
+        {
+            PasswordBox passwordBox = (PasswordBox)sender;
+
+            if (passwordBox.Password.Length > 0)
+            {
+                PasswordTextBlock.Visibility = Visibility.Hidden;
+            }
+            else
+            {
+                PasswordTextBlock.Visibility = Visibility.Visible;
+            }
+            CanContinue = FileNameTxt.Text.Length > 0 && PasswordBoxTxt.Password.Length > 0;
+        }
+        
+        private void FileNameTxt_OnTextChanged(object sender, TextChangedEventArgs e)
+        {
+            CanContinue = FileNameTxt.Text.Length > 0 && PasswordBoxTxt.Password.Length > 0;
+        }
+
+        protected void UpdateProper<T>(ref T properValue,
+            T newValue,
+            [CallerMemberName] string properName = "")
+        {
+            if (object.Equals(properValue, newValue))
+                return;
+
+            properValue = newValue;
+            OnPropertyChanged(properName);
+        }
+
+        protected void OnPropertyChanged([CallerMemberName] string propertyName = "") =>
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
     }
 }

+ 3 - 3
Demo/Examples/Compdfkit_Tools/DigitalSignature/CPDFSignatureListControl/CPDFSignatureListControl.xaml.cs

@@ -42,12 +42,12 @@ namespace Compdfkit_Tools.DigitalSignature.CPDFSignatureListControl
             DataContext = this;
             popContextMenu = new ContextMenu();
             MenuItem viewSignatureDetailsMenu = new MenuItem();
-            viewSignatureDetailsMenu.Header = "View Signature Details";
+            viewSignatureDetailsMenu.Header = "Signature Details";
             viewSignatureDetailsMenu.Click += ViewSignatureDetailsMenu_Click;
             popContextMenu.Items.Add(viewSignatureDetailsMenu);
             
             MenuItem viewCertificateDetailsMenu = new MenuItem();
-            viewCertificateDetailsMenu.Header = "View Certificate Details";
+            viewCertificateDetailsMenu.Header = "Certificate Details";
             viewCertificateDetailsMenu.Click += ViewCertificateDetailsMenu_Click;
             popContextMenu.Items.Add(viewCertificateDetailsMenu);
             
@@ -69,7 +69,7 @@ namespace Compdfkit_Tools.DigitalSignature.CPDFSignatureListControl
         private void DeleteMenu_Click(object sender, RoutedEventArgs e)
         {
             // custom button content
-            string messageBoxText = "Are you sure you want to delete this signature?";
+            string messageBoxText = "Are you sure to delete it?";
             string caption = "Delete Signature";
             MessageBoxButton button = MessageBoxButton.OKCancel;
             MessageBoxImage icon = MessageBoxImage.Warning;

+ 3 - 3
Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureControl.xaml

@@ -82,9 +82,9 @@
                     <ColumnDefinition Width="*"></ColumnDefinition>
                     <ColumnDefinition Width="auto"></ColumnDefinition>
                 </Grid.ColumnDefinitions>
-                <TextBlock FontSize="14" Margin="0,3,0,0">Contains Text</TextBlock>
+                <TextBlock FontSize="14" Margin="0,3,0,0">Include Text</TextBlock>
                 <StackPanel Margin="00,0,20,0" Grid.Column="1" Orientation="Horizontal">
-                    <TextBlock FontSize="14" VerticalAlignment="Center" Margin="0,0,8,0">Text Direction</TextBlock>
+                    <TextBlock FontSize="14" VerticalAlignment="Center" Margin="0,0,8,0">Alignment</TextBlock>
                     <ToggleButton Name="TextAlignLeftBtn" Style="{StaticResource ToggleButtonStyle}" BorderThickness="0" Width="73" Height="30" 
                             IsChecked="True" Click="TextAlignBtn_Click">
                         <Path Fill="Black">
@@ -167,7 +167,7 @@
 
                 <Button x:Name="CancelBtn" Grid.Column="3" Height="32" Width="82" Style="{StaticResource LightButtonStyle}"
                         Background="#DFE9FF" BorderThickness="0" Click="CancelBtn_Click">Cancel</Button>
-                <Button x:Name="ContinueBtn" Grid.Column="4" Margin="10,0,25,0" Height="32" Width="97" Style="{StaticResource ButtonStyle}" Click="ContinueBtn_Click">Continue</Button>
+                <Button x:Name="ContinueBtn" Grid.Column="4" Margin="10,0,25,0" Height="32" Width="97" Style="{StaticResource ButtonStyle}" Click="ContinueBtn_Click">Next</Button>
             </Grid>
         </Grid>
         

+ 1 - 0
Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureControl.xaml.cs

@@ -552,6 +552,7 @@ namespace Compdfkit_Tools.PDFControl
 
             if (Document.WriteSignatureToFilePath(signatureWidget, filePath, SignaturePath, Password, location, reason, CPDFSignaturePermissions.CPDFSignaturePermissionsNone))
             {
+                signatureCertificate.AddToTrustedCertificates();
                 AfterFillSignature?.Invoke(sender, filePath);
             }
 

+ 3 - 3
Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/CertificateDetailControl.xaml

@@ -15,7 +15,7 @@
             <ScrollViewer Margin="0,10,0,0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                 <StackPanel VerticalAlignment="Center" Margin="20,0,0,0">
                     <StackPanel Orientation="Horizontal" Margin="0,0,0,6">
-                        <TextBlock Text="Versions: " Foreground="Black" FontSize="14"></TextBlock>
+                        <TextBlock Text="Version: " Foreground="Black" FontSize="14"></TextBlock>
                         <TextBlock x:Name="AwardTxt" Text="{Binding Version}" Foreground="#666"  FontSize="14" Width="300" TextWrapping="Wrap"></TextBlock>
                     </StackPanel>
 
@@ -40,12 +40,12 @@
                     </StackPanel>
                     
                     <StackPanel Orientation="Horizontal" Margin="0,0,0,6">
-                        <TextBlock Text="Validity from: " Foreground="Black" FontSize="14"></TextBlock>
+                        <TextBlock Text="Valid from: " Foreground="Black" FontSize="14"></TextBlock>
                         <TextBlock x:Name="ValidityFromTxt" Text="{Binding ValidityFrom}" Foreground="#666"  FontSize="14" Width="300" TextWrapping="Wrap"></TextBlock>
                     </StackPanel>
                     
                     <StackPanel Orientation="Horizontal" Margin="0,0,0,6">
-                        <TextBlock Text="Validity to: " Foreground="Black" FontSize="14"></TextBlock>
+                        <TextBlock Text="Valid to: " Foreground="Black" FontSize="14"></TextBlock>
                         <TextBlock x:Name="ValidityToTxt" Text="{Binding ValidityTo}" Foreground="#666"  FontSize="14" Width="300" TextWrapping="Wrap"></TextBlock>
                     </StackPanel>
                     

+ 1 - 1
Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/ConfidenceControl.xaml

@@ -58,6 +58,6 @@
 
             </StackPanel>
         </Border>
-        <Button Grid.Row="1" Content="Click to add a creditable certificate" IsEnabled="{Binding IsTrusted, Converter={StaticResource ReverseBoolConverter}}" Click="ButtonBase_OnClick" Height="32" Width="230" HorizontalAlignment="Right" Margin="0,0,12,12"></Button>
+        <Button Grid.Row="1" Content="Add to Trusted Certificates" IsEnabled="{Binding IsTrusted, Converter={StaticResource ReverseBoolConverter}}" Click="TrustCertificateButton_OnClick" Height="32" Width="230" HorizontalAlignment="Right" Margin="0,0,12,12"></Button>
     </Grid>
 </UserControl>

+ 1 - 1
Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/ConfidenceControl.xaml.cs

@@ -74,7 +74,7 @@ namespace Compdfkit_Tools.PDFControl
         protected void OnPropertyChanged([CallerMemberName] string propertyName = "") =>
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
         
-        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
+        private void TrustCertificateButton_OnClick(object sender, RoutedEventArgs e)
         {
             cpdfCertificate.AddToTrustedCertificates();
             VerifyCertificate();

+ 2 - 2
Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/SummaryControl.xaml

@@ -24,12 +24,12 @@
                     </StackPanel>
 
                     <StackPanel Orientation="Horizontal" Margin="0,0,0,6">
-                        <TextBlock Text="Validity from: " Foreground="Black"  FontSize="14"></TextBlock>
+                        <TextBlock Text="Valid from: " Foreground="Black"  FontSize="14"></TextBlock>
                         <TextBlock Text="{Binding ValidityFrom}" Foreground="#666"  FontSize="14"></TextBlock>
                     </StackPanel>
                     
                     <StackPanel Orientation="Horizontal" Margin="0,0,0,6">
-                        <TextBlock Text="Validity to: " Foreground="Black"  FontSize="14"></TextBlock>
+                        <TextBlock Text="Valid to: " Foreground="Black"  FontSize="14"></TextBlock>
                         <TextBlock Text="{Binding ValidityTo}" Foreground="#666"  FontSize="14"></TextBlock>
                     </StackPanel>
 

+ 7 - 4
Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/ViewCertificateDialog.xaml

@@ -13,17 +13,18 @@
     
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="36"></RowDefinition>
+            <RowDefinition Height="56"></RowDefinition>
             <RowDefinition></RowDefinition>
+            <RowDefinition Height="56"></RowDefinition>
         </Grid.RowDefinitions>
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="240"></ColumnDefinition>
             <ColumnDefinition></ColumnDefinition>
         </Grid.ColumnDefinitions>
 
-        <TextBlock Grid.ColumnSpan="2" Margin="10" Foreground="#666666" Text="Browse digital ID files. Digital ID files are password protected. If you do not know its password, you cannot access the digital ID card."></TextBlock>
+        <TextBlock Grid.ColumnSpan="2" Margin="10,20,10,20" Foreground="#666666" Text="Browse digital ID files. Digital ID files are password protected. If you do not know its password, you cannot access the digital ID card."></TextBlock>
 
-        <ListView Grid.Row="1" Grid.Column="0" x:Name="CertificateListView" SelectionChanged="CertificateListView_OnSelectionChanged">
+        <ListView Grid.Row="1" Grid.Column="0" x:Name="CertificateListView" Margin="10,0,10,0" SelectionChanged="CertificateListView_OnSelectionChanged">
             <ListView.ItemsPanel>
                 <ItemsPanelTemplate>
                     <VirtualizingStackPanel Background="#FAFCFF" Margin="-5,0,0,0"/>
@@ -40,7 +41,9 @@
         </ListView>
         
         <Grid Grid.Row="1" Grid.Column="1">
-            <local:CertificateInfoControl x:Name="CertificateInfoControl"></local:CertificateInfoControl>
+            <local:CertificateInfoControl BorderBrush="#999999" Margin="0,0,10,0" BorderThickness="1" x:Name="CertificateInfoControl"></local:CertificateInfoControl>
         </Grid>
+        
+        <Button Grid.Row="2" Grid.ColumnSpan="2" Height="32" Width="112" HorizontalAlignment="Right" Margin="10" Click="ButtonBase_OnClick">Close</Button>
     </Grid>
 </Window>

+ 5 - 0
Demo/Examples/Compdfkit_Tools/DigitalSignature/ViewCertificationControl/ViewCertificateDialog.xaml.cs

@@ -43,6 +43,11 @@ namespace Compdfkit_Tools.PDFControl
                 CertificateInfoControl.LoadCertificateInfo(certificateList[index]);
             }
         }
+
+        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
     }
     
     public class DictionaryValueConverter : IValueConverter