ChartPage2ViewModel.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.Text;
  9. using System.Threading.Tasks;
  10. using Validar;
  11. namespace LogoForceTestApp.Modules.MainModule.ViewModels
  12. {
  13. [InjectValidation] //验证表单
  14. internal class ChartPage2ViewModel : BindableBase, IDialogAware
  15. {
  16. public string Title => "chart2";
  17. public event Action<IDialogResult> RequestClose;
  18. public bool CanCloseDialog()
  19. {
  20. return true;
  21. }
  22. public void OnDialogClosed()
  23. {
  24. }
  25. public void OnDialogOpened(IDialogParameters parameters)
  26. {
  27. }
  28. public string C1 { get; set; }
  29. public string C2 { get; set; }
  30. public string C3 { get; set; }
  31. public string C4 { get; set; }
  32. public string C5 { get; set; }
  33. public DelegateCommand CloseCmd { get; set; }
  34. public ChartPage2ViewModel()
  35. {
  36. CloseCmd = new DelegateCommand(Close);
  37. }
  38. private void Close()
  39. {
  40. if (C1 == null && C2 == null && C3 == null && C4 == null && C5 == null)
  41. {
  42. return;
  43. }
  44. else
  45. {
  46. var dialog = new DialogResult();
  47. dialog.Parameters.Add("c1", C1);
  48. dialog.Parameters.Add("c2", C2);
  49. dialog.Parameters.Add("c3", C3);
  50. dialog.Parameters.Add("c4", C4);
  51. dialog.Parameters.Add("c5", C5);
  52. RequestClose?.Invoke(dialog);
  53. }
  54. }
  55. }
  56. }