Inheritance: INotifyPropertyChanged
Example #1
0
 public NextVm(NextClient client)
 {
     _client = client;
     PublicFeed = new FeedVm(_client.PublicFeed);
     PrivateFeed = new FeedVm(_client.PrivateFeed);
     _client.LoggedInChanged += async (_, e) =>
         {
             OnPropertyChanged("IsLoggedIn");
             if (IsLoggedIn)
             {
                 List<InstrumentList> instrumentLists = await _client.Lists();
                 foreach (var instrumentList in instrumentLists.OrderBy(x => x.Name))
                 {
                     InstrumentLists.Add(new InstrumentListVm(instrumentList, _client));
                 }
                 List<Account> accounts = await _client.Accounts();
                 accounts.ForEach(Accounts.Add);
             }
         };
     Accounts.CollectionChanged += (o, e) =>
         {
             if (Account.Account != null || Accounts.Count > 1)
                 return;
             Account.Account = Accounts.First();
         };
     Account = new AccountVm(_client, null);
     var loginVm = new LoginVm();
     if (loginVm.Username != null && loginVm.Password != null)
     {
         _client.Login(loginVm.Username, loginVm.Password);
     }
 }
Example #2
0
 public LoginWindow(LoginVm loginVm)
 {
     LoginVm = loginVm;
     InitializeComponent();
     this.DataContext = loginVm;
     PwBox.Password = loginVm.Password;
 }
Example #3
0
 public async Task Login()
 {
     var loginVm = new LoginVm();
     var loginWindow = new LoginWindow(loginVm);
     loginWindow.ShowDialog();
     await _client.Login(loginVm.Username, loginVm.Password);
 }