NoviceGuidDialogViewModel.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. using PDF_Office.Model;
  2. using PDF_Office.Model.Dialog;
  3. using Prism.Commands;
  4. using Prism.Mvvm;
  5. using Prism.Services.Dialogs;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. namespace PDF_Office.ViewModels.Dialog
  14. {
  15. public class NoviceGuidDialogViewModel :BindableBase,IDialogAware
  16. {
  17. public string Title => "";
  18. public event Action<IDialogResult> RequestClose;
  19. private int selectedIndex;
  20. /// <summary>
  21. /// 选中索引
  22. /// </summary>
  23. public int SelectedIndex
  24. {
  25. get { return selectedIndex; }
  26. set
  27. {
  28. SetProperty(ref selectedIndex, value);
  29. if(SelectedIndex==ItemSource.Count-1)
  30. {
  31. SignUpVisible = Visibility.Visible;
  32. }
  33. else
  34. {
  35. SignUpVisible = Visibility.Collapsed;
  36. }
  37. if(SelectedIndex==0)
  38. {
  39. NextTimeVisible = Visibility.Visible;
  40. }
  41. else
  42. {
  43. NextTimeVisible = Visibility.Collapsed;
  44. }
  45. }
  46. }
  47. private Visibility signUpVisible = Visibility.Collapsed;
  48. /// <summary>
  49. /// 是否显示SignUp按钮
  50. /// </summary>
  51. public Visibility SignUpVisible
  52. {
  53. get { return signUpVisible; }
  54. set
  55. {
  56. SetProperty(ref signUpVisible, value);
  57. }
  58. }
  59. private Visibility nexttimeVisible;
  60. public Visibility NextTimeVisible
  61. {
  62. get { return nexttimeVisible; }
  63. set
  64. {
  65. SetProperty(ref nexttimeVisible, value);
  66. }
  67. }
  68. public DelegateCommand NextPageCommand { get; set; }
  69. public DelegateCommand PrePageCommand { get; set; }
  70. public DelegateCommand NextTimeCommand { get; set; }
  71. public DelegateCommand SignUpCommand { get; set; }
  72. public ObservableCollection<GuidItemModel> ItemSource { get; set; }
  73. private IDialogService dialog;
  74. public NoviceGuidDialogViewModel(IDialogService dialogService)
  75. {
  76. dialog = dialogService;
  77. NextPageCommand = new DelegateCommand(NextPage,CanNextPageExcute).ObservesProperty(()=>SelectedIndex);
  78. PrePageCommand = new DelegateCommand(PrePage,CanPrePageExcute).ObservesProperty(()=>SelectedIndex);
  79. SignUpCommand = new DelegateCommand(SignUp);
  80. InitItemSource();
  81. }
  82. private void InitItemSource()
  83. {
  84. ItemSource = new ObservableCollection<GuidItemModel>();
  85. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Office;component/Resources/GuidItems/Guid_Office.png", Title = "PDF Office 全新体验版", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
  86. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Office;component/Resources/GuidItems/Guid_Annote.png", Title = "强大的PDF注释工具", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
  87. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Office;component/Resources/GuidItems/Guid_Convert.png", Title = "将PDF转换为可编辑Office", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
  88. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Office;component/Resources/GuidItems/Guid_FillAndSign.png", Title = "填写表格,签署商务文件", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
  89. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Office;component/Resources/GuidItems/Guid_SignUp.png", Title = "注册账号享受全功能", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
  90. }
  91. /// <summary>
  92. /// 前一页
  93. /// </summary>
  94. private void NextPage()
  95. {
  96. SelectedIndex++;
  97. }
  98. /// <summary>
  99. /// 下一页
  100. /// </summary>
  101. private void PrePage()
  102. {
  103. SelectedIndex--;
  104. }
  105. /// <summary>
  106. /// 注册
  107. /// </summary>
  108. private void SignUp()
  109. {
  110. RequestClose.Invoke(new DialogResult());
  111. dialog.ShowDialog(DialogNames.RegisterDialog);
  112. }
  113. /// <summary>
  114. /// 下一次显示
  115. /// </summary>
  116. private void NextTime()
  117. {
  118. //Todo
  119. }
  120. //是否可以执行下一页
  121. private bool CanNextPageExcute()
  122. {
  123. if(SelectedIndex>=ItemSource.Count-1)
  124. {
  125. return false;
  126. }
  127. return true;
  128. }
  129. /// <summary>
  130. /// 是否可以执行上一页
  131. /// </summary>
  132. /// <returns></returns>
  133. private bool CanPrePageExcute()
  134. {
  135. if (SelectedIndex <= 0)
  136. {
  137. return false;
  138. }
  139. return true;
  140. }
  141. public bool CanCloseDialog()
  142. {
  143. return true;
  144. }
  145. public void OnDialogClosed()
  146. {
  147. }
  148. public void OnDialogOpened(IDialogParameters parameters)
  149. {
  150. }
  151. }
  152. }