소스 검색

Form-Form Undo Redo

weixiangjie 10 달 전
부모
커밋
aa71bfe11c

+ 98 - 11
Demo/Examples/Compdfkit_Tools/Form/Property/CheckBoxProperty.xaml.cs

@@ -4,9 +4,12 @@ using ComPDFKit.PDFDocument;
 using ComPDFKit.Tool;
 using ComPDFKit.Tool.Help;
 using System;
+using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
+using ComPDFKit.Tool.UndoManger;
+using ComPDFKitViewer.Helper;
 
 namespace Compdfkit_Tools.PDFControl
 {
@@ -55,7 +58,20 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
-                cPDFAnnotation.SetFieldName((sender as TextBox).Text);
+                string text = (sender as TextBox).Text;
+                if(cPDFAnnotation.GetFieldName() != text)
+                {
+                    CheckBoxHistory history = new CheckBoxHistory();
+                    history.Action = HistoryAction.Update;
+                    history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                    history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    
+                    cPDFAnnotation.SetFieldName(text);
+                    pdfViewerControl.UpdateAnnotFrame();
+                    
+                    history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+                }
                 pdfViewerControl.UpdateAnnotFrame();
             }
         }
@@ -64,8 +80,16 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                CheckBoxHistory history = new CheckBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 cPDFAnnotation.SetFlags( ParamConverter.GetFormFlags((ParamConverter.FormField)(sender as ComboBox).SelectedIndex, cPDFAnnotation));
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -77,8 +101,23 @@ namespace Compdfkit_Tools.PDFControl
                 Color[0] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.B;
-                cPDFAnnotation.SetWidgetBorderRGBColor(Color);
-                pdfViewerControl.UpdateAnnotFrame();
+
+                byte[] oldColor = new byte[3];
+                cPDFAnnotation.GetWidgetBorderRGBColor(ref oldColor);
+                if (!oldColor.SequenceEqual(Color))
+                {
+                    CheckBoxHistory history = new CheckBoxHistory();
+                    history.Action = HistoryAction.Update;
+                    history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                    history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    
+                    cPDFAnnotation.SetWidgetBorderRGBColor(Color);
+                    pdfViewerControl.UpdateAnnotFrame();
+                    
+                    history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+                }
+                
             }
         }
 
@@ -90,8 +129,22 @@ namespace Compdfkit_Tools.PDFControl
                 Color[0] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.B;
-                cPDFAnnotation.SetWidgetBgRGBColor(Color);
-                pdfViewerControl.UpdateAnnotFrame();
+                
+                byte[] oldColor = new byte[3];
+                cPDFAnnotation.GetWidgetBgRGBColor(ref oldColor);
+                if (!oldColor.SequenceEqual(Color))
+                {
+                    CheckBoxHistory history = new CheckBoxHistory();
+                    history.Action = HistoryAction.Update;
+                    history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                    history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    
+                    cPDFAnnotation.SetWidgetBgRGBColor(Color);
+                    pdfViewerControl.UpdateAnnotFrame();
+                    
+                    history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+                }
             }
         }
 
@@ -99,8 +152,20 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
-                cPDFAnnotation.SetWidgetCheckStyle((C_CHECK_STYLE)(sender as ComboBox).SelectedIndex);
-                pdfViewerControl.UpdateAnnotFrame();
+                C_CHECK_STYLE style = (C_CHECK_STYLE)(sender as ComboBox).SelectedIndex;
+                if (cPDFAnnotation.GetWidgetCheckStyle() != style)
+                {
+                    CheckBoxHistory history = new CheckBoxHistory();
+                    history.Action = HistoryAction.Update;
+                    history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                    history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    
+                    cPDFAnnotation.SetWidgetCheckStyle(style);
+                    pdfViewerControl.UpdateAnnotFrame();
+                    
+                    history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+                }
             }
         }
 
@@ -108,8 +173,19 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
-                cPDFAnnotation.SetChecked(true);
-                pdfViewerControl.UpdateAnnotFrame();
+                if (!cPDFAnnotation.IsChecked())
+                {
+                    CheckBoxHistory history = new CheckBoxHistory();
+                    history.Action = HistoryAction.Update;
+                    history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                    history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+
+                    cPDFAnnotation.SetChecked(true);
+                    pdfViewerControl.UpdateAnnotFrame();
+                    
+                    history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+                }
             }
         }
 
@@ -117,8 +193,19 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
-                cPDFAnnotation.SetChecked(false);
-                pdfViewerControl.UpdateAnnotFrame();
+                if (cPDFAnnotation.IsChecked())
+                {
+                    CheckBoxHistory history = new CheckBoxHistory();
+                    history.Action = HistoryAction.Update;
+                    history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                    history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    
+                    cPDFAnnotation.SetChecked(false);
+                    pdfViewerControl.UpdateAnnotFrame();
+                    
+                    history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+                }
             }
         }
     }

+ 99 - 11
Demo/Examples/Compdfkit_Tools/Form/Property/ComboBoxProperty.xaml.cs

@@ -6,10 +6,13 @@ using ComPDFKit.Tool.Help;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
+using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Media;
+using ComPDFKit.Tool.UndoManger;
+using ComPDFKitViewer.Helper;
 using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
 
 namespace Compdfkit_Tools.PDFControl
@@ -126,8 +129,20 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
-                cPDFAnnotation.SetFieldName((sender as TextBox).Text);
-                pdfViewerControl.UpdateAnnotFrame();
+                string text = (sender as TextBox).Text;
+                if (cPDFAnnotation.GetFieldName() != text)
+                {
+                    ComboBoxHistory history = new ComboBoxHistory();
+                    history.Action = HistoryAction.Update;
+                    history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                    history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
+                    cPDFAnnotation.SetFieldName((sender as TextBox).Text);
+                    pdfViewerControl.UpdateAnnotFrame();
+                    
+                    history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+                }
             }
         }
 
@@ -135,8 +150,16 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
-                cPDFAnnotation.SetFlags(ParamConverter.GetFormFlags((ParamConverter.FormField)(sender as ComboBox).SelectedIndex, cPDFAnnotation));
+                ComboBoxHistory history = new ComboBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
+                cPDFAnnotation.SetFlags( ParamConverter.GetFormFlags((ParamConverter.FormField)(sender as ComboBox).SelectedIndex, cPDFAnnotation));
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -148,8 +171,23 @@ namespace Compdfkit_Tools.PDFControl
                 Color[0] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.B;
-                cPDFAnnotation.SetWidgetBorderRGBColor(Color);
-                pdfViewerControl.UpdateAnnotFrame();
+
+                byte[] oldColor = new byte[3];
+                cPDFAnnotation.GetWidgetBorderRGBColor(ref oldColor);
+                if (!oldColor.SequenceEqual(Color))
+                {
+                    CheckBoxHistory history = new CheckBoxHistory();
+                    history.Action = HistoryAction.Update;
+                    history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                    history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    
+                    cPDFAnnotation.SetWidgetBorderRGBColor(Color);
+                    pdfViewerControl.UpdateAnnotFrame();
+                    
+                    history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+                }
+                
             }
         }
 
@@ -161,8 +199,22 @@ namespace Compdfkit_Tools.PDFControl
                 Color[0] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.B;
-                cPDFAnnotation.SetWidgetBgRGBColor(Color);
-                pdfViewerControl.UpdateAnnotFrame();
+                
+                byte[] oldColor = new byte[3];
+                cPDFAnnotation.GetWidgetBgRGBColor(ref oldColor);
+                if (!oldColor.SequenceEqual(Color))
+                {
+                    ComboBoxHistory history = new ComboBoxHistory();
+                    history.Action = HistoryAction.Update;
+                    history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                    history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    
+                    cPDFAnnotation.SetWidgetBgRGBColor(Color);
+                    pdfViewerControl.UpdateAnnotFrame();
+                    
+                    history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+                }
             }
         }
 
@@ -175,10 +227,22 @@ namespace Compdfkit_Tools.PDFControl
                 Color[1] = ((SolidColorBrush)TextColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)TextColorPickerControl.Brush).Color.B;
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
-                cTextAttribute.FontColor = Color;
-                cPDFAnnotation.SetTextAttribute(cTextAttribute);
-                cPDFAnnotation.UpdateFormAp();
-                pdfViewerControl.UpdateAnnotFrame();
+
+                if (!cTextAttribute.FontColor.SequenceEqual(Color))
+                {
+                    ComboBoxHistory history = new ComboBoxHistory();
+                    history.Action = HistoryAction.Update;
+                    history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                    history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    
+                    cTextAttribute.FontColor = Color;
+                    cPDFAnnotation.SetTextAttribute(cTextAttribute);
+                    cPDFAnnotation.UpdateFormAp();
+                    pdfViewerControl.UpdateAnnotFrame();
+                    
+                    history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                    pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+                }
             }
         }
 
@@ -186,6 +250,11 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                ComboBoxHistory history = new ComboBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 bool isBold = IsBold(cTextAttribute.FontName);
                 bool isItalic = IsItalic(cTextAttribute.FontName);
@@ -194,6 +263,9 @@ namespace Compdfkit_Tools.PDFControl
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -201,6 +273,11 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                ComboBoxHistory history = new ComboBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 bool isItalic = false;
                 bool isBold = false;
@@ -228,6 +305,9 @@ namespace Compdfkit_Tools.PDFControl
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -235,11 +315,19 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                ComboBoxHistory history = new ComboBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 cTextAttribute.FontSize = Convert.ToSingle((sender as ComboBox).SelectedItem);
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 

+ 66 - 0
Demo/Examples/Compdfkit_Tools/Form/Property/ListBoxProperty.xaml.cs

@@ -10,6 +10,8 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Media;
+using ComPDFKit.Tool.UndoManger;
+using ComPDFKitViewer.Helper;
 using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
 
 namespace Compdfkit_Tools.PDFControl
@@ -129,8 +131,16 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                ListBoxHistory history = new ListBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 cPDFAnnotation.SetFieldName((sender as TextBox).Text);
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -138,8 +148,16 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                ListBoxHistory history = new ListBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 cPDFAnnotation.SetFlags(ParamConverter.GetFormFlags((ParamConverter.FormField)(sender as ComboBox).SelectedIndex, cPDFAnnotation));
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -147,12 +165,20 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                ListBoxHistory history = new ListBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 byte[] Color = new byte[3];
                 Color[0] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.B;
                 cPDFAnnotation.SetWidgetBorderRGBColor(Color);
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -160,12 +186,20 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                ListBoxHistory history = new ListBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 byte[] Color = new byte[3];
                 Color[0] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.B;
                 cPDFAnnotation.SetWidgetBgRGBColor(Color);
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -173,6 +207,11 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                ListBoxHistory history = new ListBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 byte[] Color = new byte[3];
                 Color[0] = ((SolidColorBrush)TextColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)TextColorPickerControl.Brush).Color.G;
@@ -182,6 +221,9 @@ namespace Compdfkit_Tools.PDFControl
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -189,6 +231,11 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                ListBoxHistory history = new ListBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 bool isBold = IsBold(cTextAttribute.FontName);
                 bool isItalic = IsItalic(cTextAttribute.FontName);
@@ -197,6 +244,9 @@ namespace Compdfkit_Tools.PDFControl
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -204,6 +254,11 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                ListBoxHistory history = new ListBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 bool isItalic = false;
                 bool isBold = false;
@@ -231,6 +286,9 @@ namespace Compdfkit_Tools.PDFControl
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -238,11 +296,19 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                ListBoxHistory history = new ListBoxHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 cTextAttribute.FontSize = Convert.ToSingle((sender as ComboBox).SelectedItem);
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 

+ 90 - 0
Demo/Examples/Compdfkit_Tools/Form/Property/PushButtonProperty.xaml.cs

@@ -16,6 +16,8 @@ using ComPDFKit.Tool;
 using ComPDFKit.Tool.Help;
 using System.Windows.Input;
 using ComPDFKit.PDFAnnotation.Form;
+using ComPDFKit.Tool.UndoManger;
+using ComPDFKitViewer.Helper;
 using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
 using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
 
@@ -149,8 +151,16 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                PushButtonHistory history = new PushButtonHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 cPDFAnnotation.SetFieldName((sender as TextBox).Text);
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -159,8 +169,16 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                PushButtonHistory history = new PushButtonHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
                 cPDFAnnotation.SetFlags(ParamConverter.GetFormFlags((ParamConverter.FormField)(sender as ComboBox).SelectedIndex, cPDFAnnotation));
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -169,12 +187,20 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                PushButtonHistory history = new PushButtonHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 byte[] Color = new byte[3];
                 Color[0] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.B;
                 cPDFAnnotation.SetWidgetBorderRGBColor(Color);
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -183,12 +209,20 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                PushButtonHistory history = new PushButtonHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 byte[] Color = new byte[3];
                 Color[0] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.B;
                 cPDFAnnotation.SetWidgetBgRGBColor(Color);
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -196,6 +230,11 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                PushButtonHistory history = new PushButtonHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 byte[] Color = new byte[3];
                 Color[0] = ((SolidColorBrush)TextColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)TextColorPickerControl.Brush).Color.G;
@@ -205,6 +244,9 @@ namespace Compdfkit_Tools.PDFControl
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -212,6 +254,11 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                PushButtonHistory history = new PushButtonHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 bool isBold = IsBold(cTextAttribute.FontName);
                 bool isItalic = IsItalic(cTextAttribute.FontName);
@@ -220,6 +267,9 @@ namespace Compdfkit_Tools.PDFControl
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -227,6 +277,11 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                PushButtonHistory history = new PushButtonHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 bool isItalic = false;
                 bool isBold = false;
@@ -255,6 +310,9 @@ namespace Compdfkit_Tools.PDFControl
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -262,11 +320,19 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                PushButtonHistory history = new PushButtonHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 cTextAttribute.FontSize = Convert.ToSingle((sender as ComboBox).SelectedItem);
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
         #endregion
@@ -275,6 +341,11 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                PushButtonHistory history = new PushButtonHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 ActionContentText.Style = null;
                 switch (TextAlignmentCmb.SelectedIndex)
                 {
@@ -299,6 +370,9 @@ namespace Compdfkit_Tools.PDFControl
                 }
                 if (ActionContentText.Visibility != Visibility.Collapsed && ActionContentText != null)
                     AddAction();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -350,8 +424,16 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                PushButtonHistory history = new PushButtonHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 cPDFAnnotation.SetButtonTitle((sender as TextBox).Text);
                 pdfViewerControl.UpdateAnnotFrame();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 
@@ -359,7 +441,15 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                PushButtonHistory history = new PushButtonHistory();
+                history.Action = HistoryAction.Update;
+                history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+                history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                
                 AddAction();
+                
+                history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+                pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
             }
         }
 

+ 32 - 0
Demo/Examples/Compdfkit_Tools/Form/Property/RadioButtonProperty.xaml.cs

@@ -9,6 +9,8 @@ using System.Windows.Media;
 using ComPDFKit.PDFDocument;
 using ComPDFKit.Tool;
 using ComPDFKit.Tool.Help;
+using ComPDFKit.Tool.UndoManger;
+using ComPDFKitViewer.Helper;
 
 namespace Compdfkit_Tools.PDFControl
 {
@@ -81,8 +83,10 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetFieldName((sender as TextBox).Text);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -90,8 +94,10 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetFlags(ParamConverter.GetFormFlags((ParamConverter.FormField)(sender as ComboBox).SelectedIndex, cPDFAnnotation));
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -99,12 +105,14 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 byte[] Color = new byte[3];
                 Color[0] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.B;
                 cPDFAnnotation.SetWidgetBorderRGBColor(Color);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -112,12 +120,14 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 byte[] Color = new byte[3];
                 Color[0] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.B;
                 cPDFAnnotation.SetWidgetBgRGBColor(Color);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -125,8 +135,10 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetWidgetCheckStyle((C_CHECK_STYLE)(sender as ComboBox).SelectedIndex);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -134,8 +146,10 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetChecked(true);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -143,9 +157,27 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetChecked(false);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
+
+        private RadioButtonHistory GetNewHistory()
+        {
+            RadioButtonHistory history = new RadioButtonHistory();
+            history.Action = HistoryAction.Update;
+            history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+            history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+
+            return history;
+        }
+        
+        private void AddHistory(RadioButtonHistory history)
+        {
+            history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+            pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+        }
     }
 }

+ 20 - 0
Demo/Examples/Compdfkit_Tools/Form/Property/SignatureProperty.xaml.cs

@@ -5,6 +5,8 @@ using ComPDFKit.Tool;
 using ComPDFKit.Tool.Help;
 using System.Windows;
 using System.Windows.Controls;
+using ComPDFKit.Tool.UndoManger;
+using ComPDFKitViewer.Helper;
 
 namespace Compdfkit_Tools.PDFControl
 {
@@ -45,9 +47,27 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetFlags(ParamConverter.GetFormFlags((ParamConverter.FormField)(sender as ComboBox).SelectedIndex, cPDFAnnotation));
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
+        
+        private SignatureHistory GetNewHistory()
+        {
+            SignatureHistory history = new SignatureHistory();
+            history.Action = HistoryAction.Update;
+            history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+            history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+
+            return history;
+        }
+        
+        private void AddHistory(SignatureHistory history)
+        {
+            history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+            pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+        }
     }
 }

+ 42 - 0
Demo/Examples/Compdfkit_Tools/Form/Property/TextFieldProperty.xaml.cs

@@ -10,6 +10,8 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Media;
+using ComPDFKit.Tool.UndoManger;
+using ComPDFKitViewer.Helper;
 using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
 
 namespace Compdfkit_Tools.PDFControl
@@ -115,8 +117,10 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetFieldName((sender as TextBox).Text);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -125,8 +129,10 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetFlags(ParamConverter.GetFormFlags((ParamConverter.FormField)(sender as ComboBox).SelectedIndex, cPDFAnnotation));
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -135,12 +141,14 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 byte[] Color = new byte[3];
                 Color[0] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.B;
                 cPDFAnnotation.SetWidgetBorderRGBColor(Color);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -149,12 +157,14 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 byte[] Color = new byte[3];
                 Color[0] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.G;
                 Color[2] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.B;
                 cPDFAnnotation.SetWidgetBgRGBColor(Color);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -162,6 +172,7 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 byte[] Color = new byte[3];
                 Color[0] = ((SolidColorBrush)TextColorPickerControl.Brush).Color.R;
                 Color[1] = ((SolidColorBrush)TextColorPickerControl.Brush).Color.G;
@@ -171,6 +182,7 @@ namespace Compdfkit_Tools.PDFControl
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -178,6 +190,7 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 bool isBold = IsBold(cTextAttribute.FontName);
                 bool isItalic = IsItalic(cTextAttribute.FontName);
@@ -186,6 +199,7 @@ namespace Compdfkit_Tools.PDFControl
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -193,6 +207,7 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 bool isItalic = false;
                 bool isBold = false;
@@ -220,6 +235,7 @@ namespace Compdfkit_Tools.PDFControl
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -227,11 +243,13 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 cTextAttribute.FontSize = Convert.ToSingle((sender as ComboBox).SelectedItem);
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -239,8 +257,10 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetJustification((C_TEXT_ALIGNMENT)(sender as ComboBox).SelectedIndex);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -248,8 +268,10 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetText((sender as TextBox).Text);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -257,8 +279,10 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetMultiLine(true);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
 
@@ -266,10 +290,28 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (IsLoadedData)
             {
+                var history = GetNewHistory();
                 cPDFAnnotation.SetMultiLine(false);
                 pdfViewerControl.UpdateAnnotFrame();
+                AddHistory(history);
             }
         }
+        
+        private TextBoxHistory GetNewHistory()
+        {
+            TextBoxHistory history = new TextBoxHistory();
+            history.Action = HistoryAction.Update;
+            history.PDFDoc = pdfViewerControl.GetCPDFViewer().GetDocument();
+            history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+
+            return history;
+        }
+        
+        private void AddHistory(TextBoxHistory history)
+        {
+            history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, cPDFAnnotation.Page.PageIndex, cPDFAnnotation);
+            pdfViewerControl.GetCPDFViewer().UndoManager.AddHistory(history);
+        }
 
         #endregion
     }