TextFieldPropertyViewModel.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 TextFieldPropertyViewModel : FormBaseVM, INavigationAware
  15. {
  16. #region 属性
  17. #region 选项
  18. //默认值
  19. private string _defaultValue;
  20. public string DefaultValue
  21. {
  22. get { return _defaultValue; }
  23. set { SetProperty(ref _defaultValue, value); }
  24. }
  25. //多行
  26. private bool _isMultiline = false;
  27. public bool IsMultiline
  28. {
  29. get { return _isMultiline; }
  30. set { SetProperty(ref _isMultiline, value); }
  31. }
  32. //滚动显示长文本
  33. private bool _isScrollText = false;
  34. public bool IsScrollText
  35. {
  36. get { return _isScrollText; }
  37. set { SetProperty(ref _isScrollText, value); }
  38. }
  39. #endregion
  40. #endregion
  41. #region Command
  42. #endregion
  43. #region 变量
  44. private CPDFViewer PDFViewer;
  45. private WidgetTextBoxArgs textBoxArgs;
  46. #endregion
  47. #region 初始化
  48. public TextFieldPropertyViewModel()
  49. {
  50. InitVariable();
  51. InitCommand();
  52. }
  53. private void InitVariable()
  54. {
  55. }
  56. private void InitCommand()
  57. {
  58. }
  59. #endregion
  60. #region 一般处理
  61. #endregion
  62. #region 外观处理
  63. #endregion
  64. #region 选项处理
  65. #endregion
  66. #region Navegation
  67. public bool IsNavigationTarget(NavigationContext navigationContext)
  68. {
  69. return true;
  70. }
  71. public void OnNavigatedFrom(NavigationContext navigationContext)
  72. {
  73. textBoxArgs = null;
  74. }
  75. public void OnNavigatedTo(NavigationContext navigationContext)
  76. {
  77. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  78. navigationContext.Parameters.TryGetValue<WidgetTextBoxArgs>("WidgetArgs", out textBoxArgs);
  79. GetWidgeText();
  80. }
  81. private void GetWidgeText()
  82. {
  83. if (textBoxArgs == null)
  84. {
  85. WidgetTextBoxArgs textArgs = new WidgetTextBoxArgs();
  86. textArgs.BgColor = Colors.Transparent;
  87. textArgs.FontSize = 12;
  88. textArgs.FontFamily = "Courier New";
  89. textArgs.FontColor = Colors.Black;
  90. textArgs.FieldName = "TextBox";
  91. textBoxArgs = textArgs;
  92. }
  93. PDFViewer.SetMouseMode(MouseModes.FormEditTool);
  94. PDFViewer.SetToolParam(textBoxArgs);
  95. }
  96. #endregion
  97. }
  98. }