+
+ public void ShowFileProperties()
+ {
+ var account = Settings.Accounts.First(acc => acc.IsActive);
+ var dir = new DirectoryInfo(account.RootPath + @"\pithos");
+ var files=dir.GetFiles();
+ var r=new Random();
+ var idx=r.Next(0, files.Length);
+ ShowFileProperties(files[idx].FullName);
+ }
+
+ public void ShowFileProperties(string filePath)
+ {
+ if (String.IsNullOrWhiteSpace(filePath))
+ throw new ArgumentNullException("filePath");
+ if (!File.Exists(filePath) && !Directory.Exists(filePath))
+ throw new ArgumentException(String.Format("Non existent file {0}",filePath),"filePath");
+ Contract.EndContractBlock();
+
+ var pair=(from monitor in Monitors
+ where filePath.StartsWith(monitor.Value.RootPath, StringComparison.InvariantCultureIgnoreCase)
+ select monitor).FirstOrDefault();
+ var accountMonitor = pair.Value;
+
+ if (accountMonitor == null)
+ return;
+
+ var infoTask=Task.Factory.StartNew(()=>accountMonitor.GetObjectInfo(filePath));
+
+
+
+ var fileProperties = new FilePropertiesViewModel(this, infoTask,filePath);
+ _windowManager.ShowWindow(fileProperties);
+ }
+
+ public void ShowContainerProperties()
+ {
+ var account = Settings.Accounts.First(acc => acc.IsActive);
+ var dir = new DirectoryInfo(account.RootPath);
+ var fullName = (from folder in dir.EnumerateDirectories()
+ where (folder.Attributes & FileAttributes.Hidden) == 0
+ select folder.FullName).First();
+ ShowContainerProperties(fullName);
+ }
+
+ public void ShowContainerProperties(string filePath)
+ {
+ if (String.IsNullOrWhiteSpace(filePath))
+ throw new ArgumentNullException("filePath");
+ if (!Directory.Exists(filePath))
+ throw new ArgumentException(String.Format("Non existent file {0}",filePath),"filePath");
+ Contract.EndContractBlock();
+
+ var pair=(from monitor in Monitors
+ where filePath.StartsWith(monitor.Value.RootPath, StringComparison.InvariantCultureIgnoreCase)
+ select monitor).FirstOrDefault();
+ var accountMonitor = pair.Value;
+ var info = accountMonitor.GetContainerInfo(filePath);
+
+
+
+ var containerProperties = new ContainerPropertiesViewModel(this, info,filePath);
+ _windowManager.ShowWindow(containerProperties);
+ }
+
+ public void SynchNow()
+ {
+ _pollAgent.SynchNow();
+ }
+
+ public ObjectInfo RefreshObjectInfo(ObjectInfo currentInfo)
+ {
+ if (currentInfo==null)
+ throw new ArgumentNullException("currentInfo");
+ Contract.EndContractBlock();
+ var monitor = Monitors[currentInfo.AccountKey];
+ var newInfo=monitor.CloudClient.GetObjectInfo(currentInfo.Account, currentInfo.Container, currentInfo.Name);
+ return newInfo;
+ }
+
+ public ContainerInfo RefreshContainerInfo(ContainerInfo container)
+ {
+ if (container == null)
+ throw new ArgumentNullException("container");
+ Contract.EndContractBlock();
+
+ var monitor = Monitors[container.AccountKey];
+ var newInfo = monitor.CloudClient.GetContainerInfo(container.Account, container.Name);
+ return newInfo;
+ }
+
+ private bool _isPaused;
+ public bool IsPaused
+ {
+ get { return _isPaused; }
+ set
+ {
+ _isPaused = value;
+ PauseSyncCaption = IsPaused ? "Resume syncing" : "Pause syncing";
+ var iconKey = IsPaused ? "TraySyncPaused" : "TrayInSynch";
+ StatusIcon = String.Format(@"../Images/{0}.ico", iconKey);
+
+ NotifyOfPropertyChange(() => IsPaused);
+ }
+ }
+
+ public void ToggleSynching()
+ {
+ IsPaused=!IsPaused;
+ foreach (var monitor in Monitors.Values)
+ {
+ monitor.Pause = IsPaused ;
+ }
+ _pollAgent.Pause = IsPaused;
+ _networkAgent.Pause = IsPaused;
+
+
+ }