CheckBoxProperty.xaml.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using ComPDFKitViewer;
  2. using ComPDFKitViewer.AnnotEvent;
  3. using System;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using System.Windows.Media;
  7. namespace Compdfkit_Tools.PDFControl
  8. {
  9. public partial class CheckBoxProperty : UserControl
  10. {
  11. private WidgetCheckBoxArgs widgetArgs = null;
  12. private AnnotAttribEvent annotAttribEvent = null;
  13. bool IsLoadedData = false;
  14. public CheckBoxProperty()
  15. {
  16. InitializeComponent();
  17. }
  18. #region Loaded
  19. public void SetProperty(WidgetArgs Args, AnnotAttribEvent e)
  20. {
  21. widgetArgs = (WidgetCheckBoxArgs)Args;
  22. annotAttribEvent = e;
  23. }
  24. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  25. {
  26. FieldNameText.Text = widgetArgs.FieldName;
  27. FormFieldCmb.SelectedIndex = (int)widgetArgs.FormField;
  28. BorderColorPickerControl.SetCheckedForColor(widgetArgs.LineColor);
  29. BackgroundColorPickerControl.SetCheckedForColor(widgetArgs.BgColor);
  30. CheckButtonStyleCmb.SelectedIndex = (int)widgetArgs.CheckStyle;
  31. chkSelected.IsChecked = widgetArgs.IsChecked;
  32. IsLoadedData = true;
  33. }
  34. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  35. {
  36. IsLoadedData = false;
  37. }
  38. #endregion
  39. private void FieldNameText_TextChanged(object sender, TextChangedEventArgs e)
  40. {
  41. if (IsLoadedData)
  42. {
  43. annotAttribEvent.UpdateAttrib(AnnotAttrib.FieldName, (sender as TextBox).Text);
  44. annotAttribEvent.UpdateAnnot();
  45. }
  46. }
  47. private void FormFieldCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
  48. {
  49. if (IsLoadedData)
  50. {
  51. annotAttribEvent.UpdateAttrib(AnnotAttrib.FormField, (sender as ComboBox).SelectedIndex);
  52. annotAttribEvent.UpdateAnnot();
  53. }
  54. }
  55. private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
  56. {
  57. if (IsLoadedData)
  58. {
  59. annotAttribEvent.UpdateAttrib(AnnotAttrib.Color, ((SolidColorBrush)BorderColorPickerControl.Brush).Color);
  60. annotAttribEvent.UpdateAnnot();
  61. }
  62. }
  63. private void BackgroundColorPickerControl_ColorChanged(object sender, EventArgs e)
  64. {
  65. if (IsLoadedData)
  66. {
  67. annotAttribEvent.UpdateAttrib(AnnotAttrib.FillColor, ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color);
  68. annotAttribEvent.UpdateAnnot();
  69. }
  70. }
  71. private void CheckButtonStyleCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
  72. {
  73. if (IsLoadedData)
  74. {
  75. annotAttribEvent.UpdateAttrib(AnnotAttrib.CheckStyle, (sender as ComboBox).SelectedIndex);
  76. annotAttribEvent.UpdateAnnot();
  77. }
  78. }
  79. private void chkSelected_Checked(object sender, RoutedEventArgs e)
  80. {
  81. if (IsLoadedData)
  82. {
  83. annotAttribEvent.UpdateAttrib(AnnotAttrib.IsChecked, true);
  84. annotAttribEvent.UpdateAnnot();
  85. }
  86. }
  87. private void chkSelected_Unchecked(object sender, RoutedEventArgs e)
  88. {
  89. if (IsLoadedData)
  90. {
  91. annotAttribEvent.UpdateAttrib(AnnotAttrib.IsChecked, false);
  92. annotAttribEvent.UpdateAnnot();
  93. }
  94. }
  95. }
  96. }