CheckPasswordDialogViewModel.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using ComPDFKit.PDFDocument;
  2. using PDF_Office.Model;
  3. using PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs;
  4. using Prism.Commands;
  5. using Prism.Mvvm;
  6. using Prism.Services.Dialogs;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Xml.Linq;
  11. namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.SaftyDialogs
  12. {
  13. public class CheckPasswordDialogViewModel : BindableBase,IDialogAware
  14. {
  15. private CPDFDocument document;
  16. public DelegateCommand DelegateConfirmCheckPasswordCommand { get; set; }
  17. public DelegateCommand DelegateCancelCheckPasswordCommand { get; set; }
  18. public CheckPasswordDialogViewModel()
  19. {
  20. CheckPasswordDialogModel.Password = "";
  21. DelegateConfirmCheckPasswordCommand = new DelegateCommand(ConfirmCheckPassword);
  22. DelegateCancelCheckPasswordCommand = new DelegateCommand(CancelCheckPassword);
  23. }
  24. private void ConfirmCheckPassword()
  25. {
  26. if (false)//预留接口
  27. {
  28. }
  29. var dialogResult = new DialogResult(ButtonResult.OK);
  30. dialogResult.Parameters.Add("CheckPassword", true);
  31. RequestClose.Invoke(dialogResult);
  32. }
  33. private void CancelCheckPassword()
  34. {
  35. var dialogResult = new DialogResult(ButtonResult.Cancel);
  36. dialogResult.Parameters.Add("CheckPassword", false);
  37. RequestClose.Invoke(dialogResult);
  38. }
  39. public string Title =>"";
  40. public event Action<IDialogResult> RequestClose;
  41. public bool CanCloseDialog()
  42. {
  43. return true;
  44. }
  45. public void OnDialogClosed()
  46. {
  47. }
  48. public void OnDialogOpened(IDialogParameters parameters)
  49. {
  50. CPDFDocument doc = null;
  51. parameters.TryGetValue<CPDFDocument>(ParameterNames.PDFDocument, out doc);
  52. if (doc != null)
  53. {
  54. document = doc;
  55. }
  56. }
  57. }
  58. }