소스 검색

ComPDFKit.Tool(Win) - 补充图片选择控制

liyuxuan 2 달 전
부모
커밋
26839cd4c0
1개의 변경된 파일30개의 추가작업 그리고 2개의 파일을 삭제
  1. 30 2
      Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.SelectImage.cs

+ 30 - 2
Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.SelectImage.cs

@@ -13,6 +13,8 @@ namespace ComPDFKit.Tool
     public partial class CPDFViewerTool
     {
         int selectImageTag = -1;
+        private bool enableImageSelect = true;
+
         private void InsertSelectImageView()
         {
             SelectImage createAnnotTool = new SelectImage();
@@ -20,10 +22,24 @@ namespace ComPDFKit.Tool
             PDFViewer.InsertView(SelectTextindex, createAnnotTool);
             selectImageTag = createAnnotTool.GetResTag();
         }
+
+        public void SetImageSelectEnable(bool enable)
+        {
+            enableImageSelect=enable;
+            if (enableImageSelect==false && PDFViewer!=null)
+            {
+                SelectImage imageLayer = PDFViewer.GetViewForTag(selectImageTag) as SelectImage;
+                if (imageLayer != null)
+                {
+                    imageLayer.CleanDraw(PDFViewer);
+                }
+            }
+        }
+
         public bool DrawMoveSelectImage()
         {
             bool isSelect = false;
-            if (PDFViewer.CurrentRenderFrame == null)
+            if (PDFViewer.CurrentRenderFrame == null || enableImageSelect == false)
             {
                 return isSelect;
             }
@@ -40,7 +56,7 @@ namespace ComPDFKit.Tool
         public bool DrawDownSelectImage(bool isNeedClear)
         {
             bool isSelect = false;
-            if (PDFViewer.CurrentRenderFrame == null)
+            if (PDFViewer.CurrentRenderFrame == null || enableImageSelect == false)
             {
                 return isSelect;
             }
@@ -57,12 +73,20 @@ namespace ComPDFKit.Tool
 
         public void ReDrawSelectImage()
         {
+            if(enableImageSelect == false)
+            {
+                return;
+            }
             BaseLayer baseLayer = PDFViewer.GetViewForTag(selectImageTag);
             (baseLayer as SelectImage).Draw(PDFViewer);
         }
 
         public void CleanDrawSelectImage()
         {
+            if (enableImageSelect == false)
+            {
+                return;
+            }
             BaseLayer baseLayer = PDFViewer.GetViewForTag(selectImageTag);
             (baseLayer as SelectImage).CleanDraw(PDFViewer);
         }
@@ -75,6 +99,10 @@ namespace ComPDFKit.Tool
 
         public Dictionary<int, List<PageImageItem>> GetSelectImageItems()
         {
+            if (enableImageSelect == false)
+            {
+                return new Dictionary<int, List<PageImageItem>>();
+            }
             BaseLayer baseLayer = PDFViewer.GetViewForTag(selectImageTag);
             return (baseLayer as SelectImage).GetSelectImageItems();
         }