diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e68a880 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CA1416: Validate platform compatibility +dotnet_diagnostic.CA1416.severity = none diff --git a/Terms.UI.Tools/Actions/CheckForUpdates.cs b/Terms.UI.Tools/Actions/CheckForUpdates.cs deleted file mode 100644 index 4441067..0000000 --- a/Terms.UI.Tools/Actions/CheckForUpdates.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.IO; -using System.Net; -using System.Reflection; -using System.Threading; -using Terms.Tools.Settings; -using Terms.Tools.Settings.Interfaces; - -namespace Terms.UI.Tools.Actions; - -public class CheckForUpdates(string updateXmlFilename, int waitBeforeCheckingTimeout = 1000) -{ - private readonly string m_updateXmlFilename = updateXmlFilename; - private readonly int m_waitBeforeCheckingTimeout = waitBeforeCheckingTimeout; - - public void Start() - { - Thread thread = new(StartChecking); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - private void StartChecking() - { - Thread.Sleep(m_waitBeforeCheckingTimeout); - - if (File.Exists(m_updateXmlFilename)) - { - File.Delete(m_updateXmlFilename); - } - - try - { - using (WebClient client = new()) - { - client.DownloadFile($"http://www.bunoon.com/updates/{m_updateXmlFilename}", m_updateXmlFilename); - } - - CheckUpdateFile(); - } - catch - { - BackgroundAction.Run(() => { UpdateNotFound?.Invoke(); }); - } - } - - private void CheckUpdateFile() - { - if (File.Exists(m_updateXmlFilename)) - { - bool updateFound = true; - - try - { - IXmlSettings updateConfiguration = new XmlSettings(m_updateXmlFilename); - - Version version = Version.Parse(updateConfiguration.Read("Current", "Version", "")); - Version currentVersion = Version.Parse(AssemblyVersion); - - string released = updateConfiguration.Read("Current", "Released", ""); - string downloadLink = updateConfiguration.Read("Current", "DownloadLink", ""); - - if (version > currentVersion) - { - Released = released; - NewVersion = version.ToString(); - DownloadLink = downloadLink; - - BackgroundAction.Run(() => { UpdateFound?.Invoke(); }); - } - else - { - updateFound = false; - } - } - catch - { - updateFound = false; - } - - if (!updateFound) - { - BackgroundAction.Run(() => { UpdateNotFound?.Invoke(); }); - } - } - } - - public Action UpdateFound { set; get; } - public Action UpdateNotFound { set; get; } - public string DownloadLink { get; private set; } - public string Released { get; private set; } - public string NewVersion { get; private set; } - - private static string AssemblyVersion => Assembly.GetExecutingAssembly().GetName().Version.ToString(); -} \ No newline at end of file diff --git a/Terms.sln b/Terms.sln index b1af3fb..ba396a9 100644 --- a/Terms.sln +++ b/Terms.sln @@ -1,7 +1,6 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2036 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34607.119 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Terms.UI", "Terms.UI\Terms.UI.csproj", "{E3959A5F-87AE-4189-854C-A3AB037EF67F}" EndProject @@ -9,6 +8,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Terms.UI.Tools", "Terms.UI. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Terms.Tools", "Terms.Tools\Terms.Tools.csproj", "{ABF1ADDB-C8DC-4AA4-BFEA-C8680C3905CA}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{54CE5975-E2B8-4A03-95AA-88E3FE32BECA}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU