FormsToolContentViewModel.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. namespace PDF_Office.ViewModels.Form
  13. {
  14. public class FormsToolContentViewModel : BindableBase, INavigationAware
  15. {
  16. private CPDFViewer PDFViewer;
  17. public ViewContentViewModel viewContentViewModel;
  18. private IRegionManager regions;
  19. /// <summary>
  20. /// 按钮和属性面板键值对
  21. /// </summary>
  22. private Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
  23. private Visibility showPreView;
  24. /// <summary>
  25. /// 显示PreView按钮
  26. /// </summary>
  27. public Visibility ShowPreView
  28. {
  29. get { return showPreView; }
  30. set
  31. {
  32. SetProperty(ref showPreView, value);
  33. }
  34. }
  35. public DelegateCommand<string> CheckedCommand { get; set; }
  36. public FormsToolContentViewModel(IRegionManager regionManager)
  37. {
  38. regions = regionManager;
  39. CheckedCommand = new DelegateCommand<string>(CheckedEvent);
  40. InitBtnToProperty();
  41. }
  42. private void InitBtnToProperty()
  43. {
  44. btnToProperty.Add("Text", "TextFieldProperty");
  45. btnToProperty.Add("CheckBox", "CheckBoxProperty");
  46. btnToProperty.Add("RadioButton", "RadioButtonProperty");
  47. btnToProperty.Add("ListBox", "ListBoxProperty");
  48. btnToProperty.Add("Combox", "ComboxProperty");
  49. btnToProperty.Add("Button", "ButtonProperty");
  50. btnToProperty.Add("Sign", "SignProperty");
  51. }
  52. /// <summary>
  53. /// Form
  54. /// </summary>
  55. /// <param name="type"></param>
  56. private void CheckedEvent(string type)
  57. {
  58. if (btnToProperty.ContainsKey(type))
  59. {
  60. regions.RequestNavigate(RegionNames.PropertyRegionName, btnToProperty[type]);
  61. }
  62. }
  63. #region Navegation
  64. public bool IsNavigationTarget(NavigationContext navigationContext)
  65. {
  66. return true;
  67. }
  68. public void OnNavigatedFrom(NavigationContext navigationContext)
  69. {
  70. }
  71. public void OnNavigatedTo(NavigationContext navigationContext)
  72. {
  73. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel,out viewContentViewModel);
  74. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.ViewContentViewModel, out PDFViewer);
  75. }
  76. #endregion
  77. }
  78. }