FromPropertyControl.xaml.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using ComPDFKit.PDFAnnotation;
  2. using ComPDFKit.PDFDocument;
  3. using ComPDFKit.Tool;
  4. using ComPDFKit.Controls.Annotation.PDFAnnotationPanel.PDFAnnotationUI;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. namespace ComPDFKit.Controls.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. SignatureProperty signatureProperty = new SignatureProperty();
  63. signatureProperty.SetProperty(annotParam, annotation, cPDFDocument, pdfViewerControl);
  64. currentPanel = signatureProperty;
  65. break;
  66. case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_UNKNOWN:
  67. break;
  68. default:
  69. break;
  70. }
  71. SetAnnotationPanel(currentPanel);
  72. }
  73. private void SetAnnotationPanel(UIElement newChild)
  74. {
  75. FromPropertyPanel.Child = newChild;
  76. }
  77. public void SetPDFViewer(PDFViewControl pdfViewer)
  78. {
  79. this.pdfViewerControl = pdfViewer;
  80. }
  81. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  82. {
  83. }
  84. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  85. {
  86. }
  87. }
  88. }