ChartPage1ViewModel.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Prism.Commands;
  2. using Prism.Mvvm;
  3. using Prism.Services.Dialogs;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel.DataAnnotations;
  7. using System.Linq;
  8. using System.Security.Cryptography;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using Validar;
  13. using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
  14. namespace LogoForceTestApp.Modules.MainModule.ViewModels
  15. {
  16. [InjectValidation] //验证表单
  17. internal class ChartPage1ViewModel : BindableBase, IDialogAware
  18. {
  19. public string Title => "chart1";
  20. public event Action<IDialogResult> RequestClose;
  21. [Required]
  22. public string C1 { get; set; }
  23. public string C2 { get; set; }
  24. public string C3 { get; set; }
  25. //[Required] //必须写 // [Range(minimum: 1, maximum: int.MaxValue)] //范围
  26. public string C4 { get; set; }
  27. public string C5 { get; set; }
  28. public DelegateCommand CloseCmd { get; set; }
  29. public ChartPage1ViewModel()
  30. {
  31. CloseCmd = new DelegateCommand(Close);
  32. }
  33. private void Close()
  34. {
  35. if (C1 == null && C2 == null && C3 == null && C4 == null && C5 == null)
  36. {
  37. return;
  38. }
  39. else
  40. {
  41. var dialog = new DialogResult();
  42. dialog.Parameters.Add("c1", C1);
  43. dialog.Parameters.Add("c2", C2);
  44. dialog.Parameters.Add("c3", C3);
  45. dialog.Parameters.Add("c4", C4);
  46. dialog.Parameters.Add("c5", C5);
  47. RequestClose?.Invoke(dialog);
  48. }
  49. }
  50. public bool CanCloseDialog()
  51. {
  52. return true;
  53. }
  54. public void OnDialogClosed()
  55. {
  56. }
  57. public void OnDialogOpened(IDialogParameters parameters)
  58. {
  59. }
  60. }
  61. }