Просмотр исходного кода

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

liyuxuan 2 месяцев назад
Родитель
Сommit
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();
         }