Revision 8f44fd3a trunk/Pithos.Client.WPF/SelectiveSynch/SelectiveSynchViewModel.cs

b/trunk/Pithos.Client.WPF/SelectiveSynch/SelectiveSynchViewModel.cs
49 49
using Pithos.Client.WPF.Utils;
50 50
using Pithos.Core;
51 51
using Pithos.Interfaces;
52
using Pithos.Network;
52 53

  
53 54
namespace Pithos.Client.WPF.SelectiveSynch
54 55
{
......
66 67
        }
67 68

  
68 69
        private ObservableCollection<ObjectInfo> _checks;
69
        private readonly PithosMonitor _monitor;
70
        //private readonly PithosMonitor _monitor;
70 71
        private bool _isBusy=true;
72
        private string _apiKey;
71 73

  
72 74
        public ObservableCollection<ObjectInfo> Checks
73 75
        {
......
84 86
            NotifyOfPropertyChange(() => Checks);
85 87
        }
86 88

  
87
        public SelectiveSynchViewModel(PithosMonitor monitor, IEventAggregator events, AccountSettings account)
89
        public SelectiveSynchViewModel(/*PithosMonitor monitor,*/ IEventAggregator events, AccountSettings account, string apiKey)
88 90
        {
89 91
            Account = account;
90 92
            AccountName = account.AccountName;
91 93
            DisplayName = String.Format("Selective folder synchronization for {0}",account.AccountName);
92
            _monitor = monitor;
94
            //_monitor = monitor;
93 95
            _events = events;
96
            _apiKey = apiKey;
94 97
            TaskEx.Run(LoadRootNode);
95 98
        }
96 99

  
97 100
        private void LoadRootNode()
98
        {
99
            var client = _monitor.CloudClient;
101
        {            
102
            //TODO: Check this
103
            var client = new CloudFilesClient(AccountName,_apiKey){AuthenticationUrl=Account.ServerUrl,UsePithos=true};
104
            client.Authenticate();
105
            
100 106

  
101
            var dirs = from container in client.ListContainers(_monitor.UserName)                       
107
            var dirs = from container in client.ListContainers(AccountName)                       
102 108
                       select new DirectoryRecord
103 109
                                  {
104 110
                                      DisplayName = container.Name,
105 111
                                      Uri=new Uri(client.StorageUrl,String.Format(@"{0}/{1}",Account.AccountName, container.Name)),
106
                                      Directories = (from dir in client.ListObjects(_monitor.UserName, container.Name)                                                     
112
                                      Directories = (from dir in client.ListObjects(AccountName, container.Name)                                                     
107 113
                                                     where dir.IsDirectory
108 114
                                                     select dir).ToTree()
109 115
                                  };
......
173 179
                           from DirectoryRecord record in rootRecord
174 180
                           select record).ToList();
175 181

  
182
            allNodes.Apply(record => record.IsChecked = false);
183

  
176 184
            if (selections.Count == 0)
177 185
            {
178
                allNodes.Apply(record => record.IsChecked = false);
186
            //    allNodes.Apply(record => record.IsChecked = false);
179 187
                return;
180 188
            } 
181 189
            
182 190
            var selects = (from DirectoryRecord rootRecord in RootNodes
183 191
                          from DirectoryRecord record in rootRecord
184
                          where record.Uri !=null &&  !selections.Contains(record.Uri.ToString())
192
                          where record.Uri !=null &&  selections.Contains(record.Uri.ToString())
185 193
                          select record).ToList();
186
            var shouldBeChecked = allNodes.Except(selects).ToList();
194
            //var shouldBeChecked = allNodes.Except(selects).ToList();
187 195

  
188
            selects.Apply(record=>record.IsChecked=false);
196
            selects.Apply(record=>record.IsExplicitlyChecked=true);
189 197

  
190
            shouldBeChecked.Apply(record => record.IsChecked = true);
198
            //shouldBeChecked.Apply(record => record.IsChecked = true);
191 199
            
192 200
            
193 201

  

Also available in: Unified diff