public LoginPresenter(ILoginView view, IChatHubProxy proxy, INavigationService navigationService) { _view = view; _proxy = proxy; _navigationService = navigationService; _view.PropertyChanged += (s, e) => _view.SetLoginEnabled(proxy.IsConnected && !_isLoggingIn && !String.IsNullOrWhiteSpace(_view.UserName)); _view.Login += _view_Login; _proxy.Connected = (detail, details) => { }; Action connect = async () => { _isLoggingIn = true; try { await proxy.Connect(); } finally { _isLoggingIn = false; } }; connect.Invoke(); }
public LoginViewModel(IChatHubProxy proxy, IRegionManager rm) { _proxy = proxy; Login = new DelegateCommand(async () => { IsLoggingIn = true; try { await proxy.Login(Username); } finally { IsLoggingIn = false; } }, () => IsConnected && !IsLoggingIn && !String.IsNullOrWhiteSpace(Username)); proxy.Connected = (detail, details) => rm.RequestNavigate(RegionNames.MainRegion, new Uri("ChatView", UriKind.Relative)); Reconnect = new DelegateCommand(async () => await Connect(), () => !IsConnected && !IsConnecting); Reconnect.Execute(); }