Kaynağa Gözat

编辑功能开发

lvle 1 yıl önce
ebeveyn
işleme
c440b52cb1

Dosya farkı çok büyük olduğundan ihmal edildi
+ 177 - 0
PDF Office/Styles/ContextMenuTextEditStyle.xaml


+ 45 - 12
PDF Office/ViewModels/PropertyPanel/PDFEdit/ImageEditPropertyViewModel.cs

@@ -323,6 +323,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             navigationContext.Parameters.TryGetValue<List<PDFEditEvent>>(ParameterNames.AnnotEvent, out TextEditEventList);
             if (PDFViewer != null)
             {
+                PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
+                PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler;
                 PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
                 PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
                 LoadedPDFEdit();
@@ -404,26 +406,47 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             customMenu.SetMenuBinding(6, ExportImgCommand);
             return popMenu;
         }
-        //选中文字的框(暂时暂时)
-        private ContextMenu SelectTextBorder(object sender)
+
+        //选中裁剪图像时
+        private ContextMenu CropImgPDFEdit(object sender)
+        {
+            var popMenu = App.Current.FindResource("CropImgMenu") as ContextMenu;
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
+
+            //确认裁剪
+            customMenu.SetMenuBinding(0, CropImgCommand);
+            //取消裁剪
+            customMenu.SetMenuBinding(1, CancelCropCommand);
+            //还原裁剪
+            customMenu.SetMenuBinding(2, CancelCropCommand);
+            return popMenu;
+        }
+        //多选图片右键
+        private ContextMenu SelectMoreImage(object sender)
         {
-            var popMenu = App.Current.FindResource("SelectTextMenu") as ContextMenu;
+            var popMenu = App.Current.FindResource("SelectMoreImageMenu") as ContextMenu;
             CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            //编辑
-            customMenu.SetMenuBinding(0, EditImgModeCommand);
             //复制
-            customMenu.SetMenuBinding(1, ApplicationCommands.Copy);
+            customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
             //剪切
-            customMenu.SetMenuBinding(2, ApplicationCommands.Cut);
+            customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
             //粘贴
-            customMenu.SetMenuBinding(3, ApplicationCommands.Paste);
+            customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
             //删除
-            customMenu.SetMenuBinding(4, ApplicationCommands.Delete);
+            customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
+            //导出
+            customMenu.SetMenuBinding(4, ExportImgCommand);
 
-            customMenu.SetVisibilityProperty(4, false);
 
             return popMenu;
         }
+
+        private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
+        {
+            IsCrop = false;
+        }
+
+
         private void PDFViewer_PDFEditCommandHandler(object sender, PDFEditCommand e)
         {
 
@@ -435,11 +458,19 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                 case CommandType.Context:
                      if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
                     {
-                        e.PopupMenu = SelectImgPDFEdit(sender);
+                        if (IsCrop == true)
+                            {
+                            e.PopupMenu =CropImgPDFEdit(sender);
+                        }
+                        else
+                        {
+                            e.PopupMenu = SelectImgPDFEdit(sender);
+                        }
+                        
                     }
                     else if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)
                     {
-                        e.PopupMenu = SelectTextBorder(sender);
+                        e.PopupMenu = SelectMoreImage(sender);
 
                     }
            
@@ -456,6 +487,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
         }
 
+
         private void GetImagePreView()
         {
             try
@@ -502,6 +534,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             TextEditEvent = null;
             ClearCheckedAglin?.Invoke(null, null);
             PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
+            PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
         }
     }
 }

+ 4 - 3
PDF Office/ViewModels/PropertyPanel/PDFEdit/ImageTextEditPropertyViewModel.cs

@@ -72,6 +72,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             navigationContext.Parameters.TryGetValue<List<PDFEditEvent>>(ParameterNames.AnnotEvent, out TextEditEventList);
             if (PDFViewer != null)
             {
+              
                 if (TextEditEventList != null && TextEditEventList.Count > 0)
                 {
                     TextEditEvent = TextEditEventList[0];
@@ -96,12 +97,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             }
 
         }
-
-        public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
+      
+            public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
 
         
         public void OnNavigatedFrom(NavigationContext navigationContext) 
-        { 
+        {
            
             ClearCheckedAglin?.Invoke(null, null);
         }

+ 19 - 2
PDF Office/ViewModels/PropertyPanel/PDFEdit/TextEditPropertyViewModel.cs

@@ -356,7 +356,24 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
 
             return popMenu;
         }
-       
+        //多选文本框
+        private ContextMenu SelectMoreText(object sender)
+        {
+            var popMenu = App.Current.FindResource("SelectMoreTextMenu") as ContextMenu;
+            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
+
+            //复制
+            customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
+            //剪切
+            customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
+            //粘贴
+            customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
+            //删除
+            customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
+
+            return popMenu;
+        }
+        
         //选中文字内容
         private ContextMenu SelectTextContent(object sender)
         {
@@ -443,7 +460,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
                     }
                    else if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)
                     {
-                        e.PopupMenu = SelectTextBorder(sender);
+                        e.PopupMenu = SelectMoreText(sender);
 
                     }
                     break;

+ 2 - 0
PDF Office/ViewModels/Tools/TextEditToolContentViewModel.cs

@@ -258,6 +258,7 @@ namespace PDF_Master.ViewModels.Tools
                 if (isText == false && isImg == true)
                 {
                     AddToPropertyPanel("Image", e);
+                    
                 }
                 if (isText == true && isImg == true)
                 {
@@ -266,6 +267,7 @@ namespace PDF_Master.ViewModels.Tools
             }
             else
             {
+
                 AddToPropertyPanel("PropertyPanelContent", null);
             }