FromPropertyControl.xaml.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using ComPDFKit.PDFAnnotation;
  2. using ComPDFKit.PDFDocument;
  3. using ComPDFKit.Tool;
  4. using Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. namespace Compdfkit_Tools.PDFControl
  8. {
  9. public partial class FromPropertyControl : UserControl
  10. {
  11. private PDFViewControl pdfViewerControl;
  12. private UIElement currentPanel = null;
  13. public FromPropertyControl()
  14. {
  15. InitializeComponent();
  16. }
  17. public void CleanProperty()
  18. {
  19. SetAnnotationPanel(null);
  20. }
  21. public void SetPropertyForType(AnnotParam annotParam, CPDFAnnotation annotation, CPDFDocument cPDFDocument)
  22. {
  23. currentPanel = null;
  24. if (annotParam == null|| !(annotParam is WidgetParm))
  25. {
  26. SetAnnotationPanel(currentPanel);
  27. return;
  28. }
  29. switch ((annotParam as WidgetParm).WidgetType)
  30. {
  31. case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
  32. PushButtonProperty pushButtonProperty = new PushButtonProperty();
  33. pushButtonProperty.SetProperty(annotParam, annotation, cPDFDocument, pdfViewerControl);
  34. currentPanel = pushButtonProperty;
  35. break;
  36. case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_CHECKBOX:
  37. CheckBoxProperty checkBoxProperty = new CheckBoxProperty();
  38. checkBoxProperty.SetProperty(annotParam, annotation, cPDFDocument, pdfViewerControl);
  39. currentPanel = checkBoxProperty;
  40. break;
  41. case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
  42. RadioButtonProperty radioBoxProperty = new RadioButtonProperty();
  43. radioBoxProperty.SetProperty(annotParam, annotation, cPDFDocument, pdfViewerControl);
  44. currentPanel = radioBoxProperty;
  45. break;
  46. case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_TEXTFIELD:
  47. TextFieldProperty textFieldProperty = new TextFieldProperty();
  48. textFieldProperty.SetProperty(annotParam, annotation, cPDFDocument, pdfViewerControl);
  49. currentPanel = textFieldProperty;
  50. break;
  51. case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_COMBOBOX:
  52. ComboBoxProperty comboBoxProperty = new ComboBoxProperty();
  53. comboBoxProperty.SetProperty(annotParam, annotation, cPDFDocument, pdfViewerControl);
  54. currentPanel = comboBoxProperty;
  55. break;
  56. case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_LISTBOX:
  57. ListBoxProperty listBoxProperty = new ListBoxProperty();
  58. listBoxProperty.SetProperty(annotParam, annotation, cPDFDocument, pdfViewerControl);
  59. currentPanel = listBoxProperty;
  60. break;
  61. case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
  62. if (pdfViewerControl.PDFToolManager.GetToolType()==CPDFToolManager.ToolType.WidgetEdit)
  63. {
  64. CPDFSignatureUI signatureProperty = new CPDFSignatureUI();
  65. signatureProperty.SetFormProperty(annotParam, pdfViewerControl, annotation);
  66. currentPanel = signatureProperty;
  67. }
  68. else
  69. {
  70. SignatureProperty signatureProperty = new SignatureProperty();
  71. signatureProperty.SetProperty(annotParam, annotation, cPDFDocument, pdfViewerControl);
  72. currentPanel = signatureProperty;
  73. }
  74. break;
  75. case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_UNKNOWN:
  76. break;
  77. default:
  78. break;
  79. }
  80. SetAnnotationPanel(currentPanel);
  81. }
  82. private void SetAnnotationPanel(UIElement newChild)
  83. {
  84. FromPropertyPanel.Child = newChild;
  85. }
  86. public void SetPDFViewer(PDFViewControl pdfViewer)
  87. {
  88. this.pdfViewerControl = pdfViewer;
  89. }
  90. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  91. {
  92. }
  93. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  94. {
  95. }
  96. }
  97. }