Browse Source

ComPDFKit(win) - 禅道部分bug修复

weixiangjie 7 months ago
parent
commit
f3142bfd2a

+ 2 - 2
Demo/Examples/Compdfkit_Tools/Annotation/AnnotationControl/AnnotationControl.xaml.cs

@@ -100,8 +100,6 @@ namespace Compdfkit_Tools.PDFControl
                     CPDFAnnotationType.Audio
             };
             AnnotationBarControl.InitAnnotationBar(annotationProperties);
-            panelState.PropertyChanged -= PanelState_PropertyChanged;
-            panelState.PropertyChanged += PanelState_PropertyChanged;
 
             UndoBtn.ToolTip = LanguageHelper.CommonManager.GetString("Tooltip_Undo");
             RedoBtn.ToolTip = LanguageHelper.CommonManager.GetString("Tooltip_Redo");
@@ -221,6 +219,8 @@ baseWidget.GetAnnotData().Annot);
             ExpandRightPropertyPanel(null, Visibility.Collapsed);
             PDFAnnotationControl.ClearAnnotationBar -= PdfAnnotationControl_ClearAnnotationBar;
             PDFAnnotationControl.ClearAnnotationBar += PdfAnnotationControl_ClearAnnotationBar;
+            panelState.PropertyChanged -= PanelState_PropertyChanged;
+            panelState.PropertyChanged += PanelState_PropertyChanged;
             PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
             PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged += UndoManager_PropertyChanged;
         }

+ 3 - 3
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnoationListUI.xaml

@@ -100,7 +100,7 @@
                                 <Grid x:Name="StampGrid" Visibility="{Binding BindProperty.CurrentAnnotationType, Converter={StaticResource AnnotArgsTypeToVisibilityConverter}, ConverterParameter = C_ANNOTATION_STAMP}">
                                     <Path Data="M9.98201 7.97521C11.1875 7.28619 12 5.98798 12 4.5C12 2.29086 10.2091 0.5 8 0.5C5.79086 0.5 4 2.29086 4 4.5C4 5.98798 4.81248 7.2862 6.018 7.97522C6.10745 8.10318 6.5 8.69622 6.5 9.25C6.5 9.875 6 10.5 6 10.5H0V12H16V10.5H10C10 10.5 9.5 9.875 9.5 9.25C9.5 8.69621 9.89256 8.10316 9.98201 7.97521ZM16 15.5V14H0V15.5H16Z" Fill="#43474D"></Path>
                                 </Grid>
-                                <Grid x:Name="LineMeasureGrid" Visibility="{Binding BindProperty.CurrentAnnotationType, Converter={StaticResource AnnotArgsTypeToVisibilityConverter}, ConverterParameter = LineMeasure}">
+                                <Grid x:Name="LineMeasureGrid" Visibility="{Binding BindProperty.CurrentAnnotationType, Converter={StaticResource AnnotArgsTypeToVisibilityConverter}, ConverterParameter = C_ANNOTATION_LINE}">
                                     <Path Fill="#43474D">
                                         <Path.Data>
                                             M17.7782 5.75646L14.2427 2.22093L13.0052 3.45837L15.4802 5.93333L14.4195 6.99399L11.9446 4.51903L10.1768
@@ -112,7 +112,7 @@
                                         </Path.Data>
                                     </Path>
                                 </Grid>
-                                <Grid x:Name="PolyLineMeasureGrid" Visibility="{Binding BindProperty.CurrentAnnotationType, Converter={StaticResource AnnotArgsTypeToVisibilityConverter}, ConverterParameter = PolyLineMeasure}">
+                                <Grid x:Name="PolyLineMeasureGrid" Visibility="{Binding BindProperty.CurrentAnnotationType, Converter={StaticResource AnnotArgsTypeToVisibilityConverter}, ConverterParameter = C_ANNOTATION_POLYLINE}">
                                     <Path Fill="#43474D">
                                         <Path.Data>
                                             M0.5 3C0.5 1.89543 1.39543 1 2.5 1C3.33934 1 4.05793 1.51704 4.35462 2.25H15.6454C15.9421 1.51704 16.6607 1 
@@ -123,7 +123,7 @@
                                         </Path.Data>
                                     </Path>
                                 </Grid>
-                                <Grid x:Name="PolygonMeasureGrid" Visibility="{Binding BindProperty.CurrentAnnotationType, Converter={StaticResource AnnotArgsTypeToVisibilityConverter}, ConverterParameter = PolygonMeasure}">
+                                <Grid x:Name="PolygonMeasureGrid" Visibility="{Binding BindProperty.CurrentAnnotationType, Converter={StaticResource AnnotArgsTypeToVisibilityConverter}, ConverterParameter = C_ANNOTATION_POLYGON}">
                                     <Path Data="M1.37111 7.6963L10 1.42705L18.6289 7.6963L15.3329 17.8402H4.66705L1.37111 7.6963Z" Stroke="#43474D"></Path>
                                 </Grid>
                             </Canvas>

+ 6 - 1
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCreateSignatureDialog.xaml

@@ -387,7 +387,12 @@
                         VerticalAlignment="Center">
                         </ComboBox>
                         <TextBlock  Text="样式" VerticalAlignment="Center" Margin="10,0,8,0"/>
-                        <ComboBox x:Name="StyleNameCmb" Style="{StaticResource ComboBoxStyle1}" Height="25" Width="80" Margin="10,0,0,0" SelectionChanged="StyleNameCmb_SelectionChanged"></ComboBox>
+                        <ComboBox x:Name="StyleNameCmb" Style="{StaticResource ComboBoxStyle1}" Height="25" Width="80" Margin="10,0,0,0" SelectionChanged="StyleNameCmb_SelectionChanged">
+                            <ComboBoxItem Content="Regular"></ComboBoxItem>
+                            <ComboBoxItem Content="Bold"></ComboBoxItem>
+                            <ComboBoxItem Content="Oblique"></ComboBoxItem>
+                            <ComboBoxItem Content="BoldOblique"></ComboBoxItem>
+                        </ComboBox>
                     </StackPanel>
                     <StackPanel
                         Grid.Row="3"

+ 37 - 3
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCreateSignatureDialog.xaml.cs

@@ -547,7 +547,7 @@ namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
 
         private void FontNameCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            StyleNameCmb.ItemsSource = CPDFFont.GetFontNameDictionary()[FontNameCmb.SelectedValue.ToString()];  
+            //StyleNameCmb.ItemsSource = CPDFFont.GetFontNameDictionary()[FontNameCmb.SelectedValue.ToString()];  
             StyleNameCmb.SelectedIndex = 0;
             CPDFFont.GetPostScriptName(FontNameCmb.SelectedValue.ToString(), StyleNameCmb.SelectedValue.ToString(),ref postScriptName);
             InPutTextBox.FontFamily = new System.Windows.Media.FontFamily(postScriptName);
@@ -557,9 +557,43 @@ namespace Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI
         {
             if (!string.IsNullOrEmpty(StyleNameCmb.SelectedValue?.ToString()))
             {
-                CPDFFont.GetPostScriptName(FontNameCmb.SelectedValue.ToString(), StyleNameCmb.SelectedValue.ToString(), ref postScriptName);
-                InPutTextBox.FontFamily = new System.Windows.Media.FontFamily(postScriptName);
+                InPutTextBox.FontStyle = GetFontStyle(StyleNameCmb.SelectedValue.ToString());
+                InPutTextBox.FontWeight = GetFontWeight(StyleNameCmb.SelectedValue.ToString());
             } 
         }
+
+        private FontWeight GetFontWeight(string toString)
+        {
+            switch (toString)
+            {
+                case "Regular":
+                    return FontWeights.Normal;
+                case "Oblique":
+                    return FontWeights.Normal;
+                case "Bold":
+                    return FontWeights.Bold;
+                case "BoldOblique":
+                    return FontWeights.Bold;
+                default:
+                    return FontWeights.Normal;
+            }
+        }
+
+        private System.Windows.FontStyle GetFontStyle(string style)
+        {
+            switch (style)
+            {
+                case "Regular":
+                    return FontStyles.Normal;
+                case "Oblique":
+                    return FontStyles.Italic;
+                case "Bold":
+                    return FontStyles.Normal;
+                case "BoldOblique":
+                    return FontStyles.Oblique;
+                default:
+                    return FontStyles.Normal;
+            }
+        }
     }
 }

+ 1 - 0
Demo/Examples/Compdfkit_Tools/Common/BarControl/CPDFMeasureBarControl.xaml.cs

@@ -407,6 +407,7 @@ namespace Compdfkit_Tools.PDFControl
                 CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH | CPDFCaptionType.CPDF_CAPTION_AREA,
             };
             pdfViewer.SetAnnotParam(polygonMeasureParam);
+            measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE);
             //    PolygonMeasureArgs rectPolygonMeasureArgs = new PolygonMeasureArgs();
             //    rectPolygonMeasureArgs.LineColor = Colors.Red;
             //    rectPolygonMeasureArgs.IsOnlyDrawRect = true;

+ 2 - 5
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFFont/CPDFFontControl.xaml.cs

@@ -49,11 +49,8 @@ namespace Compdfkit_Tools.Common
         public string FontStyleValue
         {
             get => CPDFFontUI.StyleName;
-            set
-            {
-                CPDFFontUI.lockStyleName = true;
-                CPDFFontUI.StyleName = value;
-            }
+            set => CPDFFontUI.StyleName = value;
+            
         }
 
         public TextAlignment TextAlignment

+ 0 - 1
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFFont/CPDFFontUI.xaml.cs

@@ -12,7 +12,6 @@ namespace Compdfkit_Tools.Common
 {
     public partial class CPDFFontUI : UserControl, INotifyPropertyChanged
     {
-        internal bool lockStyleName = false;
         internal bool isFirstLoad = true;
 
         public event PropertyChangedEventHandler PropertyChanged;

+ 10 - 0
Demo/Examples/Compdfkit_Tools/Measure/MeasureControl.xaml.cs

@@ -89,7 +89,9 @@ namespace Compdfkit_Tools.Measure
             PdfViewControl.MouseLeftButtonUpHandler -= PDFToolManager_MouseLeftButtonUpHandler;
             PdfViewControl.MouseMoveHandler -= PDFToolManager_MouseMoveHandler;
             pdfViewControl.MouseRightButtonDownHandler -= PDFToolManager_MouseRightButtonDownHandler;
+            PdfViewControl.PDFViewTool.MeasureChanged -= MeasureSetting_MeasureChanged;
 
+            PdfViewControl.PDFViewTool.MeasureChanged += MeasureSetting_MeasureChanged;
             PdfViewControl.MouseLeftButtonDownHandler += PDFToolManager_MouseLeftButtonDownHandler;
             PdfViewControl.MouseLeftButtonUpHandler += PDFToolManager_MouseLeftButtonUpHandler;
             PdfViewControl.MouseMoveHandler += PDFToolManager_MouseMoveHandler;
@@ -99,6 +101,12 @@ namespace Compdfkit_Tools.Measure
             SettingPanel.PdfViewControl= pdfViewControl;
         }
 
+        private void MeasureSetting_MeasureChanged(object sender, MeasureEventArgs e)
+        {
+            InfoPanel.SetMeasureType(e.Type);
+            InfoPanel.SetMeasureInfo(e);
+        }
+
         private void PDFToolManager_MouseRightButtonDownHandler(object sender, MouseEventObject e)
         {
             ContextMenu ContextMenu = PdfViewControl.GetRightMenu();
@@ -383,6 +391,7 @@ namespace Compdfkit_Tools.Measure
         public void ClearAllToolState()
         {
             PDFMeasureTool.ClearAllToolState();
+            InfoPanel.ClearMeasureInfo();
         }
         public void ClearViewerControl()
         {
@@ -531,6 +540,7 @@ namespace Compdfkit_Tools.Measure
         {
             SetInfoPanelVisble(SettingPanel.ReturnToInfoPanel, false);
             SettingPanel.SaveMeasureSetting(currentAnnot);
+            InfoPanel.SetMeasureInfo(currentAnnot);
         }
 
         public void SetInfoPanelVisble(bool measureInfo, bool measureSetting)

+ 25 - 0
Demo/Examples/Compdfkit_Tools/Measure/MeasureInfoPanel.xaml.cs

@@ -18,6 +18,7 @@ using System.Windows.Navigation;
 using System.Windows.Shapes;
 using Compdfkit_Tools.Helper;
 using ComPDFKit.PDFAnnotation;
+using ComPDFKit.Tool;
 
 namespace Compdfkit_Tools.Measure
 {
@@ -244,5 +245,29 @@ namespace Compdfkit_Tools.Measure
             }
             return 0;
         }
+
+        public void SetMeasureInfo(MeasureEventArgs args)
+        {
+            if (args.Type == CPDFMeasureType.CPDF_DISTANCE_MEASURE)
+            {
+                DistanceText.Text = args.Distance;
+                PrecisionText.Text = args.Precision.ToString();
+                AngleText.Text = args.Angle.ToString();
+                XText.Text = args.MousePos.X.ToString();
+                YText.Text = args.MousePos.Y.ToString();
+            }
+            else if (args.Type == CPDFMeasureType.CPDF_PERIMETER_MEASURE)
+            {
+                DistancePolyLineText.Text = args.Distance;
+                PrecisionPolyLineText.Text = args.Precision.ToString();
+                AnglePolyLineText.Text = args.Angle.ToString();
+            }
+            else if (args.Type == CPDFMeasureType.CPDF_AREA_MEASURE)
+            {
+                RoundPolygonText.Text = args.Distance;
+                PrecisionPolygonText.Text = args.Precision.ToString();
+                AnglePolygonText.Text = args.Angle.ToString();
+            }
+        }
     }
 }

+ 2 - 1
Demo/Examples/PDFViewer/MainPage.xaml.cs

@@ -660,10 +660,11 @@ namespace PDFViewer
                 {
                     RightPanelButton.Visibility = Visibility.Visible;
                     PDFGrid.Child = measureControl; 
-                    viewControl.PDFViewTool.SetViewerModel(MouseModes.Viewer);
+                    viewControl.PDFViewTool.SetViewerModel(MouseModes.PanTool);
                     viewControl.SetToolType(ToolType.Pan); 
                     measureControl.InitWithPDFViewer(viewControl);
                     measureControl.SetBOTAContainer(botaBarControl);
+                    measureControl.ClearAllToolState();
                     GetPDFViewControl().PDFViewTool.GetDefaultSettingParam().IsOpenMeasure = true;
                 }
             }