// TODO: this is all kinds of wrong public LoginWindowViewModel(PasswordBox password, LoginWindow loginWindow) { pb = password; pb.PasswordChanged += (sender, args) => raisePropertyChanged("Password"); var canSave = this.WhenAny( x => x.Username, x => x.Password, (user, pass) => (!string.IsNullOrWhiteSpace(user.Value) && !string.IsNullOrEmpty(pass.Value)) ); Save = new ReactiveCommand(canSave); Save.Subscribe(o => { Settings.Username = Username; Settings.Password = pb.Password; loginWindow.Close(); }); }
protected override void OnStartup(StartupEventArgs e) { try { streamza = new Streamza(Settings.Username, Settings.Password); } catch (AuthenticationException) { Settings.Password = ""; while (Settings.Empty) { var lw = new LoginWindow(); lw.ShowDialog(); LogTo.Trace("Login window visibility: {0}", lw.IsVisible); try { streamza = new Streamza(Settings.Username, Settings.Password); } catch (AuthenticationException) { Settings.Password = ""; } } } // If we're passed a Uri, add it and quit if (e.Args != null && e.Args.Length > 0) { streamza.AddTorrent(e.Args[0]); // TODO: Verify that args[0] is a proper Uri Shutdown(); } base.OnStartup(e); }