소스 검색

注释 - 虚实线

chenrongqian@kdanmobile.com 1 년 전
부모
커밋
2b1365a67b

+ 15 - 31
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreehandAnnotPropertyViewModel.cs

@@ -24,6 +24,7 @@ using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
+    //橡皮擦的UI大小效果
     public class EraseThicknessConverter : IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@@ -46,7 +47,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         #region 文案
 
 
-        private void InitSting()
+        private void InitString()
         {
 
         }
@@ -102,16 +103,17 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         public FreehandAnnotPropertyViewModel()
         {
+            //选择工具
             EraseCommand = new DelegateCommand<object>(Erase_Command);
             PenCommand = new DelegateCommand<object>(Pen_Command);
-
+            //手绘属性
             SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged);
             SelectPenThickChangedCommand = new DelegateCommand<object>(SelectPenThickChanged);
             SetEraserThickCommand = new DelegateCommand<object>(SelectEraserThickChanged);
             LineModeCheckedCommand = new DelegateCommand<object>(LineMode_Checked);
             SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
-            InitSting();
-
+            //初始化
+            InitString();
             InitVariable();
         }
 
@@ -122,6 +124,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             InitColorItems();
         }
 
+        //画笔的大小列表
         private void InitPenSizeItems()
         {
             PenSizeItems = new List<ComboDataItem>();
@@ -137,6 +140,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             PenSizeItems.Add(item);
         }
 
+        //橡皮擦的大小列表
         private void InitEraserSizeItems()
         {
             EraserSizeItems = new List<ComboDataItem>();
@@ -224,7 +228,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                 }
                 
-                AnnotEvent?.UpdateAnnot();
             }
         }
 
@@ -308,7 +311,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 if (BasicVm.IsMultiSelected)
                 {
                     IsAttributeEquals();
-                    BasicVm.IsDashLine = BasicVm.IsSolidLine = false;
                 }
                 else
                 {
@@ -378,7 +380,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                     if(isNoEqualsDir["ThickSolidDashStyle"] == false)
                     {
-                        if(isSolidStyle(temp) != isSolidStyle(item))
+                        if (AnnotTransfer.IsSolidStyle(temp.LineDash) != AnnotTransfer.IsSolidStyle(item.LineDash))
                         {
                             isNoEqualsDir["ThickSolidDashStyle"] = true;
                         }
@@ -397,35 +399,17 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 }
 
                 if(isNoEqualsDir["ThickSolidDashStyle"] == true)
-                {
-                    var isSolid = isSolidStyle(temp);
-                    BasicVm.IsSolidLine = isSolid;
-                    BasicVm.IsDashLine = !isSolid;
-                }
-                else
                 {
                     BasicVm.IsSolidLine = BasicVm.IsDashLine = false;
+                   
                 }
-            }
-        }
-        //外部UI控件选中状态
-        private bool isSolidStyle(FreehandAnnotArgs annot)
-        {
-            bool isSolid = true;
-            if (annot.LineDash != null && annot.LineDash.Dashes.Count > 0)
-            {
-                foreach (var item in annot.LineDash.Dashes)
+                else
                 {
-                    if (item > 0)
-                    {
-                      
-                        isSolid = false;
-                        break;
-                    }
+                    var isSolid = AnnotTransfer.IsSolidStyle(temp.LineDash);
+                    BasicVm.IsSolidLine = isSolid;
+                    BasicVm.IsDashLine = !isSolid;
                 }
             }
-            return isSolid;
-            
         }
 
         private void GetAnnotProperty()
@@ -439,7 +423,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     BasicVm.FontColor = new SolidColorBrush(annot.InkColor);
                     BasicVm.AnnotThickness = annot.LineWidth;
                     BasicVm.Dash = annot.LineDash;
-                    var isSolid = isSolidStyle(annot);
+                    var isSolid = AnnotTransfer.IsSolidStyle(annot.LineDash);
                     BasicVm.IsSolidLine = isSolid;
                     BasicVm.IsDashLine = !isSolid;
  

+ 5 - 5
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SharpsAnnotPropertyViewModel.cs

@@ -472,7 +472,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                     if (isNoEqualsDir["ThickSolidDashStyle"] == false)
                     {
-                        if (IsSolidStyle(temp) != IsSolidStyle(item))
+                        if (AnnotTransfer.IsSolidStyle(temp.LineDash) != AnnotTransfer.IsSolidStyle(item.LineDash))
                         {
                             isNoEqualsDir["ThickSolidDashStyle"] = true;
                         }
@@ -499,13 +499,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                 if (isNoEqualsDir["ThickSolidDashStyle"] == true)
                 {
-                    var isSolid = IsSolidStyle(temp);
-                    BasicVm.IsSolidLine = isSolid;
-                    BasicVm.IsDashLine = !isSolid;
+                    BasicVm.IsSolidLine = BasicVm.IsDashLine = false;
                 }
                 else
                 {
-                    BasicVm.IsSolidLine = BasicVm.IsDashLine = false;
+                    var isSolid = AnnotTransfer.IsSolidStyle(temp.LineDash);
+                    BasicVm.IsSolidLine = isSolid;
+                    BasicVm.IsDashLine = !isSolid;
                 }
 
             }

+ 42 - 46
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -26,6 +26,7 @@ using System.Diagnostics;
 using PDF_Office.Model.AnnotPanel;
 using System.Windows.Input;
 using PDF_Office.ViewModels.Tools.AnnotManager;
+using ComPDFKit.Import;
 
 namespace PDF_Office.ViewModels.Tools
 {
@@ -100,7 +101,6 @@ namespace PDF_Office.ViewModels.Tools
 
         #region 与触发事件调用相关的函数
 
-
         //鼠标左键双击注释
         private void PDFViewer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
@@ -869,7 +869,6 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
-
         private void PDFViewer_AnnotHoverHandler(object sender, AnnotHoverData e)
         {
             if (e != null && e.DrawContext != null)
@@ -883,43 +882,58 @@ namespace PDF_Office.ViewModels.Tools
                 hoverPen.DashStyle = DashStyles.Dash;
                 e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
 
-
                 //便签,显示ToolTip内容
                 if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
                 {
-                    if (PDFViewer.ToolTip == null)
-                    {
-                        var content = e.Annot.GetContent();
-                        if (string.IsNullOrEmpty(content) == false)
-                        {
-                            ToolTip TipChild = new ToolTip();
-                            TipChild.Style = App.Current.Resources["FlowToolTip"] as Style;
-                            TipChild.MaxWidth = 246;
-                            TipChild.Content = content;
-                            TipChild.Visibility = Visibility.Visible;
-                            TipChild.IsOpen = true;
-                            TipChild.Placement = PlacementMode.Right;
-                            var rec = e.Annot.GetRect();
-                            TipChild.PlacementRectangle = new Rect(rec.left, rec.top, rec.right, rec.bottom);
-                            TipChild.PlacementTarget = PDFViewer.Parent as ContentControl;
-                            TipChild.Placement = PlacementMode.MousePoint;
-                            PDFViewer.ToolTip = TipChild;
-                            oldRect = hoverRect;
-                            PDFViewer.MouseMove -= PDFViewer_MouseMove;
-                            PDFViewer.MouseMove += PDFViewer_MouseMove;
-                            return;
-                        }
-
-                    }
-
+                    PopAnnotToolTip(e.Annot.GetRect(), hoverRect, e.Annot.GetContent());
+                    return;
                 }
             }
 
             CloseAnnotToolTip();
         }
 
+        private void PDFViewer_MouseMove(object sender, MouseEventArgs e)
+        {
+            if (sender != null && PDFViewer.ToolTip != null && PDFViewer.Parent != null)
+            {
+                var newPoint = e.GetPosition(PDFViewer.Parent as ContentControl);
+                var isOutw = newPoint.X > (oldRect.X + oldRect.Width + 4);
+                var isOuth = newPoint.Y > (oldRect.Y + oldRect.Height + 4);
+                if (newPoint.X < oldRect.X || newPoint.Y < oldRect.Y || isOutw || isOuth)
+                {
+                    CloseAnnotToolTip();
+                }
+            }
+        }
+
         private Rect oldRect = new Rect(0, 0, 0, 0);
+        private void PopAnnotToolTip(CRect placementRect, Rect hoverRect, string content)
+        {
+            //便签,显示ToolTip内容
+            if (PDFViewer.ToolTip == null)
+            {
+                if (string.IsNullOrEmpty(content) == false)
+                {
+                    ToolTip TipChild = new ToolTip();
+                    TipChild.Style = App.Current.Resources["FlowToolTip"] as Style;
+                    TipChild.MaxWidth = 246;
+                    TipChild.Content = content;
+                    TipChild.Visibility = Visibility.Visible;
+                    TipChild.IsOpen = true;
+                    TipChild.Placement = PlacementMode.Right;
+                    TipChild.PlacementRectangle = new Rect(placementRect.left, placementRect.top, placementRect.right, placementRect.bottom);
+                    TipChild.PlacementTarget = PDFViewer.Parent as ContentControl;
+                    TipChild.Placement = PlacementMode.MousePoint;
+                    PDFViewer.ToolTip = TipChild;
+                    oldRect = hoverRect;
+                    PDFViewer.MouseMove -= PDFViewer_MouseMove;
+                    PDFViewer.MouseMove += PDFViewer_MouseMove;
+                    return;
+                }
 
+            }
+        }
         private void CloseAnnotToolTip()
         {
             if (PDFViewer.ToolTip != null && PDFViewer.ToolTip is ToolTip)
@@ -933,28 +947,10 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
-        private void PDFViewer_MouseMove(object sender, MouseEventArgs e)
-        {
-            if (sender != null && PDFViewer.ToolTip != null && PDFViewer.Parent != null)
-            {
-                var newPoint = e.GetPosition(PDFViewer.Parent as ContentControl);
-                var isOutw = newPoint.X > (oldRect.X + oldRect.Width + 4);
-                var isOuth = newPoint.Y > (oldRect.Y + oldRect.Height + 4);
-                if (newPoint.X < oldRect.X || newPoint.Y < oldRect.Y || isOutw || isOuth)
-                {
-                    CloseAnnotToolTip();
-                }
-            }
-        }
-
         #endregion PDFViewer事件
 
         #region BindingEvent事件
 
-        private void AnnotProperty_DefaultStored(object sender, object e)
-        {
-        }
-
         //同一属性面板,不同的注释类型
         private void AnnotPropertyPanel_AnnotTypeChanged(object sender, Dictionary<AnnotArgsType, object> e)
         {

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

@@ -222,7 +222,9 @@ namespace PDF_Office.ViewModels.Tools
         //选中注释工具按钮时,处理的一些系列事情
         private void MyToolCheckedDoing(Dictionary<string, bool> dict,string tag)
         {
-            BtnHandIsChecked = !BtnHandIsChecked;
+            if (BtnHandIsChecked)
+                BtnHandIsChecked = false;
+
             PDFViewer.ClearSelectAnnots();
 
             //选中内容选择工具按钮

+ 2 - 2
PDF Office/Views/PropertyPanel/AnnotPanel/FreehandAnnotProperty.xaml

@@ -222,7 +222,7 @@
                         CommandParameter="{Binding ElementName=BtnSolid, Path=Tag}"
                         Foreground="#616469"
                         GroupName="LineMode"
-                        IsChecked="{Binding BasicVm.IsSolidLine}"
+                        IsChecked="{Binding BasicVm.IsSolidLine,Mode=TwoWay}"
                         Style="{DynamicResource GreyBgRadioBtnStyle}"
                         Tag="Solid">
                         <RadioButton.Content>
@@ -247,7 +247,7 @@
                         CommandParameter="{Binding ElementName=BtnDashed, Path=Tag}"
                         Foreground="#616469"
                         GroupName="LineMode"
-                        IsChecked="{Binding BasicVm.IsDashLine}"
+                        IsChecked="{Binding BasicVm.IsDashLine,Mode=TwoWay}"
                         Style="{DynamicResource GreyBgRadioBtnStyle}"
                         Tag="Dashed">
                         <RadioButton.Content>