Parcourir la source

ComPDFKit.Tool/Demo - 多边形

liuaoran il y a 4 semaines
Parent
commit
7cbbc0b0d0

+ 8 - 9
Demo/Examples/ComPDFKit.Tool/CPDFToolManager.cs

@@ -502,7 +502,7 @@ namespace ComPDFKit.Tool
                         if (e.annotData.AnnotType != C_ANNOTATION_TYPE.C_ANNOTATION_SOUND)
                         {
                             e.annotData.Annot.UpdateAp();
-                            if(e.annotData.Annot is CPDFTextAnnotation)
+                            if (e.annotData.Annot is CPDFTextAnnotation)
                             {
                                 CommonHelper.UpdateStickyAP(e.annotData.Annot as CPDFTextAnnotation);
                             }
@@ -1066,7 +1066,7 @@ namespace ComPDFKit.Tool
             {
                 case ToolType.CreateAnnot:
                     CreateAnnotTypeMouseLeftUp(ref e);
-                    break;
+                    break; 
 
                 case ToolType.WidgetEdit:
                     {
@@ -1448,7 +1448,7 @@ namespace ComPDFKit.Tool
 
                 annotation.SetRect(cRect);
                 SaveSharpAnnotBoundText(annotation);
-                if (annotation.Type!=C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
+                if (annotation.Type != C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
                 {
                     annotation.UpdateAp();
                 }
@@ -1456,7 +1456,7 @@ namespace ComPDFKit.Tool
                 {
                     CommonHelper.UpdateStickyAP(annotation as CPDFTextAnnotation);
                 }
-               
+
 
                 AnnotHistory annotHistory = ParamConverter.CreateHistory(annotation);
                 if (annotHistory == null)
@@ -1520,14 +1520,14 @@ namespace ComPDFKit.Tool
                 return;
             }
 
-            CPDFTextPage textPage=  boundAnnot.Page.GetTextPage();
-            if (textPage == null || textPage.IsValid()==false)
+            CPDFTextPage textPage = boundAnnot.Page.GetTextPage();
+            if (textPage == null || textPage.IsValid() == false)
             {
                 return;
             }
 
             string boundText = textPage.GetBoundedText(boundAnnot.GetRect());
-            if(string.IsNullOrEmpty(boundText)==false)
+            if (string.IsNullOrEmpty(boundText) == false)
             {
                 boundAnnot.SetContent(boundText);
             }
@@ -1926,7 +1926,7 @@ namespace ComPDFKit.Tool
                         viewerTool.DrawMoveEditAnnot();
                     }
                     else
-                    { 
+                    {
                         if (e.annotType != C_ANNOTATION_TYPE.C_ANNOTATION_LINK)
                         {
                             bool tag = viewerTool.DrawMoveSelectedRect();
@@ -2149,7 +2149,6 @@ namespace ComPDFKit.Tool
                                                 {
                                                     bool cansave = true;
                                                     CPDFPolygonAnnotation PolyAnnotation = (cPDFAnnotation as CPDFPolygonAnnotation);
-                                                    PolyAnnotation?.IsMeasured();
                                                     if (PolyAnnotation != null)
                                                     {
                                                         if (PolyAnnotation.IsMeasured())

+ 1 - 0
Demo/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolygonMeasureParam.cs

@@ -33,6 +33,7 @@ namespace ComPDFKit.Tool
         public byte[] FontColor { get; set; }
         public bool IsBold { get; set; }
         public bool IsItalic { get; set; }
+        public bool IsMeasure { get; set; } = true;
         public C_BORDER_STYLE BorderStyle { get; set; }
         public CPDFMeasureInfo measureInfo { get; set; }
 

+ 0 - 29
Demo/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolygonParam.cs

@@ -1,29 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ComPDFKit.Import;
-using ComPDFKit.PDFAnnotation;
-
-namespace ComPDFKit.Tool
-{
-    public class PolygonParam : AnnotParam
-    {
-        public byte[] FillColor { get; set; }
-        public bool HasFillColor { get; set; }
-        public float LineWidth { get; set; }
-        public byte[] LineColor { get; set; }
-        public List<CPoint> SavePoints { get; set; }
-        public C_BORDER_INTENSITY Intensity { set; get; }
-        public C_BORDER_STYLE Style { set; get; }
-        public float[] LineDash { get; set; }
-        public bool IsMeasure = false;
-        public PolygonParam()
-        {
-            CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON;
-            
-
-        }  
-    }
-}

+ 3 - 30
Demo/Examples/ComPDFKit.Tool/SettingParam/DefaultSettingParam.cs

@@ -79,24 +79,6 @@ namespace ComPDFKit.Tool.SettingParam
             }
         }
 
-        private PolygonParam polygonParamDef;
-        public PolygonParam PolygonParamDef
-        {
-            get
-            {
-                PolygonParam Param = new PolygonParam();
-                if (polygonParamDef.CopyTo(Param))
-                {
-                    return Param;
-                }
-                return null;
-            }
-            private set
-            {
-                value.CopyTo(polygonParamDef);
-            }
-        }
-
         private void InitLineMeasure()
         {
             lineMeasureParamDef = new LineMeasureParam();
@@ -494,10 +476,7 @@ namespace ComPDFKit.Tool.SettingParam
         {
             soundParamDef = new SoundParam();
         }
-        private void InitPolygon()
-        {
-            polygonParamDef = new PolygonParam();
-        }
+
         #endregion
 
         #region Widget
@@ -743,8 +722,7 @@ namespace ComPDFKit.Tool.SettingParam
             InitFreeText();
             InitCircle();
             InitStickyNote();
-            InitSound();
-            InitPolygon();
+            InitSound(); 
             #endregion
 
             #region Widget
@@ -834,12 +812,7 @@ namespace ComPDFKit.Tool.SettingParam
                     {
                         PolygonMeasureParamDef = annotParam as PolygonMeasureParam;
                         IsOK = true;
-                    }
-                    else
-                    {
-                        PolygonParamDef = annotParam as PolygonParam;
-                        IsOK = true;
-                    }
+                    } 
                     break;
                 case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
                     if (annotParam is PolyLineMeasureParam)

+ 2 - 2
Demo/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolygonAnnotHistory.cs

@@ -44,7 +44,7 @@ namespace ComPDFKit.Tool.UndoManger
 
         internal override bool Add()
         {
-            PolygonParam currentParam = CurrentParam as PolygonParam;
+            PolygonMeasureParam currentParam = CurrentParam as PolygonMeasureParam;
             if (CurrentParam == null || PDFDoc == null || !PDFDoc.IsValid())
             {
                 return false;
@@ -123,7 +123,7 @@ namespace ComPDFKit.Tool.UndoManger
 
         internal override bool Update(bool isUndo)
         {
-            if (CurrentParam as PolygonParam == null || PreviousParam as PolygonParam == null)
+            if (CurrentParam as PolygonMeasureParam == null || PreviousParam as PolygonMeasureParam == null)
             {
                 return false;
             }

+ 133 - 93
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs

@@ -267,8 +267,10 @@ namespace ComPDFKit.Controls.PDFControl
                 case CPDFAnnotationType.Square:
                     {
                         CPDFShapeData squareData = pdfAnnotationData as CPDFShapeData;
-                        annotHandlerEventArgs = new SquareParam();
-                        annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE;
+                        annotHandlerEventArgs = new SquareParam()
+                        {
+                            CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE
+                        };
                         byte[] LineColor = new byte[] { squareData.BorderColor.R, squareData.BorderColor.G, squareData.BorderColor.B };
                         (annotHandlerEventArgs as SquareParam).LineColor = LineColor;
                         if (squareData.FillColor != Colors.Transparent)
@@ -291,36 +293,51 @@ namespace ComPDFKit.Controls.PDFControl
 
                 case CPDFAnnotationType.Circle:
                     {
-                        CPDFShapeData cicleData = pdfAnnotationData as CPDFShapeData;
-                        annotHandlerEventArgs = new CircleParam();
-                        annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE;
-                        byte[] LineColor = new byte[] { cicleData.BorderColor.R, cicleData.BorderColor.G, cicleData.BorderColor.B };
-                        (annotHandlerEventArgs as CircleParam).LineColor = LineColor;
-                        if (cicleData.FillColor != Colors.Transparent)
+                        CPDFShapeData circleData = pdfAnnotationData as CPDFShapeData;
+                        byte[] LineColor = new byte[] { circleData.BorderColor.R, circleData.BorderColor.G, circleData.BorderColor.B };
+
+                        annotHandlerEventArgs = new CircleParam
                         {
-                            byte[] BgColor = new byte[] { cicleData.FillColor.R, cicleData.FillColor.G, cicleData.FillColor.B };
-                            (annotHandlerEventArgs as CircleParam).BgColor = BgColor;
-                            (annotHandlerEventArgs as CircleParam).HasBgColor = true;
+                            CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE
+                        };
+
+                        if (annotHandlerEventArgs is CircleParam circleParam)
+                        {
+                            circleParam.LineColor = LineColor;
+                            if (circleData.FillColor != Colors.Transparent)
+                            {
+                                byte[] BgColor = new byte[] { circleData.FillColor.R, circleData.FillColor.G, circleData.FillColor.B };
+                                circleParam.BgColor = BgColor;
+                                circleParam.HasBgColor = true;
+                            }
+                            circleParam.LineWidth = circleData.Thickness;
+                            circleParam.Transparency = Convert.ToByte(circleData.Opacity * 255);
+                            ParamConverter.ParseDashStyle(circleData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle);
+                            circleParam.LineDash = LineDash;
+                            circleParam.BorderStyle = BorderStyle;
+                            circleParam.Author = CPDFMarkupData.Author;
+                            circleParam.Content = circleData.Note; 
                         }
-                        (annotHandlerEventArgs as CircleParam).LineWidth = cicleData.Thickness;
-                        (annotHandlerEventArgs as CircleParam).Transparency = Convert.ToByte(cicleData.Opacity * 255);
-                        ParamConverter.ParseDashStyle(cicleData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle);
-                        (annotHandlerEventArgs as CircleParam).LineDash = LineDash;
-                        (annotHandlerEventArgs as CircleParam).BorderStyle = BorderStyle;
-                        (annotHandlerEventArgs as CircleParam).Author = CPDFMarkupData.Author;
-                        (annotHandlerEventArgs as CircleParam).Content = cicleData.Note;
                         pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE);
                     }
                     break;
                 case CPDFAnnotationType.Polygon:
                     {
                         CPDFPolygonData polygonData = pdfAnnotationData as CPDFPolygonData;
-                        annotHandlerEventArgs = new PolygonParam();
-                        annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON;
-                        (annotHandlerEventArgs as PolygonParam).LineColor = new byte[] { polygonData.LineColor.R, polygonData.LineColor.G, polygonData.LineColor.B };
-                        (annotHandlerEventArgs as PolygonParam).LineWidth = polygonData.Thickness;
-                        (annotHandlerEventArgs as PolygonParam).Transparency = Convert.ToByte(polygonData.Opacity * 255);
-
+                        annotHandlerEventArgs = new PolygonMeasureParam()
+                        {
+                            CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON
+                        };
+                        if (annotHandlerEventArgs is PolygonMeasureParam polygonMeasureParam)
+                        { 
+                            polygonMeasureParam.LineColor = new byte[] { polygonData.BorderColor.R, polygonData.BorderColor.G, polygonData.BorderColor.B };
+                            polygonMeasureParam.HasFillColor = true;
+                            polygonMeasureParam.FillColor = new byte[] { polygonData.FillColor.R, polygonData.FillColor.G, polygonData.FillColor.B };
+                            polygonMeasureParam.LineWidth = polygonData.Thickness;
+                            polygonMeasureParam.IsMeasure = polygonData.IsMeasured;
+                            polygonMeasureParam.Transparency = 255;
+                            polygonMeasureParam.IsMeasure = false;
+                        }
                         pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON);
                     }
                     break;
@@ -328,19 +345,24 @@ namespace ComPDFKit.Controls.PDFControl
                 case CPDFAnnotationType.Line:
                     {
                         CPDFLineShapeData lineData = pdfAnnotationData as CPDFLineShapeData;
-                        annotHandlerEventArgs = new LineParam();
-                        annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_LINE;
-                        byte[] LineColor = new byte[] { lineData.BorderColor.R, lineData.BorderColor.G, lineData.BorderColor.B };
-                        (annotHandlerEventArgs as LineParam).LineColor = LineColor;
-                        (annotHandlerEventArgs as LineParam).LineWidth = lineData.Thickness;
-                        (annotHandlerEventArgs as LineParam).Transparency = Convert.ToByte(lineData.Opacity * 255);
-                        ParamConverter.ParseDashStyle(lineData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle);
-                        (annotHandlerEventArgs as LineParam).LineDash = LineDash;
-                        (annotHandlerEventArgs as LineParam).BorderStyle = BorderStyle;
-                        (annotHandlerEventArgs as LineParam).HeadLineType = lineData.LineType.HeadLineType;
-                        (annotHandlerEventArgs as LineParam).TailLineType = lineData.LineType.TailLineType;
-                        (annotHandlerEventArgs as LineParam).Author = CPDFMarkupData.Author;
-                        (annotHandlerEventArgs as LineParam).Content = lineData.Note;
+                        annotHandlerEventArgs = new LineParam()
+                        {
+                            CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_LINE
+                        };
+                        if (annotHandlerEventArgs is LineParam lineParam)
+                        { 
+                            byte[] LineColor = new byte[] { lineData.BorderColor.R, lineData.BorderColor.G, lineData.BorderColor.B };
+                            lineParam.LineColor = LineColor;
+                            lineParam.LineWidth = lineData.Thickness;
+                            lineParam.Transparency = Convert.ToByte(lineData.Opacity * 255);
+                            ParamConverter.ParseDashStyle(lineData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle);
+                            lineParam.LineDash = LineDash;
+                            lineParam.BorderStyle = BorderStyle;
+                            lineParam.HeadLineType = lineData.LineType.HeadLineType;
+                            lineParam.TailLineType = lineData.LineType.TailLineType;
+                            lineParam.Author = CPDFMarkupData.Author;
+                            lineParam.Content = lineData.Note;
+                        }
                         pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINE);
                     }
                     break;
@@ -349,12 +371,15 @@ namespace ComPDFKit.Controls.PDFControl
                     {
                         CPDFNoteData noteData = pdfAnnotationData as CPDFNoteData;
                         annotHandlerEventArgs = new StickyNoteParam();
-                        annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_TEXT;
-                        byte[] StickyNoteColor = new byte[] { noteData.BorderColor.R, noteData.BorderColor.G, noteData.BorderColor.B };
-                        (annotHandlerEventArgs as StickyNoteParam).StickyNoteColor = StickyNoteColor;
-                        (annotHandlerEventArgs as StickyNoteParam).Content = noteData.Note;
-                        (annotHandlerEventArgs as StickyNoteParam).Transparency = 255;
-                        (annotHandlerEventArgs as StickyNoteParam).Author = CPDFMarkupData.Author;
+                        if (annotHandlerEventArgs is StickyNoteParam stickyNoteParam)
+                        {
+                            annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_TEXT;
+                            byte[] StickyNoteColor = new byte[] { noteData.BorderColor.R, noteData.BorderColor.G, noteData.BorderColor.B };
+                            stickyNoteParam.StickyNoteColor = StickyNoteColor;
+                            stickyNoteParam.Content = noteData.Note;
+                            stickyNoteParam.Transparency = 255;
+                            stickyNoteParam.Author = CPDFMarkupData.Author;
+                        }  
                         pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_TEXT);
                     }
                     break;
@@ -362,14 +387,20 @@ namespace ComPDFKit.Controls.PDFControl
                 case CPDFAnnotationType.Freehand:
                     {
                         CPDFFreehandData freehandData = pdfAnnotationData as CPDFFreehandData;
-                        annotHandlerEventArgs = new InkParam();
-                        annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_INK;
-                        byte[] LineColor = new byte[] { freehandData.BorderColor.R, freehandData.BorderColor.G, freehandData.BorderColor.B };
-                        (annotHandlerEventArgs as InkParam).InkColor = LineColor;
-                        (annotHandlerEventArgs as InkParam).Thickness = freehandData.Thickness;
-                        (annotHandlerEventArgs as InkParam).Transparency = Convert.ToByte(freehandData.Opacity * 255);
-                        (annotHandlerEventArgs as InkParam).Content = freehandData.Note;
-                        (annotHandlerEventArgs as InkParam).Author = CPDFMarkupData.Author;
+                        annotHandlerEventArgs = new InkParam()
+                        {
+                            CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_INK
+                        };
+                        if (annotHandlerEventArgs is InkParam inkParam)
+                        {
+                            byte[] LineColor = new byte[] { freehandData.BorderColor.R, freehandData.BorderColor.G, freehandData.BorderColor.B };
+                            inkParam.InkColor = LineColor;
+                            inkParam.Thickness = freehandData.Thickness;
+                            inkParam.Transparency = Convert.ToByte(freehandData.Opacity * 255);
+                            inkParam.Content = freehandData.Note;
+                            inkParam.Author = CPDFMarkupData.Author;
+                        } 
+
                         pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_INK);
                     }
                     break;
@@ -377,57 +408,66 @@ namespace ComPDFKit.Controls.PDFControl
                 case CPDFAnnotationType.FreeText:
                     {
                         CPDFFreeTextData freeTextData = pdfAnnotationData as CPDFFreeTextData;
-                        annotHandlerEventArgs = new FreeTextParam();
-                        annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT;
-                        (annotHandlerEventArgs as FreeTextParam).Transparency = Convert.ToByte(freeTextData.Opacity * 255);
-                        (annotHandlerEventArgs as FreeTextParam).FontName = freeTextData.FontFamily.ToString();
-
-                        byte[] FontColor = new byte[] { freeTextData.BorderColor.R, freeTextData.BorderColor.G, freeTextData.BorderColor.B };
-                        (annotHandlerEventArgs as FreeTextParam).FontColor = FontColor;
-                        (annotHandlerEventArgs as FreeTextParam).FontSize = freeTextData.FontSize;
-
-                        string postScriptName = string.Empty;
-                        CPDFFont.GetPostScriptName(pdfFreeTextUI.CPDFFontControl.FontFamilyValue, pdfFreeTextUI.CPDFFontControl.FontStyleValue, ref postScriptName);
-                        (annotHandlerEventArgs as FreeTextParam).FontName = postScriptName;
-                        switch (freeTextData.TextAlignment)
+                        annotHandlerEventArgs = new FreeTextParam()
                         {
-                            case TextAlignment.Left:
-                                (annotHandlerEventArgs as FreeTextParam).Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_LEFT;
-                                break;
-                            case TextAlignment.Right:
-                                (annotHandlerEventArgs as FreeTextParam).Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_RIGHT;
-                                break;
-                            case TextAlignment.Center:
-                                (annotHandlerEventArgs as FreeTextParam).Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_CENTER;
-                                break;
-                            default:
-                                break;
+                            CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT
+                        };
+                        if (annotHandlerEventArgs is FreeTextParam freeTextParam)
+                        {
+                            freeTextParam.Transparency = Convert.ToByte(freeTextData.Opacity * 255);
+                            freeTextParam.FontName = freeTextData.FontFamily.ToString();
+
+                            byte[] FontColor = new byte[] { freeTextData.BorderColor.R, freeTextData.BorderColor.G, freeTextData.BorderColor.B };
+                            freeTextParam.FontColor = FontColor;
+                            freeTextParam.FontSize = freeTextData.FontSize;
+
+                            string postScriptName = string.Empty;
+                            CPDFFont.GetPostScriptName(pdfFreeTextUI.CPDFFontControl.FontFamilyValue, pdfFreeTextUI.CPDFFontControl.FontStyleValue, ref postScriptName);
+                            freeTextParam.FontName = postScriptName;
+                            switch (freeTextData.TextAlignment)
+                            {
+                                case TextAlignment.Left:
+                                    freeTextParam.Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_LEFT;
+                                    break;
+                                case TextAlignment.Right:
+                                    freeTextParam.Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_RIGHT;
+                                    break;
+                                case TextAlignment.Center:
+                                    freeTextParam.Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_CENTER;
+                                    break;
+                                default:
+                                    break;
+                            }
+                            freeTextParam.Content = freeTextData.Note;
+                            freeTextParam.Author = CPDFMarkupData.Author;
                         }
-                        (annotHandlerEventArgs as FreeTextParam).Content = freeTextData.Note;
-                        (annotHandlerEventArgs as FreeTextParam).Author = CPDFMarkupData.Author;
+
                         pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT);
                     }
                     break;
 
                 case CPDFAnnotationType.Stamp:
                     {
-                        StampParam stampParam = new StampParam();
-                        stampParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_STAMP;
-                        CPDFStampData stampData = pdfAnnotationData as CPDFStampData;
-                        SetStamp(ref stampParam, stampData);
-                        annotHandlerEventArgs = stampParam;
-                        pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP);
-
-                        byte[] imageData = null;
-                        int imageWidth = 0;
-                        int imageHeight = 0;
-                        PDFHelp.ImageStreamToByte(stampParam.ImageStream, ref imageData, ref imageWidth, ref imageHeight);
-                        if (imageData != null && imageWidth > 0 && imageHeight > 0)
+                        StampParam stampParam = new StampParam()
                         {
-                            pdfViewerControl.PDFViewTool.GetCPDFViewer().SetMouseImageMaxSize(200, 300);
-                            pdfViewerControl.SetStampMouseImage(imageData, imageWidth, imageHeight);
-                        }
-
+                            CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_STAMP
+                        }; 
+                        if(pdfAnnotationData is CPDFStampData stampData)
+                        {
+                            SetStamp(ref stampParam, stampData);
+                            annotHandlerEventArgs = stampParam;
+                            pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP);
+
+                            byte[] imageData = null;
+                            int imageWidth = 0;
+                            int imageHeight = 0;
+                            PDFHelp.ImageStreamToByte(stampParam.ImageStream, ref imageData, ref imageWidth, ref imageHeight);
+                            if (imageData != null && imageWidth > 0 && imageHeight > 0)
+                            {
+                                pdfViewerControl.PDFViewTool.GetCPDFViewer().SetMouseImageMaxSize(200, 300);
+                                pdfViewerControl.SetStampMouseImage(imageData, imageWidth, imageHeight);
+                            }
+                        }  
                         pdfViewerControl.SetIsVisibleCustomMouse(true);
                         pdfViewerControl.SetIsShowStampMouse(true);
                     }

+ 2 - 5
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCloudUI.xaml

@@ -7,7 +7,7 @@
              xmlns:local="clr-namespace:ComPDFKit.Controls.PDFControlUI" 
              xmlns:cpdftools="clr-namespace:ComPDFKit.Controls.PDFControl" 
              mc:Ignorable="d" 
-             d:DesignHeight="800" d:DesignWidth="300"> 
+             d:DesignHeight="800" d:DesignWidth="300" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded"> 
     <UserControl.Resources> 
         <ResourceDictionary> 
             <ResourceDictionary.MergedDictionaries> 
@@ -23,10 +23,7 @@
                     <Grid  Height="40" Background="White" >
                         <TextBlock x:Name="TitleTextBlock" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Title_Cloud}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" FontFamily="Microsoft YaHei"></TextBlock>
                     </Grid>
-                </Border>
-                <StackPanel Orientation="Vertical" Height="130">
-                    <cpdftools:CPDFAnnotationPreviewerControl x:Name="CPDFAnnotationPreviewerControl" Height="100" Margin="16"></cpdftools:CPDFAnnotationPreviewerControl>
-                </StackPanel>
+                </Border> 
                 <StackPanel Name="CloudPanel" Orientation="Vertical">
                     <StackPanel Height="75" Margin="5">
                         <TextBlock Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_LineColor}"></TextBlock>

+ 13 - 1
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCloudUI.xaml.cs

@@ -15,6 +15,8 @@ namespace ComPDFKit.Controls.PDFControlUI
     /// </summary>
     public partial class CPDFCloudUI : UserControl
     {
+        bool IsLoadedData = false;
+
         private AnnotParam annotParam;
         private CPDFAnnotation annotCore;
         private PDFViewControl viewControl;
@@ -57,7 +59,7 @@ namespace ComPDFKit.Controls.PDFControlUI
             throw new NotImplementedException();
         }
 
-        public void SetPresentAnnotAttrib(PolygonParam polygonParam, CPDFPolygonAnnotation annotation, CPDFDocument document, PDFViewControl view)
+        public void SetPresentAnnotAttrib(PolygonMeasureParam polygonParam, CPDFPolygonAnnotation annotation, CPDFDocument document, PDFViewControl view)
         {
             annotParam = polygonParam;
             annotCore = annotation;
@@ -79,5 +81,15 @@ namespace ComPDFKit.Controls.PDFControlUI
 
             return polygonData;
         }
+
+        private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
+        {
+            IsLoadedData = true;
+        }
+
+        private void UserControl_Unloaded(object sender, System.Windows.RoutedEventArgs e)
+        {
+            IsLoadedData = false;
+        }
     }
 }

+ 1 - 1
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml

@@ -42,7 +42,7 @@
                 </StackPanel>
                 <StackPanel x:Name="LineStyleStackPanel" Height="90" Margin="5">
                     <TextBlock Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_LineStyle}"></TextBlock>
-                    <cpdfcommon:CPDFLineStyleControl x:Name="CPDFLineStyleControl"></cpdfcommon:CPDFLineStyleControl>
+                    <cpdfcommon:CPDFLineStyleControl x:Name="CPDFLineStyleControl"/>
                 </StackPanel>
                 <StackPanel x:Name="ArrowStackPanel" Visibility="Visible" Height="75"  Margin="5">
                     <StackPanel Orientation="Horizontal" Margin="0,0,0,10">

+ 1 - 2
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs

@@ -419,8 +419,7 @@ namespace ComPDFKit.Controls.PDFControlUI
                 pdfShapeData.DashStyle = CPDFLineStyleControl.DashStyle;
                 pdfShapeData.Note = NoteTextBox.Text;
                 return pdfShapeData;
-            }
-
+            } 
             else
             {
                 CPDFLineShapeData pdfLineShapeData = new CPDFLineShapeData();

+ 3 - 4
Demo/Examples/Compdfkit.Controls/Measure/MeasureControl.xaml.cs

@@ -26,6 +26,7 @@ namespace ComPDFKit.Controls.Measure
     public partial class MeasureControl : UserControl
     {
         public MeasurePropertyControl measurePropertyControl = new MeasurePropertyControl();
+
         private CPDFDisplaySettingsControl displaySettingsControl;
 
         private PDFViewControl PdfViewControl = new PDFViewControl();
@@ -36,8 +37,7 @@ namespace ComPDFKit.Controls.Measure
 
         public event EventHandler ExpandEvent;
         public event EventHandler OnAnnotEditHandler;
-
-
+         
         public MeasureControl()
         {
             InitializeComponent();
@@ -276,8 +276,7 @@ namespace ComPDFKit.Controls.Measure
                 currentAnnot = annotData.Annot;
             }
 
-            panelState.RightPanel = PanelState.RightPanelState.PropertyPanel;
-            // measurePropertyControl.SetPropertyForMeasureCreate(LineArgs, e);
+            panelState.RightPanel = PanelState.RightPanelState.PropertyPanel; 
             SetInfoPanelVisble(true, false);
         }
 

+ 1 - 1
Demo/Examples/Compdfkit.Controls/Measure/Property/MultilineProperty.xaml

@@ -20,7 +20,7 @@
         <Grid Background="#FAFCFF">
             <StackPanel Orientation="Vertical">
                 <Border BorderThickness="1" BorderBrush="#1A000000">
-                    <Grid  Height="40" Background="White" >
+                    <Grid Height="40" Background="White" >
                         <TextBlock x:Name="TitleTextBlock" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Title_Appearance_M}"  HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" FontWeight="Bold" FontFamily="Segoe UI"></TextBlock>
                     </Grid>
                 </Border>

+ 2 - 4
Demo/Examples/Compdfkit.Controls/Measure/Property/PolygonalProperty.xaml.cs

@@ -36,8 +36,7 @@ namespace ComPDFKit.Controls.Measure.Property
         public CPDFPolygonAnnotation Annotation{ get; set; }
         
         public PDFViewControl ViewControl{ get; set; }
-
-
+         
         //private AnnotAttribEvent PolygonalEvent { get; set; }
 
         public PolygonalProperty()
@@ -158,8 +157,7 @@ namespace ComPDFKit.Controls.Measure.Property
             {
                 if (Annotation != null && ViewControl != null)
                 {
-                    SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
-                    if (checkBrush != null)
+                    if (BorderColorPickerControl.GetBrush() is SolidColorBrush checkBrush)
                     {
                         byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
                         Annotation.SetLineColor(color);