ButtonPropertyViewModel.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using ComPDFKitViewer.AnnotEvent;
  2. using ComPDFKitViewer.PdfViewer;
  3. using PDF_Office.Model;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Media;
  12. namespace PDF_Office.ViewModels.Form
  13. {
  14. public class ButtonPropertyViewModel : FormBaseVM, INavigationAware
  15. {
  16. #region 属性
  17. #region 选项
  18. //标签
  19. private string _labelContent;
  20. public string LabelContent
  21. {
  22. get { return _labelContent; }
  23. set { SetProperty(ref _labelContent, value); }
  24. }
  25. private string _emailContent;
  26. public string EmailContent
  27. {
  28. get { return _emailContent; }
  29. set { SetProperty(ref _emailContent, value); }
  30. }
  31. #endregion
  32. #endregion
  33. #region Command
  34. #endregion
  35. #region 变量
  36. private CPDFViewer PDFViewer;
  37. private WidgetPushButtonArgs pushButtonArgs;
  38. #endregion
  39. #region 初始化
  40. public ButtonPropertyViewModel()
  41. {
  42. InitVariable();
  43. InitCommand();
  44. }
  45. private void InitVariable()
  46. {
  47. }
  48. private void InitCommand()
  49. {
  50. }
  51. #endregion
  52. #region 一般处理
  53. #endregion
  54. #region 外观处理
  55. #endregion
  56. #region 选项处理
  57. #endregion
  58. #region Navegation
  59. public bool IsNavigationTarget(NavigationContext navigationContext)
  60. {
  61. return true;
  62. }
  63. public void OnNavigatedFrom(NavigationContext navigationContext)
  64. {
  65. pushButtonArgs = null;
  66. }
  67. public void OnNavigatedTo(NavigationContext navigationContext)
  68. {
  69. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  70. navigationContext.Parameters.TryGetValue<WidgetPushButtonArgs>("WidgetArgs", out pushButtonArgs);
  71. GetWidgeText();
  72. }
  73. private void GetWidgeText()
  74. {
  75. if (pushButtonArgs == null)
  76. {
  77. WidgetPushButtonArgs pushButtonArgs = new WidgetPushButtonArgs();
  78. pushButtonArgs.BgColor = Colors.White;
  79. pushButtonArgs.FontFamily = "Courier New";
  80. pushButtonArgs.FontSize = 12;
  81. pushButtonArgs.FontColor = Colors.Black;
  82. pushButtonArgs.LineColor = Colors.Black;
  83. pushButtonArgs.LineWidth = 1;
  84. var action = new Dictionary<ComPDFKit.PDFDocument.Action.C_ACTION_TYPE, string>();
  85. action.Add(ComPDFKit.PDFDocument.Action.C_ACTION_TYPE.ACTION_TYPE_URI, "");
  86. pushButtonArgs.ActionDict = action;
  87. pushButtonArgs.FieldName = "PushButton";
  88. pushButtonArgs.Text = "PushButton";
  89. this.pushButtonArgs = pushButtonArgs;
  90. }
  91. PDFViewer.SetMouseMode(MouseModes.FormEditTool);
  92. PDFViewer.SetToolParam(pushButtonArgs);
  93. }
  94. #endregion
  95. }
  96. }