public SignInViewModel(IScreen screen) { HostScreen = screen; this.NotifyMsgVM = new NotifyMsgViewModel(); this.WaitingPanelVM = Locator.CurrentMutable.GetService <WaitingPanelViewModel>(); this.SignInCommand = ReactiveCommand.Create( this.WhenAny(x => x.UserName, x => x.Password, (x1, x2) => !string.IsNullOrEmpty(x1.Value) && !string.IsNullOrEmpty(x2.Value))); this.SwitchSignUpCommand = ReactiveCommand.Create(); this.SignInCommand.Subscribe(o => this.SignIn(o)); this.SwitchSignUpCommand.Subscribe(o => { this.HostScreen.Router.NavigateCommandFor <SignUpViewModel>().Execute(this.HostScreen); }); if (Loginer.CurrCC == null) { var cc = Locator.Current.GetService <CC.ICommunication>(); cc.ConnectedCallbackHandler = this.ConnectedCallback; cc.SignInCallbackHandler = this.SignInCallback; cc.DownloadAvatarCallbackHandler = this.DownloadAvatarCallback; cc.ErrorCallbackHandler = this.ErrorCallback; Loginer.CurrCC = cc; this.Connect(); } }
public SignUpViewModel(IScreen screen) { HostScreen = screen; this.NotifyMsgVM = new NotifyMsgViewModel(); this.WaitingPanelVM = Locator.CurrentMutable.GetService <WaitingPanelViewModel>(); this.SignUpCommand = ReactiveCommand.Create(this.WhenAny( x => x.UserName, x => x.Email, x => x.Password, x => x.Password2, (x1, x2, x3, x4) => !string.IsNullOrEmpty(x1.Value) && !string.IsNullOrEmpty(x2.Value) && !string.IsNullOrEmpty(x3.Value) && !string.IsNullOrEmpty(x4.Value))); this.SwitchSignInCommand = ReactiveCommand.Create(); this.SignUpCommand.Subscribe(o => this.SignUp(o)); this.SwitchSignInCommand.Subscribe(o => { this.HostScreen.Router.NavigateCommandFor <SignInViewModel>().Execute(this.HostScreen); }); Loginer.CurrCC.SignUpCallbackHandler += (res) => { this.ToggleWaiting(false); if (res.Success) { this.HostScreen.Router.NavigateCommandFor <SignInViewModel>().Execute(this.HostScreen); } else { this.NotifyMsgVM.Msg = res.RMsg; } }; }