RecipeLoopSetViewModel.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using Caliburn.Micro.Core;
  9. using FurnaceUI.Models;
  10. namespace FurnaceUI.Views.Editors
  11. {
  12. public class RecipeLoopSetViewModel : FurnaceModuleUIViewModelBase
  13. {
  14. public ObservableCollection<ShowStep> StepNames { get; set; }
  15. public string SelectedText { get; set; }
  16. public int SelectedIndex { get; set; }
  17. private string loopCounts = "1";
  18. public string LoopCounts { get { return loopCounts; } set { loopCounts = value; } }
  19. public Visibility LoopCountVisibility { get; set; } = Visibility.Hidden;
  20. public void Save()
  21. {
  22. if (LoopCountVisibility == Visibility.Visible)
  23. SelectedText = $"[{LoopCounts}]*[{StepNames[SelectedIndex].StepName}]";
  24. else
  25. {
  26. SelectedText = $"[{StepNames[SelectedIndex].StepName}]";
  27. }
  28. ((Window)GetView()).DialogResult = true;
  29. }
  30. public void Close()
  31. {
  32. ((Window)GetView()).DialogResult = false;
  33. }
  34. }
  35. public class ShowStep : PropertyChangedBase
  36. {
  37. private int _stepNo;
  38. public int StepNo
  39. {
  40. get => _stepNo;
  41. set
  42. {
  43. _stepNo = value;
  44. NotifyOfPropertyChange("StepNo");
  45. }
  46. }
  47. private string _stepName;
  48. public string StepName
  49. {
  50. get => _stepName;
  51. set
  52. {
  53. _stepName = value;
  54. NotifyOfPropertyChange("StepName");
  55. }
  56. }
  57. }
  58. }