Selaa lähdekoodia

ComPDFKit.Demo(win) - 修复用快捷键添加文字下划线和删除线后无法Undo的问题

TangJinZhou 4 päivää sitten
vanhempi
commit
396a3cb349

+ 23 - 4
Demo/Examples/Compdfkit.Controls/Edit/ContentEditCOntrol/ContentEditControl.xaml.cs

@@ -28,6 +28,7 @@ using MenuItem = System.Windows.Controls.MenuItem;
 using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
 using UserControl = System.Windows.Controls.UserControl;
 using System.Linq;
+using ComPDFKit.Tool.UndoManger;
 
 namespace ComPDFKit.Controls.PDFControl
 {
@@ -258,8 +259,17 @@ namespace ComPDFKit.Controls.PDFControl
             {
                 if(e.Key == Key.S)
                 {
-                    textArea.AddStrikethrough();
-                    UpdateEditArea(oldRect, textArea);
+                    bool result = textArea.AddStrikethrough();
+                    if (result)
+                    {
+                        PDFEditHistory editHistory = new PDFEditHistory();
+                        CPDFPage page = PdfViewControl.PDFViewTool.GetCPDFViewer().GetDocument().PageAtIndex(pageIndex);
+                        editHistory.EditPage = page.GetEditPage();
+                        editHistory.PageIndex = pageIndex;
+                        PdfViewControl.PDFViewTool.GetCPDFViewer().UndoManager.AddHistory(editHistory);
+                        UpdateEditArea(oldRect, textArea);
+                    }
+
                     e.Handled = true;
                 }
             }
@@ -296,8 +306,17 @@ namespace ComPDFKit.Controls.PDFControl
 
                 if (e.Key == Key.U)
                 {
-                    textArea.AddUnderline();
-                    UpdateEditArea(oldRect, textArea);
+                    bool result = textArea.AddUnderline();
+                    if(result)
+                    {
+                        PDFEditHistory editHistory = new PDFEditHistory();
+                        CPDFPage page = PdfViewControl.PDFViewTool.GetCPDFViewer().GetDocument().PageAtIndex(pageIndex);
+                        editHistory.EditPage = page.GetEditPage();
+                        editHistory.PageIndex = pageIndex;
+                        PdfViewControl.PDFViewTool.GetCPDFViewer().UndoManager.AddHistory(editHistory);
+                        UpdateEditArea(oldRect, textArea);
+                    }
+
                     e.Handled = true;
                 }
             }