using PDF_Office.Model; using PDF_Office.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_Office.ViewModels.Dialog { public class NoviceGuidDialogViewModel :BindableBase,IDialogAware { public string Title => ""; public event Action RequestClose; private int selectedIndex; /// /// 选中索引 /// public int SelectedIndex { get { return selectedIndex; } set { SetProperty(ref selectedIndex, value); if(SelectedIndex==ItemSource.Count-1) { SignUpVisible = Visibility.Visible; } else { SignUpVisible = Visibility.Collapsed; } if(SelectedIndex==0) { NextTimeVisible = Visibility.Visible; } else { NextTimeVisible = Visibility.Collapsed; } } } private Visibility signUpVisible = Visibility.Collapsed; /// /// 是否显示SignUp按钮 /// public Visibility SignUpVisible { get { return signUpVisible; } set { SetProperty(ref signUpVisible, value); } } private Visibility nexttimeVisible; public Visibility NextTimeVisible { get { return nexttimeVisible; } set { SetProperty(ref nexttimeVisible, 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); InitItemSource(); } private void InitItemSource() { ItemSource = new ObservableCollection(); ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Office;component/Resources/GuidItems/Guid_Office.png", Title = "PDF Office 全新体验版", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }); ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Office;component/Resources/GuidItems/Guid_Annote.png", Title = "强大的PDF注释工具", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }); ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Office;component/Resources/GuidItems/Guid_Convert.png", Title = "将PDF转换为可编辑Office", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }); ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Office;component/Resources/GuidItems/Guid_FillAndSign.png", Title = "填写表格,签署商务文件", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }); ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Office;component/Resources/GuidItems/Guid_SignUp.png", Title = "注册账号享受全功能", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }); } /// /// 前一页 /// 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) { } } }