浏览代码

合并-错误提示框弹出逻辑调整

zhuyi 1 年之前
父节点
当前提交
24d70ccf4d
共有 1 个文件被更改,包括 23 次插入29 次删除
  1. 23 29
      PDF Office/ViewModels/Dialog/ToolsDialogs/MergeDialogViewModel.cs

+ 23 - 29
PDF Office/ViewModels/Dialog/ToolsDialogs/MergeDialogViewModel.cs

@@ -148,6 +148,7 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
 
         private void Cancel()
         {
+            Clear();
             RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
         }
 
@@ -381,7 +382,7 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
             {
                 return;
             }
-            bool result = true;
+            bool showDialog = false;
             for (int i = 0; i < FilePath.Length; i++)
             {
                 MergeObject mergeObject = new MergeObject();
@@ -403,13 +404,9 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
                 string FileType = Path.GetExtension(mergeObject.FilePath).Trim().ToLower();
                 if (string.IsNullOrEmpty(FileType))
                 {
-                    AlertsMessage alertsMessage = new AlertsMessage();
-                    alertsMessage.ShowDialog("", "The file was not added successfully, please select the file again.","OK");
-                    if (alertsMessage.result == ContentResult.Ok)
-                    {
-                        //获取不到文件类型
-                        continue;
-                    }
+                    showDialog = true;
+                    //获取不到文件类型
+                    continue;
                 }
                 if (FileType != ".pdf")
                 {
@@ -419,13 +416,9 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
                     int imageindex = list.IndexOf(imagetype);
                     if (imageindex < 0)
                     {
-                        AlertsMessage alertsMessage = new AlertsMessage();
-                        alertsMessage.ShowDialog("", "The file was not added successfully, please select the file again.", "OK");
-                        if (alertsMessage.result == ContentResult.Ok)
-                        {
-                            //图片格式不支持
-                            continue;
-                        }
+                        showDialog = true;
+                        //图片格式不支持
+                        continue;
                     };
 
                     mergeObject.DocName = Path.GetFileName(mergeObject.FilePath);
@@ -438,13 +431,9 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
                     }
                     catch (Exception)
                     {
-                        AlertsMessage alertsMessage = new AlertsMessage();
-                        alertsMessage.ShowDialog("", "The file was not added successfully, please select the file again.", "OK");
-                        if (alertsMessage.result == ContentResult.Ok)
-                        {
-                            //解码错误
-                            continue;
-                        }
+                        showDialog = true;
+                        //解码错误
+                        continue;
                     }
                 }
                 else
@@ -452,13 +441,9 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
                     CPDFDocument doc = CPDFDocument.InitWithFilePath(mergeObject.FilePath);
                     if (doc == null)
                     {
-                        AlertsMessage alertsMessage = new AlertsMessage();
-                        alertsMessage.ShowDialog("", "The file was not added successfully, please select the file again.", "OK");
-                        if (alertsMessage.result == ContentResult.Ok)
-                        {
-                            //PDF打开失败
-                            continue;
-                        }
+                        showDialog = true;
+                        //PDF打开失败
+                        continue;
                     }
                     VerifyPasswordResult condition = SecurityHelper.VerifyPasswordByPasswordKind(doc, EnumPasswordKind.StatusPermissionsPassword, dialogs);
                     if (condition.IsDiscryptied)
@@ -495,6 +480,15 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
                 MergeObjectlist.Add(mergeObject);
                 UpDataMergeObjectIndex();
             }
+
+            if (showDialog)
+            {
+                AlertsMessage alertsMessage = new AlertsMessage();
+                alertsMessage.ShowDialog("", "The file was not added successfully, please select the file again.", "OK");
+                if (alertsMessage.result == ContentResult.Ok)
+                {
+                }
+            }
         }
         #endregion
     }