ModuleViewModel.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using FlowChartModule.绘制模块;
  2. using Prism.Commands;
  3. using Prism.Ioc;
  4. using Prism.Mvvm;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. namespace FlowChartModule.ViewModels
  13. {
  14. public class ModuleViewModel : BindableBase
  15. {
  16. private string _message;
  17. public string Message
  18. {
  19. get { return _message; }
  20. set { SetProperty(ref _message, value); }
  21. }
  22. public Element _element;
  23. private DrawModule drawModule;
  24. public ModuleViewModel(IContainerProvider container)
  25. {
  26. Draw_Module = container.Resolve<DrawModule>();
  27. Message = "View A from your Prism Module";
  28. }
  29. private DelegateCommand _OpenDataCommand;
  30. public DelegateCommand OpenDataCommand =>
  31. _OpenDataCommand ?? ( _OpenDataCommand = new DelegateCommand(ExecuteOpenDataCommand) );
  32. public void ExecuteOpenDataCommand()
  33. {
  34. Draw_Module.LoadPrograms();
  35. }
  36. private DelegateCommand _SaveDataCommand;
  37. public DelegateCommand SaveDataCommand =>
  38. _SaveDataCommand ?? ( _SaveDataCommand = new DelegateCommand(ExecuteSaveDataCommand) );
  39. public void ExecuteSaveDataCommand()
  40. {
  41. Draw_Module.SavePrograms();
  42. }
  43. private DelegateCommand _ClearDataCommand;
  44. public DelegateCommand ClearDataCommand =>
  45. _ClearDataCommand ?? ( _ClearDataCommand = new DelegateCommand(ExecuteClearDataCommand) );
  46. public void ExecuteClearDataCommand()
  47. {
  48. Draw_Module.ClearPrograms();
  49. }
  50. private DelegateCommand _RunProgramsCommand;
  51. public DelegateCommand RunProgramsCommand =>
  52. _RunProgramsCommand ?? ( _RunProgramsCommand = new DelegateCommand(ExecuteRunProgramsCommand) );
  53. public void ExecuteRunProgramsCommand()
  54. {
  55. Draw_Module.RunPrograms();
  56. }
  57. private DelegateCommand _StopProgramsCommand;
  58. public DelegateCommand StopProgramsCommand =>
  59. _StopProgramsCommand ?? ( _StopProgramsCommand = new DelegateCommand(ExecuteStopProgramsCommand) );
  60. public DrawModule Draw_Module { get => drawModule; set { SetProperty(ref drawModule, value); } }
  61. public void ExecuteStopProgramsCommand()
  62. {
  63. Draw_Module.StopPrograms();
  64. }
  65. }
  66. }