Преглед на файлове

compdfkit(win) - 修复form切换部分字体崩溃问题,调整了部分样式

liuaoran преди 7 месеца
родител
ревизия
b005c2e801

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs

@@ -207,7 +207,7 @@ namespace Compdfkit_Tools.PDFControlUI
                       squigglyParam.SquigglyColor[2]);
 
                     ColorPickerControl.Brush = new SolidColorBrush(newColor);
-                    ColorPickerControl.SetCheckedForColor(newColor);
+                    ColorPickerControl.SetCheckedForColor(newColor); 
                 }
                 CPDFOpacityControl.OpacityValue = (int)(param.Transparency / 255D * 100);
                 NoteTextBox.Text = param.Content;

+ 39 - 42
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFFont/CPDFFontUI.xaml.cs

@@ -15,11 +15,6 @@ namespace Compdfkit_Tools.Common
         internal bool lockStyleName = false;
         internal bool isFirstLoad = true;
 
-        private string regular = LanguageHelper.PropertyPanelManager.GetString("Font_Regular");
-        private string bold = LanguageHelper.PropertyPanelManager.GetString("Font_Bold");
-        private string italic = LanguageHelper.PropertyPanelManager.GetString("Font_Oblique");
-        private string boldItalic = LanguageHelper.PropertyPanelManager.GetString("Font_BoldOblique");
-
         public event PropertyChangedEventHandler PropertyChanged;
         public event EventHandler FontFamilyChanged;
         public event EventHandler FontStyleChanged;
@@ -31,11 +26,13 @@ namespace Compdfkit_Tools.Common
         {
             get => _familyName;
             set
-            { 
-                _familyName = value;
-                if (FontFamilyComboBox.Items.Contains(_familyName))
+            {
+                if (UpdateProper(ref _familyName, value))
                 {
-                    FontFamilyComboBox.SelectedItem = _familyName;
+                    if (FontFamilyComboBox.Items.Contains(_familyName))
+                    {
+                        FontFamilyComboBox.SelectedItem = _familyName;
+                    }
                 }
             }
         }
@@ -45,11 +42,13 @@ namespace Compdfkit_Tools.Common
         {
             get => _styleName;
             set
-            { 
-                _styleName = value;
-                if (lockStyleName && FontStyleComboBox.Items.Contains(_styleName))
+            {
+                if (UpdateProper(ref _styleName, value))
                 {
-                    FontStyleComboBox.SelectedItem = _styleName;
+                    if (FontStyleComboBox.Items.Contains(_styleName))
+                    {
+                        FontStyleComboBox.SelectedItem = _styleName;
+                    }
                 }
             }
         }
@@ -97,7 +96,7 @@ namespace Compdfkit_Tools.Common
             set
             {
                 _fontSizeValue = value;
-                OnPropertyChanged(nameof(FontSizeValue));
+                OnPropertyChanged();
                 FontSizeChanged?.Invoke(this, EventArgs.Empty);
             }
         }
@@ -114,14 +113,6 @@ namespace Compdfkit_Tools.Common
             FontFamilyComboBox.ItemsSource = CPDFFont.GetFontNameDictionary().Keys;
             FontFamilyComboBox.SelectedIndex = 0;
 
-            List<string> fontStyleList = new List<string>()
-            {
-                regular,
-                bold,
-                italic,
-                boldItalic
-            };
-
             FontStyleComboBox.ItemsSource = CPDFFont.GetFontNameDictionary()[FontFamilyComboBox.SelectedValue.ToString()];
             FontStyleComboBox.SelectedIndex = 0;
 
@@ -147,11 +138,6 @@ namespace Compdfkit_Tools.Common
             FontSizeComboBox.InitPresetNumberArray(fontSizeList);
         }
 
-        protected void OnPropertyChanged(string propertyName)
-        {
-            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
-        }
-
         private void FontFamilyComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             if (isFirstLoad)
@@ -168,34 +154,45 @@ namespace Compdfkit_Tools.Common
                 isFirstLoad = false;
                 return;
             }
-            
+
             var styleNames = CPDFFont.GetFontNameDictionary()[FontFamilyComboBox.SelectedValue.ToString()];
-            FontStyleComboBox.ItemsSource = styleNames;
-            if (FamilyName != FontFamilyComboBox.SelectedValue.ToString())
+            FontStyleComboBox.ItemsSource = styleNames; 
+
+            FamilyName = FontFamilyComboBox.SelectedValue.ToString();
+            if (styleNames.Count != 0)
             {
-                FamilyName = FontFamilyComboBox.SelectedValue.ToString();
-                if (styleNames.Count != 0)
-                {
-                    FontStyleComboBox.SelectedIndex = 0;
-                }
-                FontFamilyChanged?.Invoke(this, EventArgs.Empty);
+                FontStyleComboBox.SelectedIndex = 0;
             }
+
+            FontFamilyChanged?.Invoke(this, EventArgs.Empty);
         }
 
         private void FontStyleComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
+            StyleName = FontStyleComboBox.SelectedValue?.ToString();
+            FontStyleChanged?.Invoke(this, EventArgs.Empty);
+        }
+
+        private void AlignRadioButton_Checked(object sender, RoutedEventArgs e)
+        {
+            FontAlignChanged?.Invoke(this, EventArgs.Empty);
+        }
 
-            if (!lockStyleName)
+        protected bool UpdateProper<T>(ref T properValue, T newValue, [CallerMemberName] string properName = "")
+        {
+            if (object.Equals(properValue, newValue))
             {
-                StyleName = FontStyleComboBox.SelectedValue?.ToString();
-                FontStyleChanged?.Invoke(this, EventArgs.Empty);
+                return false;
             }
-            lockStyleName = false;
+
+            properValue = newValue;
+            OnPropertyChanged(properName);
+            return true;
         }
 
-        private void AlignRadioButton_Checked(object sender, RoutedEventArgs e)
+        protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
         {
-            FontAlignChanged?.Invoke(this, EventArgs.Empty);
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
         }
     }
 }

+ 3 - 3
Demo/Examples/Compdfkit_Tools/Form/Property/CheckBoxProperty.xaml

@@ -39,11 +39,11 @@
                     <StackPanel Grid.Column="1">
                         <StackPanel  >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Name}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <TextBox x:Name="FieldNameText" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
+                            <TextBox x:Name="FieldNameText" Height="32" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
                         </StackPanel>
                         <StackPanel >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Visibility}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <ComboBox x:Name="FormFieldCmb" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
+                            <ComboBox x:Name="FormFieldCmb" Margin="0,8,0,0" Height="32" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Visible}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Hidden}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_NoPrint}"/>
@@ -82,7 +82,7 @@
                     <StackPanel Grid.Column="1">
                         <StackPanel  >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Check_Style}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <ComboBox x:Name="CheckButtonStyleCmb" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="CheckButtonStyleCmb_SelectionChanged">
+                            <ComboBox x:Name="CheckButtonStyleCmb" Height="32" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="CheckButtonStyleCmb_SelectionChanged">
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Style_Check}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Style_Circle}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Style_Cross}"/>

+ 2 - 2
Demo/Examples/Compdfkit_Tools/Form/Property/ComboBoxProperty.xaml

@@ -40,11 +40,11 @@
                     <StackPanel Grid.Column="1">
                         <StackPanel  >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Name}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <TextBox x:Name="FieldNameText" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
+                            <TextBox x:Name="FieldNameText" Height="32" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
                         </StackPanel>
                         <StackPanel >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Visibility}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <ComboBox x:Name="FormFieldCmb" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
+                            <ComboBox x:Name="FormFieldCmb" Margin="0,8,0,0" Height="32" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Visible}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Hidden}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_NoPrint}"/>

+ 2 - 2
Demo/Examples/Compdfkit_Tools/Form/Property/ListBoxProperty.xaml

@@ -41,11 +41,11 @@
                     <StackPanel Grid.Column="1">
                         <StackPanel  >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Name}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <TextBox x:Name="FieldNameText" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
+                            <TextBox x:Name="FieldNameText" Height="32" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
                         </StackPanel>
                         <StackPanel >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Visibility}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <ComboBox x:Name="FormFieldCmb" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
+                            <ComboBox x:Name="FormFieldCmb" Height="32" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Visible}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Hidden}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_NoPrint}"/>

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Form/Property/ListBoxProperty.xaml.cs

@@ -256,7 +256,7 @@ namespace Compdfkit_Tools.PDFControl
                 
                 CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                 string psFontName = string.Empty;
-                CPDFFont.GetPostScriptName(FontCmb.SelectedValue.ToString(), FontStyleCmb.SelectedValue.ToString(), ref psFontName);
+                CPDFFont.GetPostScriptName(FontCmb.SelectedValue.ToString(), FontStyleCmb.SelectedValue?.ToString(), ref psFontName);
                 cTextAttribute.FontName = psFontName;
                 cPDFAnnotation.SetTextAttribute(cTextAttribute);
                 cPDFAnnotation.UpdateFormAp();

+ 9 - 9
Demo/Examples/Compdfkit_Tools/Form/Property/PushButtonProperty.xaml

@@ -57,11 +57,11 @@
                     <StackPanel Grid.Column="1">
                         <StackPanel>
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Name}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <TextBox x:Name="FieldNameText" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
+                            <TextBox x:Name="FieldNameText" Height="32" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
                         </StackPanel>
                         <StackPanel >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Visibility}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <ComboBox x:Name="FormFieldCmb" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
+                            <ComboBox x:Name="FormFieldCmb" Height="32" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Visible}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Hidden}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_NoPrint}"/>
@@ -101,7 +101,7 @@
                                 <ComboBox x:Name="FontSizeCmb" Width="72" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FontSizeCmb_SelectionChanged" Margin="12,0,0,0"/>
                             </StackPanel>
                         </StackPanel>
-                    </StackPanel> 
+                    </StackPanel>
                 </Grid>
             </TabItem>
             <TabItem Height="32" Style="{DynamicResource TabItemStyle1}" Header="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Title_Preferences}">
@@ -112,18 +112,18 @@
                         <ColumnDefinition Width="16"/>
                     </Grid.ColumnDefinitions>
                     <StackPanel Grid.Column="1">
-                    <StackPanel>
-                        <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Title_BtnContent}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <TextBox x:Name="ItemText" Margin="0,8,0,0" TextChanged="ItemText_TextChanged"/>
-                    </StackPanel>
+                        <StackPanel>
+                            <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Title_BtnContent}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
+                            <TextBox x:Name="ItemText" Height="32" Margin="0,8,0,0" TextChanged="ItemText_TextChanged"/>
+                        </StackPanel>
                         <StackPanel>
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Btn_Action}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <ComboBox x:Name="TextAlignmentCmb" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="TextAlignmentCmb_SelectionChanged">
+                            <ComboBox x:Name="TextAlignmentCmb" Height="32" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="TextAlignmentCmb_SelectionChanged">
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Action_None}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Action_Jump}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Action_Link}"/>
                             </ComboBox>
-                            <TextBox x:Name="ActionContentText" Margin="0,4,0,0" Text="123" TextChanged="ActionContentText_TextChanged" Visibility="Collapsed"/>
+                            <TextBox x:Name="ActionContentText" Height="32" Margin="0,4,0,0" Text="123" TextChanged="ActionContentText_TextChanged" Visibility="Collapsed"/>
                         </StackPanel>
                     </StackPanel>
                 </Grid>

+ 3 - 3
Demo/Examples/Compdfkit_Tools/Form/Property/RadioButtonProperty.xaml

@@ -50,11 +50,11 @@
                     <StackPanel Grid.Column="1" Grid.Row="1">
                         <StackPanel  >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Name}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <TextBox x:Name="FieldNameText" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
+                            <TextBox x:Name="FieldNameText" Height="32" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
                         </StackPanel>
                         <StackPanel >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Visibility}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <ComboBox x:Name="FormFieldCmb" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
+                            <ComboBox x:Name="FormFieldCmb" Height="32" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Visible}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Hidden}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_NoPrint}"/>
@@ -98,7 +98,7 @@
                     <StackPanel Grid.Column="1">
                         <StackPanel  >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Check_Style}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <ComboBox x:Name="RadioButtonStyleCmb" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="RadioButtonStyleCmb_SelectionChanged">
+                            <ComboBox x:Name="RadioButtonStyleCmb" Height="32" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="RadioButtonStyleCmb_SelectionChanged">
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Style_Check}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Style_Circle}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Style_Cross}"/>

+ 5 - 5
Demo/Examples/Compdfkit_Tools/Form/Property/TextFieldProperty.xaml

@@ -40,11 +40,11 @@
                     <StackPanel Grid.Column="1">
                         <StackPanel  >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Name}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <TextBox x:Name="FieldNameText" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
+                            <TextBox x:Name="FieldNameText" Height="32" Margin="0,8,0,0" TextChanged="FieldNameText_TextChanged"/>
                         </StackPanel>
                         <StackPanel >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Visibility}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <ComboBox x:Name="FormFieldCmb" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
+                            <ComboBox x:Name="FormFieldCmb" Height="32" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FormFieldCmb_SelectionChanged">
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Visible}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_Hidden}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Option_NoPrint}"/>
@@ -76,10 +76,10 @@
                         </StackPanel>
                         <StackPanel>
                             <TextBlock  Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Font}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold" />
-                            <ComboBox x:Name="FontCmb" Height="28" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FontCmb_SelectionChanged" PreviewMouseDown="FontCmb_PreviewMouseDown">
+                            <ComboBox x:Name="FontCmb" Height="28" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FontCmb_SelectionChanged">
                             </ComboBox>
                             <StackPanel Orientation="Horizontal"  Height="28" Margin="0,8,0,0">
-                                <ComboBox x:Name="FontStyleCmb"  Margin="0,0,0,0" Width="148" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FontStyleCmb_SelectionChanged" PreviewMouseDown="FontStyleCmb_PreviewMouseDown">
+                                <ComboBox x:Name="FontStyleCmb"  Margin="0,0,0,0" Width="148" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FontStyleCmb_SelectionChanged">
                                 </ComboBox>
                                 <ComboBox x:Name="FontSizeCmb" Margin="4,0,0,0" Width="72" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FontSizeCmb_SelectionChanged"/>
                             </StackPanel>
@@ -97,7 +97,7 @@
                     <StackPanel Grid.Column="1">
                         <StackPanel  >
                             <TextBlock Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Alignment}" FontSize="14" FontFamily="Microsoft YaHei" FontWeight="Bold"/>
-                            <ComboBox x:Name="TextAlignmentCmb" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="TextAlignmentCmb_SelectionChanged">
+                            <ComboBox x:Name="TextAlignmentCmb" Height="32" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="TextAlignmentCmb_SelectionChanged">
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Alignment_Left}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Alignment_Center}"/>
                                 <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Alignment_Right}"/>

+ 6 - 31
Demo/Examples/Compdfkit_Tools/Form/Property/TextFieldProperty.xaml.cs

@@ -19,8 +19,7 @@ using System.Windows.Input;
 namespace Compdfkit_Tools.PDFControl
 {
     public partial class TextFieldProperty : UserControl
-    {
-        public bool isFontCmbClicked;
+    { 
         public bool isFontStyleCmbClicked;
 
         private TextBoxParam widgetParam = null;
@@ -205,13 +204,11 @@ namespace Compdfkit_Tools.PDFControl
         private void FontStyleCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             if (IsLoadedData)
-            {
-                if (isFontCmbClicked)
-                {
+            { 
                     var history = GetNewHistory();
                     CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                     string psFontName = string.Empty;
-                    CPDFFont.GetPostScriptName(FontCmb.SelectedValue.ToString(), FontStyleCmb.SelectedValue.ToString(), ref psFontName);
+                    CPDFFont.GetPostScriptName(FontCmb.SelectedValue.ToString(), FontStyleCmb.SelectedValue?.ToString(), ref psFontName);
                     cTextAttribute.FontName = psFontName;
                     cPDFAnnotation.SetTextAttribute(cTextAttribute);
                     cPDFAnnotation.UpdateFormAp();
@@ -221,17 +218,13 @@ namespace Compdfkit_Tools.PDFControl
                 else
                 {
                     FontStyleCmb.ItemsSource = CPDFFont.GetFontNameDictionary()[FontCmb.SelectedValue.ToString()];
-                }
-                isFontCmbClicked = false;
-            }
+                }  
         }
 
         private void FontSizeCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             if (IsLoadedData)
-            {
-                if (isFontStyleCmbClicked)
-                {
+            { 
                     var history = GetNewHistory();
                     CTextAttribute cTextAttribute = cPDFAnnotation.GetTextAttribute();
                     cTextAttribute.FontSize = Convert.ToSingle((sender as ComboBox).SelectedItem);
@@ -239,9 +232,7 @@ namespace Compdfkit_Tools.PDFControl
                     cPDFAnnotation.UpdateFormAp();
                     pdfViewerControl.UpdateAnnotFrame();
                     AddHistory(history);
-                }
-                isFontStyleCmbClicked = false;
-            }
+                }  
         }
 
         private void TextAlignmentCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -305,21 +296,5 @@ namespace Compdfkit_Tools.PDFControl
         }
 
         #endregion
-
-        private void FontCmb_PreviewMouseDown(object sender, MouseButtonEventArgs e)
-        {
-            if (e.LeftButton == MouseButtonState.Pressed && sender is ComboBox)
-            {
-                isFontCmbClicked = true;
-            }
-        }
-
-        private void FontStyleCmb_PreviewMouseDown(object sender, MouseButtonEventArgs e)
-        {
-            if (e.LeftButton == MouseButtonState.Pressed && sender is ComboBox)
-            {
-                isFontStyleCmbClicked = true;
-            }
-        }
     }
 }

+ 1 - 2
Demo/Examples/Compdfkit_Tools/Watermark/AddWatermark/WatermarkDialog.xaml

@@ -57,7 +57,7 @@
                             </RadioButton>
                             <TextBox Grid.Row="1" Height="28" Width="438" Text="{Binding WatermarkText, UpdateSourceTrigger=PropertyChanged}" Margin="32,6,0,0" HorizontalAlignment="Left" VerticalContentAlignment="Center" IsEnabled="{Binding Path=IsChecked, ElementName=TextRdo}"></TextBox>
                             <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="32,6,0,0" Height="30">
-                                <ComboBox x:Name="FontFamilyCmb" Style="{StaticResource ComboBoxStyle1}" Width="160" Margin="0,0,20,0" SelectionChanged="FontFamilyCmb_SelectionChanged"  IsEnabled="{Binding Path=IsChecked, ElementName=TextRdo}">
+                                <ComboBox x:Name="FontFamilyCmb" Style="{StaticResource ComboBoxStyle1}" Width="242" Margin="0,0,20,0" SelectionChanged="FontFamilyCmb_SelectionChanged"  IsEnabled="{Binding Path=IsChecked, ElementName=TextRdo}">
                                 </ComboBox>
                                 <ComboBox x:Name="FontStyleCmb" Style="{StaticResource ComboBoxStyle1}" Width="90" Margin="0,0,20,0" SelectionChanged="FontStyleCmb_SelectionChanged" IsEnabled="{Binding Path=IsChecked, ElementName=TextRdo}"></ComboBox>
                                 <ComboBox x:Name="FontSizeCmb" Style="{StaticResource ComboBoxStyle1}" Width="66" Margin="0,0,20,0" SelectionChanged="FontSizeCmb_SelectionChanged"  IsEnabled="{Binding Path=IsChecked, ElementName=TextRdo}">
@@ -73,7 +73,6 @@
                                     <ComboBoxItem Tag="240" >240</ComboBoxItem>
                                     <ComboBoxItem Tag="264" >264</ComboBoxItem>
                                     <ComboBoxItem Tag="288" >288</ComboBoxItem>
-
                                 </ComboBox>
 
                             </StackPanel>