Browse Source

合并 - 修复合并功能拖拽加密文档一直loading问题;修复拖拽一个文件添加两条记录问题

ZhouJieSheng 1 year ago
parent
commit
b5a42b42ab

+ 17 - 11
PDF Office/ViewModels/Dialog/ToolsDialogs/MergeDialogViewModel.cs

@@ -245,11 +245,11 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
                 {
                     foreach (var item in listView.ItemsSource)
                     {
-                        var pagerange= listView.ItemContainerGenerator.ContainerFromItem(item) as ListViewItem;
-                        if (pagerange != null) 
+                        var pagerange = listView.ItemContainerGenerator.ContainerFromItem(item) as ListViewItem;
+                        if (pagerange != null)
                         {
-                            var pagerangecombobox= CommonHelper.FindVisualChild<WritableComboBox>(pagerange);
-                            if(pagerangecombobox!=null)
+                            var pagerangecombobox = CommonHelper.FindVisualChild<WritableComboBox>(pagerange);
+                            if (pagerangecombobox != null)
                                 pagerangecombobox.IsloseFocus = false;
                         }
                     }
@@ -326,8 +326,8 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
         }
 
         private void Merge()
-        {
-            
+        {
+
             bool result = true;
             CPDFDocument SaveDoc = CPDFDocument.CreateDocument();
 
@@ -341,7 +341,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
                     return;
                 }
             }
-               
+
             for (int i = 0; i < MergeObjectlist.Count; i++)
             {
                 if (MergeObjectlist[i].SetPageRange == null)
@@ -350,8 +350,8 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
                     alertsMessage.ShowDialog("", App.MainPageLoader.GetString("PageRangeWarning"), App.ServiceLoader.GetString("Text_ok"));
                 }
 
-                    //图片
-                    if (Path.GetExtension(MergeObjectlist[i].FilePath).Trim().ToLower() != ".pdf")
+                //图片
+                if (Path.GetExtension(MergeObjectlist[i].FilePath).Trim().ToLower() != ".pdf")
                 {
                     if (Path.GetExtension(MergeObjectlist[i].FilePath).Trim().ToLower() == ".gif")
                     {//GIF下面方法产生虚影改成与图片转PDF一致
@@ -366,7 +366,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
                         try { if (File.Exists(tempFileName)) File.Delete(tempFileName); }
                         catch
                         { }
-                            if (!result)
+                        if (!result)
                         {
                             SaveDoc.Release();
                             return;
@@ -651,7 +651,12 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
                         }
                         else
                         {
-                            VerifyPasswordResult condition = SecurityHelper.VerifyPasswordByPasswordKind(doc, EnumPasswordKind.StatusPermissionsPassword, dialogs);
+                            VerifyPasswordResult condition = new VerifyPasswordResult();
+                            //切换一下UI线程,避免解密弹窗异常
+                            App.Current.Dispatcher.Invoke(() =>
+                            {
+                                condition = SecurityHelper.VerifyPasswordByPasswordKind(doc, EnumPasswordKind.StatusPermissionsPassword, dialogs);
+                            });
                             if (condition.IsDiscryptied)
                             {
                                 if (condition.Password != null)
@@ -668,6 +673,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
                                 doc.Release();
                                 continue;
                             }
+
                         }
 
                         mergeObject.DocName = doc.FileName;

+ 7 - 6
PDF Office/Views/Dialog/ToolsDialogs/MergeDialog.xaml.cs

@@ -78,12 +78,13 @@ namespace PDF_Master.Views.Dialog.ToolsDialogs
 
         private void MergeView_Drop(object sender, DragEventArgs e)
         {
-            if (IsFile)
-            {
-                DragDropHelper.Drop(this, e);
-                string[] file = (string[])e.Data.GetData(DataFormats.FileDrop);
-                (DataContext as MergeDialogViewModel).AddFiles(file);
-            }
+            //避免和Grid_Drop事件重复触发,V1.2.0测试完成后可以删除
+            //if (IsFile)
+            //{
+            //    DragDropHelper.Drop(this, e);
+            //    string[] file = (string[])e.Data.GetData(DataFormats.FileDrop);
+            //    (DataContext as MergeDialogViewModel).AddFiles(file);
+            //}
             ListViewItem souredata = e.Data.GetData(typeof(ListViewItem)) as ListViewItem;
             if (souredata == null)
             {