ExtractDialogViewModel.cs 2.2 KB

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