Browse Source

compdfkit(win) - 更正移除密码按钮的enable绑定

weixiangjie 1 year ago
parent
commit
c8dbc50bbe

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Security/Encryption/DecryptionDialog.xaml

@@ -25,7 +25,7 @@
         </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="Remove" Click="Remove_Click" IsEnabled="{Binding  ElementName=FileListControl,Path=IsEnsure}"></Button>
             <Button Width="112" Height="32" FontFamily="Segoe UI" FontSize="14" Content="Cancel" Margin="10,0,10,0" Click="Cancel_Click"></Button>
         </StackPanel>
     </Grid>

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

@@ -14,18 +14,12 @@ namespace Compdfkit_Tools.PDFControl
     {
         private CPDFDocument document;
         private List<string> failedList = new List<string>();
-        public bool CanRemove => FileListControl.FileInfoDataList.Count > 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)

+ 2 - 16
Demo/Examples/Compdfkit_Tools/Security/Encryption/FileGridListControl.xaml.cs

@@ -9,6 +9,7 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Input;
+using Compdfkit_Tools.Helper;
 using Microsoft.Win32;
 
 namespace Compdfkit_Tools.PDFControl
@@ -45,7 +46,6 @@ namespace Compdfkit_Tools.PDFControl
         }
 
         public event PropertyChangedEventHandler PropertyChanged;
-        public event EventHandler FileNumChanged;
         
         private ObservableCollection<FileInfoData> _fileInfoDataList;
 
@@ -88,7 +88,7 @@ namespace Compdfkit_Tools.PDFControl
                 var fileInfoData = new FileInfoData()
                 {
                     FileName = file.Name,
-                    Size = GetSizeFromBytes(file.Length),
+                    Size = CommonHelper.GetFileSize(fileName),
                     Location = file.FullName
                 };
                 
@@ -99,20 +99,6 @@ namespace Compdfkit_Tools.PDFControl
             }
         }
 
-        
-        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)
         {
             if (FileDataGrid.SelectedItems.Count == 0)