Browse Source

综合-未选注释工具-形状注释,选中形状注释,属性面板不显示(矩形、圆、线、箭头),便签添加后选中(还不完整)

OYXH\oyxh 1 year ago
parent
commit
5bc7458bbe

+ 36 - 6
PDF Office/Model/AnnotPanel/AnnotCommon.cs

@@ -18,6 +18,7 @@ namespace PDF_Master.Model.AnnotPanel
     {
         //注释类型
         private AnnotArgsType _annotType;
+
         public AnnotArgsType AnnotType
         {
             get { return _annotType; }
@@ -26,6 +27,7 @@ namespace PDF_Master.Model.AnnotPanel
 
         //注释类型名称
         private string _annotTypeTitle;
+
         public string AnnotTypeTitle
         {
             get { return _annotTypeTitle; }
@@ -36,6 +38,7 @@ namespace PDF_Master.Model.AnnotPanel
 
         //线条粗细大小
         private double _annotThickness = 1;
+
         public double AnnotThickness
         {
             get { return _annotThickness; }
@@ -44,6 +47,7 @@ namespace PDF_Master.Model.AnnotPanel
 
         //线条样式
         private DashStyle dash = new DashStyle();
+
         public DashStyle Dash
         {
             get { return dash; }
@@ -53,8 +57,10 @@ namespace PDF_Master.Model.AnnotPanel
         #endregion 线条
 
         #region 填充
+
         //填充颜色透明度
         private double fillOpacity = 1;
+
         public double FillOpacity
         {
             get { return fillOpacity; }
@@ -63,6 +69,7 @@ namespace PDF_Master.Model.AnnotPanel
 
         //当前填充颜色
         private Brush _currentFillColor = new SolidColorBrush(Colors.Transparent);
+
         public Brush CurrentFillColor
         {
             get { return _currentFillColor; }
@@ -71,6 +78,7 @@ namespace PDF_Master.Model.AnnotPanel
 
         //填充颜色
         private Brush fillColor = new SolidColorBrush(Colors.Transparent);
+
         public Brush FillColor
         {
             get { return fillColor; }
@@ -79,6 +87,7 @@ namespace PDF_Master.Model.AnnotPanel
 
         //边框颜色集合
         private List<ColorItem> _colorItems = new List<ColorItem>();
+
         public List<ColorItem> ColorItems
         {
             get { return _colorItems; }
@@ -87,16 +96,20 @@ namespace PDF_Master.Model.AnnotPanel
 
         //填充颜色集合
         private List<ColorItem> _fillColorItems = new List<ColorItem>();
+
         public List<ColorItem> FillColorItems
         {
             get { return _fillColorItems; }
             set => SetProperty(ref _fillColorItems, value);
         }
+
         #endregion 填充
 
         #region 边框
+
         //边框颜色透明度
         private double _borderOpacity = 1;
+
         public double BorderOpacity
         {
             get { return _borderOpacity; }
@@ -104,6 +117,7 @@ namespace PDF_Master.Model.AnnotPanel
         }
 
         private Brush _borderColor = new SolidColorBrush(Colors.Transparent);
+
         public Brush BorderColor
         {
             get { return _borderColor; }
@@ -112,6 +126,7 @@ namespace PDF_Master.Model.AnnotPanel
 
         //当前边框颜色
         private Brush _currentBorderColor = new SolidColorBrush(Colors.Transparent);
+
         public Brush CurrentBorderColor
         {
             get { return _currentBorderColor; }
@@ -119,15 +134,16 @@ namespace PDF_Master.Model.AnnotPanel
         }
 
         private Brush _fontColor = new SolidColorBrush(Colors.Transparent);
+
         public Brush FontColor
         {
             get { return _fontColor; }
             set { SetProperty(ref _fontColor, value); CurrentFontColor = _fontColor; }
-
         }
 
         //当前边框颜色
         private Brush _currentFontColor = new SolidColorBrush(Colors.Transparent);
+
         public Brush CurrentFontColor
         {
             get { return _currentFontColor; }
@@ -136,6 +152,7 @@ namespace PDF_Master.Model.AnnotPanel
 
         //是否为实线
         private bool _isSolidLine = true;
+
         public bool IsSolidLine
         {
             get { return _isSolidLine; }
@@ -144,6 +161,7 @@ namespace PDF_Master.Model.AnnotPanel
 
         //是否为虚线
         private bool _isDashLine = true;
+
         public bool IsDashLine
         {
             get { return _isDashLine; }
@@ -152,30 +170,44 @@ namespace PDF_Master.Model.AnnotPanel
 
         //外部UI引用,其他:例如形状注释类型
         public string strOtherTag { get; private set; }
+
         //VM赋值
         public void SetOtherTag(string str)
         {
             strOtherTag = str;
         }
 
-        #endregion
+        #endregion 边框
 
         #region 多选
 
         //多选注释:用处 - 多选注释使得下拉框为空内容,刷新最新的UI布局
         private bool _isMultiSelected = false;
+
         public bool IsMultiSelected
         {
             get { return _isMultiSelected; }
             set => SetProperty(ref _isMultiSelected, value);
         }
 
-        #endregion
+        private bool isSharpAnnotSelected = false;
+
+        public bool IsSharpAnnotSelected
+        {
+            get { return isSharpAnnotSelected; }
+            set
+            {
+                SetProperty(ref isSharpAnnotSelected, value);
+            }
+        }
+
+        #endregion 多选
 
         /// <summary>
         /// VM触发到外部UI事件
         /// </summary>
         public event EventHandler<object> SelectedAnnotInvokeToUI;
+
         //Todo:由于考虑到有些UI在VM不太方便处理,因此需要触发该函数到外部xaml.cs里更改UI属性。
         //更改多个属性:value可为键值对集合
         //适应范围:若VM在Loaded进行绑定,需要UI初始化之后,才能起到作用
@@ -183,7 +215,5 @@ namespace PDF_Master.Model.AnnotPanel
         {
             SelectedAnnotInvokeToUI?.Invoke(sender, value);
         }
-
     }
-
-}
+}

+ 14 - 12
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SharpsAnnotPropertyViewModel.cs

@@ -105,10 +105,10 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             {
                 SetProperty(ref _strShapeChecked, value);
             }
-        }
-
-      
-
+        }
+
+
+
         public List<ComboDataItem> ThicknessItems { get; protected set; }
 
         private AnnotCommon _basicVm = new AnnotCommon();
@@ -539,10 +539,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                 BasicVm.IsMultiSelected = PropertyPanel.IsMultiSelected;
                 if (BasicVm.IsMultiSelected)
                 {
+                    BasicVm.IsSharpAnnotSelected = !BasicVm.IsMultiSelected;
                     IsAttributeEquals();
                 }
                 else
                 {
+                    BasicVm.IsSharpAnnotSelected = PropertyPanel.IsSharpAnnotSelected;
                     GetAnnotProperty();
                 }
 
@@ -577,13 +579,13 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             var list = ConvertLists();
             Color LineColor = Color.FromArgb(0x01, 0xff, 0xff, 0xff);
             Color BgColor = Color.FromArgb(0x01, 0xff, 0xff, 0xff);
-            double LineWidth=2;
-            DashStyle LineDash=new DashStyle();
+            double LineWidth = 2;
+            DashStyle LineDash = new DashStyle();
 
             Color LineColoritem = Color.FromArgb(0x01, 0xff, 0xff, 0xff);
-            Color BgColoritem= Color.FromArgb(0x01, 0xff, 0xff, 0xff);
-            double LineWidthitem =2;
-            DashStyle LineDashitem= new DashStyle();
+            Color BgColoritem = Color.FromArgb(0x01, 0xff, 0xff, 0xff);
+            double LineWidthitem = 2;
+            DashStyle LineDashitem = new DashStyle();
             if (list != null)
             {
                 var temp = list[0];
@@ -631,7 +633,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                     }
                     if (item is CircleAnnotArgs)
                     {
-                        args = item as CircleAnnotArgs; 
+                        args = item as CircleAnnotArgs;
                         LineColoritem = args.LineColor;
                         BgColoritem = args.BgColor;
                         LineWidthitem = args.LineWidth;
@@ -665,7 +667,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                                 if (annotLinetemp.TailLineType != annotLineitem.TailLineType)
                                 {
                                     BasicVm.AnnotTypeTitle = "其他";
-                                    
+
                                     isNoEqualsDir["AnnotTypeTitle"] = true;
                                 }
 
@@ -684,7 +686,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
 
                     if (isNoEqualsDir["LineColor"] == false)
                     {
-                        if (LineColor.A != LineColoritem.A || LineColor.R != LineColoritem.R || LineColor.G != LineColoritem.G ||LineColor.B != LineColoritem.B)
+                        if (LineColor.A != LineColoritem.A || LineColor.R != LineColoritem.R || LineColor.G != LineColoritem.G || LineColor.B != LineColoritem.B)
                         {
                             BasicVm.BorderColor = new SolidColorBrush(Color.FromArgb(0x01, 0xff, 0xff, 0xff));
                             isNoEqualsDir["LineColor"] = true;

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

@@ -34,6 +34,7 @@ namespace PDF_Master.ViewModels.Tools.AnnotManager
 
         public string SharpsAnnot = "Rect";
         public string AnnotSelect = "";
+
         //是否为填写与签名的日期文本
         public bool IsTextFill { get; private set; }
 
@@ -42,6 +43,14 @@ namespace PDF_Master.ViewModels.Tools.AnnotManager
             IsTextFill = isTextFill;
         }
 
+        private bool isSharpAnnotSelected = true;
+
+        public bool IsSharpAnnotSelected
+        {
+            get { return isSharpAnnotSelected; }
+            set { isSharpAnnotSelected = value; }
+        }
+
         public bool IsMultiSelected
         { get { return (annotlists != null && annotlists.Count > 1); } }
 
@@ -77,7 +86,6 @@ namespace PDF_Master.ViewModels.Tools.AnnotManager
             {
                 LastAnnotDict[annot.EventType] = annot;
             }
-           
         }
 
         #region 静态

+ 37 - 25
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -105,10 +105,12 @@ namespace PDF_Master.ViewModels.Tools
         private void PDFViewer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
             if (e.ClickCount == 1)
-            {
-               
-
-                //BOTA所有列表都需要响应 单击阅读页取消多选
+            {
+                //不禁止取消选中注释
+                PDFViewer.DisableClearSelectAnnot(false);
+
+                //PDFViewer.ClearSelectAnnots();
+                //BOTA所有列表都需要响应 单击阅读页取消多选
                 if (viewContentViewModel.OpenBOTA == true)
                 {
                     this.events.GetEvent<CleanSelectAllEvent>().Publish(new CleanSelectAllArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, IsCleanSelectAll = true });
@@ -120,8 +122,8 @@ namespace PDF_Master.ViewModels.Tools
                 {
                     var type = CurrentSelectedAnnot.EventType;
                     if (type != AnnotArgsType.AnnotSticky && type != AnnotArgsType.AnnotFreeText &&
-                        type != AnnotArgsType.AnnotHighlight && type != AnnotArgsType.AnnotUnderline 
-                        && type != AnnotArgsType.AnnotStrikeout &&type!=AnnotArgsType.AnnotLink)
+                        type != AnnotArgsType.AnnotHighlight && type != AnnotArgsType.AnnotUnderline
+                        && type != AnnotArgsType.AnnotStrikeout && type != AnnotArgsType.AnnotLink)
                     {
                         int dpi = DpiHelpers.Dpi;
                         var rect = CurrentSelectedAnnot.ClientRect;
@@ -135,8 +137,8 @@ namespace PDF_Master.ViewModels.Tools
                         {
                             var point = e.GetPosition(ui);
                             int pageIndex = 0;
-                            Point pagePoint = new Point(0, 0);
-                           
+                            Point pagePoint = new Point(0, 0);
+
                             PDFViewer.ConvertViewPointToPage(point, out pageIndex, out pagePoint);
                             if (pagePoint.X >= rect.Left && pagePoint.X <= rect.Right && pagePoint.Y >= rect.Top && pagePoint.Y <= rect.Bottom)
                                 PopAnnotNoteText(CurrentSelectedAnnot);
@@ -357,6 +359,7 @@ namespace PDF_Master.ViewModels.Tools
         //选中和非选中注释
         private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
         {
+            CurrentSelectedAnnot = null;
             if (viewContentViewModel.CurrentBar != "TabItemAnnotation")
             {
                 //viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
@@ -364,15 +367,17 @@ namespace PDF_Master.ViewModels.Tools
             }
             if (e == null)
             {
-                //PDFViewer.SetMouseMode(MouseModes.PanTool);
-                //HandToolIsCheckedEvent(false);
+                //PDFViewer.DisableClearSelectAnnot(false);
+
                 if (string.IsNullOrWhiteSpace(StrAnnotToolChecked))
                 {
+                    //PDFViewer.ClearSelectAnnots();
                     PropertyPanel.annot = null;
                     PropertyPanel.AnnotEvents = null;
                     PropertyPanel.AnnotEvent = null;
                     PropertyPanel.annotlists = null;
                     viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+                    return;
                 }
                 else
                 {
@@ -398,7 +403,7 @@ namespace PDF_Master.ViewModels.Tools
                         return;
                     }
                 }
-                CurrentSelectedAnnot = null;
+
                 var annot = e.AnnotItemsList[0];
                 if (annot != null)
                 {
@@ -408,9 +413,21 @@ namespace PDF_Master.ViewModels.Tools
                         if (e.IsAnnotCreateReset == false)
                         {
                             CurrentSelectedAnnot = annot;
+                            //未选注释工具-形状注释,选中形状注释,属性面板不显示(矩形、圆、线、箭头)
+                            if (e.AnnotItemsList[0].EventType == AnnotArgsType.AnnotSquare ||
+                            e.AnnotItemsList[0].EventType == AnnotArgsType.AnnotCircle ||
+                             e.AnnotItemsList[0].EventType == AnnotArgsType.AnnotLine)
+                            {
+                                PropertyPanel.IsSharpAnnotSelected = false;
+                            }
+                            else
+                            {
+                                PropertyPanel.IsSharpAnnotSelected = true;
+                            }
+
                             GetSelectedAnnots(e);
-                            SelectedSignature(e.AnnotItemsList);
-
+                            SelectedSignature(e.AnnotItemsList);
+
                             if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty
                                 && annot.EventType != AnnotArgsType.AnnotStamp && StrAnnotToolChecked != "Signature"
                                 && annot.EventType != AnnotArgsType.AnnotLink)
@@ -767,7 +784,7 @@ namespace PDF_Master.ViewModels.Tools
                     {
                         fontFamily = "Helvetica";
                     }
-                    if(fontFamily== "Courier New")
+                    if (fontFamily == "Courier New")
                     {
                         fontFamily = "Courier";
                     }
@@ -991,7 +1008,8 @@ namespace PDF_Master.ViewModels.Tools
                     {
                         case ActionType.Add:
                             if (annot.EventType == AnnotArgsType.AnnotSquare || annot.EventType == AnnotArgsType.AnnotCircle ||
-               annot.EventType == AnnotArgsType.AnnotLine || annot.EventType == AnnotArgsType.AnnotStamp || annot.EventType == AnnotArgsType.AnnotFreeText /*|| annot.EventType == AnnotArgsType.AnnotFreehand*/)
+                                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)
                                 {
@@ -1086,15 +1104,10 @@ namespace PDF_Master.ViewModels.Tools
 
                     if (StrAnnotToolChecked != "Signature")
                     {
+                        PDFViewer.DisableClearSelectAnnot(false);
                         PDFViewer.SelectAnnotation(selectAnnotDicts);
-
-                        //foreach (var item in selectAnnotDicts.Keys)
-                        //{
-                        //    List<int> value = selectAnnotDicts[item];
-                        //    foreach (var item1 in value)
-                        //    {
-                        //    }
-                        //}
+                        //禁止取消选中注释
+                        PDFViewer.DisableClearSelectAnnot(true);
                     }
                 }
                 //MultipleSelectionAnnot(e);
@@ -1513,7 +1526,7 @@ namespace PDF_Master.ViewModels.Tools
                                     if (clickBtn.Tag.ToString() != "PenBtn")
                                     {
                                         CustomIconToggleBtn btn = new CustomIconToggleBtn();
-                                        btn.Tag = "Freehand"; 
+                                        btn.Tag = "Freehand";
                                         btn.IsChecked = true;
                                         BtnMyTools_Click(btn);
                                         break;
@@ -1522,7 +1535,6 @@ namespace PDF_Master.ViewModels.Tools
                                     {
                                         CreateEraseArgs();
                                     }
-                                    
                                 }
                             }
                             break;

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

@@ -192,6 +192,7 @@ namespace PDF_Master.ViewModels.Tools
             {
                 PDFViewer.ToolManager.DisableStickyCreate = false;
                 PropertyPanel.AnnotSelect = StrAnnotToolChecked;
+                PropertyPanel.IsSharpAnnotSelected = true;
                 PropertyPanel.SaveLastAnnot();
                 MyToolCheckedDoing(dictVar, tag);
                 FindAnnotTypeKey(tag, ref annotArgs);

+ 2 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/SharpsAnnotProperty.xaml

@@ -28,6 +28,7 @@
             <convert:AnnotToolIsCheckedConvert x:Key="AnnotToolIsCheckedConvert" />
             <DashConvert:DashStyleConverter x:Key="DashStyleConverter" />
             <Convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert" />
+            <Convert:BoolToVisible x:Key="BoolToVisible" />
             <Style x:Key="line1Style" TargetType="{x:Type Line}">
                 <Setter Property="Visibility">
                     <Setter.Value>
@@ -106,7 +107,7 @@
                 HorizontalAlignment="Left"
                 BorderBrush="#FFE2E3E6"
                 BorderThickness="0"
-                Visibility="{Binding BasicVm.IsMultiSelected, Converter={StaticResource InvertBoolToVisibleConvert}}">
+                Visibility="{Binding BasicVm.IsSharpAnnotSelected, Converter={StaticResource BoolToVisible}}">
                 <Grid Name="ToolGrid">
                     <Grid.ColumnDefinitions>
                         <ColumnDefinition Width="40.5" />