123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- using PDF_Master.Helper;
- using PDF_Master.Model;
- using PDF_Master.Model.Dialog;
- using PDF_Master.Properties;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- namespace PDF_Master.ViewModels.Dialog
- {
- public class NoviceGuidDialogViewModel :BindableBase,IDialogAware
- {
- public string Title => "";
- public event Action<IDialogResult> RequestClose;
- private int selectedIndex;
- /// <summary>
- /// 免费试用天数
- /// </summary>
- private string trialDays = "7";
- /// <summary>
- /// 选中索引
- /// </summary>
- public int SelectedIndex
- {
- get { return selectedIndex; }
- set
- {
- SetProperty(ref selectedIndex, value);
- if(SelectedIndex==ItemSource.Count-1)
- {
- if (App.IsLogin)
- {
- StartVisible = Visibility.Visible;
- }
- else
- {
- SignUpVisible = Visibility.Visible;
- }
- }
- else
- {
- SignUpVisible = Visibility.Collapsed;
- StartVisible = Visibility.Collapsed;
- }
- if(SelectedIndex==0)
- {
- NextTimeVisible = Visibility.Visible;
- }
- else
- {
- NextTimeVisible = Visibility.Hidden;
- }
- }
- }
- private Visibility signUpVisible = Visibility.Collapsed;
- /// <summary>
- /// 是否显示SignUp按钮
- /// </summary>
- public Visibility SignUpVisible
- {
- get { return signUpVisible; }
- set
- {
- SetProperty(ref signUpVisible, value);
- }
- }
- /// <summary>
- /// 开始按钮时否隐藏
- /// </summary>
- private Visibility startVisible = Visibility.Collapsed;
- public Visibility StartVisible
- {
- get { return startVisible; }
- set
- {
- SetProperty(ref startVisible, value);
- }
- }
- private Visibility nexttimeVisible;
- public Visibility NextTimeVisible
- {
- get { return nexttimeVisible; }
- set
- {
- SetProperty(ref nexttimeVisible, value);
- }
- }
- private string T_btnNextStep;
- public string T_BtnNextStep
- {
- get { return T_btnNextStep; }
- set
- {
- SetProperty(ref T_btnNextStep, value);
- }
- }
- /// <summary>
- ///
- /// </summary>
- private string T_btnStart;
- public string T_BtnStart
- {
- get { return T_btnStart; }
- set
- {
- SetProperty(ref T_btnStart, value);
- }
- }
- private string T_btnNextTime;
- public string T_BtnNextTime
- {
- get { return T_btnNextTime; }
- set
- {
- SetProperty(ref T_btnNextTime, value);
- }
- }
- private string T_btnSignUp;
- public string T_BtnSignUp
- {
- get { return T_btnSignUp; }
- set
- {
- SetProperty(ref T_btnSignUp, value);
- }
- }
- public DelegateCommand NextPageCommand { get; set; }
- public DelegateCommand PrePageCommand { get; set; }
- public DelegateCommand NextTimeCommand { get; set; }
- public DelegateCommand SignUpCommand { get; set; }
- public ObservableCollection<GuidItemModel> ItemSource { get; set; }
- private IDialogService dialog;
- public NoviceGuidDialogViewModel(IDialogService dialogService)
- {
- dialog = dialogService;
- NextPageCommand = new DelegateCommand(NextPage,CanNextPageExcute).ObservesProperty(()=>SelectedIndex);
- PrePageCommand = new DelegateCommand(PrePage,CanPrePageExcute).ObservesProperty(()=>SelectedIndex);
- SignUpCommand = new DelegateCommand(SignUp);
- NextTimeCommand = new DelegateCommand(nexttime);
- InitItemSource();
- InitString();
- }
- private void InitString()
- {
- T_BtnNextStep = App.HomePageLoader.GetString("Guid_AcceptButton");
- T_BtnNextTime = App.HomePageLoader.GetString("Guid_LaterButton");
- T_BtnSignUp = App.ServiceLoader.GetString("Text_Signup");
- T_BtnStart =App.HomePageLoader.GetString("Guid_StartNow");
- }
- private void nexttime()
- {
- //忽略,下次再看
- //2023.7.17 策略调整,因配图较多,不显示再提示字样
- //this.RequestClose(new DialogResult(ButtonResult.Ignore));
- Process.Start(new ProcessStartInfo(ServiceHelper.WebHost + "/windows/store/master?email=" + Settings.Default.UserDate.Email));
- }
- private void InitItemSource()
- {
- ItemSource = new ObservableCollection<GuidItemModel>();
- //因新手引导配图顺序和功能没有直接关系,因此配图命名按顺序来,方便后面调整顺序或者插入图片后更新资源
- ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/GuidItem1.png", Title = App.HomePageLoader.GetString("GuidTitleP1"), Content = App.HomePageLoader.GetString("GuidContentP1") }) ;
- ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/GuidItem2.png", Title = App.HomePageLoader.GetString("GuidTitleP2"), Content =App.HomePageLoader.GetString("GuidContentP2") });
- ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/GuidItem3.png", Title = App.HomePageLoader.GetString("GuidTitleP3"), Content = App.HomePageLoader.GetString("GuidContentP3") });
- ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/GuidItem4.png", Title = App.HomePageLoader.GetString("GuidTitleP4"), Content = App.HomePageLoader.GetString("GuidContentP4") });
- ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/GuidItem5.png", Title = App.HomePageLoader.GetString("GuidTitleP5"), Content = App.HomePageLoader.GetString("GuidContentP5") });
- ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/GuidItem6.png", Title = App.HomePageLoader.GetString("GuidTitleP6"), Content = App.HomePageLoader.GetString("GuidContentP6") });
- }
- /// <summary>
- /// 前一页
- /// </summary>
- private void NextPage()
- {
- SelectedIndex++;
- }
- /// <summary>
- /// 下一页
- /// </summary>
- private void PrePage()
- {
- SelectedIndex--;
- }
- /// <summary>
- /// 注册
- /// </summary>
- private void SignUp()
- {
-
- RequestClose.Invoke(new DialogResult());
- Settings.Default.UserDate.TodayRegister = true;
- DateTime currentTime = DateTime.Now;
- Settings.Default.UserDate.TodayRegisterTime = currentTime.ToString();
- Settings.Default.Save();
- dialog.ShowDialog(DialogNames.RegisterDialog);
- }
- /// <summary>
- /// 下一次显示
- /// </summary>
- private void NextTime()
- {
- //Todo
- }
- //是否可以执行下一页
- private bool CanNextPageExcute()
- {
- if(SelectedIndex>=ItemSource.Count-1)
- {
- return false;
- }
- return true;
- }
- /// <summary>
- /// 是否可以执行上一页
- /// </summary>
- /// <returns></returns>
- private bool CanPrePageExcute()
- {
- if (SelectedIndex <= 0)
- {
- return false;
- }
- return true;
- }
- public bool CanCloseDialog()
- {
- return true;
- }
- public void OnDialogClosed()
- {
-
- }
- public void OnDialogOpened(IDialogParameters parameters)
- {
-
- }
- }
- }
|