Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using RStein.Posterous.API;
- using RStein.PosterousReader.Common;
- using RStein.PosterousReader.WP.HostServices;
- using System.Windows.Input;
- namespace RStein.PosterousReader.WP.ViewModels
- {
- public class LoginViewModel : PosterousViewModelBase
- {
- private string m_userPassword;
- private string m_userName;
- private ICommand m_loginCommand;
- public LoginViewModel(IPosterousApplication posterousApplication, INavigationService navigationService)
- : base(posterousApplication, navigationService, String.Empty)
- {
- m_loginCommand = new DelegateCommand<Object>(handleLogin,
- (_) => ValidateData());
- TextChangedAction = () => RaisePropertyChangedEvent(() => LoginCommand);
- }
- public Action TextChangedAction
- {
- get;
- private set;
- }
- public ICommand LoginCommand
- {
- get
- {
- return m_loginCommand;
- }
- }
- public virtual string UserName
- {
- get
- {
- return m_userName;
- }
- set
- {
- m_userName = value;
- RaisePropertyChangedEvent(() => UserName);
- }
- }
- public virtual string UserPassword
- {
- get
- {
- return m_userPassword;
- }
- set
- {
- m_userPassword = value;
- RaisePropertyChangedEvent(() => UserPassword);
- }
- }
- public override bool ValidateData()
- {
- return (!String.IsNullOrEmpty(UserName) &&
- (!String.IsNullOrEmpty(UserPassword)));
- }
- private void handleLogin(Object ignored)
- {
- if (!HasValidData)
- {
- return;
- }
- LastUsedUserName = UserName;
- LastUsedPassword = UserPassword;
- clearPassword();
- NavigationService.Navigate(GlobalConstants.PAGE_POST_LIST_URI);
- }
- protected override void DoInternalInit()
- {
- UserName = LastUsedUserName;
- }
- private void clearPassword()
- {
- UserPassword = String.Empty;
- }
- }
- }
Add Comment
Please, Sign In to add comment