NoviceGuidDialogViewModel.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. private string trialDays = "7";
  24. /// <summary>
  25. /// 选中索引
  26. /// </summary>
  27. public int SelectedIndex
  28. {
  29. get { return selectedIndex; }
  30. set
  31. {
  32. SetProperty(ref selectedIndex, value);
  33. if(SelectedIndex==ItemSource.Count-1)
  34. {
  35. if (App.IsLogin)
  36. {
  37. StartVisible = Visibility.Visible;
  38. }
  39. else
  40. {
  41. SignUpVisible = Visibility.Visible;
  42. }
  43. }
  44. else
  45. {
  46. SignUpVisible = Visibility.Collapsed;
  47. StartVisible = Visibility.Collapsed;
  48. }
  49. if(SelectedIndex==0)
  50. {
  51. NextTimeVisible = Visibility.Visible;
  52. }
  53. else
  54. {
  55. NextTimeVisible = Visibility.Hidden;
  56. }
  57. }
  58. }
  59. private Visibility signUpVisible = Visibility.Collapsed;
  60. /// <summary>
  61. /// 是否显示SignUp按钮
  62. /// </summary>
  63. public Visibility SignUpVisible
  64. {
  65. get { return signUpVisible; }
  66. set
  67. {
  68. SetProperty(ref signUpVisible, value);
  69. }
  70. }
  71. /// <summary>
  72. /// 开始按钮时否隐藏
  73. /// </summary>
  74. private Visibility startVisible = Visibility.Collapsed;
  75. public Visibility StartVisible
  76. {
  77. get { return startVisible; }
  78. set
  79. {
  80. SetProperty(ref startVisible, value);
  81. }
  82. }
  83. private Visibility nexttimeVisible;
  84. public Visibility NextTimeVisible
  85. {
  86. get { return nexttimeVisible; }
  87. set
  88. {
  89. SetProperty(ref nexttimeVisible, value);
  90. }
  91. }
  92. private string T_btnNextStep;
  93. public string T_BtnNextStep
  94. {
  95. get { return T_btnNextStep; }
  96. set
  97. {
  98. SetProperty(ref T_btnNextStep, value);
  99. }
  100. }
  101. /// <summary>
  102. ///
  103. /// </summary>
  104. private string T_btnStart;
  105. public string T_BtnStart
  106. {
  107. get { return T_btnStart; }
  108. set
  109. {
  110. SetProperty(ref T_btnStart, value);
  111. }
  112. }
  113. private string T_btnNextTime;
  114. public string T_BtnNextTime
  115. {
  116. get { return T_btnNextTime; }
  117. set
  118. {
  119. SetProperty(ref T_btnNextTime, value);
  120. }
  121. }
  122. private string T_btnSignUp;
  123. public string T_BtnSignUp
  124. {
  125. get { return T_btnSignUp; }
  126. set
  127. {
  128. SetProperty(ref T_btnSignUp, value);
  129. }
  130. }
  131. public DelegateCommand NextPageCommand { get; set; }
  132. public DelegateCommand PrePageCommand { get; set; }
  133. public DelegateCommand NextTimeCommand { get; set; }
  134. public DelegateCommand SignUpCommand { get; set; }
  135. public ObservableCollection<GuidItemModel> ItemSource { get; set; }
  136. private IDialogService dialog;
  137. public NoviceGuidDialogViewModel(IDialogService dialogService)
  138. {
  139. dialog = dialogService;
  140. NextPageCommand = new DelegateCommand(NextPage,CanNextPageExcute).ObservesProperty(()=>SelectedIndex);
  141. PrePageCommand = new DelegateCommand(PrePage,CanPrePageExcute).ObservesProperty(()=>SelectedIndex);
  142. SignUpCommand = new DelegateCommand(SignUp);
  143. NextTimeCommand = new DelegateCommand(nexttime);
  144. InitItemSource();
  145. InitString();
  146. }
  147. private void InitString()
  148. {
  149. T_BtnNextStep = App.HomePageLoader.GetString("Guid_AcceptButton");
  150. T_BtnNextTime = App.HomePageLoader.GetString("Guid_LaterButton");
  151. T_BtnSignUp = App.ServiceLoader.GetString("Text_Signup");
  152. T_BtnStart =App.HomePageLoader.GetString("Guid_StartNow");
  153. }
  154. private void nexttime()
  155. {
  156. //忽略,下次再看
  157. this.RequestClose(new DialogResult(ButtonResult.Ignore));
  158. }
  159. private void InitItemSource()
  160. {
  161. ItemSource = new ObservableCollection<GuidItemModel>();
  162. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_Office.png", Title = App.HomePageLoader.GetString("GuidTitleP1"), Content = string.Format(App.HomePageLoader.GetString("GuidContentP1"),trialDays) }) ;
  163. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_Annote.png", Title = App.HomePageLoader.GetString("GuidTitleP2"), Content =App.HomePageLoader.GetString("GuidContentP2") });
  164. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_Edit.png", Title = App.HomePageLoader.GetString("GuidTitle_Edit"), Content = App.HomePageLoader.GetString("GuidContent_Edit") });
  165. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_Convert.png", Title = App.HomePageLoader.GetString("GuidTitleP3"), Content = App.HomePageLoader.GetString("GuidContentP3") });
  166. //因填写与签名功能暂时不上,隐藏新手引导宣传页
  167. //ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_FillAndSign.png", Title = App.HomePageLoader.GetString("GuidTitleP4"), Content = App.HomePageLoader.GetString("GuidContentP4") });
  168. ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_SignUp.png", Title = App.HomePageLoader.GetString("GuidTitleP5"), Content = App.HomePageLoader.GetString("GuidContentP5") });
  169. }
  170. /// <summary>
  171. /// 前一页
  172. /// </summary>
  173. private void NextPage()
  174. {
  175. SelectedIndex++;
  176. }
  177. /// <summary>
  178. /// 下一页
  179. /// </summary>
  180. private void PrePage()
  181. {
  182. SelectedIndex--;
  183. }
  184. /// <summary>
  185. /// 注册
  186. /// </summary>
  187. private void SignUp()
  188. {
  189. RequestClose.Invoke(new DialogResult());
  190. dialog.ShowDialog(DialogNames.RegisterDialog);
  191. }
  192. /// <summary>
  193. /// 下一次显示
  194. /// </summary>
  195. private void NextTime()
  196. {
  197. //Todo
  198. }
  199. //是否可以执行下一页
  200. private bool CanNextPageExcute()
  201. {
  202. if(SelectedIndex>=ItemSource.Count-1)
  203. {
  204. return false;
  205. }
  206. return true;
  207. }
  208. /// <summary>
  209. /// 是否可以执行上一页
  210. /// </summary>
  211. /// <returns></returns>
  212. private bool CanPrePageExcute()
  213. {
  214. if (SelectedIndex <= 0)
  215. {
  216. return false;
  217. }
  218. return true;
  219. }
  220. public bool CanCloseDialog()
  221. {
  222. return true;
  223. }
  224. public void OnDialogClosed()
  225. {
  226. }
  227. public void OnDialogOpened(IDialogParameters parameters)
  228. {
  229. }
  230. }
  231. }