X-Git-Url: https://code.grnet.gr/git/pithos-ms-client/blobdiff_plain/c92e02f313ee693940bc0652bc13c1203ff13ddd..0338939c8fae9f98d2bc6d6051d371c3e0dffbd6:/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs diff --git a/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs index a4ae7f8..da7cf3c 100644 --- a/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs +++ b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs @@ -31,7 +31,7 @@ using StatusService = Pithos.Client.WPF.Services.StatusService; namespace Pithos.Client.WPF { using System.ComponentModel.Composition; - [Export(typeof(IShell))] + /// /// 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 @@ -44,6 +44,7 @@ namespace Pithos.Client.WPF { /// * ShowFilePropertiesEvent: Raised when a shell command requests the display of the file/container properties dialog /// //TODO: CODE SMELL Why does the shell handle the SelectiveSynchChanges? + [Export(typeof(IShell))] public class ShellViewModel : Screen, IStatusNotification, IShell, IHandle, IHandle, IHandle { @@ -104,6 +105,12 @@ namespace Pithos.Client.WPF { StatusMessage = "In Synch"; + _accounts.CollectionChanged += (sender, e) => + { + NotifyOfPropertyChange(() => OpenFolderCaption); + NotifyOfPropertyChange(() => HasAccounts); + }; + } catch (Exception exc) { @@ -112,6 +119,7 @@ namespace Pithos.Client.WPF { } } + protected override void OnActivate() { base.OnActivate(); @@ -163,8 +171,8 @@ namespace Pithos.Client.WPF { //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 @@ -207,9 +215,9 @@ namespace Pithos.Client.WPF { 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); } @@ -227,14 +235,29 @@ namespace Pithos.Client.WPF { } } - private ObservableConcurrentCollection _accounts = new ObservableConcurrentCollection(); + private readonly ObservableConcurrentCollection _accounts = new ObservableConcurrentCollection(); public ObservableConcurrentCollection 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; } @@ -252,13 +275,13 @@ namespace Pithos.Client.WPF { } - 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); } } @@ -303,6 +326,12 @@ namespace Pithos.Client.WPF { } + 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}", @@ -522,7 +551,7 @@ namespace Pithos.Client.WPF { 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; @@ -620,6 +649,9 @@ namespace Pithos.Client.WPF { if (String.IsNullOrWhiteSpace(accountName)) return; + var accountInfo=_accounts.FirstOrDefault(account => account.UserName == accountName); + _accounts.TryRemove(accountInfo); + PithosMonitor monitor; if (Monitors.TryGetValue(accountName, out monitor)) {