CheckPasswordDialogViewModel.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #region 参数和属性
  16. private CPDFDocument document;
  17. #endregion
  18. #region 委托声明
  19. public DelegateCommand DelegateConfirmCheckPasswordCommand { get; set; }
  20. public DelegateCommand DelegateCancelCheckPasswordCommand { get; set; }
  21. #endregion
  22. public CheckPasswordDialogViewModel()
  23. {
  24. CheckPasswordDialogModel.Password = "";
  25. DelegateConfirmCheckPasswordCommand = new DelegateCommand(ConfirmCheckPassword);
  26. DelegateCancelCheckPasswordCommand = new DelegateCommand(CancelCheckPassword);
  27. }
  28. #region 逻辑函数
  29. private void ConfirmCheckPassword()
  30. {
  31. if (false)//TODO: 用于检测输入密码的权限,以及是否输入了正确的密码
  32. { }
  33. var dialogResult = new DialogResult(ButtonResult.OK);
  34. dialogResult.Parameters.Add("CheckPassword", true);
  35. RequestClose.Invoke(dialogResult);
  36. }
  37. private void CancelCheckPassword()
  38. {
  39. var dialogResult = new DialogResult(ButtonResult.Cancel);
  40. dialogResult.Parameters.Add("CheckPassword", false);
  41. RequestClose.Invoke(dialogResult);
  42. }
  43. #endregion
  44. #region 框架相关
  45. public string Title =>"";
  46. public event Action<IDialogResult> RequestClose;
  47. public bool CanCloseDialog()
  48. {
  49. return true;
  50. }
  51. public void OnDialogClosed()
  52. {
  53. }
  54. public void OnDialogOpened(IDialogParameters parameters)
  55. {
  56. CPDFDocument doc = null;
  57. parameters.TryGetValue<CPDFDocument>(ParameterNames.PDFDocument, out doc);
  58. if (doc != null)
  59. {
  60. document = doc;
  61. }
  62. }
  63. #endregion
  64. }
  65. }