Revision 29a6b387 trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs

b/trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs
39 39
using System.Collections.Concurrent;
40 40
using System.ComponentModel.Composition;
41 41
using System.IO;
42
using System.Net;
42 43
using System.Reflection;
43 44
using System.Windows;
44 45
using System.Windows.Forms;
......
214 215
        private void DoSave()
215 216
        {
216 217
            Settings.Save();
217
            SetStartupMode();
218
            //SetStartupMode();
218 219

  
219 220

  
220 221
            foreach (var account in Settings.Accounts)
......
262 263
            }
263 264
        }
264 265
*/
266

  
267
        private WebProxy ProxyFromSettings()
268
        {
269
            if (Settings.UseManualProxy)
270
            {
271
                var proxy = new WebProxy(Settings.ProxyServer, Settings.ProxyPort);
272
                //If the proxy requires specific authentication settings, use them
273
                if (Settings.ProxyAuthentication)
274
                {
275
                    proxy.Credentials = new NetworkCredential(Settings.ProxyUsername, Settings.ProxyPassword, Settings.ProxyDomain);
276
                }
277
                //Otherwise, if there are generic authentication settings, use them
278
                if (!String.IsNullOrWhiteSpace(CredentialCache.DefaultNetworkCredentials.UserName))
279
                {
280
                    proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
281
                }
282
                return proxy;
283
            }
284
            return null;
285
        }
286

  
265 287
       public void AddAccount()
266 288
       {
267
           var wizard = new AddAccountViewModel();
289
           var wizard = new AddAccountViewModel {Proxy = ProxyFromSettings()};
268 290
           if (_windowManager.ShowDialog(wizard) == true)
269 291
           {
292
               string selectedPath = wizard.AccountPath;
293
               var initialRootPath = Path.Combine(selectedPath, "Okeanos");
294
               var actualRootPath= initialRootPath;
295
               int attempt = 1;
296
               while (Directory.Exists(actualRootPath) || File.Exists(actualRootPath))
297
               {
298
                   actualRootPath = String.Format("{0} {1}", initialRootPath,attempt++);
299
               }
300

  
270 301
               var newAccount = new AccountSettings
271 302
                                    {
272 303
                                        AccountName = wizard.AccountName,
273 304
                                        ServerUrl=wizard.CurrentServer,
274 305
                                        ApiKey=wizard.Token,
275
                                        RootPath=wizard.AccountPath,
306
                                        RootPath = actualRootPath,
276 307
                                        IsActive=wizard.IsAccountActive
277 308
                                    };
278 309
               Settings.Accounts.Add(newAccount);

Also available in: Unified diff