Winify – Diff between revs 83 and 84

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 83 Rev 84
Line 1... Line 1...
1 using System; 1 using System;
2 using System.Collections.Concurrent; 2 using System.Collections.Concurrent;
3 using System.ComponentModel; 3 using System.ComponentModel;
4 using System.Drawing; 4 using System.Drawing;
5 using System.IO; 5 using System.IO;
-   6 using System.Linq;
6 using System.Net; 7 using System.Net;
7 using System.Reflection; 8 using System.Reflection;
8 using System.Text; 9 using System.Text;
9 using System.Threading; 10 using System.Threading;
10 using System.Threading.Tasks; 11 using System.Threading.Tasks;
Line 53... Line 54...
53   54  
Line 54... Line 55...
54 private LogViewForm _logViewForm; 55 private LogViewForm _logViewForm;
Line 55... Line 56...
55   56  
Line 56... Line 57...
56 private readonly LogMemorySink _memorySink; 57 private readonly LogMemorySink _memorySink;
Line 57... Line 58...
57   58  
Line 70... Line 71...
70 _cancellationTokenSource = new CancellationTokenSource(); 71 _cancellationTokenSource = new CancellationTokenSource();
71 _cancellationToken = _cancellationTokenSource.Token; 72 _cancellationToken = _cancellationTokenSource.Token;
Line 72... Line 73...
72   73  
Line 73... Line 74...
73 ChangedConfigurationContinuation = new ScheduledContinuation(); 74 ChangedConfigurationContinuation = new ScheduledContinuation();
74   75  
Line 75... Line 76...
75 _toastDisplay = new Toasts.ToastDisplay(_cancellationToken); 76 _toastDisplay = new ToastDisplay(_cancellationToken);
76 } 77 }
77   78  
Line 139... Line 140...
139 } 140 }
140 } 141 }
Line 141... Line 142...
141   142  
142 private async void MainForm_Load(object sender, EventArgs e) 143 private async void MainForm_Load(object sender, EventArgs e)
-   144 {
-   145 #pragma warning disable CS4014
-   146 PerformUpgrade();
-   147 #pragma warning restore CS4014
143 { 148  
Line 144... Line 149...
144 Configuration = await LoadConfiguration(); 149 Configuration = await LoadConfiguration();
145   150  
146 var servers = await LoadServers(); 151 var servers = await LoadServers();
Line 322... Line 327...
322 Close(); 327 Close();
323 } 328 }
Line 324... Line 329...
324   329  
325 private async void UpdateToolStripMenuItem_Click(object sender, EventArgs e) 330 private async void UpdateToolStripMenuItem_Click(object sender, EventArgs e)
326 { -  
327 // Manually check for updates, this will not show a ui -  
328 var result = await _sparkle.CheckForUpdatesQuietly(); 331 {
329 var updates = result.Updates; -  
330 if (result.Status == UpdateStatus.UpdateAvailable) -  
331 { -  
332 // if update(s) are found, then we have to trigger the UI to show it gracefully -  
333 _sparkle.ShowUpdateNeededUI(); -  
334 return; -  
335 } -  
336   -  
337 MessageBox.Show("No updates available at this time.", "Winify", MessageBoxButtons.OK, -  
338 MessageBoxIcon.Asterisk, -  
339 MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, false); 332 await PerformUpgrade();
Line 340... Line 333...
340 } 333 }
Line 341... Line 334...
341   334  
Line 384... Line 377...
384   377  
Line 385... Line 378...
385 #endregion 378 #endregion
Line -... Line 379...
-   379  
-   380 #region Private Methods
-   381  
-   382 private async Task PerformUpgrade()
-   383 {
-   384 // Manually check for updates, this will not show a ui
-   385 var updateCheck = await _sparkle.CheckForUpdatesQuietly();
-   386 switch (updateCheck.Status)
-   387 {
-   388 case UpdateStatus.UserSkipped:
-   389 var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;
-   390 updateCheck.Updates.Sort(UpdateComparer);
-   391 var latestVersion = updateCheck.Updates.FirstOrDefault();
-   392 if (latestVersion != null)
-   393 {
-   394 var availableVersion = new Version(latestVersion.Version);
-   395  
-   396 if (availableVersion <= assemblyVersion)
-   397 {
-   398 return;
-   399 }
-   400 }
-   401  
-   402 var decision = MessageBox.Show(
-   403 "Update available but it has been previously skipped. Should the update proceed anyway?",
-   404 Assembly.GetExecutingAssembly().GetName().Name, MessageBoxButtons.YesNo,
-   405 MessageBoxIcon.Asterisk,
-   406 MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, false);
-   407  
-   408 if (decision.HasFlag(DialogResult.No))
-   409 {
-   410 return;
-   411 }
-   412  
-   413 goto default;
-   414 case UpdateStatus.UpdateNotAvailable:
-   415 MessageBox.Show("No updates available at this time.",
-   416 Assembly.GetExecutingAssembly().GetName().Name, MessageBoxButtons.OK,
-   417 MessageBoxIcon.Asterisk,
-   418 MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, false);
-   419 break;
-   420 case UpdateStatus.CouldNotDetermine:
-   421 Log.Error("Could not determine the update availability status.");
-   422 break;
-   423 default:
-   424 _sparkle.ShowUpdateNeededUI();
-   425 break;
-   426 }
-   427 }
-   428  
-   429 private static int UpdateComparer(AppCastItem x, AppCastItem y)
-   430 {
-   431 if (x == null)
-   432 {
-   433 return 1;
-   434 }
-   435  
-   436 if (y == null)
-   437 {
-   438 return -1;
-   439 }
-   440  
-   441 if (x == y)
-   442 {
-   443 return 0;
-   444 }
-   445  
386   446 return new Version(y.Version).CompareTo(new Version(x.Version));
387 #region Private Methods 447 }
388   448  
389 private static async Task SaveAnnouncements(Announcements.Announcements announcements) 449 private static async Task SaveAnnouncements(Announcements.Announcements announcements)
390 { 450 {