add update check and 'Microsoft Visual C++ 2010 Redistributable Package' check
authorStricted <info@stricted.de>
Wed, 11 Nov 2015 02:58:37 +0000 (03:58 +0100)
committerStricted <info@stricted.de>
Wed, 11 Nov 2015 02:58:37 +0000 (03:58 +0100)
add vcredis_x86.exe

SpeedportHybridControl.Implementations/util.cs
SpeedportHybridControl/PageModel/MainWindowModel.cs
SpeedportHybridControl/SpeedportHybridControl.csproj
SpeedportHybridControl/page/StatusPage.xaml.cs
SpeedportHybridControl/vcredist/vcredist_x86.exe [new file with mode: 0644]

index d4bea24d33e30d330c728b6815b9c214e09b9744..09e8bbf16b4edf748a125e93e6a2a5b5ffb915fc 100644 (file)
@@ -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;
+               }
        }
 }
index ce95de710e341597c6a2607d14c9f9368306586a..9b35b5fa571385162ba7da5263c83c5f45dd8290 100644 (file)
@@ -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));
index 619182a696146b891e9f191a2f845ec73c1c10ea..82a708c1d0ef8431bbdaa301b0d5395e1c86f34c 100644 (file)
   <ItemGroup>
     <SplashScreen Include="SplashScreen1.png" />
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="vcredist\vcredist_x86.exe">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
index 12f3f8556585427f647c772081ebb5a6ddf5f597..5b3918bcb1f5dd2f763b107ca932a8d8c243d794 100644 (file)
@@ -10,11 +10,5 @@ namespace SpeedportHybridControl.page {
                public StatusPage() {
                        InitializeComponent();
                }
-
-               private void button_click(object sender, RoutedEventArgs e) {
-                       if (sender.Equals(reload)) {
-                               //util.init("Status");
-                       }
-               }
     }
 }
diff --git a/SpeedportHybridControl/vcredist/vcredist_x86.exe b/SpeedportHybridControl/vcredist/vcredist_x86.exe
new file mode 100644 (file)
index 0000000..9c1dfdd
Binary files /dev/null and b/SpeedportHybridControl/vcredist/vcredist_x86.exe differ