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.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. return obj.Route;
  25. }
  26. set {
  27. obj.Route = value;
  28. this.RaisePropertyChanged("Route");
  29. }
  30. }
  31. public bool CanEditRoute // if the user can still edit install route
  32. {
  33. get {
  34. return !obj.HaveRoute;
  35. }
  36. set {
  37. obj.HaveRoute = !value;
  38. obj.EditingRoute = value;
  39. this.RaisePropertyChanged("CanEditRoute");
  40. }
  41. }
  42. private BaseCommand clickBrowseCommand;
  43. public BaseCommand ClickBrowseCommand
  44. {
  45. get {
  46. if (clickBrowseCommand == null)
  47. {
  48. clickBrowseCommand = new BaseCommand(new Action<object>(o =>
  49. {
  50. using (FolderBrowserDialog dialog = new FolderBrowserDialog())
  51. {
  52. _ = dialog.ShowDialog();
  53. if (dialog.SelectedPath != String.Empty)
  54. Route = dialog.SelectedPath;
  55. }
  56. }));
  57. }
  58. return clickBrowseCommand;
  59. }
  60. }
  61. private BaseCommand clickConfirmCommand;
  62. public BaseCommand ClickConfirmCommand
  63. {
  64. get {
  65. if (clickConfirmCommand == null)
  66. {
  67. clickConfirmCommand = new BaseCommand(new Action<object>(o =>
  68. {
  69. CanEditRoute = false;
  70. obj.install();
  71. }));
  72. }
  73. return clickConfirmCommand;
  74. }
  75. }
  76. }
  77. }