Browse Source

compdfkit(win) - 密码框,批量加密功能UI

weixiangjie 1 year ago
parent
commit
c04adab145
20 changed files with 745 additions and 1 deletions
  1. 32 0
      Demo/Examples/Compdfkit_Tools/Asset/Styles/EyeCheckBoxStyle.xaml
  2. 36 0
      Demo/Examples/Compdfkit_Tools/Asset/Styles/RoundCornerPasswordBoxStyle.xaml
  3. 42 0
      Demo/Examples/Compdfkit_Tools/Asset/Styles/RoundCornerTextBoxStyle.xaml
  4. 34 0
      Demo/Examples/Compdfkit_Tools/Common/Convert/AntiBoolToVisibilityConverter.cs
  5. 34 0
      Demo/Examples/Compdfkit_Tools/Common/Convert/AntiStringToVisibilityConverter.cs
  6. 35 0
      Demo/Examples/Compdfkit_Tools/Common/Convert/StringToVisibilityConverter.cs
  7. 56 0
      Demo/Examples/Compdfkit_Tools/Common/Helper/PasswordHelper.cs
  8. 44 0
      Demo/Examples/Compdfkit_Tools/Common/PasswordControl/PasswordBoxControl.xaml
  9. 97 0
      Demo/Examples/Compdfkit_Tools/Common/PasswordControl/PasswordBoxControl.xaml.cs
  10. 27 0
      Demo/Examples/Compdfkit_Tools/Compdfkit_Tools.csproj
  11. 25 0
      Demo/Examples/Compdfkit_Tools/Encryption/EncryptionDialog.xaml
  12. 32 0
      Demo/Examples/Compdfkit_Tools/Encryption/EncryptionDialog.xaml.cs
  13. 83 0
      Demo/Examples/Compdfkit_Tools/Encryption/EncryptionFileListControl.xaml
  14. 88 0
      Demo/Examples/Compdfkit_Tools/Encryption/EncryptionFileListControl.xaml.cs
  15. 12 0
      Demo/Examples/Compdfkit_Tools/Encryption/OwnerPasswordControl.xaml
  16. 12 0
      Demo/Examples/Compdfkit_Tools/Encryption/OwnerPasswordControl.xaml.cs
  17. 36 0
      Demo/Examples/Compdfkit_Tools/Encryption/UserPasswordControl.xaml
  18. 12 0
      Demo/Examples/Compdfkit_Tools/Encryption/UserPasswordControl.xaml.cs
  19. 2 0
      Demo/Examples/Viewer/MainWindow.xaml
  20. 6 1
      Demo/Examples/Viewer/MainWindow.xaml.cs

File diff suppressed because it is too large
+ 32 - 0
Demo/Examples/Compdfkit_Tools/Asset/Styles/EyeCheckBoxStyle.xaml


+ 36 - 0
Demo/Examples/Compdfkit_Tools/Asset/Styles/RoundCornerPasswordBoxStyle.xaml

@@ -0,0 +1,36 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <Style TargetType="PasswordBox" x:Key="RoundCornerPasswordBoxStyle">
+        <Setter Property="Height" Value="36"/>
+        <Setter Property="FontSize" Value="14"/>
+        <Setter Property="Padding" Value="15,0,30,0"/>
+        <Setter Property="Background" Value="Transparent"></Setter>
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="PasswordBox">
+                    <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" 
+                                    BorderThickness="{TemplateBinding BorderThickness}" 
+                                    Background="{TemplateBinding Background}" 
+                                    SnapsToDevicePixels="True"
+                                    CornerRadius="3">
+                        <ScrollViewer x:Name="PART_ContentHost" Focusable="false"
+                                                  HorizontalScrollBarVisibility="Hidden" 
+                                                  VerticalScrollBarVisibility="Hidden"
+                                                  VerticalAlignment="Center" MinHeight="20"/>
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsEnabled" Value="false">
+                            <Setter Property="Opacity" TargetName="Border" Value="0.56"/>
+                        </Trigger>
+                        <Trigger Property="IsMouseOver" Value="true">
+                            <Setter Property="BorderBrush" TargetName="Border" Value="#FF7EB4EA"/>
+                        </Trigger>
+                        <Trigger Property="IsKeyboardFocused" Value="true">
+                            <Setter Property="BorderBrush" TargetName="Border" Value="#FF569DE5"/>
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+</ResourceDictionary>

+ 42 - 0
Demo/Examples/Compdfkit_Tools/Asset/Styles/RoundCornerTextBoxStyle.xaml

@@ -0,0 +1,42 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <Style TargetType="TextBox" x:Key="RoundCornerTextBox">
+        <Setter Property="Height" Value="36"/>
+        <Setter Property="FontSize" Value="14"/>
+        <Setter Property="Padding" Value="15,0,15,0"/>
+        <Setter Property="Background" Value="Transparent"></Setter>
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="TextBox">
+                    <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" 
+                                    BorderThickness="{TemplateBinding BorderThickness}" 
+                                    Background="{TemplateBinding Background}" 
+                                    SnapsToDevicePixels="True"
+                                    CornerRadius="3">
+                        <ScrollViewer x:Name="PART_ContentHost" Focusable="false"
+                                                  HorizontalScrollBarVisibility="Hidden" 
+                                                  VerticalScrollBarVisibility="Hidden"
+                                                  VerticalAlignment="Center" MinHeight="20"/>
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsEnabled" Value="false">
+                            <Setter Property="Opacity" TargetName="Border" Value="0.56"/>
+                        </Trigger>
+                        <Trigger Property="IsMouseOver" Value="true">
+                            <Setter Property="BorderBrush" TargetName="Border" Value="#FF7EB4EA"/>
+                        </Trigger>
+                        <Trigger Property="IsKeyboardFocused" Value="true">
+                            <Setter Property="BorderBrush" TargetName="Border" Value="#FF569DE5"/>
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+
+    <Style TargetType="TextBox" x:Key="AccountTextBoxStyle" BasedOn="{StaticResource RoundCornerTextBox}"></Style>
+    
+    <Style TargetType="TextBox" x:Key="PasswordTextBoxStyle" BasedOn="{StaticResource RoundCornerTextBox}">
+        <Setter Property="Padding" Value="15,0,30,0"/>
+    </Style>
+</ResourceDictionary>

+ 34 - 0
Demo/Examples/Compdfkit_Tools/Common/Convert/AntiBoolToVisibilityConverter.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows;
+
+namespace Compdfkit_Tools.Common
+{
+    [ValueConversion(typeof(bool), typeof(Visibility))]
+    class AntiBoolToVisibilityConverter : IValueConverter
+    {
+        #region IValueConverter Members
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if ((bool)value == false)
+            {
+                return Visibility.Visible;
+            }
+            else
+            {
+                return Visibility.Hidden;
+            }
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            return null;
+        }
+        #endregion
+    }
+}

+ 34 - 0
Demo/Examples/Compdfkit_Tools/Common/Convert/AntiStringToVisibilityConverter.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows;
+
+namespace Compdfkit_Tools.Common
+{
+    [ValueConversion(typeof(string), typeof(Visibility))]
+    class AntiStringToVisibilityConverter : IValueConverter
+    {
+        #region IValueConverter Members
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if ((value as string) != string.Empty)
+            {
+                return Visibility.Visible;
+            }
+            else
+            {
+                return Visibility.Collapsed;
+            }
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            return null;
+        }
+        #endregion
+    }
+}

+ 35 - 0
Demo/Examples/Compdfkit_Tools/Common/Convert/StringToVisibilityConverter.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows;
+
+namespace Compdfkit_Tools.Common
+{
+    [ValueConversion(typeof(string), typeof(Visibility))]
+    class StringToVisibilityConverter : IValueConverter
+    {
+        #region IValueConverter Members
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if ((value as string) == string.Empty)
+            {
+                return Visibility.Visible;
+            }
+            else
+            {
+                return Visibility.Collapsed;
+            }
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            return null;
+        }
+        #endregion
+
+    }
+}

+ 56 - 0
Demo/Examples/Compdfkit_Tools/Common/Helper/PasswordHelper.cs

@@ -0,0 +1,56 @@
+using System.Windows;
+using System.Windows.Controls;
+
+namespace PasswordBoxPlus.Helper
+{
+    public class PasswordHelper
+    {
+        public static readonly DependencyProperty PasswordProperty = DependencyProperty.RegisterAttached("Password", typeof(string), typeof(PasswordHelper),
+            new PropertyMetadata(new PropertyChangedCallback(OnPropertyChanged)));
+
+        public static string GetPassword(DependencyObject d)
+        {
+            return (string)d.GetValue(PasswordProperty);
+        }
+        public static void SetPassword(DependencyObject d, string value)
+        {
+            d.SetValue(PasswordProperty, value);
+        }
+
+        public static readonly DependencyProperty AttachProperty = DependencyProperty.RegisterAttached("Attach", typeof(string), typeof(PasswordHelper),
+            new PropertyMetadata(new PropertyChangedCallback(OnAttachChanged)));
+
+        public static string GetAttach(DependencyObject d)
+        {
+            return (string)d.GetValue(AttachProperty);
+        }
+        public static void SetAttach(DependencyObject d, string value)
+        {
+            d.SetValue(AttachProperty, value);
+        }
+
+        static bool isUpdating = false;
+        private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            PasswordBox passwordBox = d as PasswordBox;
+            passwordBox.PasswordChanged -= passwordBox_PasswordChanged;
+            if (!isUpdating)
+                (d as PasswordBox).Password = e.NewValue.ToString();
+            passwordBox.PasswordChanged += passwordBox_PasswordChanged;
+        }
+
+        private static void OnAttachChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            PasswordBox passwordBox = d as PasswordBox;
+            passwordBox.PasswordChanged += passwordBox_PasswordChanged;
+        }
+
+        private static void passwordBox_PasswordChanged(object sender, RoutedEventArgs e)
+        {
+            PasswordBox passwordBox = sender as PasswordBox;
+            isUpdating = true;
+            SetPassword(passwordBox, passwordBox.Password);
+            isUpdating = false;
+        }
+    }
+}

+ 44 - 0
Demo/Examples/Compdfkit_Tools/Common/PasswordControl/PasswordBoxControl.xaml

@@ -0,0 +1,44 @@
+<UserControl x:Class="Compdfkit_Tools.Common.PasswordBoxControl"
+             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:helper="clr-namespace:PasswordBoxPlus.Helper"
+             mc:Ignorable="d" 
+            xmlns:common="clr-namespace:Compdfkit_Tools.Common"
+            d:DesignHeight="36" d:DesignWidth="200">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <common:AntiStringToVisibilityConverter x:Key="AntiStringToVisibilityConverter"></common:AntiStringToVisibilityConverter>
+            <common:StringToVisibilityConverter x:Key="StringToVisibilityConverter"></common:StringToVisibilityConverter>
+            <common:BoolToVisibleConverter x:Key="BoolToVisibilityConverter"></common:BoolToVisibleConverter>
+            <common:AntiBoolToVisibilityConverter x:Key="AntiBoolToVisibilityConverter"></common:AntiBoolToVisibilityConverter>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../Asset/Styles/RoundCornerPasswordBoxStyle.xaml"></ResourceDictionary>
+                <ResourceDictionary Source="../../Asset/Styles/RoundCornerTextBoxStyle.xaml"></ResourceDictionary>
+                <ResourceDictionary Source="../../Asset/Styles/EyeCheckBoxStyle.xaml"></ResourceDictionary>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid x:Name="Grid">
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition></ColumnDefinition>
+            <ColumnDefinition Width="24"></ColumnDefinition>
+        </Grid.ColumnDefinitions>
+        <PasswordBox x:Name="PasswordBox" Grid.ColumnSpan="2" Style="{StaticResource RoundCornerPasswordBoxStyle}" 
+                     helper:PasswordHelper.Attach="true" helper:PasswordHelper.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
+                     Visibility="{Binding ElementName=DisplayPasswordChk, Path=IsChecked, Converter={StaticResource AntiBoolToVisibilityConverter}}">
+        </PasswordBox>
+
+        <TextBox Grid.ColumnSpan="2" x:Name="TextBox" Style="{StaticResource PasswordTextBoxStyle}" 
+                 Visibility="{Binding ElementName=DisplayPasswordChk, Path=IsChecked, Converter={StaticResource BoolToVisibilityConverter}}" 
+                 Text="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="TextBox_TextChanged">
+        </TextBox>
+
+        <TextBlock x:Name="TextBlock" IsHitTestVisible="False" Text="{Binding Watermark, RelativeSource={RelativeSource AncestorType=UserControl}}"
+                   VerticalAlignment="Center" FontSize="14" Margin="20,0,0,0" Foreground="#BBB" 
+                   Visibility="{Binding Password, Converter={StaticResource StringToVisibilityConverter}}">
+        </TextBlock>
+        <CheckBox x:Name="DisplayPasswordChk" Style="{StaticResource EyeCheckBoxStyle}" Visibility="{Binding Password, Converter={StaticResource AntiStringToVisibilityConverter}}" Height="16" Grid.Column="1" HorizontalAlignment="Left" Panel.ZIndex="1" IsChecked="False"></CheckBox>
+    </Grid>
+</UserControl>

+ 97 - 0
Demo/Examples/Compdfkit_Tools/Common/PasswordControl/PasswordBoxControl.xaml.cs

@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Compdfkit_Tools.Common
+{
+    /// <summary>
+    /// Interaction logic for PasswordControl.xaml
+    /// </summary>
+    public partial class PasswordBoxControl : UserControl, INotifyPropertyChanged
+    {
+        public static readonly DependencyProperty WatermarkProperty =
+    DependencyProperty.Register("Watermark", typeof(string), typeof(PasswordBoxControl), new PropertyMetadata(null));
+        public string Watermark
+        {
+            get { return (string)GetValue(WatermarkProperty); }
+            set { SetValue(WatermarkProperty, value); }
+        }
+
+        public static readonly DependencyProperty PasswordProperty =
+DependencyProperty.Register("Password", typeof(string), typeof(PasswordBoxControl), new PropertyMetadata(string.Empty));
+        public string Password
+        {
+            get { return (string)GetValue(PasswordProperty); }
+            set { SetValue(PasswordProperty, value); }
+        }
+
+        #region - 用于绑定ViewModel部分 -
+
+        public ICommand Command
+        {
+            get { return (ICommand)GetValue(CommandProperty); }
+            set { SetValue(CommandProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty CommandProperty =
+            DependencyProperty.Register("Command", typeof(ICommand), typeof(PasswordBoxControl), new PropertyMetadata(default(ICommand)));
+
+        public object CommandParameter
+        {
+            get { return (object)GetValue(CommandParameterProperty); }
+            set { SetValue(CommandParameterProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty CommandParameterProperty =
+            DependencyProperty.Register("CommandParameter", typeof(object), typeof(PasswordBoxControl), new PropertyMetadata(default(object)));
+
+        public IInputElement CommandTarget { get; set; }
+
+        #endregion
+
+        public static readonly RoutedEvent PasswordChangedEvent =
+        EventManager.RegisterRoutedEvent("PasswordChanged", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PasswordBoxControl));
+
+        public event RoutedEventHandler PasswordChanged
+        {
+            add => AddHandler(PasswordChangedEvent, value);
+            remove => RemoveHandler(PasswordChangedEvent, value);
+        }
+
+        public PasswordBoxControl()
+        {
+            InitializeComponent();
+            Grid.DataContext = this;
+        }
+
+
+        public event PropertyChangedEventHandler PropertyChanged;
+        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+        }
+
+        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (Password == string.Empty)
+            {
+                DisplayPasswordChk.IsChecked = false;
+            }
+        }
+    }
+}

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

@@ -123,10 +123,13 @@
       <DependentUpon>PageNumberControl.xaml</DependentUpon>
     </Compile>
     <Compile Include="Common\Convert\AnnotArgsTypeToVisibilityConverter.cs" />
+    <Compile Include="Common\Convert\AntiBoolToVisibilityConverter.cs" />
+    <Compile Include="Common\Convert\AntiStringToVisibilityConverter.cs" />
     <Compile Include="Common\Convert\CaptionHeightConverter.cs" />
     <Compile Include="Common\Convert\IntAndTagToBoolMultiBinding.cs" />
     <Compile Include="Common\Convert\ReverseBoolConverter.cs" />
     <Compile Include="Common\Convert\ReverseVisibilityConverter.cs" />
+    <Compile Include="Common\Convert\StringToVisibilityConverter.cs" />
     <Compile Include="Common\Convert\ShowDefaultCloseButtonConverter.cs" />
     <Compile Include="Common\Convert\ShowIconConverter.cs" />
     <Compile Include="Common\Convert\WindowStateToPathConverter.cs" />
@@ -134,6 +137,10 @@
     <Compile Include="Common\DeviceSerial\DeviceSerialControl.xaml.cs">
       <DependentUpon>DeviceSerialControl.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Common\Helper\PasswordHelper.cs" />
+    <Compile Include="Common\PasswordControl\PasswordBoxControl.xaml.cs">
+      <DependentUpon>PasswordBoxControl.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Common\HomePage\FeaturesListControl.xaml.cs">
       <DependentUpon>FeaturesListControl.xaml</DependentUpon>
     </Compile>
@@ -312,6 +319,18 @@
     <Compile Include="Common\BarControl\FormBarControl.xaml.cs">
       <DependentUpon>FormBarControl.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Encryption\EncryptionDialog.xaml.cs">
+      <DependentUpon>EncryptionDialog.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Encryption\EncryptionFileListControl.xaml.cs">
+      <DependentUpon>EncryptionFileListControl.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Encryption\OwnerPasswordControl.xaml.cs">
+      <DependentUpon>OwnerPasswordControl.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Encryption\UserPasswordControl.xaml.cs">
+      <DependentUpon>UserPasswordControl.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Form\FormControl\FormControl.xaml.cs">
       <DependentUpon>FormControl.xaml</DependentUpon>
     </Compile>
@@ -535,6 +554,7 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="Asset\Styles\EyeCheckBoxStyle.xaml" />
     <Page Include="Asset\Styles\ListBoxItemStyle.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -547,6 +567,8 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Asset\Styles\RoundCornerPasswordBoxStyle.xaml" />
+    <Page Include="Asset\Styles\RoundCornerTextBoxStyle.xaml" />
     <Page Include="Asset\Styles\SliderStyle.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -588,6 +610,7 @@
       <SubType>Designer</SubType>
     </Page>
     <Page Include="Common\DeviceSerial\DeviceSerialControl.xaml" />
+    <Page Include="Common\PasswordControl\PasswordBoxControl.xaml" />
     <Page Include="Common\HomePage\FeaturesListControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -805,6 +828,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Encryption\EncryptionDialog.xaml" />
+    <Page Include="Encryption\EncryptionFileListControl.xaml" />
+    <Page Include="Encryption\OwnerPasswordControl.xaml" />
+    <Page Include="Encryption\UserPasswordControl.xaml" />
     <Page Include="Form\FormControl\FormControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

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

@@ -0,0 +1,25 @@
+<Window x:Class="Compdfkit_Tools.PDFControl.EncryptionDialog"
+        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"
+        Title="Batch Encryption" Height="504" Width="1052">
+    <Grid Margin="10">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto"></RowDefinition>
+            <RowDefinition Height="Auto"></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="Auto"></ColumnDefinition>
+            <ColumnDefinition Width="Auto"></ColumnDefinition>
+        </Grid.ColumnDefinitions>
+        
+        <local:EncryptionFileListControl Width="646" Height="364"></local:EncryptionFileListControl>
+        <StackPanel Grid.Row="0" Grid.Column="1" Margin="0,52.5,0,0">
+            <local:UserPasswordControl></local:UserPasswordControl>
+        </StackPanel>
+    </Grid>
+</Window>

+ 32 - 0
Demo/Examples/Compdfkit_Tools/Encryption/EncryptionDialog.xaml.cs

@@ -0,0 +1,32 @@
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
+
+namespace Compdfkit_Tools.PDFControl
+{
+    public partial class EncryptionDialog : Window
+    {
+        public EncryptionDialog()
+        {
+            InitializeComponent();
+        }
+        
+    }
+    
+    public class FileNumConverter: System.Windows.Data.IValueConverter
+    {
+        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
+        {
+            return $"Total {value} Files";
+        }
+
+        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
+        {
+            return null;
+        }
+    }
+}

+ 83 - 0
Demo/Examples/Compdfkit_Tools/Encryption/EncryptionFileListControl.xaml

@@ -0,0 +1,83 @@
+<UserControl x:Class="Compdfkit_Tools.PDFControl.EncryptionFileListControl"
+             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"
+             xmlns:pdfControl="clr-namespace:Compdfkit_Tools.PDFControl"
+             mc:Ignorable="d"
+             d:DesignHeight="364" d:DesignWidth="646">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <pdfControl:FileNumConverter x:Key="FileNumConverter"></pdfControl:FileNumConverter>
+            <Style x:Key="CustomDataGridStyle" TargetType="DataGrid">
+                <Setter Property="BorderBrush" Value="#E6E6E6" />
+                <Setter Property="BorderThickness" Value="1" />
+                <Setter Property="CellStyle">
+                    <Setter.Value>
+                        <Style TargetType="DataGridCell">
+                            <Setter Property="BorderThickness" Value="1" />
+                            <Setter Property="BorderBrush" Value="#E6E6E6" />
+                        </Style>
+                    </Setter.Value>
+                </Setter>
+            </Style>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid Margin="10,10,4,10">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto"></RowDefinition>
+            <RowDefinition Height="*"></RowDefinition>
+            <RowDefinition Height="Auto"></RowDefinition>
+        </Grid.RowDefinitions>
+        
+        <DockPanel Grid.Row="0" Grid.Column="0" Margin="0,10,0,10">
+            <Button Content="Add Files" FontFamily="Segoe UI" FontSize="14" Padding="28,6,27,6" HorizontalAlignment="Left" Click="AddFiles_Click"></Button>
+            <TextBlock FontFamily="Segoe UI" FontSize="14" Text="{Binding FileNum, Converter={StaticResource FileNumConverter} }" HorizontalAlignment="Right"></TextBlock>
+        </DockPanel>
+        
+        <Border Grid.Row="1" Grid.Column="0" BorderBrush="#CCCCCC" BorderThickness="1">
+            <Grid Margin="10">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="*"></RowDefinition>
+                    <RowDefinition Height="auto"></RowDefinition>
+                </Grid.RowDefinitions>
+                 <Grid Grid.Row="0">
+                     <DataGrid Background="White" BorderBrush="#E6E6E6" x:Name="FileDataGrid" HeadersVisibility="Column"
+                               IsReadOnly="True" AutoGenerateColumns="False" FontSize="14" SelectionMode="Extended"
+                               ScrollViewer.CanContentScroll="False" HorizontalScrollBarVisibility="Auto">
+                         <DataGrid.Columns>
+                             <DataGridTextColumn Header="File" Width="*" Binding="{Binding FileName}" />
+                             <DataGridTextColumn Header="Size" Width="*" Binding="{Binding Size}" />
+                             <DataGridTextColumn Header="Location" Width="*" Binding="{Binding Location}" />
+                         </DataGrid.Columns>
+                         <DataGrid.Resources>
+                             <Style TargetType="DataGrid">
+                                 <Setter Property="HorizontalGridLinesBrush" Value="#E6E6E6" />
+                                 <Setter Property="VerticalGridLinesBrush" Value="#E6E6E6" />
+                             </Style>
+                             <Style TargetType="DataGridColumnHeader">
+                                 <Setter Property="Foreground" Value="#666666" />
+                                 <Setter Property="FontFamily" Value="Segoe UI" />
+                                 <Setter Property="FontSize" Value="12" />
+                             </Style>
+                             <Style TargetType="DataGridCell">
+                                 <Setter Property="FontFamily" Value="Segoe UI" />
+                                 <Setter Property="FontSize" Value="12" />
+                                 <Setter Property="Foreground" Value="#666666" />
+                                 <Setter Property="BorderThickness" Value="0"></Setter>
+                                 <Style.Triggers>
+                                     <Trigger Property="IsSelected" Value="True">
+                                         <Setter Property="Background" Value="#0078D7" />
+                                         <Setter Property="Foreground" Value="White" />
+                                     </Trigger>
+                                 </Style.Triggers>
+                             </Style>
+                         </DataGrid.Resources>
+                     </DataGrid>
+                </Grid>
+                <Button Grid.Row="1" FontFamily="Segoe UI" FontSize="14" Margin="0,10,0,0" Content="Remove" Width="112" Height="32" HorizontalAlignment="Left" Click="Remove_Click"></Button>
+            </Grid>
+        </Border>
+    </Grid>
+</UserControl>

+ 88 - 0
Demo/Examples/Compdfkit_Tools/Encryption/EncryptionFileListControl.xaml.cs

@@ -0,0 +1,88 @@
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using Microsoft.Win32;
+
+namespace Compdfkit_Tools.PDFControl
+{
+    public partial class EncryptionFileListControl : UserControl, INotifyPropertyChanged
+    {
+        public class FileInfoData
+        {
+            public string FileName { get; set; }
+            public string Size { get; set; }
+            public string Location { get; set; }
+        };
+        
+        public event PropertyChangedEventHandler PropertyChanged;
+        private ObservableCollection<FileInfoData> _fileInfoDataList = new ObservableCollection<FileInfoData>();
+        
+        public int FileNum => _fileInfoDataList.Count;
+        public EncryptionFileListControl()
+        {
+            InitializeComponent();
+            DataContext = this;
+            FileDataGrid.ItemsSource = _fileInfoDataList;
+        }
+        
+        private void AddFiles_Click(object sender, RoutedEventArgs e)
+        {
+            var dialog = new OpenFileDialog();
+            dialog.Multiselect = true;
+            dialog.Filter = @"PDF Files (*.pdf)|*.pdf";
+            dialog.ShowDialog();
+            dialog.Multiselect = true;
+
+            foreach (var fileName in dialog.FileNames)
+            {
+                var file = new FileInfo(fileName);
+                var fileInfoData = new FileInfoData()
+                {
+                    FileName = file.Name,
+                    Size = GetSizeFromBytes(file.Length),
+                    Location = file.FullName
+                };
+                
+                if (_fileInfoDataList.All(item => item.Location != fileInfoData.Location))
+                {
+                    _fileInfoDataList.Add(fileInfoData);
+                }
+            }
+
+            OnPropertyChanged("FileNum");
+        }
+
+        
+        private string GetSizeFromBytes(long bytes)
+        {
+            string[] sizes = { "B", "KB", "MB", "GB", "TB" };
+            double len = bytes;
+            int order = 0;
+            while (len >= 1024 && order < sizes.Length - 1)
+            {
+                order++;
+                len /= 1024;
+            }
+            return $"{len:0.##} {sizes[order]}";
+        }
+
+        private void Remove_Click(object sender, RoutedEventArgs e)
+        {
+            var selectedItems = FileDataGrid.SelectedItems;
+            var selectedItemsList = selectedItems.Cast<FileInfoData>().ToList();
+            foreach (var item in selectedItemsList)
+            {
+                _fileInfoDataList.Remove(item);
+            }
+            OnPropertyChanged("FileNum");
+        }
+        
+        protected virtual void OnPropertyChanged(string propertyName = null)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+        }
+    }
+}

+ 12 - 0
Demo/Examples/Compdfkit_Tools/Encryption/OwnerPasswordControl.xaml

@@ -0,0 +1,12 @@
+<UserControl x:Class="Compdfkit_Tools.PDFControl.OwnerPasswordControl"
+             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"
+             mc:Ignorable="d"
+             d:DesignHeight="300" d:DesignWidth="300">
+    <Grid>
+        
+    </Grid>
+</UserControl>

+ 12 - 0
Demo/Examples/Compdfkit_Tools/Encryption/OwnerPasswordControl.xaml.cs

@@ -0,0 +1,12 @@
+using System.Windows.Controls;
+
+namespace Compdfkit_Tools.PDFControl
+{
+    public partial class OwnerPasswordControl : UserControl
+    {
+        public OwnerPasswordControl()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 36 - 0
Demo/Examples/Compdfkit_Tools/Encryption/UserPasswordControl.xaml

@@ -0,0 +1,36 @@
+<UserControl x:Class="Compdfkit_Tools.PDFControl.UserPasswordControl"
+             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"
+             xmlns:common="clr-namespace:Compdfkit_Tools.Common"
+             mc:Ignorable="d"
+             Height="130" Width="368">
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="363*"/>
+            <ColumnDefinition Width="5*"/>
+        </Grid.ColumnDefinitions>
+        <Grid Background="White" Margin="20,0,0,0"  Panel.ZIndex="1" Height="20" HorizontalAlignment="Left" VerticalAlignment="Top">
+            <TextBlock Foreground="#001A4E" Text="Open the Documentn" FontWeight="Bold" FontSize="16"></TextBlock>
+        </Grid>
+        <Border Margin="12,10,7,12" BorderBrush="#33000000" BorderThickness="1">
+            <Grid Margin="20,0,20,15">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="*"></RowDefinition>
+                    <RowDefinition Height="Auto"></RowDefinition>
+                </Grid.RowDefinitions>
+                <StackPanel Orientation="Horizontal">
+                    <CheckBox Width="20" Height="20" Margin="0,0,0,0"></CheckBox>
+                    <TextBlock Height="20" FontFamily="Segoe UI" FontSize="14" Text="Require a password to open the document"></TextBlock>
+                </StackPanel>
+
+                <StackPanel Orientation="Horizontal" Grid.Row="1" Margin="20,0,0,-5">
+                    <TextBlock Height="25" FontFamily="Segoe UI" FontSize="14" Text="Open Password"/>
+                    <common:PasswordBoxControl Margin="10,0,0,0" Watermark="Enter Password" Height="41" Width="170"></common:PasswordBoxControl>
+                </StackPanel>
+            </Grid>
+        </Border>
+    </Grid>
+</UserControl>

+ 12 - 0
Demo/Examples/Compdfkit_Tools/Encryption/UserPasswordControl.xaml.cs

@@ -0,0 +1,12 @@
+using System.Windows.Controls;
+
+namespace Compdfkit_Tools.PDFControl
+{
+    public partial class UserPasswordControl : UserControl
+    {
+        public UserPasswordControl()
+        {
+            InitializeComponent();
+        }
+    }
+}

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

@@ -166,6 +166,8 @@
 
                     <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">

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

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