\r
[ImportingConstructor]\r
public PreferencesViewModel(IWindowManager windowManager, IEventAggregator events, ShellViewModel shell, PithosSettings settings)\r
- :this(windowManager,events,shell,settings,null)\r
{\r
this.DisplayName = "Pithos+ Preferences";\r
- }\r
\r
- public PreferencesViewModel(IWindowManager windowManager, IEventAggregator events, ShellViewModel shell, PithosSettings settings, string currentTab)\r
- {\r
// ReSharper disable DoNotCallOverridableMethodsInConstructor\r
//Caliburn.Micro uses DisplayName for the view's title\r
DisplayName = "Pithos+ Preferences";\r
\r
Settings=settings;\r
Accounts = new ObservableConcurrentCollection<AccountViewModel>();\r
- if (settings.Accounts == null)\r
- {\r
- settings.Accounts=new AccountsCollection();\r
- settings.Save();\r
- }\r
- var accountVMs = from account in settings.Accounts\r
- select new AccountViewModel(account);\r
-\r
- Accounts.AddFromEnumerable(accountVMs);\r
+ \r
\r
var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);\r
_shortcutPath = Path.Combine(startupPath, "Pithos.lnk");\r
\r
StartOnSystemStartup = File.Exists(_shortcutPath);\r
\r
- SelectedTab = currentTab;\r
+ //SelectedTab = currentTab;\r
+ }\r
+\r
+ protected override void OnViewLoaded(object view)\r
+ {\r
+ base.OnViewLoaded(view);\r
+ Settings.Reload();\r
+ Accounts.Clear();\r
+\r
+ if (Settings.Accounts == null)\r
+ {\r
+ Settings.Accounts = new AccountsCollection();\r
+ Settings.Save();\r
+ }\r
+ var accountVMs = from account in Settings.Accounts\r
+ select new AccountViewModel(account);\r
+\r
+ Accounts.AddFromEnumerable(accountVMs);\r
}\r
\r
private string _selectedTab="General";\r
{\r
//var monitor = Shell.Monitors[CurrentAccount.AccountKey];\r
\r
-\r
+ \r
var model = new SelectiveSynchViewModel(_events,CurrentAccount.Account,CurrentAccount.ApiKey,false); \r
if (_windowManager.ShowDialog(model) == true)\r
{\r
tuple.ObjectInfo.X_Object_Hash);\r
\r
StatusKeeper.StoreInfo(targetPath, tuple.ObjectInfo);\r
+\r
+ AddRootFolderToSelectives(accountInfo, tuple, targetPath);\r
}\r
\r
/*\r
}\r
}\r
else\r
- {\r
+ { \r
+\r
//Local changes found\r
\r
//Server unchanged?\r
//Detect server moves\r
var targetPath = MoveForServerMove(accountInfo, tuple);\r
StatusKeeper.StoreInfo(targetPath, tuple.ObjectInfo);\r
+ \r
+ AddRootFolderToSelectives(accountInfo, tuple, targetPath);\r
}\r
else\r
{\r
}\r
}\r
\r
+ private void AddRootFolderToSelectives(AccountInfo accountInfo, StateTuple tuple, string targetPath)\r
+ {\r
+ //Also ensure that any newly created folders are added to the selectives, if the original folder was selected\r
+ var containerPath = Path.Combine(accountInfo.AccountPath, tuple.ObjectInfo.Container);\r
+\r
+ //If this is a root folder encountered for the first time\r
+ if (tuple.L == null && Directory.Exists(tuple.FileInfo.FullName) \r
+ && (tuple.FileInfo.FullName.IsAtOrDirectlyBelow(containerPath)))\r
+ {\r
+ \r
+ var relativePath = tuple.ObjectInfo.RelativeUrlToFilePath(accountInfo.UserName);\r
+ var initialPath = Path.Combine(accountInfo.AccountPath, relativePath);\r
+\r
+ var hasMoved = true;// !initialPath.Equals(targetPath);\r
+ if (hasMoved && Selectives.IsSelected(accountInfo, initialPath))\r
+ {\r
+ Selectives.AddUri(accountInfo, tuple.ObjectInfo.Uri);\r
+ Selectives.Save(accountInfo);\r
+ }\r
+ }\r
+ }\r
+\r
private string MoveForServerMove(AccountInfo accountInfo, StateTuple tuple)\r
{\r
if (tuple.ObjectInfo == null)\r