CheckBoxProperty.xaml.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using ComPDFKit.PDFAnnotation;
  2. using ComPDFKit.PDFAnnotation.Form;
  3. using ComPDFKit.PDFDocument;
  4. using ComPDFKit.Tool;
  5. using ComPDFKit.Tool.Help;
  6. using System;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Media;
  10. namespace Compdfkit_Tools.PDFControl
  11. {
  12. public partial class CheckBoxProperty : UserControl
  13. {
  14. private CheckBoxParam widgetParam = null;
  15. private CPDFCheckBoxWidget cPDFAnnotation = null;
  16. private PDFViewControl pdfViewerControl = null;
  17. private CPDFDocument cPDFDocument = null;
  18. bool IsLoadedData = false;
  19. public CheckBoxProperty()
  20. {
  21. InitializeComponent();
  22. }
  23. #region Loaded
  24. public void SetProperty(AnnotParam annotParam, CPDFAnnotation annotation, CPDFDocument doc, PDFViewControl cPDFViewer)
  25. {
  26. widgetParam = (CheckBoxParam)annotParam;
  27. cPDFAnnotation = (CPDFCheckBoxWidget)annotation;
  28. pdfViewerControl = cPDFViewer;
  29. cPDFDocument = doc;
  30. }
  31. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  32. {
  33. FieldNameText.Text = widgetParam.FieldName;
  34. FormFieldCombox.SelectedIndex = (int)ParamConverter.ConverterWidgetFormFlags(widgetParam.Flags, widgetParam.IsHidden);
  35. BorderColorPickerControl.SetCheckedForColor(ParamConverter.ConverterByteForColor(widgetParam.LineColor));
  36. BackgroundColorPickerControl.SetCheckedForColor(ParamConverter.ConverterByteForColor(widgetParam.BgColor));
  37. CheckButtonStyleCombox.SelectedIndex = (int)widgetParam.CheckStyle;
  38. chkSelected.IsChecked = widgetParam.IsChecked;
  39. IsLoadedData = true;
  40. }
  41. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  42. {
  43. IsLoadedData = false;
  44. }
  45. #endregion
  46. private void FieldNameText_TextChanged(object sender, TextChangedEventArgs e)
  47. {
  48. if (IsLoadedData)
  49. {
  50. cPDFAnnotation.SetFieldName((sender as TextBox).Text);
  51. pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame();
  52. }
  53. }
  54. private void FormFieldCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  55. {
  56. if (IsLoadedData)
  57. {
  58. cPDFAnnotation.SetFlags( ParamConverter.GetFormFlags((ParamConverter.FormField)(sender as ComboBox).SelectedIndex, cPDFAnnotation));
  59. pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame();
  60. }
  61. }
  62. private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
  63. {
  64. if (IsLoadedData)
  65. {
  66. byte[] Color = new byte[3];
  67. Color[0] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.R;
  68. Color[1] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.G;
  69. Color[2] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.B;
  70. cPDFAnnotation.SetWidgetBorderRGBColor(Color);
  71. pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame();
  72. }
  73. }
  74. private void BackgroundColorPickerControl_ColorChanged(object sender, EventArgs e)
  75. {
  76. if (IsLoadedData)
  77. {
  78. byte[] Color = new byte[3];
  79. Color[0] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.R;
  80. Color[1] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.G;
  81. Color[2] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.B;
  82. cPDFAnnotation.SetWidgetBgRGBColor(Color);
  83. pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame();
  84. }
  85. }
  86. private void CheckButtonStyleCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  87. {
  88. if (IsLoadedData)
  89. {
  90. cPDFAnnotation.SetWidgetCheckStyle((C_CHECK_STYLE)(sender as ComboBox).SelectedIndex);
  91. pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame();
  92. }
  93. }
  94. private void chkSelected_Checked(object sender, RoutedEventArgs e)
  95. {
  96. if (IsLoadedData)
  97. {
  98. cPDFAnnotation.SetChecked(true);
  99. pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame();
  100. }
  101. }
  102. private void chkSelected_Unchecked(object sender, RoutedEventArgs e)
  103. {
  104. if (IsLoadedData)
  105. {
  106. cPDFAnnotation.SetChecked(false);
  107. pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame();
  108. }
  109. }
  110. }
  111. }