NoviceGuidDialogViewModel.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. using PDF_Master.Model;
  2. using PDF_Master.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_Master.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. NextTimeCommand = new DelegateCommand(nexttime);
  81. InitItemSource();
  82. }
  83. private void nexttime()
  84. {
  85. //忽略,下次再看
  86. this.RequestClose(new DialogResult(ButtonResult.Ignore));
  87. }
  88. private void InitItemSource()
  89. {
  90. ItemSource = new ObservableCollection<GuidItemModel>();
  91. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_Office.png", Title = "PDF Master 全新体验版", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
  92. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_Annote.png", Title = "强大的PDF注释工具", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
  93. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_Convert.png", Title = "将PDF转换为可编辑Office", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
  94. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_FillAndSign.png", Title = "填写表格,签署商务文件", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
  95. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_SignUp.png", Title = "注册账号享受全功能", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
  96. }
  97. /// <summary>
  98. /// 前一页
  99. /// </summary>
  100. private void NextPage()
  101. {
  102. SelectedIndex++;
  103. }
  104. /// <summary>
  105. /// 下一页
  106. /// </summary>
  107. private void PrePage()
  108. {
  109. SelectedIndex--;
  110. }
  111. /// <summary>
  112. /// 注册
  113. /// </summary>
  114. private void SignUp()
  115. {
  116. RequestClose.Invoke(new DialogResult());
  117. dialog.ShowDialog(DialogNames.RegisterDialog);
  118. }
  119. /// <summary>
  120. /// 下一次显示
  121. /// </summary>
  122. private void NextTime()
  123. {
  124. //Todo
  125. }
  126. //是否可以执行下一页
  127. private bool CanNextPageExcute()
  128. {
  129. if(SelectedIndex>=ItemSource.Count-1)
  130. {
  131. return false;
  132. }
  133. return true;
  134. }
  135. /// <summary>
  136. /// 是否可以执行上一页
  137. /// </summary>
  138. /// <returns></returns>
  139. private bool CanPrePageExcute()
  140. {
  141. if (SelectedIndex <= 0)
  142. {
  143. return false;
  144. }
  145. return true;
  146. }
  147. public bool CanCloseDialog()
  148. {
  149. return true;
  150. }
  151. public void OnDialogClosed()
  152. {
  153. }
  154. public void OnDialogOpened(IDialogParameters parameters)
  155. {
  156. }
  157. }
  158. }