소스 검색

ComPDFKit.Controls - 添加加载时避免鼠标移动、加载完成时恢复鼠标样式、修复一个颜色控件的bug

liuaoran 1 주 전
부모
커밋
d06df580d3

+ 2 - 3
Demo/Examples/Compdfkit.Controls/Common/PropertyControl/ColorPickerControl.xaml.cs

@@ -25,8 +25,7 @@ namespace ComPDFKit.Controls.Common
         // Using a DependencyProperty as the backing store for TransparentBtnProperty.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty TransparentBtnPropertyProperty =
             DependencyProperty.Register("TransparentBtnProperty", typeof(Visibility), typeof(ColorPickerControl), new PropertyMetadata(Visibility.Visible));
-
-
+         
         public void SetIsChecked(int index)
         {
             switch (index)
@@ -97,7 +96,7 @@ namespace ComPDFKit.Controls.Common
 
         public bool GetTransparentBtnVisibility()
         {
-            if (TransparentBtn.Visibility == Visibility.Visible)
+            if (TransparentBtnProperty == Visibility.Visible)
             {
                 return true;
             }

+ 84 - 4
Demo/Examples/Compdfkit.Controls/PDFView/PDFViewControl/PDFViewControl.xaml.cs

@@ -57,7 +57,7 @@ namespace ComPDFKit.Controls.PDFControl
         private double splitWidthScale = 0.5;
         private double splitHeightScale = 0.5;
 
-        public bool CustomSignHandle { get; set; } 
+        public bool CustomSignHandle { get; set; }
 
         private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
         #endregion
@@ -117,9 +117,17 @@ namespace ComPDFKit.Controls.PDFControl
             splitToolManager.MouseMoveHandler += PDFToolManager_MouseMoveHandler;
             splitToolManager.MouseRightButtonDownHandler += PDFToolManager_MouseRightButtonDownHandler;
 
+            GetCPDFViewer().OnRenderFinish -= PDFViewControl_OnRenderFinish;
+            GetCPDFViewer().OnRenderFinish += PDFViewControl_OnRenderFinish;
+
             SetCursor();
         }
 
+        private void PDFViewControl_OnRenderFinish(object sender, EventArgs e)
+        {
+           SetCursorStatus();
+        }
+
         private void PDFViewTool_DrawChanged(object sender, EventArgs e)
         {
             FocusPDFViewToolChanged?.Invoke(this, EventArgs.Empty);
@@ -345,7 +353,7 @@ namespace ComPDFKit.Controls.PDFControl
             toolManager?.SetCreateWidgetType(type);
             splitToolManager?.SetCreateWidgetType(type);
         }
-        
+
         public void SetAnnotParam(AnnotParam param)
         {
             DefaultSettingParam defaultSettingParam = viewerTool.GetDefaultSettingParam();
@@ -437,7 +445,7 @@ namespace ComPDFKit.Controls.PDFControl
                 FocusPDFViewTool?.GetCPDFViewer()?.SetZoom(CheckZoomLevel(zoom, true));
                 FocusPDFViewTool?.GetCPDFViewer()?.UpdateRenderFrame();
             };
-            contextMenu.Items.Add(zoomInMenu); 
+            contextMenu.Items.Add(zoomInMenu);
 
             MenuItem zoomOutMenu = new MenuItem();
             zoomOutMenu.Header = LanguageHelper.CommonManager.GetString("Menu_ZoomOut");
@@ -643,8 +651,79 @@ namespace ComPDFKit.Controls.PDFControl
             }
         }
 
+        private void SetCursorStatus()
+        {
+            List<ToolType> toolTypes = new List<ToolType>
+                {
+                      ToolType.Viewer,
+                      ToolType.Pan
+                };
+
+            ToolType currentMode = PDFViewTool.GetToolType();
+            Cursor newCursor = Cursors.Arrow;
+
+            if (toolTypes.Contains(currentMode))
+            {
+                BaseAnnot hitAnnot = GetCPDFViewer().AnnotHitTest();
+                if (hitAnnot != null)
+                {
+                    if (hitAnnot is LinkAnnot || hitAnnot is BaseWidget)
+                    {
+                        newCursor = Cursors.Hand;
+                    }
+                    else
+                    {
+                        newCursor = annotEditCursor;
+                    }
+                }
+                else
+                {
+                    if (!PDFViewTool.IsSelectRectMousePoint())
+                    {
+                        newCursor = (PDFToolManager.GetToolType() == ToolType.Pan) ? panToolCursor : Cursors.Arrow;
+
+                        if (PDFViewTool.IsText())
+                        {
+                            newCursor = Cursors.IBeam;
+                        }
+                    }
+                }
+
+
+                if (currentMode == ToolType.CreateAnnot)
+                {
+                    List<C_ANNOTATION_TYPE> annotTypes = new List<C_ANNOTATION_TYPE>
+                    {
+                         C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT,
+                         C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE,
+                         C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY,
+                         C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT
+                    };
+
+                    if (GetCPDFViewer().AnnotHitTest() == null && PDFViewTool.IsText() && annotTypes.Contains(toolManager.GetAnnotType()))
+                    {
+                        newCursor = Cursors.IBeam;
+                    }
+                    else
+                    {
+                        if (newCursor == Cursors.IBeam || newCursor == panToolCursor || newCursor == Cursors.Arrow)
+                        {
+                            newCursor = annotEditCursor;
+                        }
+                    }
+                }
+            }
+            GetCPDFViewer().Cursor = newCursor;
+        }
+
         private void PDFViewControl_MouseMove(object sender, MouseEventArgs e)
         {
+            if (GetCPDFViewer().IsRendering)
+            {
+               GetCPDFViewer().Cursor = Cursors.Wait;
+               return;
+            }
+
             if (isAutomaticScroll)
             {
                 middleMovePoint = e.GetPosition(this);
@@ -711,7 +790,7 @@ namespace ComPDFKit.Controls.PDFControl
                             {
                                 newCursor = Cursors.IBeam;
                             }
-                            cursorSet = true; 
+                            cursorSet = true;
                         }
                     }
 
@@ -730,6 +809,7 @@ namespace ComPDFKit.Controls.PDFControl
                          C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY,
                          C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT
                     };
+
                     if (GetCPDFViewer().AnnotHitTest() == null && PDFViewTool.IsText() && annotTypes.Contains(toolManager.GetAnnotType()))
                     {
                         newCursor = Cursors.IBeam;