From: Stricted Date: Wed, 11 Nov 2015 02:58:37 +0000 (+0100) Subject: add update check and 'Microsoft Visual C++ 2010 Redistributable Package' check X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a8e0f728ce70a3d657ba445dd6478defaa58536b;p=GitHub%2FStricted%2FSpeedportHybridControl.git add update check and 'Microsoft Visual C++ 2010 Redistributable Package' check add vcredis_x86.exe --- diff --git a/SpeedportHybridControl.Implementations/util.cs b/SpeedportHybridControl.Implementations/util.cs index d4bea24..09e8bbf 100644 --- a/SpeedportHybridControl.Implementations/util.cs +++ b/SpeedportHybridControl.Implementations/util.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json.Linq; +using Microsoft.Win32; +using Newtonsoft.Json.Linq; using System; using System.Linq; using System.Security.Cryptography; @@ -152,18 +153,17 @@ namespace SpeedportHybridControl.Implementations { return Brushes.Transparent; } - + /** * check for update */ - /* - public static bool checkUpdate () { + public static bool checkUpdate (string currentVersion) { try { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load("https://stricted.net/version.xml"); string version = xmlDocument.DocumentElement["version"].InnerText; - if (MainWindow.VERSION.Equals(version).Equals(false)) { + if (currentVersion.Equals(version).Equals(false)) { return true; } } @@ -173,7 +173,6 @@ namespace SpeedportHybridControl.Implementations { return false; } - */ /** * process login stuff @@ -265,5 +264,37 @@ namespace SpeedportHybridControl.Implementations { } } */ + + public static bool checkInstalled (string c_name) { + string displayName = string.Empty; + + string registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; + RegistryKey key = Registry.LocalMachine.OpenSubKey(registryKey); + if (key != null) { + foreach (RegistryKey subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName))) { + displayName = subkey.GetValue("DisplayName") as string; + + if (string.IsNullOrWhiteSpace(displayName).Equals(false) && displayName.Equals(c_name)) { + return true; + } + } + key.Close(); + } + + registryKey = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"; + key = Registry.LocalMachine.OpenSubKey(registryKey); + if (key != null) { + foreach (RegistryKey subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName))) { + displayName = subkey.GetValue("DisplayName") as string; + + if (string.IsNullOrWhiteSpace(displayName).Equals(false) && displayName.Equals(c_name)) { + return true; + } + } + key.Close(); + } + + return false; + } } } diff --git a/SpeedportHybridControl/PageModel/MainWindowModel.cs b/SpeedportHybridControl/PageModel/MainWindowModel.cs index ce95de7..9b35b5f 100644 --- a/SpeedportHybridControl/PageModel/MainWindowModel.cs +++ b/SpeedportHybridControl/PageModel/MainWindowModel.cs @@ -6,9 +6,12 @@ using System.Windows.Media; using System.Threading; using SpeedportHybridControl.Data; using SpeedportHybridControl.Model; +using System.Windows; namespace SpeedportHybridControl.PageModel { class MainWindowModel : SuperViewModel { + public const string VERSION = "1.0-pre9"; //TODO: change this later + private string _loginButtonContent = "Login"; private DelegateCommand _switchToLoginPage; @@ -365,6 +368,15 @@ namespace SpeedportHybridControl.PageModel { } public MainWindowModel () { + if (util.checkInstalled("Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219").Equals(false)) { + new Thread(() => { MessageBox.Show("Bitte installiere das 'Microsoft Visual C++ 2010 Redistributable Package' aus den ordner 'vcredis' um das programm vollständig benutzen zu können.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Warning); }).Start(); + } + + if (util.checkUpdate(VERSION).Equals(true)) { + new Thread(() => { MessageBox.Show("Ein Update ist verfügbar.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Warning); }).Start(); + } + + changePage("login"); SwitchToLoginPage = new DelegateCommand(new Action(OnSwitchToLoginPageExecute)); diff --git a/SpeedportHybridControl/SpeedportHybridControl.csproj b/SpeedportHybridControl/SpeedportHybridControl.csproj index 619182a..82a708c 100644 --- a/SpeedportHybridControl/SpeedportHybridControl.csproj +++ b/SpeedportHybridControl/SpeedportHybridControl.csproj @@ -223,6 +223,11 @@ + + + Always + +