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 4.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. 
  2. using starter.viewmodel.common;
  3. using System;
  4. using System.Windows;
  5. using System.Windows.Forms;
  6. namespace starter.viewmodel.settings
  7. {
  8. public class SettingsViewModel : NotificationObject
  9. {
  10. /// <summary>
  11. /// Model object
  12. /// </summary>
  13. private SettingsModel obj = new SettingsModel();
  14. /// <summary>
  15. /// initializer
  16. /// </summary>
  17. public SettingsViewModel()
  18. {
  19. if (Downloader.Program.Tencent_cos_download.CheckAlreadyDownload())
  20. {
  21. Installed = true;
  22. }
  23. else
  24. {
  25. Route = Environment.GetEnvironmentVariable("USERPROFILE") + "\\THUAI6";
  26. EditingRoute = true;
  27. }
  28. }
  29. public string Route
  30. {
  31. get
  32. {
  33. return obj.Route;
  34. }
  35. set
  36. {
  37. obj.Route = value;
  38. this.RaisePropertyChanged("Route");
  39. }
  40. }
  41. public bool Installed
  42. {
  43. get
  44. {
  45. return obj.installed;
  46. }
  47. set
  48. {
  49. obj.installed = value;
  50. this.RaisePropertyChanged("Installed");
  51. this.RaisePropertyChanged("InstIntroVis");
  52. this.RaisePropertyChanged("EditIntroVis");
  53. this.RaisePropertyChanged("MoveIntroVis");
  54. }
  55. }
  56. public bool EditingRoute
  57. {
  58. get
  59. {
  60. return obj.EditingRoute;
  61. }
  62. set
  63. {
  64. obj.EditingRoute = value;
  65. this.RaisePropertyChanged("EditingRoute");
  66. this.RaisePropertyChanged("MoveIntroVis");
  67. this.RaisePropertyChanged("RouteBoxVis");
  68. }
  69. }
  70. public Visibility RouteBoxVis //if the route editing textbox is visible
  71. {
  72. get
  73. {
  74. return obj.EditingRoute ? Visibility.Visible : Visibility.Collapsed;
  75. }
  76. }
  77. /// <summary>
  78. /// if the install/edit instruction can be seen
  79. /// </summary>
  80. public Visibility InstIntroVis
  81. {
  82. get
  83. {
  84. return obj.installed ? Visibility.Collapsed : Visibility.Visible;
  85. }
  86. }
  87. public Visibility EditIntroVis
  88. {
  89. get
  90. {
  91. return obj.installed ? Visibility.Visible : Visibility.Collapsed;
  92. }
  93. }
  94. public Visibility MoveIntroVis
  95. {
  96. get
  97. {
  98. if (obj.installed == true && obj.EditingRoute == true)
  99. return Visibility.Visible;
  100. else
  101. return Visibility.Collapsed;
  102. }
  103. }
  104. private BaseCommand clickBrowseCommand;
  105. public BaseCommand ClickBrowseCommand
  106. {
  107. get
  108. {
  109. if (clickBrowseCommand == null)
  110. {
  111. clickBrowseCommand = new BaseCommand(new Action<object>(o =>
  112. {
  113. using (FolderBrowserDialog dialog = new FolderBrowserDialog())
  114. {
  115. _ = dialog.ShowDialog();
  116. if (dialog.SelectedPath != String.Empty)
  117. Route = dialog.SelectedPath;
  118. }
  119. }));
  120. }
  121. return clickBrowseCommand;
  122. }
  123. }
  124. private BaseCommand clickConfirmCommand;
  125. public BaseCommand ClickConfirmCommand
  126. {
  127. get
  128. {
  129. if (clickConfirmCommand == null)
  130. {
  131. clickConfirmCommand = new BaseCommand(new Action<object>(o =>
  132. {
  133. if (obj.install())
  134. {
  135. EditingRoute = false;
  136. Installed = true;
  137. }
  138. }));
  139. }
  140. return clickConfirmCommand;
  141. }
  142. }
  143. }
  144. }