ComboBoxParam.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using ComPDFKit.PDFAnnotation;
  2. using ComPDFKit.PDFAnnotation.Form;
  3. using System.Collections.Generic;
  4. namespace ComPDFKit.Tool
  5. {
  6. public class ComboBoxParam:WidgetParm
  7. {
  8. public ComboBoxParam ()
  9. {
  10. CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET;
  11. WidgetType = C_WIDGET_TYPE.WIDGET_COMBOBOX;
  12. }
  13. public bool IsItalic { get; set; }
  14. public bool IsBold { get; set; }
  15. public Dictionary<string,string> OptionItems { get; set; }=new Dictionary<string,string>();
  16. public List<int> SelectItemsIndex { get; set; } = new List<int>();
  17. public override bool CopyTo(AnnotParam transfer)
  18. {
  19. ComboBoxParam comboboxTransfer = transfer as ComboBoxParam;
  20. if (comboboxTransfer == null)
  21. {
  22. return false;
  23. }
  24. if (!base.CopyTo(comboboxTransfer))
  25. {
  26. return false;
  27. }
  28. comboboxTransfer.IsItalic = IsItalic;
  29. comboboxTransfer.IsBold = IsBold;
  30. if(OptionItems != null)
  31. {
  32. Dictionary<string, string> optionDict=new Dictionary<string, string>();
  33. foreach (string dictKey in OptionItems.Keys)
  34. {
  35. optionDict[dictKey] = OptionItems[dictKey];
  36. }
  37. comboboxTransfer.OptionItems = optionDict;
  38. }
  39. if(SelectItemsIndex != null)
  40. {
  41. List<int> selectList=new List<int>();
  42. foreach (int index in SelectItemsIndex)
  43. {
  44. selectList.Add(index);
  45. }
  46. comboboxTransfer.SelectItemsIndex = selectList;
  47. }
  48. return true;
  49. }
  50. }
  51. }