SelectExistViewModel.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using FurnaceUI.Models;
  8. namespace FurnaceUI.Client.Dialog
  9. {
  10. public class SelectExistViewModel : FurnaceUIViewModelBase
  11. {
  12. private SelectExistView _view;
  13. public string DialogResultString { get; set; }
  14. private string _productZeroStr;
  15. public string ProductZeroStr
  16. {
  17. get => _productZeroStr;
  18. set
  19. {
  20. _productZeroStr = value;
  21. NotifyOfPropertyChange(nameof(ProductZeroStr));
  22. }
  23. }
  24. protected override void OnViewLoaded(object view)
  25. {
  26. base.OnViewLoaded(view);
  27. _view=(SelectExistView)view;
  28. LoadSetDefaultOption(view);
  29. }
  30. private void LoadSetDefaultOption(object view)
  31. {
  32. if (_view != null && !string.IsNullOrEmpty(ProductZeroStr))
  33. {
  34. switch (ProductZeroStr.ToLower())
  35. {
  36. case "none":
  37. _view.RdoNone.IsChecked = true;
  38. break;
  39. case "exist":
  40. _view.RdoExist.IsChecked = true;
  41. break;
  42. default:
  43. break;
  44. }
  45. }
  46. }
  47. public void SelectExistClick(string cmd,object obj)
  48. {
  49. DialogResultString = cmd;
  50. if (cmd == "Cancel")
  51. {
  52. ((Window)GetView()).DialogResult = false;
  53. }
  54. else
  55. {
  56. ((Window)GetView()).DialogResult = true;
  57. }
  58. }
  59. }
  60. }