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 RequestClose; private int selectedIndex; /// /// 免费试用天数 /// private string trialDays = "7"; /// /// 选中索引 /// 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; /// /// 是否显示SignUp按钮 /// public Visibility SignUpVisible { get { return signUpVisible; } set { SetProperty(ref signUpVisible, value); } } /// /// 开始按钮时否隐藏 /// 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); } } /// /// /// 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 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(); //因新手引导配图顺序和功能没有直接关系,因此配图命名按顺序来,方便后面调整顺序或者插入图片后更新资源 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") }); } /// /// 前一页 /// private void NextPage() { SelectedIndex++; } /// /// 下一页 /// private void PrePage() { SelectedIndex--; } /// /// 注册 /// 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); } /// /// 下一次显示 /// private void NextTime() { //Todo } //是否可以执行下一页 private bool CanNextPageExcute() { if(SelectedIndex>=ItemSource.Count-1) { return false; } return true; } /// /// 是否可以执行上一页 /// /// private bool CanPrePageExcute() { if (SelectedIndex <= 0) { return false; } return true; } public bool CanCloseDialog() { return true; } public void OnDialogClosed() { } public void OnDialogOpened(IDialogParameters parameters) { } } }