Created Windows 7 Sunset branch

This commit is contained in:
Jon Galloway 2017-07-05 20:21:10 -07:00
parent 6936444f26
commit 0e1e3a5f2f
2 changed files with 53 additions and 7 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details. // Licensed under the MIT license. See LICENSE file in the project root for details.
using Microsoft.Win32;
using OpenLiveWriter.CoreServices; using OpenLiveWriter.CoreServices;
using OpenLiveWriter.CoreServices.ResourceDownloading; using OpenLiveWriter.CoreServices.ResourceDownloading;
using Squirrel; using Squirrel;
@ -10,6 +11,7 @@ using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using System.Windows.Forms;
using System.Xml; using System.Xml;
namespace OpenLiveWriter.PostEditor.Updates namespace OpenLiveWriter.PostEditor.Updates
@ -20,13 +22,38 @@ namespace OpenLiveWriter.PostEditor.Updates
public static void CheckforUpdates(bool forceCheck = false) public static void CheckforUpdates(bool forceCheck = false)
{ {
var checkNow = forceCheck || UpdateSettings.AutoUpdate; var result = System.Windows.Forms.DialogResult.No;
var downloadUrl = UpdateSettings.CheckForBetaUpdates ?
UpdateSettings.BetaUpdateDownloadUrl : UpdateSettings.UpdateDownloadUrl;
// Schedule Open Live Writer 10 seconds after the launch if (UpdateSettings.AutoUpdate && HasNet462OrLater())
var delayUpdate = new DelayUpdateHelper(UpdateOpenLiveWriter(downloadUrl, checkNow), UPDATELAUNCHDELAY); {
delayUpdate.StartBackgroundUpdate("Background OpenLiveWriter application update"); result = MessageBox.Show("An update for OpenLiveWriter may be available. Would you like to check for it?"
+ Environment.NewLine
+ Environment.NewLine
+ "Select Cancel to permanently cancel update checks."
, "Update", MessageBoxButtons.YesNoCancel);
if (result == System.Windows.Forms.DialogResult.Yes)
{
var checkNow = forceCheck || UpdateSettings.AutoUpdate;
var downloadUrl = UpdateSettings.CheckForBetaUpdates ?
UpdateSettings.BetaUpdateDownloadUrl : UpdateSettings.UpdateDownloadUrl;
// Schedule Open Live Writer 10 seconds after the launch
var delayUpdate = new DelayUpdateHelper(UpdateOpenLiveWriter(downloadUrl, checkNow), UPDATELAUNCHDELAY);
delayUpdate.StartBackgroundUpdate("Background OpenLiveWriter application update");
} else if (result == System.Windows.Forms.DialogResult.Cancel) {
MessageBox.Show(@"Attempting to disable AutoUpdate."
+ Environment.NewLine
+ Environment.NewLine
+ "AutoUpdate can be turned on and off by setting this registry key: " +
@"HKEY_CURRENT_USER\Software\OpenLiveWriter\Updates\AutoUpdate to 0", "Disabling AutoUpdate", MessageBoxButtons.OK);
UpdateSettings.AutoUpdate = false;
//Manually writing out values since they're not always persisted
Registry.SetValue(@"HKEY_CURRENT_USER\Software\OpenLiveWriter\Updates", "AutoUpdate", 0);
}
return;
}
} }
private static ThreadStart UpdateOpenLiveWriter(string downloadUrl, bool checkNow) private static ThreadStart UpdateOpenLiveWriter(string downloadUrl, bool checkNow)
@ -50,6 +77,25 @@ namespace OpenLiveWriter.PostEditor.Updates
}; };
} }
private static bool HasNet462OrLater()
{
const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey))
{
if (ndpKey != null && ndpKey.GetValue("Release") != null && (int)ndpKey.GetValue("Release") >= 394254) //.NET 4.6.1 or later is installed
{
return true;
}
else
{
Trace.WriteLine("Old operating system or .NET version, skipping update.");
Trace.WriteLine("Windows Version: " + Environment.OSVersion.VersionString);
Trace.WriteLine(".NET NPD version number: " + ndpKey);
}
}
return false;
}
private const int UPDATELAUNCHDELAY = 10000; private const int UPDATELAUNCHDELAY = 10000;
} }
} }

View File

@ -1 +1 @@
0.6.0.0 0.6.0.1