1 // -----------------------------------------------------------------------
2 // <copyright file="StatusViewModel.cs" company="Microsoft">
3 // TODO: Update copyright text.
5 // -----------------------------------------------------------------------
7 using System.ComponentModel.Composition;
8 using System.Diagnostics;
11 using Pithos.Client.WPF.Properties;
13 using Pithos.Interfaces;
15 namespace Pithos.Client.WPF
18 using System.Collections.Generic;
23 /// TODO: Update summary.
26 public class TaskbarViewModel:ViewAware
28 private IStatusChecker _statusChecker;
30 public PithosMonitor Monitor { get; private set; }
32 public IPithosSettings Settings { get; private set; }
34 public IScreen Parent { get; set; }
36 [ImportingConstructor]
37 public TaskbarViewModel(IStatusChecker statusChecker,PithosMonitor monitor,IPithosSettings settings)
39 OpenPithosFolderCommand = new PithosCommand(OpenPithosFolder);
40 _statusChecker = statusChecker;
45 #region Status Properties
47 private string _statusMessage;
48 public string StatusMessage
50 get { return _statusMessage; }
53 _statusMessage = value;
54 NotifyOfPropertyChange(() => StatusMessage);
58 private string _usageMessage;
59 public string UsageMessage
61 get { return _usageMessage; }
64 _usageMessage = value;
65 NotifyOfPropertyChange(() => UsageMessage);
70 private string _pauseSyncCaption="Pause Syncing";
71 public string PauseSyncCaption
73 get { return _pauseSyncCaption; }
76 _pauseSyncCaption = value;
77 NotifyOfPropertyChange(() => PauseSyncCaption);
81 private readonly IObservableCollection<FileEntry> _recentFiles = new BindableCollection<FileEntry>();
82 public IObservableCollection<FileEntry> RecentFiles
84 get { return _recentFiles; }
88 private string _statusIcon;
89 public string StatusIcon
91 get { return _statusIcon; }
95 NotifyOfPropertyChange(() => StatusIcon);
103 public void ShowPreferences()
109 public PithosCommand OpenPithosFolderCommand { get; private set; }
111 public void OpenPithosFolder()
113 Process.Start(Settings.PithosPath);
116 public void GoToSite()
118 Process.Start(Properties.Settings.Default.PithosSite);
122 public void ToggleSynching()
124 Monitor.Pause = !Monitor.Pause;
125 PauseSyncCaption = Monitor.Pause ? "Resume syncing" : "Pause syncing";
126 var iconKey = Monitor.Pause ? "TraySyncPaused" : "TrayInSynch";
127 StatusIcon = String.Format(@"Images/{0}.ico", iconKey);
130 public void ExitPithos()
138 private Dictionary<PithosStatus, StatusInfo> iconNames = new List<StatusInfo>
140 new StatusInfo(PithosStatus.InSynch, "All files up to date", "TrayInSynch"),
141 new StatusInfo(PithosStatus.Syncing, "Syncing Files", "TraySynching"),
142 new StatusInfo(PithosStatus.SyncPaused, "Sync Paused", "TraySyncPaused")
143 }.ToDictionary(s => s.Status);
146 public void UpdateStatus()
148 var pithosStatus = _statusChecker.GetPithosStatus();
150 if (iconNames.ContainsKey(pithosStatus))
152 var info = iconNames[pithosStatus];
153 StatusIcon = String.Format(@"Images/{0}.ico", info.IconName);
154 StatusMessage = String.Format("Pithos 1.0\r\n{0}", info.StatusText);
156 if (!String.IsNullOrWhiteSpace(Settings.UserName) &&
157 !String.IsNullOrWhiteSpace(Settings.ApiKey))