/trunk/Winify/MainForm.cs |
@@ -3,6 +3,7 @@ |
using System.ComponentModel; |
using System.Drawing; |
using System.IO; |
using System.Linq; |
using System.Net; |
using System.Reflection; |
using System.Text; |
@@ -55,7 +56,7 @@ |
|
private readonly LogMemorySink _memorySink; |
|
private readonly Toasts.ToastDisplay _toastDisplay; |
private readonly ToastDisplay _toastDisplay; |
|
#endregion |
|
@@ -72,7 +73,7 @@ |
|
ChangedConfigurationContinuation = new ScheduledContinuation(); |
|
_toastDisplay = new Toasts.ToastDisplay(_cancellationToken); |
_toastDisplay = new ToastDisplay(_cancellationToken); |
} |
|
public MainForm(Mutex mutex) : this() |
@@ -141,6 +142,10 @@ |
|
private async void MainForm_Load(object sender, EventArgs e) |
{ |
#pragma warning disable CS4014 |
PerformUpgrade(); |
#pragma warning restore CS4014 |
|
Configuration = await LoadConfiguration(); |
|
var servers = await LoadServers(); |
@@ -324,19 +329,7 @@ |
|
private async void UpdateToolStripMenuItem_Click(object sender, EventArgs e) |
{ |
// Manually check for updates, this will not show a ui |
var result = await _sparkle.CheckForUpdatesQuietly(); |
var updates = result.Updates; |
if (result.Status == UpdateStatus.UpdateAvailable) |
{ |
// if update(s) are found, then we have to trigger the UI to show it gracefully |
_sparkle.ShowUpdateNeededUI(); |
return; |
} |
|
MessageBox.Show("No updates available at this time.", "Winify", MessageBoxButtons.OK, |
MessageBoxIcon.Asterisk, |
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, false); |
await PerformUpgrade(); |
} |
|
#endregion |
@@ -386,6 +379,73 @@ |
|
#region Private Methods |
|
private async Task PerformUpgrade() |
{ |
// Manually check for updates, this will not show a ui |
var updateCheck = await _sparkle.CheckForUpdatesQuietly(); |
switch (updateCheck.Status) |
{ |
case UpdateStatus.UserSkipped: |
var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; |
updateCheck.Updates.Sort(UpdateComparer); |
var latestVersion = updateCheck.Updates.FirstOrDefault(); |
if (latestVersion != null) |
{ |
var availableVersion = new Version(latestVersion.Version); |
|
if (availableVersion <= assemblyVersion) |
{ |
return; |
} |
} |
|
var decision = MessageBox.Show( |
"Update available but it has been previously skipped. Should the update proceed anyway?", |
Assembly.GetExecutingAssembly().GetName().Name, MessageBoxButtons.YesNo, |
MessageBoxIcon.Asterisk, |
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, false); |
|
if (decision.HasFlag(DialogResult.No)) |
{ |
return; |
} |
|
goto default; |
case UpdateStatus.UpdateNotAvailable: |
MessageBox.Show("No updates available at this time.", |
Assembly.GetExecutingAssembly().GetName().Name, MessageBoxButtons.OK, |
MessageBoxIcon.Asterisk, |
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, false); |
break; |
case UpdateStatus.CouldNotDetermine: |
Log.Error("Could not determine the update availability status."); |
break; |
default: |
_sparkle.ShowUpdateNeededUI(); |
break; |
} |
} |
|
private static int UpdateComparer(AppCastItem x, AppCastItem y) |
{ |
if (x == null) |
{ |
return 1; |
} |
|
if (y == null) |
{ |
return -1; |
} |
|
if (x == y) |
{ |
return 0; |
} |
|
return new Version(y.Version).CompareTo(new Version(x.Version)); |
} |
|
private static async Task SaveAnnouncements(Announcements.Announcements announcements) |
{ |
switch (await Serialization.Serialize(announcements, Constants.AnnouncementsFile, "Announcements", |
/trunk/Winify/Winify.csproj |
@@ -78,8 +78,8 @@ |
<Reference Include="Serilog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL"> |
<HintPath>..\packages\Serilog.4.0.0\lib\net471\Serilog.dll</HintPath> |
</Reference> |
<Reference Include="Serilog.Sinks.File, Version=5.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL"> |
<HintPath>..\packages\Serilog.Sinks.File.5.0.0\lib\net45\Serilog.Sinks.File.dll</HintPath> |
<Reference Include="Serilog.Sinks.File, Version=6.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL"> |
<HintPath>..\packages\Serilog.Sinks.File.6.0.0\lib\net471\Serilog.Sinks.File.dll</HintPath> |
</Reference> |
<Reference Include="System" /> |
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
@@ -171,6 +171,8 @@ |
<DependentUpon>AboutForm.cs</DependentUpon> |
</Compile> |
<Compile Include="Constants.cs" /> |
<Compile Include="Gotify\GotifyConnectionApplication.cs" /> |
<Compile Include="Gotify\GotifyConnectionData.cs" /> |
<Compile Include="Gotify\GotifyMessageExtras.cs" /> |
<Compile Include="Gotify\GotifyMessageExtrasClientDisplay.cs" /> |
<Compile Include="Gotify\GotifyMessageQuery.cs" /> |