private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private readonly PollAgent _pollAgent;
+ private readonly NetworkAgent _networkAgent;
+ [Import]
+ public Selectives Selectives { get; set; }
private MiniStatusViewModel _miniStatus;
/// The PithosSettings class encapsulates the app's settings to abstract their storage mechanism (App settings, a database or registry)
///</remarks>
[ImportingConstructor]
- public ShellViewModel(IWindowManager windowManager, IEventAggregator events, IStatusChecker statusChecker, PithosSettings settings,PollAgent pollAgent)
+ public ShellViewModel(IWindowManager windowManager, IEventAggregator events, IStatusChecker statusChecker, PithosSettings settings,PollAgent pollAgent,NetworkAgent networkAgent)
{
try
{
_events.Subscribe(this);
_pollAgent = pollAgent;
+ _networkAgent = networkAgent;
Settings = settings;
Proxy.SetFromSettings(settings);
PithosMonitor monitor;
var accountName = account.AccountName;
+ MigrateFolders(account);
+
+ Selectives.SetIsSelectiveEnabled(account.AccountKey, account.SelectiveSyncEnabled);
+
if (Monitors.TryGetValue(account.AccountKey, out monitor))
{
//If the account is active
});
}
+ private void MigrateFolders(AccountSettings account)
+ {
+ var oldOthersFolder=Path.Combine(account.RootPath, FolderConstants.OldOthersFolder);
+ var newOthersFolder = Path.Combine(account.RootPath, FolderConstants.OthersFolder);
+ var oldFolder = new DirectoryInfo(oldOthersFolder);
+ var newFolder = new DirectoryInfo(newOthersFolder);
+
+ if (oldFolder.Exists && !newFolder.Exists)
+ {
+ oldFolder.MoveTo(newOthersFolder);
+ }
+ }
- protected override void OnViewLoaded(object view)
+
+ protected override void OnViewLoaded(object view)
{
UpdateStatus();
var window = (Window)view;
}
}
+ public string TooltipMiniStatus
+ {
+ get
+ {
+ return String.Format("{0}\r\n{1}", "Status Window", "Enable / Disable the status window");
+ }
+ }
+
public string ToggleStatusWindowMessage
{
get
#region Commands
+ public void CancelCurrentOperation()
+ {
+ _networkAgent.CancelCurrentOperation();
+ }
+
public void ShowPreferences()
{
ShowPreferences(null);
public void ShowPreferences(string currentTab)
{
//Settings.Reload();
+
var preferences = new PreferencesViewModel(_windowManager, _events, this, Settings,currentTab);
_windowManager.ShowDialog(preferences);
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()
+ public void ToggleSynching()
{
- bool isPaused=false;
- foreach (var pair in Monitors)
+ IsPaused=!IsPaused;
+ foreach (var monitor in Monitors.Values)
{
- var monitor = pair.Value;
- monitor.Pause = !monitor.Pause;
- isPaused = monitor.Pause;
+ monitor.Pause = IsPaused ;
}
-
+ _pollAgent.Pause = IsPaused;
+ _networkAgent.Pause = IsPaused;
+
- PauseSyncCaption = isPaused ? "Resume syncing" : "Pause syncing";
- var iconKey = isPaused? "TraySyncPaused" : "TrayInSynch";
- StatusIcon = String.Format(@"../Images/{0}.ico", iconKey);
}
public void ExitPithos()
#region Event Handlers
public void Handle(SelectiveSynchChanges message)
- {
- PithosMonitor monitor;
- if (Monitors.TryGetValue(message.Account.AccountKey, out monitor))
- {
- monitor.SetSelectivePaths(message.Uris, message.Added, message.Removed);
-
- }
-
- var account = Accounts.FirstOrDefault(acc => acc.AccountKey == message.Account.AccountKey);
- if (account!=null)
- {
- this._pollAgent.SetSelectivePaths(account, message.Added, message.Removed);
- }
-
+ {
+ TaskEx.Run(() =>
+ {
+ PithosMonitor monitor;
+ if (Monitors.TryGetValue(message.Account.AccountKey, out monitor))
+ {
+ Selectives.SetIsSelectiveEnabled(message.Account.AccountKey, message.Enabled);
+ monitor.SetSelectivePaths(message.Uris, message.Added, message.Removed);
+ }
+
+ var account = Accounts.FirstOrDefault(acc => acc.AccountKey == message.Account.AccountKey);
+ if (account != null)
+ {
+ this._pollAgent.SetSelectivePaths(account, message.Added, message.Removed);
+ }
+ });
- }
+ }
private bool _pollStarted;