CheckBoxProperty.xaml.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using compdfkit_tools.Common;
  2. using ComPDFKitViewer;
  3. using ComPDFKitViewer.AnnotEvent;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace compdfkit_tools.Form.Property
  19. {
  20. /// <summary>
  21. /// CheckBoxProperty.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class CheckBoxProperty : UserControl
  24. {
  25. private WidgetCheckBoxArgs widgetArgs = null;
  26. private AnnotAttribEvent annotAttribEvent = null;
  27. bool IsLoadedData = false;
  28. public CheckBoxProperty()
  29. {
  30. InitializeComponent();
  31. }
  32. #region Loaded
  33. public void SetProperty(WidgetArgs Args, AnnotAttribEvent e)
  34. {
  35. widgetArgs = (WidgetCheckBoxArgs)Args;
  36. annotAttribEvent = e;
  37. }
  38. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  39. {
  40. FieldNameText.Text = widgetArgs.FieldName;
  41. FormFieldCombox.SelectedIndex = (int)widgetArgs.FormField;
  42. BorderColorPickerControl.SetCheckedForColor(widgetArgs.LineColor);
  43. BackgroundColorPickerControl.SetCheckedForColor(widgetArgs.BgColor);
  44. CheckButtonStyleCombox.SelectedIndex = (int)widgetArgs.CheckStyle;
  45. chkSelected.IsChecked = widgetArgs.IsChecked;
  46. IsLoadedData = true;
  47. }
  48. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  49. {
  50. IsLoadedData = false;
  51. }
  52. #endregion
  53. private void FieldNameText_TextChanged(object sender, TextChangedEventArgs e)
  54. {
  55. if (IsLoadedData)
  56. {
  57. annotAttribEvent.UpdateAttrib(AnnotAttrib.FieldName, (sender as TextBox).Text);
  58. annotAttribEvent.UpdateAnnot();
  59. }
  60. }
  61. private void FormFieldCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  62. {
  63. if (IsLoadedData)
  64. {
  65. annotAttribEvent.UpdateAttrib(AnnotAttrib.FormField, (sender as ComboBox).SelectedIndex);
  66. annotAttribEvent.UpdateAnnot();
  67. }
  68. }
  69. private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
  70. {
  71. if (IsLoadedData)
  72. {
  73. annotAttribEvent.UpdateAttrib(AnnotAttrib.Color, ((SolidColorBrush)BorderColorPickerControl.Brush).Color);
  74. annotAttribEvent.UpdateAnnot();
  75. }
  76. }
  77. private void BackgroundColorPickerControl_ColorChanged(object sender, EventArgs e)
  78. {
  79. if (IsLoadedData)
  80. {
  81. annotAttribEvent.UpdateAttrib(AnnotAttrib.FillColor, ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color);
  82. annotAttribEvent.UpdateAnnot();
  83. }
  84. }
  85. private void CheckButtonStyleCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  86. {
  87. if (IsLoadedData)
  88. {
  89. annotAttribEvent.UpdateAttrib(AnnotAttrib.CheckStyle, (sender as ComboBox).SelectedIndex);
  90. annotAttribEvent.UpdateAnnot();
  91. }
  92. }
  93. private void chkSelected_Checked(object sender, RoutedEventArgs e)
  94. {
  95. if (IsLoadedData)
  96. {
  97. annotAttribEvent.UpdateAttrib(AnnotAttrib.IsChecked, true);
  98. annotAttribEvent.UpdateAnnot();
  99. }
  100. }
  101. private void chkSelected_Unchecked(object sender, RoutedEventArgs e)
  102. {
  103. if (IsLoadedData)
  104. {
  105. annotAttribEvent.UpdateAttrib(AnnotAttrib.IsChecked, false);
  106. annotAttribEvent.UpdateAnnot();
  107. }
  108. }
  109. }
  110. }