zhuyi 10 mesi fa
parent
commit
bbdab2c4ff

+ 36 - 31
Demo/Examples/Compdfkit_Tools/Common/BarControl/CPDFMeasureBarControl.xaml.cs

@@ -1,6 +1,7 @@
 using ComPDFKit.Measure;
 using ComPDFKit.PDFAnnotation;
 using ComPDFKit.PDFAnnotation.Form;
+using ComPDFKit.Tool;
 using Compdfkit_Tools.Helper;
 using Compdfkit_Tools.Measure;
 using Compdfkit_Tools.Measure.Property;
@@ -206,7 +207,7 @@ namespace Compdfkit_Tools.PDFControl
 
         private void MeasureBtn_Click(object sender, RoutedEventArgs e)
         {
-            //AnnotHandlerEventArgs args = null;
+            AnnotParam annotParam = null;
             ClearToolState(sender as ToggleButton);
             if ((bool)(sender as ToggleButton).IsChecked)
             {
@@ -215,7 +216,7 @@ namespace Compdfkit_Tools.PDFControl
                     case MeasureType.UnKnown:
                         break;
                     case MeasureType.Line:
-                        //args = CreateLine();
+                        annotParam = CreateLine();
                         break;
                     case MeasureType.Multiline:
                         //args = CreateMultiline();
@@ -235,41 +236,45 @@ namespace Compdfkit_Tools.PDFControl
                 //pdfViewer.SetMouseMode(MouseModes.PanTool);
                 measureControl.SetInfoPanelVisble(false, false);
             }
-            //if (args != null)
-            //{
-            //    panelState.RightPanel = RightPanelState.PropertyPanel;
-            //}
-            //measurePropertyControl.SetPropertyForMeasureCreate(args,null);
+            if (annotParam != null)
+            {
+                panelState.RightPanel = RightPanelState.PropertyPanel;
+            }
+            measurePropertyControl.SetPropertyForMeasureCreate(annotParam);
         }
 
         #endregion
 
         //#region Create Form
 
-        //private AnnotHandlerEventArgs CreateLine()
-        //{
-        //    LineMeasureArgs lineMeasureArgs = new LineMeasureArgs();
-        //    lineMeasureArgs.LineColor = Colors.Red;
-        //    lineMeasureArgs.LineWidth = 2;
-        //    lineMeasureArgs.Transparency = 1;
-        //    lineMeasureArgs.FontColor = Colors.Red;
-        //    lineMeasureArgs.FontName = "Arial";
-        //    lineMeasureArgs.FontSize = 14;
-        //    lineMeasureArgs.HeadLineType = C_LINE_TYPE.LINETYPE_ARROW;
-        //    lineMeasureArgs.TailLineType = C_LINE_TYPE.LINETYPE_ARROW;
-        //    pdfViewer?.ClearSelectAnnots();
-        //    pdfViewer?.SetMouseMode(MouseModes.AnnotCreate);
-        //    pdfViewer?.SetToolParam(lineMeasureArgs);
-        //    measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_DISTANCE_MEASURE);
-        //    measureControl.SetInfoPanelVisble(true, false);
-        //    measureControl.SetMeasureScale(CPDFMeasureType.CPDF_DISTANCE_MEASURE,
-        //        string.Format("{0}{1}={2}{3}",
-        //                    MeasureSetting.RulerBase,
-        //                    MeasureSetting.RulerBaseUnit,
-        //                    MeasureSetting.RulerTranslate,
-        //                    MeasureSetting.RulerTranslateUnit));
-        //    return lineMeasureArgs;
-        //}
+        private AnnotParam CreateLine()
+        {
+            pdfViewer.SetToolType(CPDFToolManager.ToolType.CreateAnnot);
+            pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINE);
+            LineMeasureParam textBoxParam = new LineMeasureParam();
+            textBoxParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_LINE;
+            textBoxParam.LineColor = new byte[] { 255, 0, 0, };
+            textBoxParam.LineWidth = 2;
+            textBoxParam.Transparency = 1;
+            textBoxParam.FontColor = new byte[] { 255, 0, 0, };
+            textBoxParam.FontName = "Arial";
+            textBoxParam.FontSize = 14;
+            textBoxParam.HeadLineType = C_LINE_TYPE.LINETYPE_ARROW;
+            textBoxParam.TailLineType = C_LINE_TYPE.LINETYPE_ARROW; 
+            pdfViewer.SetAnnotParam(textBoxParam);
+            //pdfViewer?.ClearSelectAnnots();
+            //pdfViewer?.SetMouseMode(MouseModes.AnnotCreate);
+            //pdfViewer?.SetToolParam(lineMeasureArgs);
+            //measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_DISTANCE_MEASURE);
+            //measureControl.SetInfoPanelVisble(true, false);
+            //measureControl.SetMeasureScale(CPDFMeasureType.CPDF_DISTANCE_MEASURE,
+            //    string.Format("{0}{1}={2}{3}",
+            //                MeasureSetting.RulerBase,
+            //                MeasureSetting.RulerBaseUnit,
+            //                MeasureSetting.RulerTranslate,
+            //                MeasureSetting.RulerTranslateUnit));
+            return textBoxParam;
+        }
 
         //private AnnotHandlerEventArgs CreateMultiline()
         //{

+ 25 - 1
Demo/Examples/Compdfkit_Tools/Measure/MeasureControl.xaml.cs

@@ -1,5 +1,6 @@
 using ComPDFKit.Measure;
 using ComPDFKit.PDFAnnotation;
+using ComPDFKit.Tool;
 using Compdfkit_Tools.Helper;
 using Compdfkit_Tools.PDFControl;
 using ComPDFKitViewer;
@@ -75,7 +76,14 @@ namespace Compdfkit_Tools.Measure
             PDFGrid.Child = PdfViewControl;
 
             panelState.PropertyChanged -= PanelState_PropertyChanged;
-            panelState.PropertyChanged += PanelState_PropertyChanged;
+            panelState.PropertyChanged += PanelState_PropertyChanged; 
+            PdfViewControl.MouseLeftButtonDownHandler -= PDFToolManager_MouseLeftButtonDownHandler;
+            PdfViewControl.MouseLeftButtonUpHandler -= PDFToolManager_MouseLeftButtonUpHandler;
+            PdfViewControl.MouseMoveHandler -= PDFToolManager_MouseMoveHandler;
+
+            PdfViewControl.MouseLeftButtonDownHandler += PDFToolManager_MouseLeftButtonDownHandler;
+            PdfViewControl.MouseLeftButtonUpHandler += PDFToolManager_MouseLeftButtonUpHandler;
+            PdfViewControl.MouseMoveHandler += PDFToolManager_MouseMoveHandler;
             //pdfViewControl.PDFView.AnnotActiveHandler -= PDFView_AnnotActiveHandler;
             //pdfViewControl.PDFView.AnnotActiveHandler += PDFView_AnnotActiveHandler;
             //pdfViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
@@ -84,6 +92,22 @@ namespace Compdfkit_Tools.Measure
             SettingPanel.PdfViewControl= pdfViewControl;
         }
 
+        private void PDFToolManager_MouseMoveHandler(object sender, MouseEventObject e)
+        {
+        }
+
+        private void PDFToolManager_MouseLeftButtonUpHandler(object sender, MouseEventObject e)
+        {
+        }
+
+        private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
+        {
+            if (e.annotType == C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
+            {
+
+            }
+        }
+
         //private void PDFView_AnnotCommandHandler(object sender, AnnotCommandArgs e)
         //{
         //    switch (e.CommandType)

+ 53 - 51
Demo/Examples/Compdfkit_Tools/Measure/MeasurePropertyControl.xaml.cs

@@ -1,4 +1,6 @@
-using Compdfkit_Tools.Measure.Property;
+using ComPDFKit.PDFAnnotation;
+using ComPDFKit.Tool;
+using Compdfkit_Tools.Measure.Property;
 using Compdfkit_Tools.PDFControl;
 using System;
 using System.Collections.Generic;
@@ -28,57 +30,57 @@ namespace Compdfkit_Tools.Measure
             InitializeComponent();
         }
 
-        //public void SetPropertyForMeasureCreate(AnnotHandlerEventArgs Args, AnnotAttribEvent attribEvent)
-        //{
-        //    if (Args == null)
-        //    {
-        //        ClearMeasurePanel();
-        //        return;
-        //    }
+        public void SetPropertyForMeasureCreate(AnnotParam Args)
+        {
+            if (Args == null)
+            {
+                ClearMeasurePanel();
+                return;
+            }
 
-        //    switch (Args.EventType)
-        //    {
-        //        case AnnotArgsType.LineMeasure:
-        //            StraightnessProperty straightnessProperty = new StraightnessProperty();
-        //            if (attribEvent != null)
-        //            {
-        //                straightnessProperty.SetAnnotEventData(attribEvent);
-        //            }
-        //            else
-        //            {
-        //                straightnessProperty.SetAnnotArgsData((LineMeasureArgs)Args);
-        //            }
-        //            currentPanel = straightnessProperty;
-        //            break;
-        //        case AnnotArgsType.PolyLineMeasure:
-        //            MultilineProperty multilineProperty = new MultilineProperty();
-        //            if (attribEvent != null)
-        //            {
-        //                multilineProperty.SetAnnotEventData(attribEvent);
-        //            }
-        //            else
-        //            {
-        //                multilineProperty.SetAnnotArgsData((PolyLineMeasureArgs)Args);
-        //            }
-        //            currentPanel = multilineProperty;
-        //            break;
-        //        case AnnotArgsType.PolygonMeasure:
-        //            PolygonalProperty polygonalProperty = new PolygonalProperty();
-        //            if (attribEvent != null)
-        //            {
-        //                polygonalProperty.SetAnnotEventData(attribEvent);
-        //            }
-        //            else
-        //            {
-        //                polygonalProperty.SetAnnotArgsData((PolygonMeasureArgs)Args);
-        //            }
-        //            currentPanel = polygonalProperty;
-        //            break;
-        //        default:
-        //            break;
-        //    }
-        //    SetMeasurePanel(currentPanel);
-        //}
+            switch (Args.CurrentType)
+            {
+                case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
+                    StraightnessProperty straightnessProperty = new StraightnessProperty();
+                    //if (attribEvent != null)
+                    //{
+                    //    straightnessProperty.SetAnnotEventData(attribEvent);
+                    //}
+                    //else
+                    //{
+                    //    straightnessProperty.SetAnnotArgsData((LineMeasureArgs)Args);
+                    //}
+                    currentPanel = straightnessProperty;
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
+                    //MultilineProperty multilineProperty = new MultilineProperty();
+                    //if (attribEvent != null)
+                    //{
+                    //    multilineProperty.SetAnnotEventData(attribEvent);
+                    //}
+                    //else
+                    //{
+                    //    multilineProperty.SetAnnotArgsData((PolyLineMeasureArgs)Args);
+                    //}
+                    //currentPanel = multilineProperty;
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
+                    //PolygonalProperty polygonalProperty = new PolygonalProperty();
+                    //if (attribEvent != null)
+                    //{
+                    //    polygonalProperty.SetAnnotEventData(attribEvent);
+                    //}
+                    //else
+                    //{
+                    //    polygonalProperty.SetAnnotArgsData((PolygonMeasureArgs)Args);
+                    //}
+                    //currentPanel = polygonalProperty;
+                    break;
+                default:
+                    break;
+            }
+            SetMeasurePanel(currentPanel);
+        }
 
         private void SetMeasurePanel(UIElement newChild)
         {