namespace Pithos.Client.WPF {
using System.ComponentModel.Composition;
- [Export(typeof(IShell))]
+
///<summary>
/// The "shell" of the Pithos application displays the taskbar icon, menu and notifications.
/// The shell also hosts the status service called by shell extensions to retrieve file info
/// * ShowFilePropertiesEvent: Raised when a shell command requests the display of the file/container properties dialog
///</remarks>
//TODO: CODE SMELL Why does the shell handle the SelectiveSynchChanges?
+ [Export(typeof(IShell))]
public class ShellViewModel : Screen, IStatusNotification, IShell,
IHandle<Notification>, IHandle<SelectiveSynchChanges>, IHandle<ShowFilePropertiesEvent>
{
StatusMessage = "In Synch";
+ _accounts.CollectionChanged += (sender, e) =>
+ {
+ NotifyOfPropertyChange(() => OpenFolderCaption);
+ NotifyOfPropertyChange(() => HasAccounts);
+ };
+
}
catch (Exception exc)
{
}
}
+
protected override void OnActivate()
{
base.OnActivate();
//If the account is active
if (account.IsActive)
//Start the monitor. It's OK to start an already started monitor,
- //it will just ignore the call
- monitor.Start();
+ //it will just ignore the call
+ StartMonitor(monitor).Wait();
else
{
//If the account is inactive
protected override void OnViewLoaded(object view)
{
- var window = (Window)view;
- window.Hide();
UpdateStatus();
+ var window = (Window)view;
+ TaskEx.Delay(1000).ContinueWith(t => Execute.OnUIThread(window.Hide));
base.OnViewLoaded(view);
}
}
}
- private ObservableConcurrentCollection<AccountInfo> _accounts = new ObservableConcurrentCollection<AccountInfo>();
+ private readonly ObservableConcurrentCollection<AccountInfo> _accounts = new ObservableConcurrentCollection<AccountInfo>();
public ObservableConcurrentCollection<AccountInfo> Accounts
{
get { return _accounts; }
}
+ public bool HasAccounts
+ {
+ get { return _accounts.Count > 0; }
+ }
+
+
+ public string OpenFolderCaption
+ {
+ get
+ {
+ return (_accounts.Count == 0)
+ ? "No Accounts Defined"
+ : "Open Pithos Folder";
+ }
+ }
- private string _pauseSyncCaption="Pause Syncing";
+ private string _pauseSyncCaption="Pause Synching";
public string PauseSyncCaption
{
get { return _pauseSyncCaption; }
}
- private string _statusIcon="../Images/Tray.ico";
+ private string _statusIcon="../Images/Pithos.ico";
public string StatusIcon
{
get { return _statusIcon; }
set
{
- _statusIcon = value;
+ //_statusIcon = value;
NotifyOfPropertyChange(() => StatusIcon);
}
}
}
+ public void GoToSite()
+ {
+ var site = Properties.Settings.Default.PithosSite;
+ Process.Start(site);
+ }
+
public void GoToSite(AccountInfo account)
{
var site = String.Format("{0}/ui/?token={1}&user={2}",
try
{
- var credentials = await PithosAccount.RetrieveCredentialsAsync(Settings.PithosLoginUrl);
+ var credentials = await PithosAccount.RetrieveCredentials(Settings.PithosLoginUrl);
var account = Settings.Accounts.FirstOrDefault(act => act.AccountName == credentials.UserName);
account.ApiKey = credentials.Password;
if (String.IsNullOrWhiteSpace(accountName))
return;
+ var accountInfo=_accounts.FirstOrDefault(account => account.UserName == accountName);
+ _accounts.TryRemove(accountInfo);
+
PithosMonitor monitor;
if (Monitors.TryGetValue(accountName, out monitor))
{