Ejemplo n.º 1
0
        public static OpenVrDriverFiles Read()
        {
            var xmlSerializer     = new XmlSerializer(typeof(OpenVrDriverFiles));
            var s                 = Application.GetResourceStream(new Uri("pack://application:,,,/Resources/OpenVrDriverFiles.xml"));
            OpenVrDriverFiles obj = (OpenVrDriverFiles)xmlSerializer.Deserialize(s.Stream);

            s.Stream.Dispose();
            return(obj);
        }
Ejemplo n.º 2
0
        public static bool UninstallAllK2EX(Pages.Install installPage)
        {
            var paths = FindK2EX();

            foreach (KeyValuePair <string, K2EXInstallProperties> pair in paths)
            {
                string path = pair.Key;
                if (path == App.state.GetFullInstallationPath())
                {
                    continue;
                }
                installPage.Log("Found old installation at \"" + path + "\"...", false);
                if (pair.Value.DriverRegistered || pair.Value.AppConfigRegistered)
                {
                    if (MessageBox.Show("K2EX appears to also be installed in " + "\"" + path + "\"" + ". Do you wish to disable it?", "Already installed", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        installPage.Log("Disabling...", false);
                        UnregisterK2EX(path);
                    }
                    else
                    {
                        MessageBox.Show("Multiple installations of K2EX would interfere with each other." + Environment.NewLine +
                                        "Restart this installer to try again" + Environment.NewLine +
                                        "Please join our Discord server for further assistance (link on www.k2vr.tech)");
                        installPage.Cancel();
                        return(false);
                    }
                }
                DeleteK2EXFolder(path);
            }
            if (Directory.Exists(App.state.copiedDriverPath))
            {
                installPage.Log("Deleting copied driver...", false);
                var ovrDriverFiles = OpenVrDriverFiles.Read();
                foreach (string file in ovrDriverFiles.Files)
                {
                    string delFile = Path.Combine(App.state.copiedDriverPath, file);
                    if (File.Exists(delFile))
                    {
                        File.Delete(delFile);
                    }
                }
                for (int i = ovrDriverFiles.Folders.Count - 1; i >= 0; i--)
                {
                    string delDir = Path.Combine(App.state.copiedDriverPath, ovrDriverFiles.Folders[i]);
                    if (Directory.Exists(delDir))
                    {
                        Directory.Delete(delDir, false);
                    }
                }
                try { Directory.Delete(App.state.copiedDriverPath, false); } catch (IOException) { }
                installPage.Log("Deleted...", false);
            }
            if (Directory.Exists(App.state.GetFullInstallationPath()))
            {
                installPage.Log("Removing previous version...", false);
                if (MessageBox.Show("KinectToVR appears to be already installed in \"" + App.state.GetFullInstallationPath() + "\"." + Environment.NewLine +
                                    "Do you wish to update this installation?", "Confirm update", MessageBoxButton.YesNo) != MessageBoxResult.Yes ||
                    !DeleteK2EXFolder(App.state.GetFullInstallationPath()))
                {
                    // We need to abort because we can't unzip into a dir with files in it
                    MessageBox.Show("Cannot install two versions of KinectToVR into the same directory." + Environment.NewLine +
                                    "Either uninstall the old version or select another install directory." + Environment.NewLine +
                                    "Restart this installer to try again");
                    installPage.Cancel();
                    return(false);
                }
            }
            if (Directory.Exists(App.startMenuFolder))
            {
                installPage.Log("Removing start menu shortcuts...", false);
                DeleteK2EXStartMenuShortcuts();
            }
            return(true);
        }
Ejemplo n.º 3
0
        public static bool UninstallAllK2EX(Pages.Install installPage)
        {
            var paths = FindK2EX();

            foreach (KeyValuePair <string, K2EXInstallProperties> pair in paths)
            {
                string path = pair.Key;
                if (path == App.state.GetFullInstallationPath())
                {
                    continue;
                }
                installPage.Log("Found old installation at \"" + path + "\"...", false);
                if (pair.Value.DriverRegistered || pair.Value.AppConfigRegistered)
                {
                    if (MessageBox.Show(Properties.Resources.installer_previous_disable.Replace("{0}", path), Properties.Resources.installer_previous_disable_title, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        installPage.Log("Disabling...", false);
                        UnregisterK2EX(path);
                    }
                    else
                    {
                        MessageBox.Show(Properties.Resources.install_multiple_k2ex);
                        installPage.Cancel();
                        return(false);
                    }
                }
                DeleteK2EXFolder(path);
            }
            if (Directory.Exists(App.state.copiedDriverPath))
            {
                installPage.Log("Deleting copied driver...", false);
                var ovrDriverFiles = OpenVrDriverFiles.Read();
                foreach (string file in ovrDriverFiles.Files)
                {
                    string delFile = Path.Combine(App.state.copiedDriverPath, file);
                    if (File.Exists(delFile))
                    {
                        File.Delete(delFile);
                    }
                }
                for (int i = ovrDriverFiles.Folders.Count - 1; i >= 0; i--)
                {
                    string delDir = Path.Combine(App.state.copiedDriverPath, ovrDriverFiles.Folders[i]);
                    if (Directory.Exists(delDir))
                    {
                        Directory.Delete(delDir, false);
                    }
                }
                try { Directory.Delete(App.state.copiedDriverPath, false); } catch (IOException) { }
                installPage.Log("Deleted...", false);
            }
            if (Directory.Exists(App.state.GetFullInstallationPath()))
            {
                installPage.Log("Removing previous version...", false);
                if (MessageBox.Show(Properties.Resources.install_update.Replace("{0}", App.state.GetFullInstallationPath()), Properties.Resources.install_update_title, MessageBoxButton.YesNo) != MessageBoxResult.Yes ||
                    !DeleteK2EXFolder(App.state.GetFullInstallationPath()))
                {
                    // We need to abort because we can't unzip into a dir with files in it
                    MessageBox.Show(Properties.Resources.install_existing_folder_fail);
                    installPage.Cancel();
                    return(false);
                }
            }
            if (Directory.Exists(App.startMenuFolder))
            {
                installPage.Log("Removing start menu shortcuts...", false);
                DeleteK2EXStartMenuShortcuts();
            }
            return(true);
        }