PurgeDialogViewModel.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using OpenSEMI.ClientBase;
  2. namespace MECF.Framework.UI.Client.CenterViews.Dialogs
  3. {
  4. public class PurgeDialogViewModel : DialogViewModel<string>
  5. {
  6. public int CycleCountValue { get; set; }
  7. public double PumpPressureValue { get; set; }
  8. public double VentPressureValue { get; set; }
  9. public string CycleCount { get; set; }
  10. public string PumpPressure { get; set; }
  11. public string VentPressure { get; set; }
  12. public void OK()
  13. {
  14. if (!int.TryParse(CycleCount, out int cycleCount) || cycleCount<0)
  15. {
  16. DialogBox.ShowWarning($"{CycleCount} is not a valid cycle count value");
  17. return;
  18. }
  19. if (!double.TryParse(PumpPressure, out double pumpPressureValue) || pumpPressureValue < 0)
  20. {
  21. DialogBox.ShowWarning($"{PumpPressure} is not a valid pump base value");
  22. return;
  23. }
  24. if (!double.TryParse(VentPressure, out double ventPressureValue) || ventPressureValue < 0)
  25. {
  26. DialogBox.ShowWarning($"{VentPressure} is not a valid vent pressure value");
  27. return;
  28. }
  29. if (pumpPressureValue >= ventPressureValue)
  30. {
  31. DialogBox.ShowWarning($"Pump pressure {pumpPressureValue} should be less than {ventPressureValue}");
  32. return;
  33. }
  34. CycleCountValue = cycleCount;
  35. PumpPressureValue = pumpPressureValue;
  36. VentPressureValue = ventPressureValue;
  37. IsCancel = false;
  38. TryClose(true);
  39. }
  40. public void Cancel()
  41. {
  42. IsCancel = true;
  43. TryClose(false);
  44. }
  45. }
  46. }