Revision 049333d2 trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs

b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs
50 50
using System.Threading.Tasks;
51 51
using System.Windows;
52 52
using System.Windows.Controls.Primitives;
53
using AppLimit.NetSparkle;
53 54
using Caliburn.Micro;
54 55
using Hardcodet.Wpf.TaskbarNotification;
55 56
using Pithos.Client.WPF.Configuration;
......
179 180
		{
180 181
			base.OnActivate();
181 182

  
182
			
183
            _sparkle = new Sparkle(Settings.UpdateUrl);
184
            _sparkle.updateDetected += OnUpgradeDetected;
185
            _sparkle.ShowDiagnosticWindow = Settings.UpdateDiagnostics;
186

  
187
            //Must delay opening the upgrade window
188
            //to avoid Windows Messages sent by the TaskbarIcon
189
            TaskEx.Delay(5000).ContinueWith(_=>
190
                Execute.OnUIThread(()=> _sparkle.StartLoop(true,true,Settings.UpdateCheckInterval)));
191

  
183 192

  
184 193
			StartMonitoring();                    
185 194
		}
186 195

  
196
	    private void OnUpgradeDetected(object sender, UpdateDetectedEventArgs e)
197
	    {
198
	        Log.InfoFormat("Update detected {0}",e.LatestVersion);
199
	    }
187 200

  
201
        public void CheckForUpgrade()
202
        {
203
            _sparkle.StopLoop();
204
            _sparkle.Dispose();
205
            _sparkle=new Sparkle(Settings.UpdateUrl);
206
            _sparkle.StartLoop(true,true,Settings.UpdateCheckInterval);
207
        }
188 208

  
189
		private async void StartMonitoring()
209
	    private async void StartMonitoring()
190 210
		{
191 211
			try
192 212
			{
......
831 851

  
832 852

  
833 853
		private bool _pollStarted;
854
	    private Sparkle _sparkle;
834 855

  
835
		//SMELL: Doing so much work for notifications in the shell is wrong
856
	    //SMELL: Doing so much work for notifications in the shell is wrong
836 857
		//The notifications should be moved to their own view/viewmodel pair
837 858
		//and different templates should be used for different message types
838 859
		//This will also allow the addition of extra functionality, eg. actions

Also available in: Unified diff