Guest User

Untitled

a guest
Jul 20th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. using System;
  2. using RStein.Posterous.API;
  3. using RStein.PosterousReader.Common;
  4. using RStein.PosterousReader.WP.HostServices;
  5. using System.Windows.Input;
  6.  
  7. namespace RStein.PosterousReader.WP.ViewModels
  8. {
  9. public class LoginViewModel : PosterousViewModelBase
  10. {
  11. private string m_userPassword;
  12. private string m_userName;
  13. private ICommand m_loginCommand;
  14.  
  15. public LoginViewModel(IPosterousApplication posterousApplication, INavigationService navigationService)
  16. : base(posterousApplication, navigationService, String.Empty)
  17. {
  18.  
  19. m_loginCommand = new DelegateCommand<Object>(handleLogin,
  20. (_) => ValidateData());
  21.  
  22. TextChangedAction = () => RaisePropertyChangedEvent(() => LoginCommand);
  23.  
  24. }
  25.  
  26.  
  27. public Action TextChangedAction
  28. {
  29. get;
  30. private set;
  31. }
  32.  
  33.  
  34. public ICommand LoginCommand
  35. {
  36. get
  37. {
  38. return m_loginCommand;
  39. }
  40. }
  41.  
  42.  
  43. public virtual string UserName
  44. {
  45. get
  46. {
  47. return m_userName;
  48. }
  49.  
  50. set
  51. {
  52. m_userName = value;
  53. RaisePropertyChangedEvent(() => UserName);
  54. }
  55. }
  56.  
  57.  
  58.  
  59. public virtual string UserPassword
  60. {
  61. get
  62. {
  63. return m_userPassword;
  64. }
  65.  
  66. set
  67. {
  68. m_userPassword = value;
  69. RaisePropertyChangedEvent(() => UserPassword);
  70. }
  71. }
  72.  
  73.  
  74. public override bool ValidateData()
  75. {
  76. return (!String.IsNullOrEmpty(UserName) &&
  77. (!String.IsNullOrEmpty(UserPassword)));
  78.  
  79. }
  80.  
  81. private void handleLogin(Object ignored)
  82. {
  83. if (!HasValidData)
  84. {
  85. return;
  86. }
  87.  
  88. LastUsedUserName = UserName;
  89. LastUsedPassword = UserPassword;
  90. clearPassword();
  91. NavigationService.Navigate(GlobalConstants.PAGE_POST_LIST_URI);
  92.  
  93. }
  94.  
  95. protected override void DoInternalInit()
  96. {
  97. UserName = LastUsedUserName;
  98. }
  99.  
  100. private void clearPassword()
  101. {
  102. UserPassword = String.Empty;
  103. }
  104. }
  105. }
Add Comment
Please, Sign In to add comment