You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ViewModel.cs 2.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. 
  2. using starter.viewmodel.common;
  3. using System;
  4. using System.Windows.Forms;
  5. namespace starter.viewmodel.settings
  6. {
  7. public class SettingsViewModel : NotificationObject
  8. {
  9. /// <summary>
  10. /// Model object
  11. /// </summary>
  12. private SettingsModel obj = new SettingsModel();
  13. /// <summary>
  14. /// initializer
  15. /// </summary>
  16. public SettingsViewModel()
  17. {
  18. Route = Environment.GetEnvironmentVariable("USERPROFILE") + "\\THUAI6";
  19. CanEditRoute = true;
  20. }
  21. public string Route
  22. {
  23. get
  24. {
  25. return obj.Route;
  26. }
  27. set
  28. {
  29. obj.Route = value;
  30. this.RaisePropertyChanged("Route");
  31. }
  32. }
  33. public bool CanEditRoute // if the user can still edit install route
  34. {
  35. get
  36. {
  37. return !obj.HaveRoute;
  38. }
  39. set
  40. {
  41. obj.HaveRoute = !value;
  42. obj.EditingRoute = value;
  43. this.RaisePropertyChanged("CanEditRoute");
  44. }
  45. }
  46. private BaseCommand clickBrowseCommand;
  47. public BaseCommand ClickBrowseCommand
  48. {
  49. get
  50. {
  51. if (clickBrowseCommand == null)
  52. {
  53. clickBrowseCommand = new BaseCommand(new Action<object>(o =>
  54. {
  55. using (FolderBrowserDialog dialog = new FolderBrowserDialog())
  56. {
  57. _ = dialog.ShowDialog();
  58. if (dialog.SelectedPath != String.Empty)
  59. Route = dialog.SelectedPath;
  60. }
  61. }));
  62. }
  63. return clickBrowseCommand;
  64. }
  65. }
  66. private BaseCommand clickConfirmCommand;
  67. public BaseCommand ClickConfirmCommand
  68. {
  69. get
  70. {
  71. if (clickConfirmCommand == null)
  72. {
  73. clickConfirmCommand = new BaseCommand(new Action<object>(o =>
  74. {
  75. CanEditRoute = false;
  76. obj.install();
  77. }));
  78. }
  79. return clickConfirmCommand;
  80. }
  81. }
  82. }
  83. }