Bläddra i källkod

PDFAnnotation(windows) - markup点击回写

liuaoran 1 år sedan
förälder
incheckning
527f951d10
16 ändrade filer med 356 tillägg och 40 borttagningar
  1. 12 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationData/CPDFAnnotationData.cs
  2. 93 8
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs
  3. 2 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreeTextUI.xaml
  4. 6 6
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreeTextUI.xaml.cs
  5. 36 4
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs
  6. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFNoteUI.xaml
  7. 1 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/ColorPickerControl.xaml
  8. 9 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/ColorPickerControl.xaml.cs
  9. 0 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFArrow/CPDFArrowControl.xaml.cs
  10. 2 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontControl.xaml
  11. 23 1
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontControl.xaml.cs
  12. 20 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontUI.xaml
  13. 143 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontUI.xaml.cs
  14. 7 2
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFLineStyle/CPDFLineStyleUI.xaml.cs
  15. 1 0
      compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFOpacity/CPDFOpacityControl.xaml.cs
  16. 0 5
      compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

+ 12 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationData/CPDFAnnotationData.cs

@@ -70,6 +70,17 @@ namespace compdfkit_tools.Data
             { 8, C_LINE_TYPE.LINETYPE_RCLOSEDARROW },
             { 9, C_LINE_TYPE.LINETYPE_SLASH }
         };
+
+        public static Dictionary<AnnotArgsType, AnnotationType> GetAnnotArgsTypeFromAnnotationType = new Dictionary<AnnotArgsType, AnnotationType>()
+        {
+            { AnnotArgsType.AnnotHighlight, AnnotationType.Highlight},
+            { AnnotArgsType.AnnotUnderline, AnnotationType.Underline },
+            {AnnotArgsType.AnnotSquiggly , AnnotationType.Squiggly },
+            {AnnotArgsType.AnnotStrikeout , AnnotationType.Strikeout},
+            {AnnotArgsType.AnnotSquare , AnnotationType.Square },
+            {AnnotArgsType.AnnotCircle , AnnotationType.Circle },
+            {AnnotArgsType.AnnotLine , AnnotationType.Line},
+        };
     }
 
     /// <summary>
@@ -253,7 +264,7 @@ namespace compdfkit_tools.Data
 
     }
     public class CustomStampList : List<CPDFStampData>
-    { 
+    {
 
     }
 

+ 93 - 8
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs

@@ -30,6 +30,8 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
     {
         private CPDFViewer pdfViewer;
         private UIElement annotationPanel = null;
+        private UIElement tempAnnotationPanel = null;
+
         private AnnotationType currentAnnotationType = AnnotationType.None;
 
         private CPDFMarkupUI pdfHighlightUI;
@@ -116,6 +118,10 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
             }
         }
 
+        /// <summary>
+        /// 参数解析
+        /// </summary>
+        /// <param name="pdfAnnotationData"></param>
         private void SetAnnotationProperty(CPDFAnnotationData pdfAnnotationData = null)
         {
             AnnotationType annotationType = pdfAnnotationData.AnnotationType;
@@ -291,11 +297,15 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
         {
             SetAnnotationProperty(e);
         }
-
-        public void LoadAnnotationPanel(AnnotationType annotationType)
+        
+        /// <summary>
+        /// 选择对应注释面板
+        /// 若未创建则创建
+        /// 已创建则使用已有项
+        /// </summary>
+        /// <param name="annotationType"></param>
+        public void InitAnnotationPanel(AnnotationType annotationType)
         {
-            currentAnnotationType = annotationType;
-            annotationPanel = GetAnnotationPanel();
             switch (annotationType)
             {
                 case AnnotationType.Highlight:
@@ -377,7 +387,7 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                     annotationPanel = pdfFreeTextUI;
                     break;
                 case AnnotationType.Note:
-                    if(pdfNoteUI == null)
+                    if (pdfNoteUI == null)
                     {
                         pdfNoteUI = new CPDFNoteUI();
                     }
@@ -390,21 +400,96 @@ namespace compdfkit_tools.Annotation.PDFAnnotationControl
                 default:
                     break;
             }
+        }
+
+        /// <summary>
+        /// 创建临时注释面板
+        /// </summary>
+        /// <param name="annotArgsType"></param>
+        public void CreatTempAnnotationPanel(AnnotAttribEvent annotAttribEvent)
+        {
+            AnnotArgsType annotArgsType = annotAttribEvent.GetAnnotTypes();
+            switch (annotArgsType)
+            {
+                case AnnotArgsType.AnnotHighlight:
+                case AnnotArgsType.AnnotUnderline:
+                case AnnotArgsType.AnnotStrikeout:
+                case AnnotArgsType.AnnotSquiggly:
+                    tempAnnotationPanel = new CPDFMarkupUI();
+                    (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationDictionary.GetAnnotArgsTypeFromAnnotationType[annotArgsType]);
+                    (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
+                    break;
+
+                case AnnotArgsType.AnnotSquare:
+                case AnnotArgsType.AnnotCircle:
+                case AnnotArgsType.AnnotLine:
+                    tempAnnotationPanel = new CPDFShapeUI();
+                    (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationDictionary.GetAnnotArgsTypeFromAnnotationType[annotArgsType]);
+                    break;
+
+                case AnnotArgsType.AnnotFreehand:
+                    tempAnnotationPanel = new CPDFFreehandUI();
+                    break;
+                case AnnotArgsType.AnnotFreeText:
+                    tempAnnotationPanel = new CPDFFreeTextUI();
+                    break;
+                case AnnotArgsType.AnnotSticky:
+                    tempAnnotationPanel = new CPDFNoteUI();
+                    break;
+                case AnnotArgsType.AnnotStamp:
+                    tempAnnotationPanel = new CPDFStampUI();
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        /// <summary>
+        /// 根据注释类型显示注释面板
+        /// </summary>
+        /// <param name="annotationType"></param>
+        public void LoadAnnotationPanel(AnnotationType annotationType)
+        {
+            currentAnnotationType = annotationType;
+            annotationPanel = GetAnnotationPanel();
+            InitAnnotationPanel(annotationType);
+            ShowCurrentAnnotPanel();
+        }
+
+        /// <summary>
+        /// 展示正在使用的属性面板
+        /// </summary>
+        private void ShowCurrentAnnotPanel()
+        {
             SetAnnotationPanel(annotationPanel);
             ExpandPanel();
             ChangeAnnotationData();
         }
 
-        public void SetSelectAnnotList(Dictionary<int, List<int>> selectAnnotDicts)
+        /// <summary>
+        /// 根据参数展开指定临时面板
+        /// </summary>
+        /// <param name="annotArgsType"></param>
+        private void ShowTempAnnotPanel(AnnotAttribEvent annotAttribEvent)
         {
-
+            CreatTempAnnotationPanel(annotAttribEvent);
+            SetAnnotationPanel(tempAnnotationPanel);
+            ExpandPanel();
         }
 
         private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
         {
             if (e != null)
             {
-                AnnotArgsType annotArgsType = e.GetAnnotTypes();
+                if (e.IsAnnotCreateReset)
+                {
+                    ShowCurrentAnnotPanel();
+                }
+                else
+                {
+                    AnnotArgsType annotArgsType = e.GetAnnotTypes();
+                    ShowTempAnnotPanel(e);
+                }
             }
         }
     }

+ 2 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreeTextUI.xaml

@@ -10,7 +10,7 @@
     <Grid>
         <StackPanel Orientation="Vertical">
             <StackPanel Orientation="Vertical" Height="150">
-                <TextBlock x:Name="TitileTextBlock" HorizontalAlignment="Center"></TextBlock>
+                <TextBlock x:Name="TitileTextBlock" Text="FreeText" HorizontalAlignment="Center"></TextBlock>
                 <Border Height="100" Background="#DEDEDE" Margin="10" CornerRadius="5"></Border>
             </StackPanel>
             <StackPanel Height="75" Margin="5">
@@ -21,7 +21,7 @@
                 <TextBlock Text="Opacity"></TextBlock>
                 <cpdfcommon:CPDFOpacityControl x:Name="CPDFOpacityControl"></cpdfcommon:CPDFOpacityControl>
             </StackPanel>
-            <StackPanel Height="80" Margin="5">
+            <StackPanel Height="100" Margin="5">
                 <TextBlock Text="Font Style"></TextBlock>
                 <cpdfcommon:CPDFFontControl x:Name="CPDFFontControl"></cpdfcommon:CPDFFontControl>
             </StackPanel>

+ 6 - 6
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFFreeTextUI.xaml.cs

@@ -29,7 +29,7 @@ namespace compdfkit_tools.PDFControlUI
             InitializeComponent();
             ColorPickerControl.ColorChanged += ColorPickerControl_ColorChanged;
             CPDFOpacityControl.OpacityChanged += CPDFOpacityControl_OpacityChanged;
-            //CPDFFontControl.FontChanged += CPDFFontControl_FontChanged;
+            CPDFFontControl.FontChanged += CPDFFontControl_FontChanged;
         }
 
         private void CPDFFontControl_FontChanged(object sender, EventArgs e)
@@ -54,11 +54,11 @@ namespace compdfkit_tools.PDFControlUI
             pdfFreeTextData.AnnotationType = AnnotationType.FreeText;
             pdfFreeTextData.BorderColor = ((SolidColorBrush)ColorPickerControl.Brush).Color;
             pdfFreeTextData.Opacity = CPDFOpacityControl.OpacityValue / 100.0;
-            //pdfFreeTextData.Font.FontFamily = CPDFFontControl.CPDFFontData.FontFamily;
-            //pdfFreeTextData.Font.FontSize = CPDFFontControl.CPDFFontData.FontSize;
-            //pdfFreeTextData.Font.IsBold = CPDFFontControl.CPDFFontData.IsBold;
-            //pdfFreeTextData.Font.IsItalic = CPDFFontControl.CPDFFontData.IsItalic;
-            //pdfFreeTextData.Font.TextAlignment = CPDFFontControl.CPDFFontData.TextAlignment;
+            pdfFreeTextData.Font.FontFamily = CPDFFontControl.CPDFFontData.FontFamily;
+            pdfFreeTextData.Font.FontSize = CPDFFontControl.CPDFFontData.FontSize;
+            pdfFreeTextData.Font.IsBold = CPDFFontControl.CPDFFontData.IsBold;
+            pdfFreeTextData.Font.IsItalic = CPDFFontControl.CPDFFontData.IsItalic;
+            pdfFreeTextData.Font.TextAlignment = CPDFFontControl.CPDFFontData.TextAlignment;
             pdfFreeTextData.Note = NoteTextBox.Text;
             return pdfFreeTextData;
         }

+ 36 - 4
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs

@@ -1,4 +1,5 @@
 using compdfkit_tools.Data;
+using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using System;
@@ -24,7 +25,7 @@ namespace compdfkit_tools.PDFControlUI
     public partial class CPDFMarkupUI : UserControl
     {
         private AnnotationType currentAnnotationType;
-
+        private AnnotAttribEvent annotAttribEvent;
         public event EventHandler<CPDFAnnotationData> PropertyChanged;
 
         public CPDFMarkupUI()
@@ -36,17 +37,40 @@ namespace compdfkit_tools.PDFControlUI
 
         private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
         {
-            PropertyChanged?.Invoke(this, GetMarkupData());
+            if (annotAttribEvent == null)
+            {
+                PropertyChanged?.Invoke(this, GetMarkupData());
+            }
+            else
+            {
+                annotAttribEvent.UpdateAttrib(AnnotAttrib.Transparency, CPDFOpacityControl.OpacityValue / 100.0);
+                annotAttribEvent.UpdateAnnot();
+            }
         }
 
         private void ColorPickerControl_ColorChanged(object sender, EventArgs e)
         {
-            PropertyChanged?.Invoke(this, GetMarkupData());
+            if (annotAttribEvent == null)
+            {
+                PropertyChanged?.Invoke(this, GetMarkupData());
+            }
+            else
+            {
+                annotAttribEvent.UpdateAttrib(AnnotAttrib.Color, ((SolidColorBrush)ColorPickerControl.Brush).Color);
+                annotAttribEvent.UpdateAnnot();
+            }
         }
 
         private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
         {
-            PropertyChanged?.Invoke(this, GetMarkupData());
+            if (annotAttribEvent == null)
+            {
+                PropertyChanged?.Invoke(this, GetMarkupData());
+            }
+            else
+            {
+                annotAttribEvent.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
+            }
         }
 
         public CPDFMarkupData GetMarkupData()
@@ -59,6 +83,14 @@ namespace compdfkit_tools.PDFControlUI
             return pdfMarkupData;
         }
 
+        public void SetPresentAnnotAttrib(AnnotAttribEvent annotAttribEvent)
+        {
+            this.annotAttribEvent = annotAttribEvent;
+            ColorPickerControl.Brush = new SolidColorBrush((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
+            CPDFOpacityControl.OpacityValue = (int)((double)annotAttribEvent.Attribs[AnnotAttrib.Transparency] * 100);
+            NoteTextBox.Text = (string)annotAttribEvent.Attribs[AnnotAttrib.NoteText];
+        }
+
         public void InitWithAnnotationType(AnnotationType annotationType)
         {
             switch (annotationType)

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFNoteUI.xaml

@@ -10,7 +10,7 @@
     <Grid>
         <StackPanel Orientation="Vertical">
             <StackPanel Orientation="Vertical" Height="150">
-                <TextBlock x:Name="TitileTextBlock" HorizontalAlignment="Center"></TextBlock>
+                <TextBlock x:Name="TitileTextBlock" Text="Note" HorizontalAlignment="Center"></TextBlock>
                 <Border Height="100" Background="#DEDEDE" Margin="10" CornerRadius="5"></Border>
             </StackPanel>
             <StackPanel Height="75" Margin="5">

+ 1 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/ColorPickerControl.xaml

@@ -102,6 +102,6 @@
         <RadioButton Background="#000000" Grid.Column="1" Style="{StaticResource CommonColorRadioButton}" Tag="Black" Click="ColorRadioButton_Click"></RadioButton>
         <RadioButton Background="#00FF00" Grid.Column="2" Style="{StaticResource CommonColorRadioButton}" Tag="Green"  Click="ColorRadioButton_Click"></RadioButton>
         <RadioButton Background="#0000FF" Grid.Column="3" Style="{StaticResource CommonColorRadioButton}" Tag="Blue" Click="ColorRadioButton_Click"></RadioButton>
-        <RadioButton x:Name="CustomColorRadioButton" Background="{Binding Brush, RelativeSource={RelativeSource AncestorType={x:Type local:ColorPickerControl}}}" Grid.Column="4" Style="{StaticResource CustomColorRadioButton}" GroupName="Color" Click="CustomColorRadioButton_Click"></RadioButton>
+        <RadioButton x:Name="CustomColorRadioButton" Background="{Binding Brush, RelativeSource={RelativeSource AncestorType={x:Type local:ColorPickerControl}},Mode=TwoWay}" Grid.Column="4" Style="{StaticResource CustomColorRadioButton}" GroupName="Color" Click="CustomColorRadioButton_Click"></RadioButton>
     </Grid>
 </UserControl>

+ 9 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/ColorPickerControl.xaml.cs

@@ -43,8 +43,15 @@ namespace compdfkit_tools.Common
         public static readonly DependencyProperty BrushProperty = DependencyProperty.Register("Brush", typeof(Brush), typeof(ColorPickerControl), new PropertyMetadata(Brushes.Red));
         public Brush Brush
         {
-            get { return (Brush)GetValue(BrushProperty); }
-            set { SetValue(BrushProperty, value); OnColorChanged(); }
+            get
+            {
+                return (Brush)GetValue(BrushProperty);
+            }
+            set
+            {
+                SetValue(BrushProperty, value);
+                OnColorChanged();
+            }
         }
 
         public ColorPickerControl()

+ 0 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFArrow/CPDFArrowControl.xaml.cs

@@ -23,7 +23,6 @@ namespace compdfkit_tools.Common
     /// </summary>
     public partial class CPDFArrowControl : UserControl
     {
-
         public event EventHandler ArrowChanged;
         public LineType LineType
         {

+ 2 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontControl.xaml

@@ -5,8 +5,8 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:compdfkit_tools.Common"
              mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800">
+             d:DesignHeight="80" d:DesignWidth="300">
     <Grid>
-            
+        <local:CPDFFontUI x:Name="CPDFFontUI"></local:CPDFFontUI>
     </Grid>
 </UserControl>

+ 23 - 1
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontControl.xaml.cs

@@ -1,4 +1,5 @@
-using System;
+using compdfkit_tools.Data;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -20,9 +21,30 @@ namespace compdfkit_tools.Common
     /// </summary>
     public partial class CPDFFontControl : UserControl
     {
+        public CPDFFontData CPDFFontData
+        {
+            get;
+           private set;
+        } = new CPDFFontData();
+
+        public event EventHandler FontChanged;
         public CPDFFontControl()
         {
             InitializeComponent();
+            CPDFFontUI.FontChanged += CPDFFontUI_FontChanged;
+        }
+
+        private void CPDFFontUI_FontChanged(object sender, EventArgs e)
+        {
+            FontChanged?.Invoke(this, EventArgs.Empty);
+            CPDFFontData = new CPDFFontData()
+            {
+                FontFamily = CPDFFontUI.FontFamilyValue,
+                FontSize = CPDFFontUI.FontSizeValue,
+                IsBold = CPDFFontUI.IsBold,
+                IsItalic = CPDFFontUI.IsItalic,
+                TextAlignment = CPDFFontUI.TextAlignment
+            };
         }
     }
 }

+ 20 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontUI.xaml

@@ -5,8 +5,26 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:compdfkit_tools.Common"
              mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800">
+             d:DesignHeight="80" d:DesignWidth="300">
     <Grid>
-            
+        <Grid.RowDefinitions>
+            <RowDefinition></RowDefinition>
+            <RowDefinition></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <ComboBox x:Name="FontFamilyComboBox" SelectionChanged="FontFamilyComboBox_SelectionChanged"> </ComboBox>
+        <Grid Grid.Row="1">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="2*"></ColumnDefinition>
+                <ColumnDefinition></ColumnDefinition>
+            </Grid.ColumnDefinitions>
+            <ComboBox x:Name="FontStyleComboBox" SelectionChanged="FontStyleComboBox_SelectionChanged"></ComboBox>
+            <local:DropDownNumberBoxControl x:Name="FontSizeComboBox" Maxium="100" Minimum="1" Grid.Column="1" Unit="pt" Text="{Binding FontSizeValue,Mode=TwoWay}"></local:DropDownNumberBoxControl>
+        </Grid>
+        <StackPanel Orientation="Horizontal" Grid.Row="2">
+            <RadioButton x:Name="LeftAlignRadioButton" Content="Left" Tag="Left" IsChecked="True" Checked="AlignRadioButton_Checked"></RadioButton>
+            <RadioButton x:Name="CenterAlignRadioButton" Content="Center" Tag="Center" Checked="AlignRadioButton_Checked"></RadioButton>
+            <RadioButton x:Name="RightAlignRadioButton" Content="Right" Tag="Right" Checked="AlignRadioButton_Checked"></RadioButton>
+        </StackPanel>
     </Grid>
 </UserControl>

+ 143 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFFont/CPDFFontUI.xaml.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -18,11 +19,151 @@ namespace compdfkit_tools.Common
     /// <summary>
     /// CPDFFontUI.xaml 的交互逻辑
     /// </summary>
-    public partial class CPDFFontUI : UserControl
+    public partial class CPDFFontUI : UserControl, INotifyPropertyChanged
     {
+
+        public event PropertyChangedEventHandler PropertyChanged;
+        public event EventHandler FontChanged;
+
+        public string FontFamilyValue
+        {
+            get => FontFamilyComboBox.SelectedItem.ToString();
+        }
+
+        public bool IsBold
+        {
+            get
+            {
+                if (FontStyleComboBox.SelectedItem.ToString() == null || (FontStyleComboBox.SelectedItem.ToString() == "Italic"))
+                {
+                    return false;
+                }
+                else
+                {
+                    return true;
+                }
+            }
+        }
+
+        public bool IsItalic
+        {
+            get
+            {
+                if (FontStyleComboBox.SelectedItem.ToString() == null || (FontStyleComboBox.SelectedItem.ToString() == "Bold"))
+                {
+                    return false;
+                }
+                else
+                {
+                    return true;
+                }
+            }
+        }
+
+        public TextAlignment TextAlignment
+        {
+            get
+            {
+                if ((bool)LeftAlignRadioButton.IsChecked)
+                {
+                    return TextAlignment.Left;
+                }
+                else if ((bool)CenterAlignRadioButton.IsChecked)
+                {
+                    return TextAlignment.Center;
+                }
+                else
+                {
+                    return TextAlignment.Right;
+                }
+            }
+        }
+
+        private int _fontSizeValue = 20;
+        public int FontSizeValue
+        {
+            get => _fontSizeValue;
+            set
+            {
+                _fontSizeValue = value;
+                OnPropertyChanged(nameof(FontSizeValue));
+                OnFontChanged();
+                FontChanged?.Invoke(this, EventArgs.Empty);
+            }
+        }
+
+
         public CPDFFontUI()
         {
             InitializeComponent();
+            InitComboBox();
+            this.DataContext = this;
+        }
+
+        public void InitComboBox()
+        {
+            List<string> fontNameList = new List<string>()
+            {
+                {"Courier New" },
+                {"Helvetica" },
+                {"Times Roman" }
+            };
+            FontFamilyComboBox.ItemsSource = fontNameList;
+            FontFamilyComboBox.SelectedIndex = 1;
+
+            List<string> fontStyleList = new List<string>()
+            {
+                {"Common" },
+                {"Bold" },
+                {"Italic" },
+                {"Bold and Italic" }
+            };
+            FontStyleComboBox.ItemsSource = fontStyleList;
+            FontStyleComboBox.SelectedIndex = 0;
+
+            List<int> fontSizeList = new List<int>()
+            {
+                {6},
+                {8},
+                {9},
+                {10},
+                {12},
+                {14},
+                {18},
+                {20},
+                {24},
+                {26},
+                {28},
+                {32},
+                {30},
+                {32},
+                {48},
+                {72}
+            };
+            FontSizeComboBox.InitPresetNumberArray(fontSizeList);
+        }
+        protected void OnPropertyChanged(string propertyName)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+        }
+
+        private void FontFamilyComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            FontChanged?.Invoke(this, EventArgs.Empty);
+        }
+
+        private void FontStyleComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            FontChanged?.Invoke(this, EventArgs.Empty);
+        }
+
+        private void AlignRadioButton_Checked(object sender, RoutedEventArgs e)
+        {
+            FontChanged?.Invoke(this, EventArgs.Empty);
+        }
+        private void OnFontChanged()
+        {
+            FontChanged?.Invoke(this, EventArgs.Empty);
         }
     }
-}
+}

+ 7 - 2
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFLineStyle/CPDFLineStyleUI.xaml.cs

@@ -1,6 +1,7 @@
 using compdfkit_tools.Data;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Drawing.Drawing2D;
 using System.Linq;
 using System.Text;
@@ -21,7 +22,7 @@ namespace compdfkit_tools.Common
     /// <summary>           
     /// CPDFLineStyleUI.xaml 的交互逻辑
     /// </summary>
-    public partial class CPDFLineStyleUI : UserControl
+    public partial class CPDFLineStyleUI : UserControl, INotifyPropertyChanged
     {
         private CPDFDashData _dashStyle = new CPDFDashData();
         public CPDFDashData DashStyle
@@ -43,6 +44,7 @@ namespace compdfkit_tools.Common
         }
 
         public event EventHandler LineStyleChanged;
+        public event PropertyChangedEventHandler PropertyChanged;
 
         public CPDFLineStyleUI()
         {
@@ -69,6 +71,9 @@ namespace compdfkit_tools.Common
         {
             LineStyleChanged?.Invoke(this, EventArgs.Empty);
         }
-
+        protected void OnPropertyChanged(string propertyName)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+        }
     }
 }

+ 1 - 0
compdfkit_demo_windows/compdfkit/compdfkit-tools/Common/PropertyControl/PDFOpacity/CPDFOpacityControl.xaml.cs

@@ -28,6 +28,7 @@ namespace compdfkit_tools.Common
         public int OpacityValue
         {
             get=> CPDFOpacityUI.OpacityValue;
+            set => CPDFOpacityUI.OpacityValue = value;
         }
 
         public CPDFOpacityControl()

+ 0 - 5
compdfkit_demo_windows/compdfkit/compdfkit-tools/compdfkit-tools.csproj

@@ -591,10 +591,5 @@
   <ItemGroup>
     <Resource Include="Asset\Resource\Annotation\Arrow.png" />
   </ItemGroup>
-  <ItemGroup>
-    <PackageReference Include="System.ValueTuple">
-      <Version>4.5.0</Version>
-    </PackageReference>
-  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>