123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- 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<IDialogResult> RequestClose;
- private int selectedIndex;
- /// <summary>
- /// 选中索引
- /// </summary>
- 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;
- /// <summary>
- /// 是否显示SignUp按钮
- /// </summary>
- 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<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();
- }
- private void nexttime()
- {
- //忽略,下次再看
- this.RequestClose(new DialogResult(ButtonResult.Ignore));
- }
- private void InitItemSource()
- {
- ItemSource = new ObservableCollection<GuidItemModel>();
- ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_Office.png", Title = "PDF Master 全新体验版", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
- ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_Annote.png", Title = "强大的PDF注释工具", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
- ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_Convert.png", Title = "将PDF转换为可编辑Office", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
- ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_FillAndSign.png", Title = "填写表格,签署商务文件", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
- ItemSource.Add(new GuidItemModel() { ImageSource = "pack://application:,,,/PDF Master;component/Resources/GuidItems/Guid_SignUp.png", Title = "注册账号享受全功能", Content = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" });
- }
- /// <summary>
- /// 前一页
- /// </summary>
- private void NextPage()
- {
- SelectedIndex++;
- }
- /// <summary>
- /// 下一页
- /// </summary>
- private void PrePage()
- {
- SelectedIndex--;
- }
- /// <summary>
- /// 注册
- /// </summary>
- private void SignUp()
- {
- RequestClose.Invoke(new DialogResult());
- 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)
- {
-
- }
- }
- }
|