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

compdfkit(win) - 数字签名MouseMode

weixiangjie 9 hónapja
szülő
commit
1837a7b784

+ 1 - 1
Demo/Examples/Compdfkit_Tools/DigitalSignature/DigitalSignatureControl/DigitalSignatureControl.xaml.cs

@@ -218,7 +218,7 @@ namespace Compdfkit_Tools.PDFControl
 
         private void PDFViewControl_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
         {
-            if (PDFViewControl.PDFViewTool.GetViewerModel() == MouseModes.PanTool && e.annotType== C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
+            if (PDFViewControl.PDFViewTool.GetViewerModel() == MouseModes.Viewer && e.annotType== C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
             {
                 BaseWidget baseWidget = PDFViewControl.GetCacheHitTestWidget();
                 if(baseWidget == null)

+ 23 - 1
Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureControl.xaml.cs

@@ -117,7 +117,29 @@ namespace Compdfkit_Tools.PDFControl
             tempSignatureConfig.IsDrawLogo = (bool)LogoChk.IsChecked;
             if (tempSignatureConfig.IsDrawLogo)
             {
-                tempSignatureConfig.LogoData = CommonHelper.ConvertBitmapToByteArray(new Bitmap(logoPath));
+                using (FileStream fileData = File.OpenRead(logoPath))
+                {
+                    BitmapFrame frame = null;
+                    BitmapDecoder decoder = BitmapDecoder.Create(fileData, BitmapCreateOptions.None, BitmapCacheOption.Default);
+                    if (decoder != null && decoder.Frames.Count > 0)
+                    {
+                        frame = decoder.Frames[0];
+                    }
+                    if (frame != null)
+                    {
+                        byte[] imageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
+                        //int ImageWidth = frame.PixelWidth;
+                        //int ImageHeight = frame.PixelHeight;
+                        frame.CopyPixels(imageArray, frame.PixelWidth * 4, 0);
+                        if(signatureWidget.IsValid())
+                        {
+                            tempSignatureConfig.LogoData = imageArray;
+                            //signatureWidget.UpdateApWithImage(ImageArray, ImageWidth, ImageHeight, C_Scale_Type.fitCenter, 0);
+                        }
+                    }
+                }
+                
+                //tempSignatureConfig.LogoData = CommonHelper.ConvertBitmapToByteArray(new Bitmap(logoPath));
             }
             tempSignatureConfig.Content = Text;
             tempSignatureConfig.TextColor = textColor;

+ 2 - 2
Demo/Examples/DigitalSignature/MainWindow.xaml.cs

@@ -444,13 +444,13 @@ namespace DigitalSignature
                 if (digitalSignatureControl.PDFViewControl != null)
                 {
                     PDFGrid.Child = digitalSignatureControl;
-                    digitalSignatureControl.PDFViewControl.PDFViewTool.SetViewerModel(MouseModes.Viewer);
+                    digitalSignatureControl.PDFViewControl.PDFViewTool.SetViewerModel(MouseModes.WidgetEditTool);
                     digitalSignatureControl.PDFViewControl = pdfViewer;
                     digitalSignatureControl.InitWithPDFViewer(pdfViewer);
                     digitalSignatureControl.SetBOTAContainer(botaBarControl);
                     digitalSignatureControl.SetDisplaySettingsControl(displaySettingsControl);
                     digitalSignatureControl.SetSignatureStatusBarControl(signatureStatusBarControl);
-                    pdfViewer.PDFViewTool.SetViewerModel(MouseModes.PanTool);
+                    //pdfViewer.PDFViewTool.SetViewerModel(MouseModes.PanTool);
                 }
             }
             currentMode = item.Content as string;