瀏覽代碼

综合-注释bug

OYXH\oyxh 1 年之前
父節點
當前提交
e366f892cd

+ 6 - 2
PDF Office/Model/AnnotPanel/FontBoard.cs

@@ -557,8 +557,12 @@ namespace PDF_Master.Model.AnnotPanel
                     && (annot.FontFamily.Source == item.mFontFamily.Source || annot.FontFamily.Source == "Arial" && item.mFontFamily.Source == "Helvatica")
                     )
                 {
-                    CurrentPresetFont = new ComboDataItem(item.mTag, item.mTagContent);
-                    isExist = true;
+                    if(item.mTag!= "Custom")
+                    {
+                        CurrentPresetFont = new ComboDataItem(item.mTag, item.mTagContent);
+                        isExist = true;
+                    }
+                    
                     break;
                 }
             }

+ 51 - 54
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SharpsAnnotPropertyViewModel.cs

@@ -1,18 +1,23 @@
 using ComPDFKit.PDFAnnotation;
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
+using ImTools;
 using PDF_Master.CustomControl.CompositeControl;
 using PDF_Master.Helper;
 using PDF_Master.Model;
 using PDF_Master.Model.AnnotPanel;
+using PDF_Master.Properties;
 using PDF_Master.ViewModels.Tools;
 using PDF_Master.ViewModels.Tools.AnnotManager;
+using PDF_Master.Views.Tools;
 using PDFSettings;
 using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
+using System.Drawing;
 using System.Globalization;
 using System.Linq;
 using System.Text;
@@ -21,6 +26,8 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Media;
+using Color = System.Windows.Media.Color;
+using Point = System.Windows.Point;
 
 namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
 {
@@ -158,8 +165,11 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
 
         public event EventHandler<object> LoadPropertyHandler;
 
-        public SharpsAnnotPropertyViewModel()
+        public IRegionManager region;
+
+        public SharpsAnnotPropertyViewModel(IRegionManager regionManager)
         {
+            region = regionManager;
             InitColorItems();
             InitFillColorItems();
             InitThicknessItems();
@@ -221,41 +231,20 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             {
                 var tag = (string)obj;
                 SharpsType(tag, true);
-                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
-                switch (tag)
-                {
-                    case "Rect":
-                        changeData[AnnotArgsType.AnnotSquare] = tag;
-                        break;
-
-                    case "Circle":
-                        changeData[AnnotArgsType.AnnotCircle] = tag;
-                        break;
-
-                    case "Arrow":
-                        changeData[AnnotArgsType.AnnotLine] = tag;
-                        break;
-
-                    case "Line":
-                        changeData[AnnotArgsType.AnnotLine] = tag;
-                        break;
-                }
-                PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
             }
         }
 
         private void SharpsType(string tag, bool isFromToolsBtn = false)
         {
+            Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
             switch (tag)
             {
                 case "Rect":
                     RectangleGeometry rectPath = new RectangleGeometry();
                     rectPath.Rect = new Rect(0, 5, 28, 22);
                     DataPath = rectPath;
-
+                    changeData[AnnotArgsType.AnnotSquare] = tag;
                     IsLineAnnot = false;
-                    //if (IsRect == false)
-                    //    IsRect = true;
                     break;
 
                 case "Circle":
@@ -264,10 +253,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                     circlePath.RadiusY = 14;
                     circlePath.Center = new Point(14, 14);
                     DataPath = circlePath;
-
+                    changeData[AnnotArgsType.AnnotCircle] = tag;
                     IsLineAnnot = false;
-                    //if (IsCircle == false)
-                    //    IsCircle = true;
                     break;
 
                 case "Arrow":
@@ -279,12 +266,9 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                         arrowLine.StartSharp = C_LINE_TYPE.LINETYPE_NONE;
                         arrowLine.EndSharp = C_LINE_TYPE.LINETYPE_ARROW;
                         DataPath = arrowLine.BuildArrowBody();
-
+                        changeData[AnnotArgsType.AnnotLine] = tag;
                         if (IsLineAnnot == false)
                             IsLineAnnot = true;
-                        //if (isArrow == false)
-                        //    isArrow = true;
-                        //  changeData[AnnotArgsType.AnnotLine] = tag;
                     }
 
                     break;
@@ -295,18 +279,16 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                         arrowLine.LineStart = new Point(0, 32);
                         arrowLine.LineEnd = new Point(32, 0);
                         DataPath = arrowLine.BuildArrowBody();
-
+                        changeData[AnnotArgsType.AnnotLine] = tag;
                         if (IsLineAnnot == false)
                             IsLineAnnot = true;
-                        //if (IsLine == false)
-                        //    IsLine = true;
                     }
 
                     break;
             }
 
-            //if (isFromToolsBtn)
-            //    PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
+            if (isFromToolsBtn)
+                PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
 
             StrShapeChecked = tag;
             PropertyPanel.SharpsAnnot = tag;
@@ -403,9 +385,34 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             if (obj is double)
             {
                 var tran = (double)obj;
+                AnnotArgsType argsType = AnnotArgsType.AnnotSquare;
+                bool isLine = false;
+                switch (BasicVm.strOtherTag)
+                {
+                    case "Rect":
+                        argsType = AnnotArgsType.AnnotSquare;
+                        break;
 
-                //BasicVm.AnnotThickness = tran;
-                PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, tran);
+                    case "Circle":
+                        argsType = AnnotArgsType.AnnotCircle;
+                        break;
+
+                    case "Line":
+                        argsType = AnnotArgsType.AnnotLine;
+                        isLine = true;
+                        break;
+
+                    case "Arrow":
+                        argsType = AnnotArgsType.AnnotLine;
+                        isLine = false;
+                        break;
+                }
+                if (argsType == BasicVm.AnnotType)
+                {
+                    //if(argsType== AnnotArgsType.AnnotLine && isLine)
+                    BasicVm.AnnotThickness = tran;
+                    PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, tran);
+                }
 
                 if (BasicVm.IsMultiSelected == false)
                     PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, Annot);
@@ -457,10 +464,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
         public AnnotAttribEvent AnnotEvent { get; set; }
         public AnnotHandlerEventArgs Annot;
         public AnnotTransfer PropertyPanel;
+        public ViewContentViewModel ViewContentViewModel;
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<AnnotTransfer>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out ViewContentViewModel);
             if (PropertyPanel != null)
             {
                 AnnotEvent = PropertyPanel.AnnotEvent;
@@ -623,13 +632,10 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                             BasicVm.FillOpacity = Square.Transparency;
                             BasicVm.AnnotThickness = Square.LineWidth;
                             Dash = Square.LineDash;
-                            //SharpsType("Rect", false);
+                            SharpsType("Rect", false);
                             BasicVm.AnnotTypeTitle = "矩形";
                             IsLineAnnot = false;
                             IsRect = true;
-                            //IsCircle = false;
-                            //IsArrow=false;
-                            //IsLine= false;
                         }
                         break;
 
@@ -643,13 +649,10 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                             BasicVm.FillOpacity = Circle.Transparency;
                             BasicVm.AnnotThickness = Circle.LineWidth;
                             Dash = Circle.LineDash;
-                            //SharpsType("Circle", false);
+                            SharpsType("Circle", false);
                             BasicVm.AnnotTypeTitle = "圆";
                             IsLineAnnot = false;
                             IsCircle = true;
-                            //IsRect = false;
-                            //IsArrow = false;
-                            //IsLine = false;
                         }
                         break;
 
@@ -666,21 +669,15 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
 
                             if (line.TailLineType == C_LINE_TYPE.LINETYPE_ARROW && line.HeadLineType == C_LINE_TYPE.LINETYPE_NONE)
                             {
-                                //SharpsType("Arrow", false);
+                                SharpsType("Arrow", false);
                                 BasicVm.AnnotTypeTitle = "箭头";
                                 IsArrow = true;
-                                //IsCircle = false;
-                                //IsRect = false;
-                                //IsLine = false;
                             }
                             else
                             {
-                                //SharpsType("Line", false);
+                                SharpsType("Line", false);
                                 BasicVm.AnnotTypeTitle = "线条";
                                 IsLine = true;
-                                //IsCircle = false;
-                                //IsRect = false;
-                                //IsArrow = false;
                             }
 
                             IsLineAnnot = true;

+ 1 - 1
PDF Office/ViewModels/Tools/AnnotManager/AnnotTransfer.cs

@@ -31,7 +31,7 @@ namespace PDF_Master.ViewModels.Tools.AnnotManager
         public AnnotHandlerEventArgs LastArrowAnnot = null;
 
         public string SharpsAnnot = "Rect";
-
+        public string AnnotSelect = "";
         //是否为填写与签名的日期文本
         public bool IsTextFill { get; private set; }
 

+ 66 - 8
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -25,6 +25,7 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls.Primitives;
 using System.Windows.Input;
+using System.Windows.Markup;
 using System.Windows.Media;
 
 namespace PDF_Master.ViewModels.Tools
@@ -406,15 +407,15 @@ namespace PDF_Master.ViewModels.Tools
                 CurrentSelectedAnnot = null;
                 var annot = e.AnnotItemsList[0];
                 if (annot != null)
-                {
+                {
                     if (e.AnnotItemsList.Count == 1)
-                    {
-                        //IsAnnotCreateReset:是否为创建注释的状态
+                    {
+                        //IsAnnotCreateReset:是否为创建注释的状态
                         if (e.IsAnnotCreateReset == false)
-                        {
+                        {
+                            CurrentSelectedAnnot = annot;
                             GetSelectedAnnots(e);
                             SelectedSignature(e.AnnotItemsList);
-                            CurrentSelectedAnnot = annot;
 
                             if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty
                                 && annot.EventType != AnnotArgsType.AnnotStamp && StrAnnotToolChecked != "Signature"
@@ -1159,6 +1160,7 @@ namespace PDF_Master.ViewModels.Tools
             {
                 AnnotHandlerEventArgs annotArgs = null;
                 //PropertyPanel.SaveLastAnnot();
+                List<AnnotHandlerEventArgs> annots = new List<AnnotHandlerEventArgs>();
 
                 foreach (AnnotArgsType argsType in e.Keys)
                 {
@@ -1169,17 +1171,73 @@ namespace PDF_Master.ViewModels.Tools
                     switch (argsType)
                     {
                         case AnnotArgsType.AnnotSquare:
+                            if (CurrentSelectedAnnot != null)
+                            {
+                                if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotSquare)
+                                    annots.Add(CurrentSelectedAnnot);
+                            }
+                            if (annots.Count > 0)
+                            {
+                                annotArgs = GetRect(annots);
+                            }
+                            else
+                            {
+                                annotArgs = GetRect();
+                            }
 
-                            annotArgs = GetRect();
                             break;
 
                         case AnnotArgsType.AnnotCircle:
-                            annotArgs = GetCircle();
+                            if (CurrentSelectedAnnot != null)
+                            {
+                                if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotCircle)
+                                    annots.Add(CurrentSelectedAnnot);
+                            }
+                            if (annots.Count > 0)
+                            {
+                                annotArgs = GetCircle(annots);
+                            }
+                            else
+                            {
+                                annotArgs = GetCircle();
+                            }
+
                             break;
 
                         case AnnotArgsType.AnnotLine:
                             var LineTag = e[argsType] as string;
-                            annotArgs = GetArrowLine(LineTag);
+                            if (CurrentSelectedAnnot != null)
+                            {
+                                if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotLine)
+                                {
+                                    if (CurrentSelectedAnnot is LineAnnotArgs lineAnnotArgs)
+                                    {
+                                        if (lineAnnotArgs.HeadLineType >= (C_LINE_TYPE)1 || lineAnnotArgs.TailLineType >= (C_LINE_TYPE)1)
+                                        {
+                                            if (LineTag == "Arrow")
+                                            {
+                                                annots.Add(CurrentSelectedAnnot);
+                                            }
+                                        }
+                                        else
+                                        {
+                                            if (LineTag == "Line")
+                                            {
+                                                annots.Add(CurrentSelectedAnnot);
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                            if (annots.Count > 0)
+                            {
+                                annotArgs = GetArrowLine(LineTag, annots);
+                            }
+                            else
+                            {
+                                annotArgs = GetArrowLine(LineTag);
+                            }
+
                             break;
                     }
                     ShowPropertyPanel();

+ 3 - 3
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -913,7 +913,7 @@ namespace PDF_Master.ViewModels.Tools
         /// </summary>
         /// <param name="selectedArgs"></param>
         /// <returns></returns>
-        private AnnotHandlerEventArgs GetRect(List<AnnotHandlerEventArgs> selectedArgs = null)
+        public AnnotHandlerEventArgs GetRect(List<AnnotHandlerEventArgs> selectedArgs = null)
         {
             SquareAnnotArgs squareArgs = null;
 
@@ -998,7 +998,7 @@ namespace PDF_Master.ViewModels.Tools
         /// </summary>
         /// <param name="selectedArgs"></param>
         /// <returns></returns>
-        private AnnotHandlerEventArgs GetCircle(List<AnnotHandlerEventArgs> selectedArgs = null)
+        public AnnotHandlerEventArgs GetCircle(List<AnnotHandlerEventArgs> selectedArgs = null)
         {
             CircleAnnotArgs circleAnnotArgs = null;
 
@@ -1084,7 +1084,7 @@ namespace PDF_Master.ViewModels.Tools
         /// <param name="TagStr"></param>
         /// <param name="selectedArgs"></param>
         /// <returns></returns>
-        private AnnotHandlerEventArgs GetArrowLine(string TagStr, List<AnnotHandlerEventArgs> selectedArgs = null)
+        public AnnotHandlerEventArgs GetArrowLine(string TagStr, List<AnnotHandlerEventArgs> selectedArgs = null)
         {
             LineAnnotArgs lineArgs = new LineAnnotArgs();
 

+ 1 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -188,6 +188,7 @@ namespace PDF_Master.ViewModels.Tools
 
             if (annotBtn.IsChecked == true)
             {
+                PropertyPanel.AnnotSelect = StrAnnotToolChecked;
                 PropertyPanel.SaveLastAnnot();
                 MyToolCheckedDoing(dictVar, tag);
                 FindAnnotTypeKey(tag, ref annotArgs);