Forráskód Böngészése

PDFForm(Windows)-RadioButton高保真

zhuyi 1 éve
szülő
commit
7b27268bf4

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Form/FromPropertyControl.xaml.cs

@@ -54,7 +54,7 @@ namespace compdfkit_tools.Form
                     break;
                 case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
                     RadioButtonProperty radioBoxProperty = new RadioButtonProperty();
-                    radioBoxProperty.SetProperty(Args, e);
+                    radioBoxProperty.SetProperty(Args, e, pdfViewer);
                     currentPanel = radioBoxProperty;
                     break;
                 case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_TEXTFIELD:

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 16 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Form/Property/RadioButtonProperty.xaml


+ 32 - 3
compdfkit_demo_windows/compdfkit/compdfkit-tools/Form/Property/RadioButtonProperty.xaml.cs

@@ -1,6 +1,9 @@
-using compdfkit_tools.Common;
+using ComPDFKit.PDFAnnotation.Form;
+using ComPDFKit.PDFAnnotation;
+using compdfkit_tools.Common;
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -24,7 +27,8 @@ namespace compdfkit_tools.Form.Property
     public partial class RadioButtonProperty : UserControl
     {
         private WidgetRadioButtonArgs widgetArgs = null;
-        private AnnotAttribEvent annotAttribEvent = null;
+        private AnnotAttribEvent annotAttribEvent = null; 
+        private CPDFViewer pdfViewer;
 
         bool IsLoadedData = false;
         public RadioButtonProperty()
@@ -33,10 +37,11 @@ namespace compdfkit_tools.Form.Property
         }
 
         #region Loaded
-        public void SetProperty(WidgetArgs Args, AnnotAttribEvent e)
+        public void SetProperty(WidgetArgs Args, AnnotAttribEvent e, CPDFViewer cPDFViewer)
         {
             widgetArgs = (WidgetRadioButtonArgs)Args;
             annotAttribEvent = e;
+            pdfViewer = cPDFViewer;
         }
 
 
@@ -48,9 +53,33 @@ namespace compdfkit_tools.Form.Property
             BackgroundColorPickerControl.SetCheckedForColor(widgetArgs.BgColor);
             RadioButtonStyleCombox.SelectedIndex = (int)widgetArgs.CheckStyle;
             chkSelected.IsChecked = widgetArgs.IsChecked;
+
+            if (IsShowWarning())
+            {
+                WarningPanel.Visibility = Visibility.Collapsed;
+            }
+            else
+            {
+                WarningPanel.Visibility = Visibility.Visible;
+            }
+
             IsLoadedData = true;
         }
 
+        private bool IsShowWarning()
+        {
+            int count = 0;
+            var page = pdfViewer.Document.PageAtIndex(pdfViewer.CurrentIndex);
+            List<CPDFAnnotation> annotList = page.GetAnnotations();
+            if (annotList != null && annotList.Count > 0)
+            {
+                count = annotList.Where(x => x.Type == C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
+                    .Cast<CPDFWidget>().Where(x => x.WidgeType == C_WIDGET_TYPE.WIDGET_RADIOBUTTON).Count();
+            }
+
+            return count>1;
+        }
+
         private void UserControl_Unloaded(object sender, RoutedEventArgs e)
         {
             IsLoadedData = false;