Bladeren bron

标记密文-补充应用逻辑

ZhouJieSheng 2 jaren geleden
bovenliggende
commit
4580a04a9e

+ 5 - 0
PDF Office/App.xaml.cs

@@ -52,6 +52,7 @@ using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomeP
 using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark;
 using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
 using ComDocumentAIKit;
+using PDF_Office.Views.Dialog.Redaction;
 
 namespace PDF_Office
 {
@@ -296,6 +297,10 @@ namespace PDF_Office
             containerRegistry.RegisterDialog<AddBookmarkDialog>(DialogNames.AddBookmarkDialog);
             containerRegistry.RegisterDialog<EditPresetColorsDialog>(DialogNames.EditPresetColorsDialog);
             containerRegistry.RegisterDialog<CreateFromHtmlDialog>(DialogNames.CreateFromHtmlDialog);
+            //标记密文弹窗
+            containerRegistry.RegisterDialog<MarkSettingDialog>(DialogNames.MarkSettingDialog);
+            containerRegistry.RegisterDialog<PageMarkDialog>(DialogNames.PageMarkDialog);
+            containerRegistry.RegisterDialog<RepeatMarkDialog>(DialogNames.RepeatMarkDialog);
             #endregion 注册弹窗
         }
 

+ 9 - 0
PDF Office/Model/DialogNames.cs

@@ -155,5 +155,14 @@ namespace PDF_Office.Model
         /// 从网页创建PDF弹窗
         /// </summary>
         public static string CreateFromHtmlDialog = "CreateFromHtmlDialog";
+
+        /// <summary>
+        /// 标记密文相关弹窗
+        /// </summary>
+        public static string MarkSettingDialog = "MarkSettingsDialog";
+
+        public static string PageMarkDialog = "PageMarkDialog";
+
+        public static string RepeatMarkDialog = "RepeatMarkDialog";
     }
 }

+ 5 - 0
PDF Office/Model/ParameterNames.cs

@@ -39,6 +39,11 @@ namespace PDF_Office.Model
 
         public static string BatchProcessing_Name = "BatchProcessing_Name";
 
+        /// <summary>
+        /// 页码集合
+        /// </summary>
+        public static string PageList = "PageList";
+
         /// <summary>
         /// 书签
         /// </summary>

+ 3 - 0
PDF Office/PDF Office.csproj

@@ -391,6 +391,9 @@
       <AutoGen>True</AutoGen>
     </Compile>
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\CreateFromHtmlDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\Redaction\MarkSettingDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\Redaction\PageMarkDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\Redaction\RepeatMarkDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\ToolsDialogs\MergeDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePageBatchProcessing\HomePageRemoveDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\HomePageToolsDialogs\HomePagePrinter\HomePagePrinterDocumentContentViewModel.cs" />

+ 32 - 0
PDF Office/ViewModels/Dialog/Redaction/MarkSettingDialogViewModel.cs

@@ -0,0 +1,32 @@
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.Dialog.Redaction
+{
+    public class MarkSettingDialogViewModel : BindableBase, IDialogAware
+    {
+        public string Title => "";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+           
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+           
+        }
+    }
+}

+ 32 - 0
PDF Office/ViewModels/Dialog/Redaction/PageMarkDialogViewModel.cs

@@ -0,0 +1,32 @@
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.Dialog.Redaction
+{
+    public class PageMarkDialogViewModel : BindableBase, IDialogAware
+    {
+        public string Title =>"";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+   
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+    
+        }
+    }
+}

+ 32 - 0
PDF Office/ViewModels/Dialog/Redaction/RepeatMarkDialogViewModel.cs

@@ -0,0 +1,32 @@
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.Dialog.Redaction
+{
+    public class RepeatMarkDialogViewModel : BindableBase, IDialogAware
+    {
+        public string Title => "";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+           
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+           
+        }
+    }
+}

+ 51 - 2
PDF Office/ViewModels/EditTools/Redaction/RedactionContentViewModel.cs

@@ -1,11 +1,13 @@
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
+using PDF_Office.CustomControl;
 using PDF_Office.EventAggregators;
 using PDF_Office.Model;
 using Prism.Commands;
 using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
+using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -20,8 +22,12 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
 
         public IRegionManager redactionRegion;
 
+        public IDialogService dialogs;
+
         private CPDFViewer PDFViewer;
 
+        private ViewContentViewModel viewContentViewModel;
+
         public string RedactionDocumentRegionName { get; set; }
         public string RedactionBottomBarRegionName { get; set; }
 
@@ -31,16 +37,55 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
 
         public DelegateCommand CloseEditToolCommand { get; set; }
 
-        public RedactionContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
+        public DelegateCommand ApplyCommmand { get; set; }
+
+        public DelegateCommand RemoveCommand { get; set; }
+
+        public DelegateCommand PageRedactionCommand { get; set; }
+
+        public RedactionContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator,IDialogService dialogService)
         {
             this.redactionRegion = regionManager;
             this.eventAggregator = eventAggregator;
+            this.dialogs = dialogService;
 
             RedactionDocumentRegionName = Guid.NewGuid().ToString();
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             CloseEditToolCommand = new DelegateCommand(CloseEditTool);
+            ApplyCommmand = new DelegateCommand(apply);
+            RemoveCommand = new DelegateCommand(remove);
+            PageRedactionCommand = new DelegateCommand(pageMark);
+        }
+
+        /// <summary>
+        /// 应用
+        /// </summary>
+        private void apply()
+        {
+            AlertsMessage alertsMessage = new AlertsMessage();
+            alertsMessage.ShowDialog("Apply Redactions", "Use blank blocks to remove selected sensitive content."+
+
+"This action will permanently delete the marked ciphertext information from this document and you will not be able to retrieve the marked ciphertext information.","Cancel","Apply & Save As");
+            if(alertsMessage.result== ContentResult.Ok)
+            {
+                viewContentViewModel.saveAsFile(true);
+            }
+        }
+
+        /// <summary>
+        /// 擦除
+        /// </summary>
+        private void remove()
+        {
+
         }
 
+        private void pageMark()
+        {
+            dialogs.ShowDialog(DialogNames.PageMarkDialog);
+        }
+
+
         public void CloseEditTool()
         {
             PDFViewer.SetMouseMode(MouseModes.Default);
@@ -49,6 +94,8 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
             this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = this.Unicode, Status = EnumCloseMode.StatusCancel });
         }
 
+        #region Navigation
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -61,7 +108,8 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
-            if(!redactionRegion.Regions[RedactionDocumentRegionName].Views.Contains(PDFViewer))
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+            if (!redactionRegion.Regions[RedactionDocumentRegionName].Views.Contains(PDFViewer))
             {
                 RedactionAnnotArgs redactionArgs = new RedactionAnnotArgs();
                 AnnotHandlerEventArgs annotArgs = null;
@@ -89,5 +137,6 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
             }
   
         }
+        #endregion
     }
 }

+ 12 - 1
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -927,7 +927,7 @@ namespace PDF_Office.ViewModels
         /// <summary>
         /// 另存为或新文档保存逻辑
         /// </summary>
-        private bool saveAsFile()
+        public bool saveAsFile(bool isFromRedaction = false)
         {
             var dlg = new SaveFileDialog();
             dlg.Filter = Properties.Resources.OpenDialogFilter;
@@ -935,6 +935,17 @@ namespace PDF_Office.ViewModels
             if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
             {
                 bool result = false;
+                if(isFromRedaction)
+                {
+                    //应用标记密文并另存为保存
+                    try
+                    {
+                        PDFViewer.Document.ApplyRedaction();
+                        PDFViewer.Document.ReleasePages();
+                        PDFViewer.ReloadDocument();
+                    }
+                    catch { }
+                }
                 if (App.OpenedFileList.Contains(dlg.FileName))
                 {
                     //提示文件已经被打开

+ 20 - 1
PDF Office/Views/Dialog/Redaction/PageMarkDialog.xaml

@@ -58,6 +58,25 @@
                     Text="/" />
             </StackPanel>
         </StackPanel>
-
+        <cus:DialogContent.BottmBar>
+            <StackPanel VerticalAlignment="Center">
+                <StackPanel
+                    Margin="16,0"
+                    HorizontalAlignment="Right"
+                    Orientation="Horizontal">
+                    <Button
+                        Width="80"
+                        Height="32"
+                        Content="Apply"
+                        Style="{StaticResource Btn.cta}" />
+                    <Button
+                        Width="80"
+                        Height="32"
+                        Margin="16,0,0,0"
+                        Content="Cancel"
+                        Style="{StaticResource btn.sec}" />
+                </StackPanel>
+            </StackPanel>
+        </cus:DialogContent.BottmBar>
     </cus:DialogContent>
 </UserControl>

+ 3 - 0
PDF Office/Views/EditTools/Redaction/RedactionContent.xaml

@@ -59,6 +59,7 @@
                     Height="28"
                     Margin="8,0"
                     Padding="4,0"
+                    Command="{Binding PageRedactionCommand}"
                     Style="{StaticResource subToolBar}">
                     <StackPanel Orientation="Horizontal">
                         <Path
@@ -79,12 +80,14 @@
                     Margin="8,0"
                     Padding="8,0"
                     Content="应用密文"
+                    Command="{Binding ApplyCommmand}"
                     Style="{StaticResource Btn.cta}" />
                 <Button
                     Height="24"
                     Margin="8,0"
                     Padding="8,0"
                     Content="擦除密文"
+                    Command="{Binding RemoveCommand}"
                     Style="{StaticResource Btn.cta}" />
                 <Button
                     Width="auto"