liuaoran 2 vuotta sitten
vanhempi
commit
4abb3f895a

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

@@ -42,6 +42,7 @@ using PDF_Office.Helper;
 using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter;
 using PDF_Office.Views.EditTools.Watermark; 
 using PDF_Office.Views.EditTools.Background;
+using PDF_Office.Views.EditTools.Redaction;
 
 namespace PDF_Office
 {
@@ -134,6 +135,7 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<ThemesContent>();
             containerRegistry.RegisterForNavigation<ReadModeContent>();
 
+
             containerRegistry.RegisterForNavigation<HomePagePrinterModSizeContent>();
             containerRegistry.RegisterForNavigation<HomePagePrinterModPosterContent>();
             containerRegistry.RegisterForNavigation<HomePagePrinterModMultipleContent>();
@@ -171,6 +173,8 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<StampAnnotProperty>();
             containerRegistry.RegisterForNavigation<TextAnnotProperty>();
             containerRegistry.RegisterForNavigation<TextEditProperty>();
+            containerRegistry.RegisterForNavigation<RedactionContent>();
+            containerRegistry.RegisterForNavigation<RedactionDocumentContent>();
             //填写与签名
             containerRegistry.RegisterForNavigation<FillAndSignContent>();
             containerRegistry.RegisterForNavigation<DateFillProperty>();

+ 9 - 1
PDF Office/Model/RegionNames.cs

@@ -50,7 +50,7 @@ namespace PDF_Office.Model
             }
         }
 
-        public static string BackgroundViewRegionName
+        public static string BackgroundViewerRegionName
         {
             get
             {
@@ -58,6 +58,14 @@ namespace PDF_Office.Model
             }
         }
 
+        public static string RedactionViewerRegionName
+        {
+            get
+            {
+                return GetRegionName("RedactionViewerRegionName");
+            }
+        }
+
         /// <summary>
         /// BOTA内容项 对应的Content RegionName
         /// </summary>

+ 16 - 0
PDF Office/PDF Office.csproj

@@ -330,6 +330,8 @@
     <Compile Include="ViewModels\EditTools\Background\BackgroundTemplateListBaseContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Background\BackgroundTemplateListColorContentViewModel.cs" />
     <Compile Include="ViewModels\EditTools\Background\BackgroundTemplateListFileContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\Redaction\RedactionContentViewModel.cs" />
+    <Compile Include="ViewModels\EditTools\Redaction\RedactionDocumentContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\RecentFiles\RecentFilesContentViewModel.cs" />
     <Compile Include="ViewModels\Tools\ConverterBarContentViewModel.cs" />
     <Compile Include="ViewModels\Dialog\ExtractDialogViewModel.cs" />
@@ -524,6 +526,12 @@
     <Compile Include="Views\Dialog\VerifyPassWordDialog.xaml.cs">
       <DependentUpon>VerifyPassWordDialog.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\EditTools\Redaction\RedactionContent.xaml.cs">
+      <DependentUpon>RedactionContent.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Views\EditTools\Redaction\RedactionDocumentContent.xaml.cs">
+      <DependentUpon>RedactionDocumentContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\FillAndSign\FillAndSignContent.xaml.cs">
       <DependentUpon>FillAndSignContent.xaml</DependentUpon>
     </Compile>
@@ -899,6 +907,14 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\EditTools\Redaction\RedactionContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Views\EditTools\Redaction\RedactionDocumentContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\FillAndSign\FillAndSignContent.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 197 - 198
PDF Office/ViewModels/EditTools/Background/BackgroundDocumentContentViewModel.cs

@@ -1,201 +1,200 @@
-using ComPDFKit.PDFDocument;
-using ComPDFKit.PDFPage;
-using ComPDFKit.PDFWatermark;
-using ComPDFKitViewer;
-using ComPDFKitViewer.PdfViewer;
-using PDF_Office.EventAggregators;
-using PDF_Office.Helper;
-using PDF_Office.Model;
-using PDF_Office.Model.EditTools.Background;
-using PDF_Office.Model.EditTools.Watermark;
-using Prism.Commands;
-using Prism.Events;
-using Prism.Mvvm;
-using Prism.Regions;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Drawing;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using Size = System.Windows.Size;
-
-namespace PDF_Office.ViewModels.EditTools.Background
-{
-    public class BackgroundDocumentContentViewModel : BindableBase, INavigationAware
-    {
-        public IEventAggregator eventAggregator;
-        public IRegionManager regionManager;
-        public CPDFViewer PDFViewer;
-        public CPDFDocument Document;
-        private ViewContentViewModel viewContentViewModel;
-        CPDFViewer pdfViewer;
-
-        private CPDFBackground background;
-        private BackgroundInfo backgroundInfo;
-
-
-        public bool firstin = true;
-
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKit.PDFWatermark;
+using ComPDFKitViewer;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Watermark;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using Size = System.Windows.Size;
+
+namespace PDF_Office.ViewModels.EditTools.Background
+{
+    public class BackgroundDocumentContentViewModel : BindableBase, INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+        public IRegionManager regionManager;
+        public CPDFViewer PDFViewer;
+        public CPDFDocument Document;
+        private ViewContentViewModel viewContentViewModel;
+        CPDFViewer pdfViewer;
+         
+        private CPDFBackground background;
+        private BackgroundInfo backgroundInfo;
+
+        public bool firstin = true;
+
         public string ViewerRegionName { get; set; }
 
-        public string unicode = null;
-        public string Unicode = null;
-
-        public BackgroundDocumentContentViewModel(IEventAggregator eventAggregator, IRegionManager regionManager)
-        {
-            this.regionManager = regionManager;
-            this.eventAggregator = eventAggregator;
-            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
-            eventAggregator.GetEvent<ConfirmEditToolsBackgroundEvent>().Subscribe(ConfirmEditToolsBackground);
-            eventAggregator.GetEvent<SetBackgroundEvent>().Subscribe(SetBackground, e => e.Unicode == Unicode);
-            ViewerRegionName = RegionNames.BackgroundViewRegionName;
-        }
-
-        public void ConfirmEditToolsBackground()
-        {
-            if (backgroundInfo != null)
-            {
-                CreateBackground(viewContentViewModel.PDFViewer.Document);
-            }
-        }
-
-        public void SetBackground(BackgroundInfoUnicode backgroundInfounicode)
-        {
-            BackgroundInfo backgroundInfo=backgroundInfounicode.Status;
-            this.backgroundInfo = backgroundInfo;
-            CreateBackground(PDFViewer.Document);
-            PDFViewer.InvalidChildVisual(false);
-            PDFViewer.Document.ReleasePages();
-            PDFViewer.ReloadDocument();
-        }
-
-        public void CreateBackground(CPDFDocument document, bool IsNewDoc = false)
-        {
-            if (backgroundInfo != null)
-            {
-                background = document.GetBackground();
-                if (backgroundInfo.BackgroundType == C_Background_Type.BG_TYPE_COLOR)
-                {
-                    background.SetBackgroundType(C_Background_Type.BG_TYPE_COLOR);
-                    background.SetColor(backgroundInfo.Color);
-                }
-                else
-                {
-                    background.SetBackgroundType(C_Background_Type.BG_TYPE_IMAGE);
-                    background.SetImage(backgroundInfo.ImageArray, backgroundInfo.ImageWidth, backgroundInfo.ImageHeight, ComPDFKit.Import.C_Scale_Type.fitCenter);
-                }
-
-                background.SetScale(1);
-                background.SetRotation(backgroundInfo.Rotation);
-                background.SetOpacity(backgroundInfo.Opacity);
-                background.SetVertalign(backgroundInfo.Vertalign);
-                background.SetHorizalign(backgroundInfo.Horizalign);
-                background.SetXOffset(backgroundInfo.HorizOffset);
-                background.SetYOffset(backgroundInfo.VertOffset);
-                background.SetAllowsPrint(true);
-                background.SetAllowsView(true);
-                if (IsNewDoc) { background.SetPages("0"); }
-                else
-                {
-                    background.SetPages(backgroundInfo.PageRange);
-                }
-                background.Update();
-            }
-        }
-
-
-        private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
-        {
-        }
-
-        private void CurrentViewer_CustomDrawHandler(object sender, CustomDrawData e)
-        {
-            if (e.DrawPages.Count > 0 && e.DrawContext != null)
-            {
-                List<int> PageIndexLists = new List<int>();
-                foreach (DrawPageData drawPageData in e.DrawPages)
-                {
-                    if (backgroundInfo != null)
-                    {
-                        char[] enumerationSeparator = new char[] { ',' };
-                        char[] rangeSeparator = new char[] { '-' };
-                        if (CommonHelper.GetPagesInRange(ref PageIndexLists, backgroundInfo.PageRange, Document.PageCount, enumerationSeparator, rangeSeparator, true))
-                        { //TODO
-                            if (PageIndexLists.Contains(drawPageData.PageIndex - 1))
-                            {
-                                WriteableBitmap backgroundBitmap = GetBackground(PDFViewer.Document, e.Zoom, drawPageData.PageIndex);
-                                e.DrawContext.DrawImage(backgroundBitmap, drawPageData.PageBound);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        private WriteableBitmap GetBackground(CPDFDocument oldDoc, double zoom, int pageIndex)
-        {
-            Size pageSize = oldDoc.GetPageSize(pageIndex);
-
-            CPDFDocument newDoc = CPDFDocument.CreateDocument();
-            newDoc.InsertPage(0, pageSize.Width, pageSize.Height, null);
-            CreateBackground(newDoc, true);
-            CPDFPage newPage = newDoc.PageAtIndex(0);
-            double scale = 96.0 / 72.0;
-            zoom = zoom * scale;
-            Rect renderRect = new Rect(0, 0, (int)(pageSize.Width * scale), (int)(pageSize.Height * scale));
-            byte[] imageArray = new byte[(int)(renderRect.Width * renderRect.Height * 4)];
-            newPage.RenderPageBitmapWithMatrix((float)zoom, renderRect, 0x00FFFFFF, imageArray, 1, true);
-            WriteableBitmap WirteBitmap = new WriteableBitmap((int)renderRect.Width, (int)renderRect.Height, 96, 96, PixelFormats.Bgra32, null);
-            WirteBitmap.WritePixels(new Int32Rect(0, 0, (int)renderRect.Width, (int)renderRect.Height), imageArray, WirteBitmap.BackBufferStride, 0);
-            return WirteBitmap;
-        }
-
-        public bool IsNavigationTarget(NavigationContext navigationContext)
-        {
-            return true;
-        }
-
-        public void OnNavigatedFrom(NavigationContext navigationContext)
-        {
-
-        }
-
-        public void OnNavigatedTo(NavigationContext navigationContext)
-        {
-            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
+        public string unicode = null;
+        public string Unicode = null;
+
+        public BackgroundDocumentContentViewModel(IEventAggregator eventAggregator, IRegionManager regionManager)
+        {
+            this.regionManager = regionManager;
+            this.eventAggregator = eventAggregator;
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            eventAggregator.GetEvent<ConfirmEditToolsBackgroundEvent>().Subscribe(ConfirmEditToolsBackground);
+            eventAggregator.GetEvent<SetBackgroundEvent>().Subscribe(SetBackground, e => e.Unicode == Unicode);
+            ViewerRegionName = RegionNames.BackgroundViewerRegionName;
+        }
+
+        public void ConfirmEditToolsBackground()
+        {
+            if (backgroundInfo != null)
+            {
+                CreateBackground(viewContentViewModel.PDFViewer.Document);
+            }
+        }
+
+        public void SetBackground(BackgroundInfoUnicode backgroundInfounicode)
+        {
+            BackgroundInfo backgroundInfo=backgroundInfounicode.Status;
+            this.backgroundInfo = backgroundInfo;
+            CreateBackground(PDFViewer.Document);
+            PDFViewer.InvalidChildVisual(false);
+            PDFViewer.Document.ReleasePages();
+            PDFViewer.ReloadDocument();
+        }
+
+        public void CreateBackground(CPDFDocument document, bool IsNewDoc = false)
+        {
+            if (backgroundInfo != null)
+            {
+                background = document.GetBackground();
+                if (backgroundInfo.BackgroundType == C_Background_Type.BG_TYPE_COLOR)
+                {
+                    background.SetBackgroundType(C_Background_Type.BG_TYPE_COLOR);
+                    background.SetColor(backgroundInfo.Color);
+                }
+                else
+                {
+                    background.SetBackgroundType(C_Background_Type.BG_TYPE_IMAGE);
+                    background.SetImage(backgroundInfo.ImageArray, backgroundInfo.ImageWidth, backgroundInfo.ImageHeight, ComPDFKit.Import.C_Scale_Type.fitCenter);
+                }
+
+                background.SetScale(1);
+                background.SetRotation(backgroundInfo.Rotation);
+                background.SetOpacity(backgroundInfo.Opacity);
+                background.SetVertalign(backgroundInfo.Vertalign);
+                background.SetHorizalign(backgroundInfo.Horizalign);
+                background.SetXOffset(backgroundInfo.HorizOffset);
+                background.SetYOffset(backgroundInfo.VertOffset);
+                background.SetAllowsPrint(true);
+                background.SetAllowsView(true);
+                if (IsNewDoc) { background.SetPages("0"); }
+                else
+                {
+                    background.SetPages(backgroundInfo.PageRange);
+                }
+                background.Update();
+            }
+        }
+
+
+        private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+        }
+
+        private void CurrentViewer_CustomDrawHandler(object sender, CustomDrawData e)
+        {
+            if (e.DrawPages.Count > 0 && e.DrawContext != null)
+            {
+                List<int> PageIndexLists = new List<int>();
+                foreach (DrawPageData drawPageData in e.DrawPages)
+                {
+                    if (backgroundInfo != null)
+                    {
+                        char[] enumerationSeparator = new char[] { ',' };
+                        char[] rangeSeparator = new char[] { '-' };
+                        if (CommonHelper.GetPagesInRange(ref PageIndexLists, backgroundInfo.PageRange, Document.PageCount, enumerationSeparator, rangeSeparator, true))
+                        { //TODO
+                            if (PageIndexLists.Contains(drawPageData.PageIndex - 1))
+                            {
+                                WriteableBitmap backgroundBitmap = GetBackground(PDFViewer.Document, e.Zoom, drawPageData.PageIndex);
+                                e.DrawContext.DrawImage(backgroundBitmap, drawPageData.PageBound);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        private WriteableBitmap GetBackground(CPDFDocument oldDoc, double zoom, int pageIndex)
+        {
+            Size pageSize = oldDoc.GetPageSize(pageIndex);
+
+            CPDFDocument newDoc = CPDFDocument.CreateDocument();
+            newDoc.InsertPage(0, pageSize.Width, pageSize.Height, null);
+            CreateBackground(newDoc, true);
+            CPDFPage newPage = newDoc.PageAtIndex(0);
+            double scale = 96.0 / 72.0;
+            zoom = zoom * scale;
+            Rect renderRect = new Rect(0, 0, (int)(pageSize.Width * scale), (int)(pageSize.Height * scale));
+            byte[] imageArray = new byte[(int)(renderRect.Width * renderRect.Height * 4)];
+            newPage.RenderPageBitmapWithMatrix((float)zoom, renderRect, 0x00FFFFFF, imageArray, 1, true);
+            WriteableBitmap WirteBitmap = new WriteableBitmap((int)renderRect.Width, (int)renderRect.Height, 96, 96, PixelFormats.Bgra32, null);
+            WirteBitmap.WritePixels(new Int32Rect(0, 0, (int)renderRect.Width, (int)renderRect.Height), imageArray, WirteBitmap.BackBufferStride, 0);
+            return WirteBitmap;
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
             navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
-            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
-            if (pdfViewer != null)
-            {
-                if (!regionManager.Regions[ViewerRegionName].Views.Contains(PDFViewer))
-                {
-                    PDFViewer = new CPDFViewer();
-                    PDFViewer.InitDocument(pdfViewer.Document);
-                    Document = PDFViewer.Document;
-                    PDFViewer.CustomDrawHandler += CurrentViewer_CustomDrawHandler;
-                    PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
-                    regionManager.AddToRegion(ViewerRegionName, PDFViewer);
-                    PDFViewer.SetAnnotInteraction(!PDFViewer.GetAnnotInteraction());
-                    PDFViewer.Load();
-                    PDFViewer.ChangeViewMode(ViewMode.Single);
-                    PDFViewer.SetMouseMode(MouseModes.Default);
-                }
-            }
-        }
-    }
-}
-
-
-
-
-
-
-
-
-
-
-
+            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
+            if (pdfViewer != null)
+            {
+                if (!regionManager.Regions[ViewerRegionName].Views.Contains(PDFViewer))
+                {
+                    PDFViewer = new CPDFViewer();
+                    PDFViewer.InitDocument(pdfViewer.Document);
+                    Document = PDFViewer.Document;
+                    PDFViewer.CustomDrawHandler += CurrentViewer_CustomDrawHandler;
+                    PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
+                    regionManager.AddToRegion(ViewerRegionName, PDFViewer);
+                    PDFViewer.SetAnnotInteraction(!PDFViewer.GetAnnotInteraction());
+                    PDFViewer.Load();
+                    PDFViewer.ChangeViewMode(ViewMode.Single);
+                    PDFViewer.SetMouseMode(MouseModes.Default);
+                }
+            }
+        }
+    }
+}
+
+
+
+
+
+
+
+
+
+
+

+ 9 - 6
PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListColorContentViewModel.cs

@@ -176,15 +176,18 @@ namespace PDF_Office.ViewModels.EditTools.Background
             {
                 int temp = 0;
                 var template = Settings.Default.BackgroundTemplateList[temp];
-                if (!string.IsNullOrEmpty(BackgroundItem.previewImagePath)&& File.Exists(BackgroundItem.previewImagePath))
+                if (template.type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_IMAGE)
                 {
-                    Settings.Default.AppProperties.NeedToDeletePath.Add(BackgroundItem.previewImagePath);
-                }
+                    if (!string.IsNullOrEmpty(BackgroundItem.previewImagePath) && File.Exists(BackgroundItem.previewImagePath))
+                    {
+                        Settings.Default.AppProperties.NeedToDeletePath.Add(BackgroundItem.previewImagePath);
+                    }
 
-                Settings.Default.BackgroundTemplateList.Remove(template);
-                Settings.Default.Save();
+                    Settings.Default.BackgroundTemplateList.Remove(template);
+                    Settings.Default.Save();
 
-                BackgroundModColorCollection.Remove(template);
+                    BackgroundModColorCollection.Remove(template);
+                }
             }
             GetBackgroundSource();
         }

+ 12 - 6
PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListFileContentViewModel.cs

@@ -175,17 +175,23 @@ namespace PDF_Office.ViewModels.EditTools.Background
             while (Settings.Default.BackgroundTemplateList.Count != 0)
             {
                 int temp = 0;
+
                 var template = Settings.Default.BackgroundTemplateList[temp];
-                if (!string.IsNullOrEmpty(BackgroundItem.previewImagePath))
+                if (template.type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_COLOR)
                 {
-                    Settings.Default.AppProperties.NeedToDeletePath.Add(BackgroundItem.previewImagePath);
-                }
 
-                Settings.Default.BackgroundTemplateList.Remove(template);
-                Settings.Default.Save();
+                    if (!string.IsNullOrEmpty(BackgroundItem.previewImagePath))
+                    {
+                        Settings.Default.AppProperties.NeedToDeletePath.Add(BackgroundItem.previewImagePath);
+                    }
 
-                BackgroundModFileCollection.Remove(template);
+                    Settings.Default.BackgroundTemplateList.Remove(template);
+                    Settings.Default.Save();
+
+                    BackgroundModFileCollection.Remove(template);
+                }
             }
+
             GetBackgroundSource();
         }
 

+ 64 - 0
PDF Office/ViewModels/EditTools/Redaction/RedactionContentViewModel.cs

@@ -0,0 +1,64 @@
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+
+namespace PDF_Office.ViewModels.EditTools.Redaction
+{
+    public class RedactionContentViewModel : BindableBase,INavigationAware
+    {
+        public IEventAggregator eventAggregator;
+
+        public IRegionManager redactionRegion;
+
+        private CPDFViewer PDFViewer;
+
+        public string RedactionDocumentRegionName { get; set; }
+        public string RedactionBottomBarRegionName { get; set; }
+
+        public string RedactionDocumentName = "RedactionDocumentContent";
+
+        public string Unicode = null;
+
+        public DelegateCommand CloseEditToolCommand { get; set; }
+
+        public RedactionContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
+        {
+            this.redactionRegion = regionManager;
+            this.eventAggregator = eventAggregator;
+
+            RedactionDocumentRegionName = Guid.NewGuid().ToString();
+            Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            CloseEditToolCommand = new DelegateCommand(CloseEditTool);
+        }
+
+        public void CloseEditTool()
+        {
+            this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = this.Unicode, Status = EnumCloseMode.StatusCancel });
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            redactionRegion.RequestNavigate(RedactionDocumentRegionName, RedactionDocumentName, param);
+        }
+    }
+}

+ 88 - 0
PDF Office/ViewModels/EditTools/Redaction/RedactionDocumentContentViewModel.cs

@@ -0,0 +1,88 @@
+using ComPDFKit.PDFDocument;
+using ComPDFKitViewer;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Drawing.Printing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media.Imaging;
+
+namespace PDF_Office.ViewModels.EditTools.Redaction
+{
+    public class RedactionDocumentContentViewModel : BindableBase, INavigationAware
+    {
+        private CPDFViewer pdfViewer;
+        public IRegionManager regionManager;
+        public CPDFViewer PDFViewer;
+        public CPDFDocument Document;
+
+        public string ViewerRegionName { get; set; }
+
+        private int _currentPageIndex;
+        public int CurrentPageIndex
+        {
+            get { return _currentPageIndex; }
+            set
+            {
+                SetProperty(ref _currentPageIndex, PDFViewer.CurrentIndex);
+            }
+        }
+
+        public int PageRangeNumber
+        {
+            get { return PDFViewer.Document.PageCount; }
+        }
+
+        public RedactionDocumentContentViewModel(IRegionManager regionManager)
+        {
+            this.regionManager = regionManager;
+
+            ViewerRegionName = RegionNames.BackgroundViewerRegionName;
+        }
+
+        private void CurrentViewer_CustomDrawHandler(object sender, CustomDrawData e)
+        {
+        }
+
+        private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
+            if (pdfViewer != null)
+            {
+                if (!regionManager.Regions[ViewerRegionName].Views.Contains(PDFViewer))
+                {
+                    PDFViewer = new CPDFViewer();
+                    PDFViewer.InitDocument(pdfViewer.Document);
+                    Document = PDFViewer.Document;
+                    PDFViewer.CustomDrawHandler += CurrentViewer_CustomDrawHandler;
+                    PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
+                    regionManager.AddToRegion(ViewerRegionName, PDFViewer);
+                    PDFViewer.SetAnnotInteraction(!PDFViewer.GetAnnotInteraction());
+                    PDFViewer.Load();
+                    PDFViewer.ChangeViewMode(ViewMode.SingleContinuous);
+                    PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
+                }
+            }
+        }
+    }
+}

+ 0 - 1
PDF Office/ViewModels/EditTools/Watermark/WatermarkDocumentContentViewModel.cs

@@ -63,7 +63,6 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
 
         public void ConfirmEditToolsWatermark()
         {
-
             if (EnumDelete == EnumDelete.StatusDeleteAll)
             {
                 viewContentViewModel.PDFViewer.Document.DeleteWatermarks();

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

@@ -469,6 +469,7 @@ namespace PDF_Office.ViewModels
                 case "TabItemPageEdit":
                 case "WatermarkContent":
                 case "BackgroundContent":
+                case "RedactionContent":
                     ToolContentVisible = Visibility.Visible;
                     break;
                 default:
@@ -907,7 +908,6 @@ namespace PDF_Office.ViewModels
         private void EnterEditTools(StringWithUnicode EditToolName)
         {
             EnterSelectedEditTool(EditToolName);
-
         }
 
         private void CloseEditTool(EnumCloseModeUnicode enumCloseModeunicode)
@@ -929,7 +929,6 @@ namespace PDF_Office.ViewModels
         /// <param name="e"></param>
         private void EnterSelectedEditTool(StringWithUnicode EditToolName)
         {
-
             CurrentBar = EditToolName.EditToolsContentName;
             EnterToolMode(CurrentBar);
         }
@@ -948,7 +947,6 @@ namespace PDF_Office.ViewModels
             {
                 param.Add(ParameterNames.PDFViewer, PDFViewer);
                 param.Add(ParameterNames.ViewContentViewModel, this);
-                param.Add("UniCode", unicode);
             }
             else//有传入其他内容的参数时
             {

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

@@ -0,0 +1,47 @@
+<UserControl x:Class="PDF_Office.Views.EditTools.Redaction.RedactionContent"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/"             
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:redaction="clr-namespace:PDF_Office.ViewModels.EditTools.Redaction" d:DataContext="{d:DesignInstance Type=redaction:RedactionContentViewModel}"
+             mc:Ignorable =" d"
+             d:DesignHeight="760"
+             d:DesignWidth="1280">
+    <Grid Background="#FFFFFF">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid>
+            <WrapPanel HorizontalAlignment="Center">
+                <Button Style="{StaticResource InsideBarBtnStyle }">
+                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                        <StackPanel Margin="0,0,8,0">
+                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                        </StackPanel >
+                        <TextBlock Text="文本和图像标记密文" VerticalAlignment="Center"></TextBlock>
+                    </StackPanel>
+                </Button>
+                <Button Style="{StaticResource InsideBarBtnStyle }">
+                    <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
+                        <StackPanel Margin="0,0,8,0">
+                            <Border Height="30" Width="30" Background="LightSeaGreen" ></Border>
+                        </StackPanel >
+                        <TextBlock Text="页面标记密文" VerticalAlignment="Center"></TextBlock>
+                    </StackPanel>
+                </Button>
+            </WrapPanel>
+            <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
+                <Button Content="应用密文" Height="24" Padding="10,2,10,2"></Button>
+                <Button Content="擦除密文" Height="24"  Margin="8,0,8,0" Padding="10,2,10,2"></Button>
+                <Button Content="关闭" Height="24" Padding="10,2,10,2"  Margin="0,0,16,0"  Command="{Binding CloseEditToolCommand}"></Button>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="1" Background="#E7E9EC">
+            <Grid Margin="60,12,0,0">
+                <ContentControl prism:RegionManager.RegionName="{Binding RedactionDocumentRegionName}" Visibility ="Visible"></ContentControl>
+            </Grid>
+        </Grid>
+    </Grid>
+</UserControl>

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

@@ -0,0 +1,22 @@
+using Prism.Ioc;
+using Prism.Regions;
+using System.Windows.Controls;
+
+namespace PDF_Office.Views.EditTools.Redaction
+{
+    /// <summary>
+    /// Interaction logic for RedactionContent
+    /// </summary>
+    public partial class RedactionContent : UserControl
+    {
+        private IContainerProvider containerProvider;
+        public RedactionContent(IContainerProvider containerProvider)
+        {
+            InitializeComponent();
+            this.containerProvider = containerProvider;
+            var regionManager = containerProvider.Resolve<IRegionManager>();
+            RegionManager.SetRegionManager(this, regionManager);
+            RegionManager.UpdateRegions();
+        }
+    }
+}

+ 21 - 0
PDF Office/Views/EditTools/Redaction/RedactionDocumentContent.xaml

@@ -0,0 +1,21 @@
+<UserControl x:Class="PDF_Office.Views.EditTools.Redaction.RedactionDocumentContent"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/" xmlns:redaction="clr-namespace:PDF_Office.ViewModels.EditTools.Redaction" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             prism:ViewModelLocator.AutoWireViewModel="True">
+    <Grid Height="720" Width="1280">
+        <Border CornerRadius="4" Background="#323232"  HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="41,0,0,25" Height="53" Width="93"  Panel.ZIndex="1" >
+            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
+                <TextBlock Text="{Binding CurrentPageIndex, Mode=TwoWay}" Foreground="White" FontSize="20"></TextBlock>
+                <TextBlock Text="/" Foreground="White" FontSize="20"></TextBlock>
+                <TextBlock  Text="{Binding PageRangeNumber, Mode=TwoWay}" FontSize="20"  Foreground="White"></TextBlock>
+            </StackPanel>
+        </Border>
+        <Grid Height="676" Width="1220" VerticalAlignment="Bottom" HorizontalAlignment="Right"> 
+            <ContentControl
+                x:Name="PDFViewerContent"
+                HorizontalAlignment="Stretch"
+                prism:RegionManager.RegionName="{Binding ViewerRegionName}" />
+        </Grid>
+    </Grid>
+</UserControl>

+ 15 - 0
PDF Office/Views/EditTools/Redaction/RedactionDocumentContent.xaml.cs

@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace PDF_Office.Views.EditTools.Redaction
+{
+    /// <summary>
+    /// Interaction logic for RedactionDocumentContent
+    /// </summary>
+    public partial class RedactionDocumentContent : UserControl
+    {
+        public RedactionDocumentContent()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 2 - 2
PDF Office/Views/Tools/ToolsBarContent.xaml

@@ -1,7 +1,7 @@
 <UserControl x:Class="PDF_Office.Views.Tools.ToolsBarContent"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:prism="http://prismlibrary.com/" xmlns:tools="clr-namespace:PDF_Office.ViewModels.Tools" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:prism="http://prismlibrary.com/" xmlns:tools="clr-namespace:PDF_Office.ViewModels.Tools" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              prism:ViewModelLocator.AutoWireViewModel="True">
     <UserControl.Resources>
         <ResourceDictionary>
@@ -68,7 +68,7 @@
                         </MenuItem>
                     </MenuItem>
                 </Menu>
-                <Button Style="{StaticResource InsideBarBtnStyle }" >
+                <Button   Name="RedactionContent" Style="{StaticResource InsideBarBtnStyle }" Command="{Binding SetEditToolsCommand }" CommandParameter="{Binding ElementName=RedactionContent}" >
 
                     <StackPanel Orientation="Horizontal" Margin="12 0 12 0">
                         <StackPanel Margin="0,0,8,0">