Просмотр исходного кода

首页-补充关闭全部页签功能

ZhouJieSheng 2 лет назад
Родитель
Сommit
2fb3d0625a

+ 5 - 2
PDF Office/ViewModels/MainContentViewModel.cs

@@ -170,7 +170,7 @@ namespace PDF_Office.ViewModels
         {
             var folder = PDFViewer.Document.FilePath.Substring(0, PDFViewer.Document.FilePath.LastIndexOf("\\"));
             ////File.Move(PDFViewer.Document.FilePath,Path.Combine(folder,FileName));
-            ///TODO:
+            ///TODO:会被占用 无法操作
             IsReNameTextShow = Visibility.Collapsed;
         }
 
@@ -542,8 +542,11 @@ namespace PDF_Office.ViewModels
         #region Navigation
         public async void OnNavigatedTo(NavigationContext navigationContext)
         {
+            mainWindowViewModel = App.mainWindowViewModel;
+            //常规加载首页的情况
             if (navigationContext.Parameters.Count <= 0)
                 return;
+
             var filepath = navigationContext.Parameters[ParameterNames.FilePath].ToString();
             if (filepath!= null)
             {
@@ -562,7 +565,7 @@ namespace PDF_Office.ViewModels
                 }
             }
 
-            mainWindowViewModel = App.mainWindowViewModel;
+            
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)

+ 20 - 15
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -1152,7 +1152,7 @@ namespace PDF_Office.ViewModels
         /// <summary>
         /// 另存为或新文档保存逻辑
         /// </summary>
-        public bool saveAsFile(bool isApplyRedaction = false, bool isEraseRedaction = false)
+        public bool saveAsFile(Action RedactionAction=null)
         {
             var dlg = new Microsoft.Win32.SaveFileDialog();
             dlg.Filter = Properties.Resources.OpenDialogFilter;
@@ -1160,22 +1160,27 @@ namespace PDF_Office.ViewModels
             if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
             {
                 bool result = false;
-                //标记密文后的保存
-                if (isApplyRedaction)
+                if(RedactionAction!=null)
                 {
-                    //应用标记密文并另存为保存
-                    try
-                    {
-                        PDFViewer.Document.ApplyRedaction();
-                        PDFViewer.Document.ReleasePages();
-                        PDFViewer.ReloadDocument();
-                    }
-                    catch { }
-                }
-                else if (isEraseRedaction)
-                {
-                    EraseReadction();
+                    //保存前进行标记密文处理应用或擦除
+                    RedactionAction.Invoke();
                 }
+                ////标记密文后的保存
+                //if (isApplyRedaction)
+                //{
+                //    //应用标记密文并另存为保存
+                //    try
+                //    {
+                //        PDFViewer.Document.ApplyRedaction();
+                //        PDFViewer.Document.ReleasePages();
+                //        PDFViewer.ReloadDocument();
+                //    }
+                //    catch { }
+                //}
+                //else if (isEraseRedaction)
+                //{
+                //    EraseReadction();
+                //}
 
                 if (App.OpenedFileList.Contains(dlg.FileName))
                 {

+ 1 - 1
PDF Office/Views/MainWindow.xaml

@@ -140,7 +140,7 @@
                                             CommandParameter="{Binding}"
                                             Header="Close Tab" />
                                         <MenuItem
-                                            Command="{Binding DataContext.mainWindowViewModel.CloseAllTabCommand}"
+                                            Command="{Binding DataContext.mainWindowViewModel.CloseAllCommand}"
                                             Header="Close All Tab"
                                             IsEnabled="{Binding DataContext.mainWindowViewModel.IsCloseAllEnable}" />
                                         <MenuItem Header="Open In New Window" Visibility="Collapsed" />