AddBookmarkDialogViewModel.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using PDF_Master.Model;
  2. using Prism.Commands;
  3. using Prism.Mvvm;
  4. using Prism.Services.Dialogs;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace PDF_Master.ViewModels.Dialog.BOTA
  11. {
  12. public class AddBookmarkDialogViewModel : BindableBase, IDialogAware
  13. {
  14. //public string Title => "";
  15. private string title;
  16. public string Title
  17. {
  18. get { return title; }
  19. set { SetProperty(ref title, value); }
  20. }
  21. public event Action<IDialogResult> RequestClose;
  22. private string bookmark;
  23. public string Bookmark
  24. {
  25. get { return bookmark; }
  26. set
  27. {
  28. SetProperty(ref bookmark, value);
  29. }
  30. }
  31. public DelegateCommand CancelCommand { get; set; }
  32. public DelegateCommand CreateCommnad { get; set; }
  33. public AddBookmarkDialogViewModel()
  34. {
  35. CancelCommand = new DelegateCommand(CancelEvent);
  36. CreateCommnad = new DelegateCommand(CreateEvent);
  37. }
  38. private void CreateEvent()
  39. {
  40. DialogParameters valuePairs = new DialogParameters();
  41. valuePairs.Add(ParameterNames.Bookmark, Bookmark);
  42. RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
  43. }
  44. private void CancelEvent()
  45. {
  46. RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
  47. }
  48. public bool CanCloseDialog()
  49. {
  50. return true;
  51. }
  52. public void OnDialogClosed()
  53. {
  54. return;
  55. }
  56. public void OnDialogOpened(IDialogParameters parameters)
  57. {
  58. string mark;
  59. parameters.TryGetValue<string>(ParameterNames.Bookmark, out mark);
  60. Bookmark = mark;
  61. string title;
  62. parameters.TryGetValue<string>(ParameterNames.Title, out title);
  63. Title = title;
  64. return;
  65. }
  66. }
  67. }