using PDF_Master.Model; using PDF_Master.Model.Dialog; using Prism.Commands; using Prism.Mvvm; using Prism.Services.Dialogs; using System; using System.Collections.Generic; using System.Collections.ObjectModel; 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() { //忽略,下次再看 this.RequestClose(new DialogResult(ButtonResult.Ignore)); } private void InitItemSource() { ItemSource = new ObservableCollection(); 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) }) ; 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") }); 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") }); 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") }); //因填写与签名功能暂时不上,隐藏新手引导宣传页 //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") }); 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") }); } /// /// 前一页 /// private void NextPage() { SelectedIndex++; } /// /// 下一页 /// private void PrePage() { SelectedIndex--; } /// /// 注册 /// private void SignUp() { RequestClose.Invoke(new DialogResult()); 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) { } } }