瀏覽代碼

多页签-修复多开窗体时,无法关闭其中窗体问题

ZhouJieSheng 2 年之前
父節點
當前提交
588c1d16da
共有 2 個文件被更改,包括 13 次插入39 次删除
  1. 13 2
      PDF Office/ViewModels/MainWindowViewModel.cs
  2. 0 37
      PDF Office/ViewModels/ViewContentViewModel.cs

+ 13 - 2
PDF Office/ViewModels/MainWindowViewModel.cs

@@ -214,8 +214,16 @@ namespace PDF_Office.ViewModels
                     App.OpenedFileList.Remove(CurrentPDFViewer.Document.FilePath);
                     CurrentPDFViewer.CloseDocument();
                 }
-              
-                region.Regions[RegionNames.MainRegion].Remove(selectedItem);
+                if (selectedItem != null)
+                {
+                    region.Regions[RegionNames.MainRegion].Remove(selectedItem);
+                }
+
+                //多窗体情况下,单个窗体的所有页签均已关闭时,返回true,允许关闭窗体
+                if(selectedItem==null)
+                {
+                    return true;
+                }
             }
             return true;
         }
@@ -268,6 +276,9 @@ namespace PDF_Office.ViewModels
 
         }
 
+        /// <summary>
+        /// 检查页签个数 更新close allcommand 命令状态
+        /// </summary>
         private void CheckViewsCount()
         {
             if(region.Regions[RegionNames.MainRegion].Views.Count()>1)

+ 0 - 37
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -1165,22 +1165,6 @@ namespace PDF_Office.ViewModels
                     //保存前进行标记密文处理应用或擦除
                     RedactionAction.Invoke();
                 }
-                ////标记密文后的保存
-                //if (isApplyRedaction)
-                //{
-                //    //应用标记密文并另存为保存
-                //    try
-                //    {
-                //        PDFViewer.Document.ApplyRedaction();
-                //        PDFViewer.Document.ReleasePages();
-                //        PDFViewer.ReloadDocument();
-                //    }
-                //    catch { }
-                //}
-                //else if (isEraseRedaction)
-                //{
-                //    EraseReadction();
-                //}
 
                 if (App.OpenedFileList.Contains(dlg.FileName))
                 {
@@ -1229,27 +1213,6 @@ namespace PDF_Office.ViewModels
             }
         }
 
-        private void EraseReadction()
-        {
-            for (int i = 0; i < PDFViewer.Document.PageCount; i++)
-            {
-                //获取页面Page对象
-                var page = PDFViewer.Document.PageAtIndex(i);
-                var annots = PDFViewer.GetAnnotCommentList(i, PDFViewer.Document);
-                //循环擦除当前页的标记密文
-                for (int j = 0; j < annots.Count; j++)
-                {
-                    if (annots[j].EventType == AnnotArgsType.AnnotRedaction)
-                    {
-                        foreach (var rect in (annots[j] as RedactionAnnotArgs).QuardRects)
-                        {
-                            page.ErasureRedaction(rect);
-                        }
-                    }
-                }
-            }
-        }
-
         /// <summary>
         /// 另存为后进行的操作
         /// 重新打开新文档