Browse Source

填写与前面-颜色选中,复制区分

liyijie 1 year ago
parent
commit
5e74d316df

+ 93 - 76
PDF Office/ViewModels/FillAndSign/FillAndSignContentViewModel.cs

@@ -774,11 +774,11 @@ namespace PDF_Master.ViewModels.FillAndSign
             }
             else
             {
-                if (IsCopyShape && !IsSelectShape)
-                {
-                    ShapeNames.Clear();
+                //if (IsCopyShape && !IsSelectShape)
+                //{
+                //    ShapeNames.Clear();
 
-                }
+                //}
                 freehandArgs = selectedArgs[0] as FreehandAnnotArgs;
                 foreach (var item in selectedArgs)
                 {
@@ -788,18 +788,18 @@ namespace PDF_Master.ViewModels.FillAndSign
                     {
                         if ((item as FreehandAnnotArgs).PageIndex == point.PageIndex && (item as FreehandAnnotArgs).AnnotIndex == point.AnnotIndex)
                         {
-                            if (IsCopyShape && !IsSelectShape)
-                            {
-                                ShapeNames.Add(point.Shape);
-                                Trace.WriteLine("woshi什么" + point.Shape);
-                            }
-
+                            //if (IsCopyShape && !IsSelectShape)
+                            //{
+                            //    ShapeNames.Add(point.Shape);
+                            //    Trace.WriteLine("woshi什么" + point.Shape);
+                            //}
                             newSelectedArgs.Add(item);
+                            break;
                         }
                     }
 
                 }
-                IsCopyShape = true;
+                //IsCopyShape = true;
                 //freehandArgs.RawPointList = ShapePoints;
                 //freehandArgs.InkColor = (SelectColor as SolidColorBrush).Color;
                 //freehandArgs.Transparency = 1;
@@ -1195,7 +1195,7 @@ namespace PDF_Master.ViewModels.FillAndSign
                 PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
                 PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
                 PDFViewer.AnnotHoverHandler += PDFViewer_AnnotHoverHandler;
-                CommandManager.AddPreviewExecutedHandler(PDFViewer, PreviewExcuteView);
+                //CommandManager.AddPreviewExecutedHandler(PDFViewer, PreviewExcute);
                 KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
                 KeyEventsHelper.KeyDown += ShortCut_KeyDown;
             }
@@ -1225,11 +1225,11 @@ namespace PDF_Master.ViewModels.FillAndSign
         {
             if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
                 return;
-            if ((UIElement)sender != null)
-            {
+            //if ((UIElement)sender != null)
+            //{
 
-                CommandManager.AddPreviewExecutedHandler((UIElement)sender, PreviewExcute);
-            }
+            //    CommandManager.AddPreviewExecutedHandler((UIElement)sender, PreviewExcute);
+            //}
             switch (e.CommandType)
             {
                 case CommandType.Context:
@@ -1534,6 +1534,7 @@ namespace PDF_Master.ViewModels.FillAndSign
             if (e != null && e.Count > 0)
             {
                 Dictionary<int, List<int>> selectAnnotDicts = new Dictionary<int, List<int>>();
+
                 for (int i = 0; i < e.Count; i++)
                 {
                     AnnotEditEvent editEvent = e[i];
@@ -1551,23 +1552,25 @@ namespace PDF_Master.ViewModels.FillAndSign
                             {
                                 selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
                             }
-                            if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreehand)
-                            {
-                                if (IsSelectShape)
-                                {
-                                    if (ShapeNames.Count == 0) { continue; }
-                                    try
-                                    {
-                                        viewContentViewModel.FillAndSign.Add(new FillAndSignIsShape(pageindex, annotindex, ShapeNames[i]));
-                                        //PDFViewer.SelectAnnotation(pageindex, annotindex);
+                            //if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreehand)
+                            //{
+                            //    //if (IsSelectShape)
+                            //    //{
+                            //    if (ShapeNames.Count == 0) { continue; }
+                            //    if (ShapeNames[i] == "Freehand") { continue; }
+                            //    try
+                            //    {
+                            //        viewContentViewModel.FillAndSign.Add(new FillAndSignIsShape(pageindex, annotindex, ShapeNames[i]));
+                            //        //PDFViewer.SelectAnnotation(pageindex, annotindex);
 
-                                        continue;
-                                    }
-                                    catch { continue; }
+                            //        continue;
+                            //    }
+                            //    catch { continue; }
 
-                                }
+                            //    //}
+
+                            //}
 
-                            }
                             if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotStamp)
                             {
                                 if (Shape != "None")
@@ -1583,34 +1586,26 @@ namespace PDF_Master.ViewModels.FillAndSign
                                 }
                                 PDFViewer.SelectAnnotation(pageindex, annotindex);
                             }
+                            //else
+                            //{
+                            //    foreach (var point in viewContentViewModel.FillAndSign)
+                            //    {
+                            //        if (pageindex == point.PageIndex && annotindex == point.AnnotIndex)
+                            //        {
+                            //            point.Shape= Shape;
+                            //        }
+                            //    }
+                            //}
+
 
                             break;
                         case ActionType.Del:
-                            if (Shape != "None")
-                            {
-                                for (int j = 0; j < viewContentViewModel.FillAndSign.Count; j++)
-                                {
-                                    if (viewContentViewModel.FillAndSign[j].PageIndex == pageindex && viewContentViewModel.FillAndSign[j].AnnotIndex == annotindex)
-                                    {
-
-                                        viewContentViewModel.FillAndSign.Remove(viewContentViewModel.FillAndSign[j]);
-                                    }
-                                }
-                                for (int j = 0; j < viewContentViewModel.AnnotSignatures.Count; j++)
-                                {
-                                    if (viewContentViewModel.AnnotSignatures[j].Item1 == pageindex && viewContentViewModel.AnnotSignatures[j].Item2 == annotindex)
-                                    {
-
-                                        viewContentViewModel.AnnotSignatures.Remove(viewContentViewModel.AnnotSignatures[j]);
-                                    }
-                                }
-                            }
+                            
 
                             break;
                     }
                 }
-                IsSelectShape = false;
-                if (selectAnnotDicts.Count > 0)
+                if (selectAnnotDicts.Count > 1)
                 {
                     PDFViewer.SelectAnnotation(selectAnnotDicts);
                 }
@@ -1792,31 +1787,53 @@ namespace PDF_Master.ViewModels.FillAndSign
             viewContentViewModel.IsPropertyOpen = show;
         }
 
-        private void PreviewExcute(object sender, ExecutedRoutedEventArgs e)
-        {
-            if (e.Command == ApplicationCommands.Paste)
-            {
-                IsSelectShape = true;
-            }
-            if (e.Command == ApplicationCommands.Copy)
-            {
-
-                IsCopyShape = false;
-            }
-        }
-
-        private void PreviewExcuteView(object sender, ExecutedRoutedEventArgs e)
-        {
-            if (e.Command == ApplicationCommands.Paste)
-            {
-                IsSelectShape = true;
-            }
-            if (e.Command == ApplicationCommands.Copy)
-            {
-
-                IsCopyShape = false;
-            }
-        }
+        //private void PreviewExcute(object sender, ExecutedRoutedEventArgs e)
+        //{
+        //    if (e.Command == ApplicationCommands.Paste)
+        //    {
+        //        ShapeNames.Clear();
+        //        Trace.WriteLine("几次" + 1);
+        //        var items = PDFViewer.GetCopyAnnotData();
+        //        foreach (var item in items)
+        //        {
+        //            bool IsShape = false;
+        //            foreach (var point in viewContentViewModel.FillAndSign)
+        //            {
+        //                if ((item as FreehandAnnotArgs).PageIndex == point.PageIndex && (item as FreehandAnnotArgs).AnnotIndex == point.AnnotIndex)
+        //                {
+
+        //                    ShapeNames.Add(point.Shape);
+        //                    Trace.WriteLine("woshi什么" + point.Shape);
+        //                    IsShape = true;
+        //                    continue;
+        //                }
+
+        //            }
+        //            if (!IsShape) {
+        //                ShapeNames.Add("Freehand");
+        //                Trace.WriteLine("woshi什么" + "Freehand");
+        //            }
+        //        }
+        //    }
+        //    if (e.Command == ApplicationCommands.Copy)
+        //    {
+
+        //        IsCopyShape = false;
+        //    }
+        //}
+
+        //private void PreviewExcuteView(object sender, ExecutedRoutedEventArgs e)
+        //{
+        //    if (e.Command == ApplicationCommands.Paste)
+        //    {
+        //        IsSelectShape = true;
+        //    }
+        //    if (e.Command == ApplicationCommands.Copy)
+        //    {
+
+        //        IsCopyShape = false;
+        //    }
+        //}
 
         #region Navigation
 

+ 1 - 0
PDF Office/ViewModels/FillAndSign/PropertyPanel/ShapFillPropertyViewModel.cs

@@ -486,6 +486,7 @@ namespace PDF_Master.ViewModels.FillAndSign.PropertyPanel
         private void InitShapesType(string tag)
         {
             ShapeType = UPDateShapeType(tag);
+            Trace.WriteLine("ShapeType" + ShapeType);
             fillAndSignContentViewModel.LineWidthMultiple = 1;
             switch (tag)
             {

+ 99 - 22
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -9,6 +9,7 @@ using PDF_Master.CustomControl;
 using PDF_Master.EventAggregators;
 using PDF_Master.Helper;
 using PDF_Master.Model.AnnotPanel;
+using PDF_Master.Model.FillAndSign;
 using PDF_Master.Properties;
 using PDF_Master.ViewModels.BOTA;
 using PDF_Master.ViewModels.PropertyPanel.AnnotPanel;
@@ -79,9 +80,56 @@ namespace PDF_Master.ViewModels.Tools
 
                 PDFViewer.PreviewMouseLeftButtonDown -= PDFViewer_PreviewMouseLeftButtonDown;
                 PDFViewer.PreviewMouseLeftButtonDown += PDFViewer_PreviewMouseLeftButtonDown;
+                CommandManager.AddPreviewExecutedHandler(PDFViewer, PreviewExcutePDFViewer);
             }
         }
-
+        
+
+        //判断
+        private void PreviewExcutePDFViewer(object sender, ExecutedRoutedEventArgs e)
+        {
+            if (e.Command == ApplicationCommands.Paste)
+            {
+                IsPasteShape = true;
+                ShapeNames.Clear();
+                Trace.WriteLine("几次" + 1);
+                var items = PDFViewer.GetCopyAnnotData();
+                foreach (var item in items)
+                {
+                    bool IsShape = false;
+                    if (item is FreehandAnnotArgs)
+                    {
+                        foreach (var point in viewContentViewModel.FillAndSign)
+                        {
+
+                            if ((item as FreehandAnnotArgs).PageIndex == point.PageIndex && (item as FreehandAnnotArgs).AnnotIndex == point.AnnotIndex)
+                            {
+
+                                ShapeNames.Add(point.Shape);
+                                Trace.WriteLine("woshi什么" + point.Shape);
+                                IsShape = true;
+                                continue;
+                            }
+
+                        }
+                        if (!IsShape)
+                        {
+                            ShapeNames.Add("Annot");
+                            Trace.WriteLine("woshi什么" + "Freehand");
+                        }
+                    }
+                    else
+                    {
+                        ShapeNames.Add("Annot");
+                    }
+                }
+            }
+            if (e.Command == ApplicationCommands.Copy)
+            {
+
+
+            }
+        }
         private void UnBindingPDFViewerHandler()
         {
             if (PDFViewer != null)
@@ -994,8 +1042,33 @@ namespace PDF_Master.ViewModels.Tools
                     switch (editEvent.EditAction)
                     {
                         case ActionType.Add:
-                            //多选注释
-                            if (PropertyPanel.IsMultiSelected)
+
+                            #region 区分复制填写签名图形
+
+                            if (IsPasteShape)
+                            {
+                                if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreehand)
+                                {
+
+                                    if (ShapeNames.Count != 0 && ShapeNames[i] != "Annot")
+                                    {
+                                        try
+                                        {
+                                            viewContentViewModel.FillAndSign.Add(new FillAndSignIsShape(editEvent.PageIndex, editEvent.AnnotIndex, ShapeNames[i]));
+                                        }
+                                        catch { }
+                                    }
+
+                                }
+                            }
+                            #endregion
+                            if (viewContentViewModel.CurrentBar != "TabItemAnnotation")
+                            {
+                                //填写与签名在此区域不选中,不添加selectAnnotDicts词典当中
+                            }
+                            else if (annot.EventType == AnnotArgsType.AnnotSquare || annot.EventType == AnnotArgsType.AnnotCircle ||
+                                annot.EventType == AnnotArgsType.AnnotLine || annot.EventType == AnnotArgsType.AnnotStamp ||
+                                annot.EventType == AnnotArgsType.AnnotFreeText || annot.EventType == AnnotArgsType.AnnotSticky/*|| annot.EventType == AnnotArgsType.AnnotFreehand*/)
                             {
                                 if (selectAnnotDicts.ContainsKey(editEvent.PageIndex) == false)
                                 {
@@ -1008,25 +1081,6 @@ namespace PDF_Master.ViewModels.Tools
                                 }
                                 isMultiple = true;
                             }
-                            else
-                            {
-                                if (annot.EventType == AnnotArgsType.AnnotSquare || annot.EventType == AnnotArgsType.AnnotCircle ||
-                               annot.EventType == AnnotArgsType.AnnotLine || annot.EventType == AnnotArgsType.AnnotStamp ||
-                               annot.EventType == AnnotArgsType.AnnotSticky/*||
-                               annot.EventType == AnnotArgsType.AnnotFreeText ||  annot.EventType == AnnotArgsType.AnnotFreehand*/)
-                                {
-                                    if (selectAnnotDicts.ContainsKey(editEvent.PageIndex) == false)
-                                    {
-                                        selectAnnotDicts.Add(editEvent.PageIndex, new List<int>());
-                                        selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
-                                    }
-                                    else
-                                    {
-                                        selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
-                                    }
-                                    isMultiple = true;
-                                }
-                            }
 
                             if (viewModel != null)
                             {
@@ -1059,7 +1113,29 @@ namespace PDF_Master.ViewModels.Tools
                             break;
 
                         case ActionType.Del:
+                            //isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
+                            //if (viewContentViewModel.OpenBOTA == true && bOTAContent.TabItemAnnotation.IsSelected)
+                            //{
+                            //    AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
+                            //if (Shape != "None")
+                            {
+                                for (int j = 0; j < viewContentViewModel.FillAndSign.Count; j++)
+                                {
+                                    if (viewContentViewModel.FillAndSign[j].PageIndex == editEvent.PageIndex && viewContentViewModel.FillAndSign[j].AnnotIndex == editEvent.AnnotIndex)
+                                    {
 
+                                        viewContentViewModel.FillAndSign.Remove(viewContentViewModel.FillAndSign[j]);
+                                    }
+                                }
+                                for (int j = 0; j < viewContentViewModel.AnnotSignatures.Count; j++)
+                                {
+                                    if (viewContentViewModel.AnnotSignatures[j].Item1 == editEvent.PageIndex && viewContentViewModel.AnnotSignatures[j].Item2 == editEvent.AnnotIndex)
+                                    {
+
+                                        viewContentViewModel.AnnotSignatures.Remove(viewContentViewModel.AnnotSignatures[j]);
+                                    }
+                                }
+                            }
                             if (viewModel != null)
                             {
                                 int pageindex = editEvent.PageIndex;
@@ -1077,6 +1153,7 @@ namespace PDF_Master.ViewModels.Tools
                             break;
                     }
                 }
+                IsPasteShape = false;
                 if (isMultiple && selectAnnotDicts.Count >= 1)
                 {
                     PDFViewer.ClearSelectAnnots();

+ 4 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Properties.cs

@@ -129,6 +129,10 @@ namespace PDF_Master.ViewModels.Tools
         #endregion 注释工具
 
         #endregion 属性
+        // 填写与签名图案名字链表 
+        private List<string> ShapeNames = new List<string>();
+       // 是否处于打印
+        private bool IsPasteShape = false;
 
         public string PropertyRegionName { get; set; }
         private IEventAggregator events;