Notification changes
[pithos-ms-client] / trunk / Pithos.Client.WPF / SelectiveSynch / SelectiveSynchViewModel.cs
index 50a19cb..00ce722 100644 (file)
@@ -46,6 +46,7 @@ using System.Linq;
 using System.Threading.Tasks;
 using Caliburn.Micro;
 using Pithos.Client.WPF.Properties;
+using Pithos.Client.WPF.Utils;
 using Pithos.Core;
 using Pithos.Interfaces;
 
@@ -78,7 +79,7 @@ namespace Pithos.Client.WPF.SelectiveSynch
         {
             var root = RootNodes[0];            
             _checks = new ObservableCollection<ObjectInfo>(
-                from record in root
+                from DirectoryRecord record in root
                 where record.IsChecked==true
                 select record.ObjectInfo);
             NotifyOfPropertyChange(() => Checks);
@@ -88,7 +89,7 @@ namespace Pithos.Client.WPF.SelectiveSynch
         {
             Account = account;
             AccountName = account.AccountName;
-            DisplayName = account.AccountName;
+            DisplayName = String.Format("Selective folder synchronization for {0}",account.AccountName);
             _monitor = monitor;
             _events = events;
             TaskEx.Run(LoadRootNode);
@@ -98,14 +99,14 @@ namespace Pithos.Client.WPF.SelectiveSynch
         {
             var client = _monitor.CloudClient;
 
-            var dirs = from container in client.ListContainers(_monitor.UserName)
+            var dirs = from container in client.ListContainers(_monitor.UserName)                       
                        select new DirectoryRecord
                                   {
                                       DisplayName = container.Name,
                                       Uri=new Uri(client.StorageUrl,container.Name),
-                                      Directories = (from dir in client.ListObjects(_monitor.UserName, container.Name, "")
+                                      Directories = (from dir in client.ListObjects(_monitor.UserName, container.Name)                                                     
                                                      where dir.Content_Type == DirectoryType
-                                                     select new DirectoryRecord { DisplayName = dir.Name, ObjectInfo = dir }).ToList()
+                                                     select dir).ToTree()
                                   };
             var ownFolders = dirs.ToList();
 
@@ -119,9 +120,9 @@ namespace Pithos.Client.WPF.SelectiveSynch
                                                         {
                                                             DisplayName=container.Name,
                                                             Uri = new Uri(client.StorageUrl, "../" + account.name + "/" + container.Name),
-                                                            Directories=(from folder in client.ListObjects(account.name,container.Name,"")
+                                                            Directories=(from folder in client.ListObjects(account.name,container.Name)
                                                                         where folder.Content_Type==DirectoryType
-                                                                        select new DirectoryRecord{DisplayName=folder.Name,ObjectInfo=folder}).ToList()
+                                                                        select folder).ToTree()
                                                         }).ToList()
                              };                                                          
 
@@ -169,8 +170,8 @@ namespace Pithos.Client.WPF.SelectiveSynch
             //Initially, all nodes are checked
             //We need to *uncheck* the nodes that are not selected
 
-            var selects = from rootRecord in RootNodes
-                          from record in rootRecord
+            var selects = from DirectoryRecord rootRecord in RootNodes
+                          from DirectoryRecord record in rootRecord
                           where record.Uri !=null &&  !selections.Contains(record.Uri.ToString())
                           select record;
 
@@ -181,21 +182,21 @@ namespace Pithos.Client.WPF.SelectiveSynch
 
         public void SaveChanges()
         {
-            var uris = (from root in RootNodes
-                        from record in root
+            var uris = (from DirectoryRecord root in RootNodes
+                        from DirectoryRecord record in root
                         where record.IsChecked == true && record.Uri != null
                         select record.Uri).ToArray();            
 
             SaveSettings(uris);
             
             //RootNodes is an ObservableCollection, it can't be enumerated iterativelly
-            
-            var added= (from root in RootNodes
-                        from record in root
+
+            var added = (from DirectoryRecord root in RootNodes
+                         from DirectoryRecord record in root
                          where record.Added && record.Uri != null
                          select record.Uri).ToArray();
-            var removed = (from root in RootNodes
-                            from record in root
+            var removed = (from DirectoryRecord root in RootNodes
+                           from DirectoryRecord record in root
                           where record.Removed && record.Uri != null
                          select record.Uri).ToArray();
             //TODO: Include Uris for the containers as well