FillAndSignContentViewModel.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using ComPDFKitViewer.PdfViewer;
  2. using PDF_Office.Model;
  3. using Prism.Commands;
  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;
  12. using System.Windows.Controls;
  13. namespace PDF_Office.ViewModels.FillAndSign
  14. {
  15. public class FillAndSignContentViewModel : BindableBase, INavigationAware
  16. {
  17. #region
  18. private CPDFViewer pdfViewer;
  19. private ViewContentViewModel viewContentViewMode;
  20. private IRegionManager regions { get; set; }
  21. #endregion
  22. #region Command
  23. public DelegateCommand<RoutedEventArgs> CheckCommand { get; set; }
  24. /// <summary>
  25. /// 按钮名称和属性面板映射字典
  26. /// </summary>
  27. public Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
  28. #endregion
  29. public FillAndSignContentViewModel(IRegionManager regionManager)
  30. {
  31. regions = regionManager;
  32. CheckCommand = new DelegateCommand<RoutedEventArgs>(CheckedEvent);
  33. InitDictionary();
  34. }
  35. private void CheckedEvent(RoutedEventArgs e)
  36. {
  37. var control = e.OriginalSource as Control;
  38. NavigateToProperty(control.Name);
  39. }
  40. private void NavigateToProperty(string btnName)
  41. {
  42. NavigationParameters values = new NavigationParameters();
  43. values.Add(ParameterNames.PDFViewer, pdfViewer);
  44. regions.RequestNavigate(RegionNames.PropertyRegionName,btnToProperty[btnName]);
  45. viewContentViewMode.IsPropertyOpen = true;
  46. }
  47. /// <summary>
  48. /// 初始化按钮名称-属性面板字典
  49. /// </summary>
  50. private void InitDictionary()
  51. {
  52. btnToProperty["RbtnText"] = "TextFillProperty";
  53. btnToProperty["RbtnTick"] = "ShapFillProperty";
  54. btnToProperty["RbtnFork"] = "ShapFillProperty";
  55. btnToProperty["RbtnRectangle"] = "ShapFillProperty";
  56. btnToProperty["RbtnLine"] = "ShapFillProperty";
  57. btnToProperty["RbtnPoint"] = "ShapFillProperty";
  58. btnToProperty["RbtnDate"] = "DateFillProperty";
  59. btnToProperty["RbtnSign"] = "";
  60. }
  61. #region Navigation
  62. public bool IsNavigationTarget(NavigationContext navigationContext)
  63. {
  64. return true;
  65. }
  66. public void OnNavigatedFrom(NavigationContext navigationContext)
  67. {
  68. }
  69. public void OnNavigatedTo(NavigationContext navigationContext)
  70. {
  71. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewMode);
  72. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
  73. }
  74. #endregion
  75. }
  76. }