Sfoglia il codice sorgente

Merge branch 'compdfkit_demo_win_rebuild' of http://git.kdan.cc:8865/Others/kmpdfkit_demo into compdfkit_demo_win_rebuild

sunhaonan 11 mesi fa
parent
commit
daffa0c82c

+ 5 - 26
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs

@@ -904,6 +904,7 @@ namespace Compdfkit_Tools.PDFControl
                         try
                         {
                             BitmapImage image = new BitmapImage(new Uri(openFileDialog.FileName));
+
                             PngBitmapEncoder encoder = new PngBitmapEncoder();
                             encoder.Frames.Add(BitmapFrame.Create(image));
                             MemoryStream memoryStream = new MemoryStream();
@@ -912,32 +913,10 @@ namespace Compdfkit_Tools.PDFControl
                             stampParam.Transparency = 255;
                             stampParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_STAMP;
                             stampParam.StampType = C_STAMP_TYPE.IMAGE_STAMP;
-                            BitmapDecoder decoder = BitmapDecoder.Create(stampParam.ImageStream, BitmapCreateOptions.None, BitmapCacheOption.Default);
-                            BitmapFrame frame = null;
-                            if (decoder != null && decoder.Frames.Count > 0)
-                            {
-                                frame = decoder.Frames[0];
-                            }
-                            if (frame != null)
-                            {
-                                byte[] imageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
-                                if (frame.Format != PixelFormats.Bgra32)
-                                {
-                                    FormatConvertedBitmap covert = new FormatConvertedBitmap(
-                                        frame,
-                                        PixelFormats.Bgra32,
-                                        frame.Palette,
-                                        0);
-                                    covert.CopyPixels(imageArray, frame.PixelWidth * 4, 0);
-                                }
-                                else
-                                {
-                                    frame.CopyPixels(imageArray, frame.PixelWidth * 4, 0);
-                                }
-                                pdfViewerControl.PDFViewTool.GetCPDFViewer().SetStampMouseImage(imageArray, frame.PixelWidth, frame.PixelHeight);
-                                pdfViewerControl.PDFViewTool.GetCPDFViewer().SetIsVisibleCustomMouse(true);
-                                pdfViewerControl.PDFViewTool.GetCPDFViewer().SetIsShowStampMouse(true);
-                            }
+
+                            bool SetStamp = pdfViewerControl.PDFViewTool.GetCPDFViewer().SetStampMouseImage(openFileDialog.FileName);
+                            pdfViewerControl.PDFViewTool.GetCPDFViewer().SetIsVisibleCustomMouse(SetStamp);
+                            pdfViewerControl.PDFViewTool.GetCPDFViewer().SetIsShowStampMouse(SetStamp);
                             DefaultSettingParam defaultSettingParam = pdfViewerControl.PDFViewTool.GetDefaultSettingParam();
                             defaultSettingParam.SetAnnotParam(stampParam);
                             pdfViewerControl.SetToolType(ToolType.CreateAnnot);

+ 64 - 15
Demo/Examples/Compdfkit_Tools/Edit/ContentEditCOntrol/ContentEditControl.xaml.cs

@@ -1,7 +1,9 @@
-using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFAnnotation;
+using ComPDFKit.PDFDocument;
 using ComPDFKit.PDFPage;
 using ComPDFKit.PDFPage.Edit;
 using ComPDFKit.Tool;
+using ComPDFKit.Tool.SettingParam;
 using Compdfkit_Tools.Edit;
 using Compdfkit_Tools.Helper;
 using ComPDFKitViewer;
@@ -11,12 +13,15 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.Diagnostics;
 using System.Drawing;
+using System.IO;
 using System.Runtime.CompilerServices;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls.Primitives;
 using System.Windows.Input;
 using System.Windows.Media;
+using static ComPDFKit.Tool.CPDFToolManager;
+using System.Windows.Media.Imaging;
 
 namespace Compdfkit_Tools.PDFControl
 {
@@ -154,6 +159,9 @@ namespace Compdfkit_Tools.PDFControl
                 }
                 item.IsChecked = false;
             }
+            PdfViewControl.PDFToolManager.SetCreateContentEditType(CPDFEditType.None);
+            PdfViewControl.PDFViewTool.GetCPDFViewer().SetIsVisibleCustomMouse(false);
+            PdfViewControl.PDFViewTool.GetCPDFViewer().SetIsShowStampMouse(false);
         }
          
         private void PDFTextEditButton_Click(object sender, RoutedEventArgs e)
@@ -162,8 +170,28 @@ namespace Compdfkit_Tools.PDFControl
             if (senderBtn != null && PdfViewControl != null)
             {
                 ClearPDFEditState(senderBtn);
-                //if (senderBtn.IsChecked == true)
-                //{
+                if (senderBtn.IsChecked == true)
+                {
+                    TextEditParam textEditParam = new TextEditParam();
+                    textEditParam.EditType = CPDFEditType.EditText;
+                    textEditParam.IsBold = false;
+                    textEditParam.IsItalic = false;
+                    textEditParam.FontSize = 14;
+                    textEditParam.FontName = "Helvetica";
+                    textEditParam.FontColor = new byte[] { 0, 0, 0 };
+                    textEditParam.EditIndex = -1;
+                    textEditParam.TextAlign = TextAlignType.AlignLeft;
+                    textEditParam.Transparency = 255;
+                    pdfContentEditControl.SetPDFTextEditData(textEditParam);
+                    DefaultSettingParam defaultSettingParam = PdfViewControl.PDFViewTool.GetDefaultSettingParam();
+                    defaultSettingParam.SetPDFEditParamm(textEditParam);
+                    panelState.RightPanel = PanelState.RightPanelState.PropertyPanel;
+                    PdfViewControl.PDFToolManager.SetCreateContentEditType(CPDFEditType.EditText);
+                }
+                else
+                {
+
+                }
                 //    PDFEditEvent createParam = new PDFEditEvent();
                 //    createParam.EditType = CPDFEditType.EditText;
                 //    createParam.IsBold = false;
@@ -188,7 +216,7 @@ namespace Compdfkit_Tools.PDFControl
                 //            editPage.EndEdit();
                 //        }
                 //    }
-                  
+
                 //    PdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText);
                 //    PdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditText);
                 //    PdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
@@ -221,17 +249,38 @@ namespace Compdfkit_Tools.PDFControl
                 senderBtn.IsChecked = false;
                 OpenFileDialog openFileDialog = new OpenFileDialog();
                 openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
-                //if (openFileDialog.ShowDialog() == true)
-                //{
-                //    ClearPDFEditState(senderBtn);
-                //    PdfViewControl.PDFView?.ClearSelectPDFEdit();
-                //    PdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditImage | CPDFEditType.EditText);
-                //    PdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
-                //    PdfViewControl.PDFView?.ReloadDocument();
-                     
-                //    PdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditImage);
-                //    PdfViewControl.PDFView?.AddPDFEditImage(openFileDialog.FileName); 
-                //}
+                if (openFileDialog.ShowDialog() == true)
+                {
+                    ClearPDFEditState(senderBtn);
+                    try
+                    {
+                        BitmapImage image = new BitmapImage(new Uri(openFileDialog.FileName));
+                        PngBitmapEncoder encoder = new PngBitmapEncoder();
+                        encoder.Frames.Add(BitmapFrame.Create(image));
+                        MemoryStream memoryStream = new MemoryStream();
+                        encoder.Save(memoryStream);
+
+                        bool SetImage = PdfViewControl.PDFViewTool.GetCPDFViewer().SetStampMouseImage(openFileDialog.FileName);
+                        PdfViewControl.PDFToolManager.SetCreateImagePath(openFileDialog.FileName);
+                        PdfViewControl.PDFViewTool.GetCPDFViewer().SetIsVisibleCustomMouse(SetImage);
+                        PdfViewControl.PDFViewTool.GetCPDFViewer().SetIsShowStampMouse(SetImage);
+                        PdfViewControl.PDFToolManager.SetCreateContentEditType(CPDFEditType.EditImage);
+                    }
+                    catch
+                    {
+                    }
+                    //if (openFileDialog.ShowDialog() == true)
+                    //{
+                    //    ClearPDFEditState(senderBtn);
+                    //    PdfViewControl.PDFView?.ClearSelectPDFEdit();
+                    //    PdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditImage | CPDFEditType.EditText);
+                    //    PdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
+                    //    PdfViewControl.PDFView?.ReloadDocument();
+
+                    //    PdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditImage);
+                    //    PdfViewControl.PDFView?.AddPDFEditImage(openFileDialog.FileName); 
+                    //}
+                }
             }
         }
 

+ 4 - 2
Demo/Examples/Compdfkit_Tools/Edit/PDFContentEditControl.xaml.cs

@@ -21,6 +21,7 @@ namespace Compdfkit_Tools.Edit
         {
             ViewControl = newPDFView;
             PDFImageEditControl.InitWithPDFViewer(newPDFView.PDFViewTool);
+            PDFTextEditControl.InitWithPDFViewer(newPDFView.PDFViewTool);
         }
 
         public void SetPDFTextEditData(TextEditParam editEvent, bool isTemp = false)
@@ -33,6 +34,7 @@ namespace Compdfkit_Tools.Edit
             else
             {
                 PDFTextEditControl tempPDFTextEditControl = new PDFTextEditControl();
+                tempPDFTextEditControl.InitWithPDFViewer(ViewControl.PDFViewTool);
                 tempPDFTextEditControl.SetPDFTextEditData(editEvent);
                 ContentEditContainer.Child = tempPDFTextEditControl;
             }
@@ -45,8 +47,8 @@ namespace Compdfkit_Tools.Edit
 
         public void SetPDFImageEditData(ImageEditParam editEvent)
         {
-                PDFImageEditControl.SetPDFImageEditData(editEvent);
-                ContentEditContainer.Child = PDFImageEditControl;
+            PDFImageEditControl.SetPDFImageEditData(editEvent);
+            ContentEditContainer.Child = PDFImageEditControl;
         }
 
         public void RefreshThumb()

+ 120 - 32
Demo/Examples/Compdfkit_Tools/Edit/PDFTextEdit/PDFTextEditControl/PDFTextEditControl.xaml.cs

@@ -2,8 +2,10 @@
 using ComPDFKit.PDFPage;
 using ComPDFKit.PDFPage.Edit;
 using ComPDFKit.Tool;
+using ComPDFKit.Tool.SettingParam;
 using ComPDFKit.Tool.UndoManger;
 using ComPDFKit.Viewer.Helper;
+using Compdfkit_Tools.PDFControl;
 using ComPDFKitViewer;
 using System;
 using System.Collections.Generic;
@@ -37,7 +39,7 @@ namespace Compdfkit_Tools.Edit
                 List<string> sysfontList = new List<string>();
                 if (textArea != null)
                 {
-                  sysfontList=  textArea.GetFontList();
+                    sysfontList = textArea.GetFontList();
                 }
                 if (sysfontList.Count == 0)
                 {
@@ -57,14 +59,14 @@ namespace Compdfkit_Tools.Edit
                 OpacityTextBox.Text = string.Format("{0}%", (int)(Math.Ceiling(newEvent.Transparency * 100 / 255D)));
                 FontOpacitySlider.Value = ((int)(Math.Ceiling(newEvent.Transparency * 100 / 255D))) / 100D;
                 TextAlignUI.SetFontAlign(newEvent.TextAlign);
-                if(newEvent.FontColor != null && newEvent.FontColor.Length==3)
+                if (newEvent.FontColor != null && newEvent.FontColor.Length == 3)
                 {
                     FontColorUI.SetCheckedForColor(Color.FromRgb(
                         newEvent.FontColor[0],
                         newEvent.FontColor[1],
                         newEvent.FontColor[2]));
                 }
-               
+
             }
             EditEvent = newEvent;
         }
@@ -79,8 +81,8 @@ namespace Compdfkit_Tools.Edit
             GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
             if (textArea != null)
             {
-                Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
-                if (textArea.SetCharsFontSize((float)slider.Value,false))
+                Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
+                if (textArea.SetCharsFontSize((float)slider.Value, false))
                 {
                     PDFEditHistory editHistory = new PDFEditHistory();
                     editHistory.EditPage = editPage;
@@ -91,8 +93,15 @@ namespace Compdfkit_Tools.Edit
 
                     ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
                     ToolView.UpDateRender(oldRect, textArea);
+                    editPage.EndEdit();
                 }
             }
+            if (EditEvent != null && textArea == null)
+            {
+                EditEvent.FontSize = slider.Value;
+                DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
+                defaultSettingParam.SetPDFEditParamm(EditEvent);
+            }
         }
 
         private void SliderOpacity_DragCompleted(object sender, DragCompletedEventArgs e)
@@ -105,8 +114,8 @@ namespace Compdfkit_Tools.Edit
             GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
             if (textArea != null)
             {
-                Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
-                if(textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255)))
+                Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
+                if (textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255)))
                 {
                     PDFEditHistory editHistory = new PDFEditHistory();
                     editHistory.EditPage = editPage;
@@ -116,8 +125,15 @@ namespace Compdfkit_Tools.Edit
                     }
                     ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
                     ToolView.UpDateRender(oldRect, textArea);
+                    editPage.EndEdit();
                 }
             }
+            if (EditEvent != null && textArea == null)
+            {
+                EditEvent.Transparency = (byte)(FontOpacitySlider.Value * 255);
+                DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
+                defaultSettingParam.SetPDFEditParamm(EditEvent);
+            }
         }
 
         private void SliderOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
@@ -135,7 +151,7 @@ namespace Compdfkit_Tools.Edit
             GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
             if (textArea != null)
             {
-                Rect oldRect=DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
+                Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
                 if (textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255)))
                 {
                     PDFEditHistory editHistory = new PDFEditHistory();
@@ -146,8 +162,15 @@ namespace Compdfkit_Tools.Edit
                     }
                     ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
                     ToolView.UpDateRender(oldRect, textArea);
+                    editPage.EndEdit();
                 }
             }
+            if (EditEvent != null && textArea == null)
+            {
+                EditEvent.Transparency = (byte)(FontOpacitySlider.Value * 255);
+                DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
+                defaultSettingParam.SetPDFEditParamm(EditEvent);
+            }
         }
 
         private void Slider_DragStarted(object sender, DragStartedEventArgs e)
@@ -170,8 +193,8 @@ namespace Compdfkit_Tools.Edit
             GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
             if (textArea != null)
             {
-                Rect oldRect=DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
-                if (textArea.SetCharsFontSize((float)slider.Value,false))
+                Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
+                if (textArea.SetCharsFontSize((float)slider.Value, false))
                 {
                     PDFEditHistory editHistory = new PDFEditHistory();
                     editHistory.EditPage = editPage;
@@ -181,8 +204,15 @@ namespace Compdfkit_Tools.Edit
                     }
                     ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
                     ToolView.UpDateRender(oldRect, textArea);
+                    editPage.EndEdit();
                 }
             }
+            if (EditEvent != null && textArea == null)
+            {
+                EditEvent.FontSize = slider.Value;
+                DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
+                defaultSettingParam.SetPDFEditParamm(EditEvent);
+            }
         }
 
         private void PDFTextEditControl_Loaded(object sender, RoutedEventArgs e)
@@ -208,7 +238,7 @@ namespace Compdfkit_Tools.Edit
             GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
             if (textArea != null)
             {
-                Rect oldRect=DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
+                Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
                 if (textArea.SetCharsFontSize((float)e, false))
                 {
                     PDFEditHistory editHistory = new PDFEditHistory();
@@ -219,17 +249,24 @@ namespace Compdfkit_Tools.Edit
                     }
                     ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
                     ToolView.UpDateRender(oldRect, textArea);
+                    editPage.EndEdit();
                 }
             }
+            if (EditEvent != null && textArea == null)
+            {
+                EditEvent.FontSize = e;
+                DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
+                defaultSettingParam.SetPDFEditParamm(EditEvent);
+            }
         }
 
         private void FontColorUI_ColorChanged(object sender, EventArgs e)
         {
             SolidColorBrush newBrush = FontColorUI.Brush as SolidColorBrush;
             GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
-            if (textArea != null && newBrush!=null)
+            if (textArea != null && newBrush != null)
             {
-                Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
+                Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
                 if (textArea.SetCharsFontColor(newBrush.Color.R, newBrush.Color.G, newBrush.Color.B))
                 {
                     PDFEditHistory editHistory = new PDFEditHistory();
@@ -240,8 +277,19 @@ namespace Compdfkit_Tools.Edit
                     }
                     ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
                     ToolView.UpDateRender(oldRect, textArea);
+                    editPage.EndEdit();
                 }
             }
+            if (EditEvent != null && textArea == null && newBrush != null)
+            {
+                byte[] Color = new byte[3];
+                Color[0] = newBrush.Color.R;
+                Color[1] = newBrush.Color.G;
+                Color[2] = newBrush.Color.B;
+                EditEvent.FontColor = Color;
+                DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
+                defaultSettingParam.SetPDFEditParamm(EditEvent);
+            }
         }
 
         private void TextAlignUI_TextAlignChanged(object sender, TextAlignType e)
@@ -250,14 +298,14 @@ namespace Compdfkit_Tools.Edit
             if (textArea != null)
             {
                 bool result = false;
-                Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
-                if(textArea.SelectLineRects!=null && textArea.SelectLineRects.Count>0)
+                Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
+                if (textArea.SelectLineRects != null && textArea.SelectLineRects.Count > 0)
                 {
                     result = textArea.SetTextRangeAlign(e);
                 }
                 else
                 {
-                    result= textArea.SetTextAreaAlign(e);
+                    result = textArea.SetTextAreaAlign(e);
                 }
                 if (result)
                 {
@@ -269,8 +317,16 @@ namespace Compdfkit_Tools.Edit
                     }
                     ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
                     ToolView.UpDateRender(oldRect, textArea);
+                    editPage.EndEdit();
                 }
             }
+
+            if (EditEvent != null && textArea == null)
+            {
+                EditEvent.TextAlign = e;
+                DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
+                defaultSettingParam.SetPDFEditParamm(EditEvent);
+            }
         }
 
         private void TextStyleUI_TextItalicChanged(object sender, bool e)
@@ -278,8 +334,8 @@ namespace Compdfkit_Tools.Edit
             GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
             if (textArea != null)
             {
-                Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
-                if(textArea.SetCharsFontItalic(e))
+                Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
+                if (textArea.SetCharsFontItalic(e))
                 {
                     PDFEditHistory editHistory = new PDFEditHistory();
                     editHistory.EditPage = editPage;
@@ -289,8 +345,15 @@ namespace Compdfkit_Tools.Edit
                     }
                     ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
                     ToolView.UpDateRender(oldRect, textArea);
+                    editPage.EndEdit();
                 }
             }
+            if (EditEvent != null && textArea == null)
+            {
+                EditEvent.IsItalic = e;
+                DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
+                defaultSettingParam.SetPDFEditParamm(EditEvent);
+            }
         }
 
         private void TextStyleUI_TextBoldChanged(object sender, bool e)
@@ -298,7 +361,7 @@ namespace Compdfkit_Tools.Edit
             GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
             if (textArea != null)
             {
-                Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
+                Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
                 if (textArea.SetCharsFontBold(e))
                 {
                     PDFEditHistory editHistory = new PDFEditHistory();
@@ -309,8 +372,15 @@ namespace Compdfkit_Tools.Edit
                     }
                     ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
                     ToolView.UpDateRender(oldRect, textArea);
+                    editPage.EndEdit();
                 }
             }
+            if (EditEvent != null && textArea == null)
+            {
+                EditEvent.IsBold = e;
+                DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
+                defaultSettingParam.SetPDFEditParamm(EditEvent);
+            }
         }
 
         private void TextStyleUI_TextFontChanged(object sender, string e)
@@ -318,7 +388,7 @@ namespace Compdfkit_Tools.Edit
             GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
             if (textArea != null)
             {
-                Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
+                Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
                 if (textArea.SetCharsFontName(e))
                 {
                     PDFEditHistory editHistory = new PDFEditHistory();
@@ -329,8 +399,15 @@ namespace Compdfkit_Tools.Edit
                     }
                     ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
                     ToolView.UpDateRender(oldRect, textArea);
+                    editPage.EndEdit();
                 }
             }
+            if (EditEvent != null && textArea == null)
+            {
+                EditEvent.FontName = e;
+                DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
+                defaultSettingParam.SetPDFEditParamm(EditEvent);
+            }
         }
 
         private void OpacityComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -351,26 +428,37 @@ namespace Compdfkit_Tools.Edit
             textArea = null;
             editPage = null;
             pdfPage = null;
-            if (ToolView == null || EditEvent == null)
+            if (ToolView == null)
             {
                 return;
             }
-
-            try
+            if (EditEvent != null)
             {
-                CPDFViewer pdfViewer = ToolView.GetCPDFViewer();
-                CPDFDocument pdfDoc = pdfViewer.GetDocument();
-                pdfPage = pdfDoc.PageAtIndex(EditEvent.PageIndex);
-                editPage = pdfPage.GetEditPage();
-                List<CPDFEditArea> editAreas = editPage.GetEditAreaList();
-                if (editAreas != null && editAreas.Count > EditEvent.EditIndex)
+                try
                 {
-                    textArea = editAreas[EditEvent.EditIndex] as CPDFEditTextArea;
+                    CPDFViewer pdfViewer = ToolView.GetCPDFViewer();
+                    CPDFDocument pdfDoc = pdfViewer.GetDocument();
+                    pdfPage = pdfDoc.PageAtIndex(EditEvent.PageIndex);
+                    editPage = pdfPage.GetEditPage();
+                    List<CPDFEditArea> editAreas = editPage.GetEditAreaList();
+                    if (editAreas != null && editAreas.Count > EditEvent.EditIndex)
+                    {
+                        textArea = editAreas[EditEvent.EditIndex] as CPDFEditTextArea;
+                    }
+                }
+                catch (Exception ex)
+                {
+
                 }
             }
-            catch (Exception ex)
+            else
             {
-
+                CPDFViewer pdfViewer = ToolView.GetCPDFViewer();
+                CPDFDocument pdfDoc = pdfViewer.GetDocument();
+                pdfPage = pdfDoc.PageAtIndex(0);
+                editPage = pdfPage.GetEditPage();
+                editPage.BeginEdit(CPDFEditType.EditText);
+                editPage.EndEdit();
             }
         }