Jelajahi Sumber

其他 - 替换便签控件

liyuxuan 1 tahun lalu
induk
melakukan
85562c5761

+ 51 - 16
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFNoteUI.xaml.cs

@@ -1,6 +1,8 @@
-using Compdfkit_Tools.Common;
+using ComPDFKit.PDFAnnotation;
+using ComPDFKit.Tool;
+using Compdfkit_Tools.Common;
 using Compdfkit_Tools.Data;
-using ComPDFKitViewer.AnnotEvent;
+using Compdfkit_Tools.PDFControl;
 using ComPDFKitViewer;
 using System;
 using System.Windows.Controls;
@@ -11,7 +13,9 @@ namespace Compdfkit_Tools.PDFControlUI
     public partial class CPDFNoteUI : UserControl
     {
         public event EventHandler<CPDFAnnotationData> PropertyChanged;
-        internal AnnotAttribEvent annotAttribEvent { get;private set; }
+        internal StickyNoteParam stickyParam { get;private set; }
+        private CPDFTextAnnotation textAnnot;
+        private PDFViewControl viewControl;
 
         public CPDFNoteUI()
         {
@@ -22,42 +26,73 @@ namespace Compdfkit_Tools.PDFControlUI
 
         private void ColorPickerControl_ColorChanged(object sender, EventArgs e)
         {
-            if (annotAttribEvent == null)
+            if (stickyParam == null)
             {
                 PropertyChanged?.Invoke(this, GetNoteData());
             }
             else
             {
-                annotAttribEvent.UpdateAttrib(AnnotAttrib.Color, ((SolidColorBrush)ColorPickerControl.Brush).Color);
-                annotAttribEvent.UpdateAnnot();
+                SolidColorBrush colorBrush= ColorPickerControl.Brush as SolidColorBrush;
+                if (textAnnot!=null && textAnnot.IsValid() && colorBrush!=null)
+                {
+                    textAnnot.SetColor(new byte[3]
+                    {
+                        colorBrush.Color.R,
+                        colorBrush.Color.G,
+                        colorBrush.Color.B
+                    });
+                    if (viewControl != null && viewControl.PDFViewTool != null)
+                    {
+                        CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
+                        pdfViewer?.UpDataAnnotFrame();
+                    }
+                }
             }
             CPDFAnnotationPreviewerControl.DrawNotePreview(GetNoteData());
         }
 
         private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
         {
-            if (annotAttribEvent == null)
+            if (stickyParam == null)
             {
                 PropertyChanged?.Invoke(this, GetNoteData());
             }
             else
             {
-                annotAttribEvent.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
-                annotAttribEvent.UpdateAnnot();
+                if (textAnnot != null && textAnnot.IsValid())
+                {
+                    textAnnot.SetContent(NoteTextBox.Text);
+                    if (viewControl != null && viewControl.PDFViewTool != null)
+                    {
+                        CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
+                        pdfViewer?.UpDataAnnotFrame();
+                    }
+                }
             }
         }
 
-        public void SetPresentAnnotAttrib(AnnotAttribEvent annotAttribEvent)
+        public void SetPresentAnnotAttrib(StickyNoteParam param,CPDFTextAnnotation annot,PDFViewControl view)
         {
-            this.annotAttribEvent = null;
-            ColorPickerControl.Brush = new SolidColorBrush((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
-            NoteTextBox.Text = (string)annotAttribEvent.Attribs[AnnotAttrib.NoteText];
-            this.annotAttribEvent = annotAttribEvent;
+            this.stickyParam = null;
+            this.viewControl = null;
+            this.textAnnot = null;
 
-            if (annotAttribEvent.Attribs != null && annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.Color))
+            if(param != null)
             {
-                ColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+                ColorPickerControl.Brush = new SolidColorBrush(Color.FromRgb(
+                    param.StickyNoteColor[0],
+                    param.StickyNoteColor[1],
+                    param.StickyNoteColor[2]));
+                NoteTextBox.Text = param.Content;
+                ColorPickerControl.SetCheckedForColor(Color.FromRgb(
+                    param.StickyNoteColor[0],
+                    param.StickyNoteColor[1],
+                    param.StickyNoteColor[2]));
             }
+           
+            this.stickyParam = param;
+            this.textAnnot=annot;
+            this.viewControl = view;
         }
 
         public CPDFNoteData GetNoteData()

+ 88 - 293
Demo/Examples/Compdfkit_Tools/Edit/ContentEditCOntrol/ContentEditControl.xaml.cs

@@ -162,52 +162,52 @@ namespace Compdfkit_Tools.PDFControl
             if (senderBtn != null && PdfViewControl != null)
             {
                 ClearPDFEditState(senderBtn);
-                if (senderBtn.IsChecked == true)
-                {
-                    PDFEditEvent createParam = new PDFEditEvent();
-                    createParam.EditType = CPDFEditType.EditText;
-                    createParam.IsBold = false;
-                    createParam.IsItalic = false;
-                    createParam.FontSize = 14;
-                    createParam.FontName = "Helvetica";
-                    createParam.FontColor = Colors.Black;
-                    createParam.TextAlign = TextAlignType.AlignLeft;
-                    createParam.Transparency = 255;
-
-                    if (PdfViewControl.PDFView != null && PdfViewControl.PDFView.Document != null)
-                    {
-                        CPDFDocument pdfDoc = PdfViewControl.PDFView.Document;
-                        PdfViewControl.PDFView.ToolManager.EnableClickCreate = true;
-                        PdfViewControl.PDFView.ToolManager.ClickCreateWidth = 100;
-                        if (pdfDoc.PageCount > 0)
-                        {
-                            CPDFPage pdfPage = pdfDoc.PageAtIndex(0);
-                            CPDFEditPage editPage = pdfPage.GetEditPage();
-                            editPage.BeginEdit(CPDFEditType.EditText);
-                            createParam.SystemFontNameList.AddRange(editPage.GetFontList());
-                            editPage.EndEdit();
-                        }
-                    }
+                //if (senderBtn.IsChecked == true)
+                //{
+                //    PDFEditEvent createParam = new PDFEditEvent();
+                //    createParam.EditType = CPDFEditType.EditText;
+                //    createParam.IsBold = false;
+                //    createParam.IsItalic = false;
+                //    createParam.FontSize = 14;
+                //    createParam.FontName = "Helvetica";
+                //    createParam.FontColor = Colors.Black;
+                //    createParam.TextAlign = TextAlignType.AlignLeft;
+                //    createParam.Transparency = 255;
+
+                //    if (PdfViewControl.PDFView != null && PdfViewControl.PDFView.Document != null)
+                //    {
+                //        CPDFDocument pdfDoc = PdfViewControl.PDFView.Document;
+                //        PdfViewControl.PDFView.ToolManager.EnableClickCreate = true;
+                //        PdfViewControl.PDFView.ToolManager.ClickCreateWidth = 100;
+                //        if (pdfDoc.PageCount > 0)
+                //        {
+                //            CPDFPage pdfPage = pdfDoc.PageAtIndex(0);
+                //            CPDFEditPage editPage = pdfPage.GetEditPage();
+                //            editPage.BeginEdit(CPDFEditType.EditText);
+                //            createParam.SystemFontNameList.AddRange(editPage.GetFontList());
+                //            editPage.EndEdit();
+                //        }
+                //    }
                   
-                    PdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText);
-                    PdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditText);
-                    PdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
-                    PdfViewControl.PDFView?.ReloadDocument();
-
-                    PdfViewControl.PDFView?.SetPDFEditParam(createParam);
-                    pdfContentEditControl.SetPDFTextEditData(createParam);
-                    panelState.RightPanel = PanelState.RightPanelState.PropertyPanel;
-                    pdfTextCreateParam = createParam;
-                }
-                else
-                {
-                    PdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.None);
-                    PdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditImage | CPDFEditType.EditText);
-                    PdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
-                    PdfViewControl.PDFView?.ReloadDocument();
-                    pdfContentEditControl.ClearContentControl();
-                    panelState.RightPanel = PanelState.RightPanelState.None;
-                }
+                //    PdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText);
+                //    PdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditText);
+                //    PdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
+                //    PdfViewControl.PDFView?.ReloadDocument();
+
+                //    PdfViewControl.PDFView?.SetPDFEditParam(createParam);
+                //    pdfContentEditControl.SetPDFTextEditData(createParam);
+                //    panelState.RightPanel = PanelState.RightPanelState.PropertyPanel;
+                //    pdfTextCreateParam = createParam;
+                //}
+                //else
+                //{
+                //    PdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.None);
+                //    PdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditImage | CPDFEditType.EditText);
+                //    PdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
+                //    PdfViewControl.PDFView?.ReloadDocument();
+                //    pdfContentEditControl.ClearContentControl();
+                //    panelState.RightPanel = PanelState.RightPanelState.None;
+                //}
             }
 
         }
@@ -221,17 +221,17 @@ 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();
+                //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); 
-                }
+                //    PdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditImage);
+                //    PdfViewControl.PDFView?.AddPDFEditImage(openFileDialog.FileName); 
+                //}
             }
         }
 
@@ -253,17 +253,17 @@ namespace Compdfkit_Tools.PDFControl
 
         private void UndoBtn_Click(object sender, RoutedEventArgs e)
         {
-            if (PdfViewControl != null && PdfViewControl.PDFView != null)
+            if (PdfViewControl != null && PdfViewControl.PDFViewTool != null)
             {
-                PdfViewControl.PDFView.UndoManager?.Undo();
+                PdfViewControl.PDFViewTool.GetCPDFViewer()?.UndoManager?.Undo();
             }
         }
 
         private void RedoBtn_Click(object sender, RoutedEventArgs e)
         {
-            if (PdfViewControl != null && PdfViewControl.PDFView != null)
+            if (PdfViewControl != null && PdfViewControl.PDFViewTool != null)
             {
-                PdfViewControl.PDFView.UndoManager?.Redo();
+                PdfViewControl.PDFViewTool.GetCPDFViewer()?.UndoManager?.Redo();
             }
         }
 
@@ -285,12 +285,12 @@ namespace Compdfkit_Tools.PDFControl
 
         private void UserControl_Loaded(object sender, RoutedEventArgs e)
         {
-            PdfViewControl.PDFView.PDFEditCommandHandler += PDFView_PDFEditCommandHandler;
+          
         }
 
         private void UserControl_UnLoaded(object sender, RoutedEventArgs e)
         {
-            PdfViewControl.PDFView.PDFEditCommandHandler -= PDFView_PDFEditCommandHandler;
+          
         }
          
         public void ExpandRightPropertyPanel(UIElement propertytPanel, Visibility visible)
@@ -300,19 +300,19 @@ namespace Compdfkit_Tools.PDFControl
             PropertyContainer.Visibility = visible;
         }
 
-        public void InitWithPDFViewer(CPDFViewer pdfViewer)
+        public void InitWithPDFViewer(PDFViewControl view)
         {
-            PdfViewControl.PDFView = pdfViewer;
+            PdfViewControl = view;
             PDFGrid.Child = PdfViewControl;
-            FloatPageTool.InitWithPDFViewer(pdfViewer);
-            pdfContentEditControl.InitWithPDFViewer(pdfViewer);
+            FloatPageTool.InitWithPDFViewer(view);
+            pdfContentEditControl.InitWithPDFViewer(view);
             DataContext = this;
         }
 
         /// <summary>
         /// Text and Image Selected Event
         /// </summary>
-        private void PDFView_PDFEditActiveHandler(object sender, PDFEditEvent e)
+        private void PDFView_PDFEditActiveHandler(object sender, PDFEditParam e)
         {
             lastPDFEditEvent = e; 
 
@@ -320,28 +320,27 @@ namespace Compdfkit_Tools.PDFControl
             {
                 PropertyContainer.Child = pdfContentEditControl;
 
-                if (pdfTextCreateParam != null && PdfViewControl != null && PdfViewControl.PDFView != null)
-                {
-                    if (PdfViewControl.PDFView.GetPDFEditCreateType() == CPDFEditType.EditText)
-                    {
-                        pdfContentEditControl.SetPDFTextEditData(pdfTextCreateParam);
-                    }
-                    else if (PdfViewControl.PDFView.GetPDFEditCreateType() == CPDFEditType.None)
-                    {
-                        pdfContentEditControl.ClearContentControl();
-
-                    }
-                }
-                else
-                {
-                    pdfContentEditControl.ClearContentControl();
-                }
+                //if (pdfTextCreateParam != null && PdfViewControl != null && PdfViewControl.PDFView != null)
+                //{
+                //    if (PdfViewControl.PDFView.GetPDFEditCreateType() == CPDFEditType.EditText)
+                //    {
+                //        pdfContentEditControl.SetPDFTextEditData(pdfTextCreateParam);
+                //    }
+                //    else if (PdfViewControl.PDFView.GetPDFEditCreateType() == CPDFEditType.None)
+                //    {
+                //        pdfContentEditControl.ClearContentControl();
+                //    }
+                //}
+                //else
+                //{
+                //    pdfContentEditControl.ClearContentControl();
+                //}
                 return;
             }
 
             if (e.EditType == CPDFEditType.EditText)
             {
-                pdfContentEditControl.SetPDFTextEditData(e, true);
+                pdfContentEditControl.SetPDFTextEditData((TextEditParam)e, true);
                 return;
             }
 
@@ -352,7 +351,7 @@ namespace Compdfkit_Tools.PDFControl
                 {
                     pageView.MouseLeftButtonUp += PageView_MouseLeftButtonUp;
                 }
-                pdfContentEditControl.SetPDFImageEditData(e);
+                pdfContentEditControl.SetPDFImageEditData((ImageEditParam)e);
                 return;
             }
         }
@@ -366,7 +365,7 @@ namespace Compdfkit_Tools.PDFControl
             }
             if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
             {
-                pdfContentEditControl.SetPDFImageEditData(lastPDFEditEvent);
+                pdfContentEditControl.SetPDFImageEditData((ImageEditParam)lastPDFEditEvent);
             }
         }
         
@@ -395,223 +394,19 @@ namespace Compdfkit_Tools.PDFControl
         }
         #endregion
 
-        #region Context menu
-
-        private void PDFView_PDFEditCommandHandler(object sender, PDFEditCommand e)
-        {
-            if (e == null)
-            {
-                return;
-            }
-
-            if (e.EditType == CPDFEditType.EditText)
-            {
-                e.Handle = true;
-                PDFEditTextContextMenu(sender, e);
-            }
-
-            if (e.EditType == CPDFEditType.EditImage)
-            {
-                e.Handle = true;
-                PDFEditImageContextMenu(sender, e);
-            }
-        }
-        
-        private void PDFEditTextContextMenu(object sender, PDFEditCommand editCommand)
-        {
-            editCommand.PopupMenu = new ContextMenu();
-            if (lastPDFEditEvent != null)
-            {
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
-            }
-            else
-            {
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
-                if (editCommand.TextAreaCopied)
-                {
-                    editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste And Match Style", Command = CustomCommands.PasteMatchStyle, CommandTarget = (UIElement)sender });
-                }
-            }
-        }
-
-        private void PDFEditImageContextMenu(object sender, PDFEditCommand editCommand)
-        {
-            editCommand.PopupMenu = new ContextMenu();
-            if (lastPDFEditEvent != null)
-            {
-                MenuItem rotateLeftMenu = new MenuItem();
-                rotateLeftMenu.Header = "Left Rotate";
-                rotateLeftMenu.Click += (o, p) =>
-                {
-                    if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
-                    {
-                        lastPDFEditEvent.Rotate = -90;
-                        lastPDFEditEvent.UpdatePDFEditByEventArgs();
-                        pdfContentEditControl.RefreshThumb();
-                    }
-                };
-                editCommand.PopupMenu.Items.Add(rotateLeftMenu);
-
-                MenuItem rotateRightMenu = new MenuItem();
-                rotateRightMenu.Header = "Right Rotate";
-                rotateRightMenu.Click += (o, p) =>
-                {
-                    if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
-                    {
-                        lastPDFEditEvent.Rotate = 90;
-                        lastPDFEditEvent.UpdatePDFEditByEventArgs();
-                        pdfContentEditControl.RefreshThumb();
-                    }
-                };
-                editCommand.PopupMenu.Items.Add(rotateRightMenu);
-
-                MenuItem replaceMenu = new MenuItem();
-                replaceMenu.Header = "Replace";
-                replaceMenu.Click += (o, p) =>
-                {
-                    if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
-                    {
-                        OpenFileDialog openFileDialog = new OpenFileDialog();
-                        openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
-                        if (openFileDialog.ShowDialog() == true)
-                        {
-                            lastPDFEditEvent.ReplaceImagePath = openFileDialog.FileName;
-                            lastPDFEditEvent.UpdatePDFEditByEventArgs();
-                            PdfViewControl.PDFView?.ClearSelectPDFEdit();
-                            pdfContentEditControl.RefreshThumb();
-                        }
-                    }
-                };
-                editCommand.PopupMenu.Items.Add(replaceMenu);
-
-                MenuItem exportMenu = new MenuItem();
-                exportMenu.Header = "Export";
-                exportMenu.Click += (o, p) =>
-                {
-                    if (PdfViewControl != null && PdfViewControl.PDFView != null)
-                    {
-                        Dictionary<int, List<Bitmap>> imageDict = PdfViewControl.PDFView.GetSelectedImages();
-                        if (imageDict != null && imageDict.Count > 0)
-                        {
-                            System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
-                            if (folderBrowser.ShowDialog() == System.Windows.Forms.DialogResult.OK)
-                            {
-                                string choosePath = folderBrowser.SelectedPath;
-                                string openPath = choosePath;
-                                foreach (int pageIndex in imageDict.Keys)
-                                {
-                                    List<Bitmap> imageList = imageDict[pageIndex];
-                                    foreach (Bitmap image in imageList)
-                                    {
-                                        string savePath = System.IO.Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
-                                        image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
-                                        openPath = savePath;
-                                    }
-                                }
-                                Process.Start("explorer", "/select,\"" + openPath + "\"");
-                            }
-                        }
-                    }
-                };
-                editCommand.PopupMenu.Items.Add(exportMenu);
-
-                MenuItem opacityMenu = new MenuItem();
-                opacityMenu.Header = "Opacity";
-                editCommand.PopupMenu.Items.Add(opacityMenu);
-
-                AppendOpacityMenu(opacityMenu);
-
-                MenuItem horizonMirror = new MenuItem();
-                horizonMirror.Header = "HMirror";
-                horizonMirror.Click += (o, p) =>
-                {
-                    if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
-                    {
-                        lastPDFEditEvent.HorizontalMirror = true;
-                        lastPDFEditEvent.UpdatePDFEditByEventArgs();
-                    }
-                };
-                editCommand.PopupMenu.Items.Add(horizonMirror);
-
-                MenuItem verticalMirror = new MenuItem();
-                verticalMirror.Header = "VMirror";
-                verticalMirror.Click += (o, p) =>
-                {
-                    if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
-                    {
-                        lastPDFEditEvent.VerticalMirror = true;
-                        lastPDFEditEvent.UpdatePDFEditByEventArgs();
-                    }
-                };
-                editCommand.PopupMenu.Items.Add(verticalMirror);
-
-                MenuItem cropMenu = new MenuItem();
-                cropMenu.Header = "Crop";
-                cropMenu.Click += (o, p) =>
-                {
-                    if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
-                    {
-                        lastPDFEditEvent.ClipImage = true;
-                        lastPDFEditEvent.UpdatePDFEditByEventArgs();
-                    }
-                };
-                editCommand.PopupMenu.Items.Add(cropMenu);
-
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
-                if (editCommand.TextAreaCopied)
-                {
-                    editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste And Match Style", Command = CustomCommands.PasteMatchStyle, CommandTarget = (UIElement)sender });
-                }
-            }
-            else
-            {
-                editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
-            }
-        }
-        
-        private void AppendOpacityMenu(MenuItem parentMenu)
-        {
-            List<int> opacityList = new List<int>()
-            {
-                25,50,75,100
-            };
-
-            foreach (int opacity in opacityList)
-            {
-                MenuItem opacityMenu = new MenuItem();
-                opacityMenu.Header = string.Format("{0}%", opacity);
-                opacityMenu.Click += (o, p) =>
-                {
-                    if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
-                    {
-                        lastPDFEditEvent.Transparency = (int)Math.Ceiling(opacity * 255 / 100D);
-                        lastPDFEditEvent.UpdatePDFEditByEventArgs();
-                    }
-                };
-                parentMenu.Items.Add(opacityMenu);
-            }
-        }
-
-        #endregion
         private void CommandBinding_Executed_Undo(object sender, ExecutedRoutedEventArgs e)
         {
-            if (PdfViewControl != null && PdfViewControl.PDFView != null && CanUndo)
+            if (PdfViewControl != null && PdfViewControl.PDFViewTool != null && CanUndo)
             {
-                PdfViewControl.PDFView.UndoManager?.Undo();
+                PdfViewControl.PDFViewTool.GetCPDFViewer()?.UndoManager?.Undo();
             }
         }
 
         private void CommandBinding_Executed_Redo(object sender, ExecutedRoutedEventArgs e)
         {
-            if (PdfViewControl != null && PdfViewControl.PDFView != null && CanRedo)
+            if (PdfViewControl != null && PdfViewControl.PDFViewTool != null && CanRedo)
             {
-                PdfViewControl.PDFView.UndoManager?.Redo();
+                PdfViewControl.PDFViewTool.GetCPDFViewer()?.UndoManager?.Redo();
             }
         }
     }

+ 9 - 28
Demo/Examples/Compdfkit_Tools/Edit/PDFContentEditControl.xaml.cs

@@ -1,48 +1,29 @@
-using ComPDFKitViewer.PdfViewer;
-using ComPDFKitViewer;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
+using ComPDFKit.Tool;
+using Compdfkit_Tools.PDFControl;
 using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
 
 namespace Compdfkit_Tools.Edit
 {
-    /// <summary>
-    /// Interaction logic for PDFContentEditControl.xaml
-    /// </summary>
     public partial class PDFContentEditControl : UserControl
     {
-        private UIElement contentEditPanel = null;
-        private UIElement tempContentEditPanel = null;
-
         private PDFImageEditControl PDFImageEditControl = new PDFImageEditControl();
         private PDFTextEditControl PDFTextEditControl = new PDFTextEditControl();
 
-        public CPDFViewer PDFView { get; private set; }
-        public PDFEditEvent EditEvent { get; set; }
+        public PDFViewControl ViewControl { get; private set; }
+        public PDFEditParam EditEvent { get; set; }
 
         public PDFContentEditControl()
         {
             InitializeComponent();
         }
 
-        public void InitWithPDFViewer(CPDFViewer newPDFView)
+        public void InitWithPDFViewer(PDFViewControl newPDFView)
         {
-            PDFView = newPDFView;
-            PDFImageEditControl.InitWithPDFViewer(newPDFView);
+            ViewControl = newPDFView;
+            PDFImageEditControl.InitWithPDFViewer(newPDFView.PDFViewTool);
         }
 
-        public void SetPDFTextEditData(PDFEditEvent editEvent, bool isTemp = false)
+        public void SetPDFTextEditData(TextEditParam editEvent, bool isTemp = false)
         {
             if (!isTemp)
             {
@@ -62,7 +43,7 @@ namespace Compdfkit_Tools.Edit
             ContentEditContainer.Child = null;
         }
 
-        public void SetPDFImageEditData(PDFEditEvent editEvent)
+        public void SetPDFImageEditData(ImageEditParam editEvent)
         {
                 PDFImageEditControl.SetPDFImageEditData(editEvent);
                 ContentEditContainer.Child = PDFImageEditControl;