Jelajahi Sumber

ComPDFKit(win) - 新版保存框架,需补充

weixiangjie 7 bulan lalu
induk
melakukan
babec2e4c1

+ 8 - 1
Demo/Examples/Compdfkit_Tools/PageEdit/PDFPageEdit/CPDFPageEditControl.xaml.cs

@@ -118,6 +118,12 @@ namespace Compdfkit_Tools.PDFControl
         {
             get { return PageEditListBox.SelectedIndex; }
         }
+        
+        private bool CanSave
+        {
+            get => viewControl.PDFViewTool.IsDocumentModified;
+            set => viewControl.PDFViewTool.IsDocumentModified = value;
+        }
 
         public event EventHandler ExitPageEdit;
         private delegate void OnThumbnailGeneratedEventHandler(int pageIndex, byte[] thumb, int w, int h);
@@ -1959,11 +1965,12 @@ namespace Compdfkit_Tools.PDFControl
                 {
                     return;
                 }
-               CPDFViewer pdfViewer= GetPDFViewer();
+                CPDFViewer pdfViewer= GetPDFViewer();
                 pdfViewer?.UndoManager?.ClearHistory();
 
                 UpdateAllPageNum();
                 pdfViewer?.UpdateVirtualNodes();
+                CanSave = true;
             }
         }
 

+ 10 - 0
Demo/Examples/PDFViewer/MainPage.xaml.cs

@@ -385,6 +385,9 @@ namespace PDFViewer
             digitalSignatureControl.LoadUndoManagerEvent(viewControl.GetCPDFViewer());
             signatureStatusBarControl.SetStatus(SignatureHelper.SignatureList);
             viewControl.PDFViewTool.SetViewerModel(MouseModes.Viewer);
+            
+            viewControl.PDFViewTool.DocumentModifiedChanged -= PDFViewTool_DocumentModifiedChanged;
+            viewControl.PDFViewTool.DocumentModifiedChanged += PDFViewTool_DocumentModifiedChanged;
         }
 
         /// <summary>
@@ -611,6 +614,8 @@ namespace PDFViewer
             {
                 pageEditControl.PDFViewControl = viewControl;
                 pageEditControl.ExitPageEdit += PageEditControl_ExitPageEdit;
+                pageEditControl.OnCanSaveChanged -= ControlOnCanSaveChanged;
+                pageEditControl.OnCanSaveChanged += ControlOnCanSaveChanged;
                 PDFGrid.Child = pageEditControl;
                 NotDocsEditorVisible = Visibility.Collapsed;
             }
@@ -776,6 +781,11 @@ namespace PDFViewer
             this.CanSave = e;
         }
 
+        private void PDFViewTool_DocumentModifiedChanged(object sender, EventArgs e)
+        {
+            CanSave = viewControl.PDFViewTool.IsDocumentModified;
+        }
+        
         protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
         {
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));