Ejemplo n.º 1
0
        /// <summary>
        /// Runs when the user clicks on the reinstall button.
        /// Uninstalls and then installs the program.
        /// </summary>
        private void ReinstallButtonClick(object sender, RoutedEventArgs e)
        {
            LogData("[Main]: Reinstall button pressed.");
            reinstallButton.Visibility = Visibility.Hidden;
            installButton.Visibility   = Visibility.Hidden;
            subTitle.Content           = "Installing program...";

            LogData("[Main]: Uninstalling program...");
            Uninstaller uninstaller = new Uninstaller();

            //uninstaller.RequestProgramShutdown(SETTINGS_PATH);
            uninstaller.Uninstall(DATA_DIRECTORY_PATH, INSTALL_DIRECTORY, BASE_DIRECTORY, REGISTRY, SHORTCUT_LOCATION);

            LogData("[Main]: Uninstalled program! Installing...");
            InstallProgram(PROGRAM_PATH, INSTALL_DIRECTORY, ONLINE_PROGRAM_LINK, ZIP_PATH);
            LogData("[Main]: Reinstalled program!");

            //try {
            //    Registry.CurrentUser.DeleteSubKey(REGISTRY);
            //    LogData("[Main]: Deleted the old registry");
            //}
            //catch (ArgumentException) { // Registry doesn't exist
            //    LogData("[Main]: ERROR: Tried to remove a registry that doesn't exist!");
            //}
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Runs when the user clicks on the install button.
        /// If the program is already installed, it becomes an uninstall button.
        /// </summary>
        private void InstallButtonClick(object sender, RoutedEventArgs e)
        {
            LogData("[Main]: Install/uninstall button pressed");
            if (retrying == true)
            {
                installButton.Content = "Install";
                retrying         = false;
                subTitle.Content = "";
            }

            if (!uninstall)   // We're installing the program normally
            // Hide/show components
            {
                copyright.Visibility     = Visibility.Hidden;
                installButton.Visibility = Visibility.Hidden;
                subTitle.Visibility      = Visibility.Visible;

                mainTitle.Content = "Installing program...";
                LogData("[Main]: Installing program...");
                InstallProgram(PROGRAM_PATH, INSTALL_DIRECTORY, ONLINE_PROGRAM_LINK, ZIP_PATH);
                LogData("[Main]: Finished installing!");
            }
            else   // Uninstall == true
            {
                Dispatcher.Invoke(new Action(() => {
                    installButton.Visibility   = Visibility.Hidden;
                    reinstallButton.Visibility = Visibility.Hidden;
                    subTitle.Visibility        = Visibility.Hidden;
                    mainTitle.Content          = "Uninstalling";
                    installBar.Visibility      = Visibility.Hidden;

                    LogData("[Main]: Uninstalling program...");
                    Uninstaller uninstaller = new Uninstaller();
                    //uninstaller.RequestProgramShutdown(SETTINGS_PATH);
                    uninstaller.Uninstall(DATA_DIRECTORY_PATH, INSTALL_DIRECTORY, BASE_DIRECTORY, REGISTRY, SHORTCUT_LOCATION);

                    LogData("[Main]: Successfully uninstalled!");
                    FinalResult("Successfully uninstalled!", "You can close this uninstaller whenever.");
                }));
            }
        }