Revision 153975d0 trunk/Pithos.Client.WPF/PreferencesViewModel.cs

b/trunk/Pithos.Client.WPF/PreferencesViewModel.cs
151 151
        {
152 152
            Settings.Save();
153 153
            NotifyOfPropertyChange(()=>Settings);
154

  
155
            var activeAccount = Settings.Accounts.FirstOrDefault(account => account.IsActive);
156
            if (activeAccount == null)
157
                return;
158
            if (String.IsNullOrWhiteSpace(activeAccount.AccountName))
159
                return;
160

  
161
            Monitor.ApiKey = activeAccount.ApiKey;
162
            Monitor.UserName = activeAccount.AccountName;
163
            Monitor.UsePithos = activeAccount.UsePithos;
164

  
154 165
            Monitor.Start();
155 166
        }
156 167

  
......
226 237
            get { return _selectedAccountIndex; }
227 238
            set
228 239
            {
229
                _selectedAccountIndex = value;
240
                //var accountCount=Settings.Accounts.Count;
241
                //if (accountCount == 0)
242
                //    return;
243
                //if (0 <= value && value < accountCount)
244
                //    _selectedAccountIndex = value;
245
                //else
246
                //    _selectedAccountIndex = 0;
230 247
                NotifyOfPropertyChange(() => CurrentAccount);
231 248
                NotifyOfPropertyChange(() => CanRemoveAccount);
232 249
                NotifyOfPropertyChange(()=>SelectedAccountIndex);
......
236 253
        private AccountSettings _currentAccount;
237 254
        public AccountSettings CurrentAccount
238 255
        {
239
            get { return Settings.Accounts[SelectedAccountIndex]; }
256
            get {
257
                if (0 <= SelectedAccountIndex && SelectedAccountIndex < Settings.Accounts.Count)                    
258
                    return Settings.Accounts[SelectedAccountIndex];
259
                return null;
260
            }
240 261
/*
241 262
            set
242 263
            {

Also available in: Unified diff