Ejemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            tboxLocation.Text = "C:\\Users\\" + Environment.UserName + "\\Desktop\\GrainBound";

            WebRequest.DefaultWebProxy = null;
            webClient       = new WebClient();
            webClient.Proxy = null;
            webClient.DownloadFileCompleted   += new AsyncCompletedEventHandler(DownloadCompleted);
            webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);

            string installLoc = GBRegistry.checkRegistryKey(GBRegistry.GRAINBOUND_INSTALL_KEY);

            if (installLoc != null)
            {
                if (Directory.Exists(installLoc))
                {
                    this.Hide();
                    (new UninstallForm()).ShowDialog();
                }
                else
                {
                    GBRegistry.removeRegistryKey();
                }
            }
        }
Ejemplo n.º 2
0
        private void btnUninstall_Click(object sender, EventArgs e)
        {
            bool   backedUpProjects = false;
            string newPath          = "";

            if (MessageBox.Show("This operation will permanently remove GrainBound from your computer. Are you sure you wish to proceed?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string[] files = Directory.GetFiles(tboxLocation.Text, "*.grainbound", SearchOption.AllDirectories);
                if (files.Length > 0)
                {
                    DialogResult result = MessageBox.Show("GrainBound files have been detected inside the install folder. Do you want to save these files before uninstalling?\n\nYes = GrainBound projects will be moved to a different folder, then the program will be uninstalled.\nNo = Delete all files, including GrainBound projects.\nCancel = Stop uninstallation process.", "GrainBound Saved Projects Detected", MessageBoxButtons.YesNoCancel);
                    if (result == DialogResult.Yes)
                    {
                        newPath = tboxLocation.Text.Substring(0, tboxLocation.Text.LastIndexOf("\\")) + "\\GrainBound Projects";
                        try
                        {
                            Directory.CreateDirectory(newPath);
                            for (int i = 0; i < files.Length; i++)
                            {
                                File.Move(files[i], newPath + files[i].Substring(files[i].LastIndexOf("\\")));
                            }
                            backedUpProjects = true;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("An error occurred while moving GrainBound projects: " + ex.Message + "\n\nThe uninstall process has been cancelled.", "Error");
                        }
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }

                btnUninstall.Text    = "Uninstalling...";
                btnUninstall.Enabled = false;
                Directory.Delete(tboxLocation.Text, true);
                if (File.Exists("C:\\Users\\" + Environment.UserName + "\\Desktop\\GrainBound.lnk"))
                {
                    File.Delete("C:\\Users\\" + Environment.UserName + "\\Desktop\\GrainBound.lnk");
                }
                try
                {
                    File.Delete("C:\\Windows\\System32\\pythoncom37.dll");
                    File.Delete("C:\\Windows\\System32\\pywintypes37.dll");
                }
                catch { }
                GBRegistry.removeRegistryKey();
                MessageBox.Show("GrainBound uninstalled successfully." + (backedUpProjects ? (" Existing projects have been moved to " + newPath) : ""), "Success");
                this.Close();
            }
        }
Ejemplo n.º 3
0
        private void unzipApplication()
        {
            lblStatus.Text = "Status: Unzipping files...";
            lblStatus.Refresh();

            try
            {
                System.IO.Compression.ZipFile.ExtractToDirectory(tboxLocation.Text + "\\gb.zip", tboxLocation.Text);

                File.Delete(tboxLocation.Text + "\\gb.zip");

                File.Copy(
                    tboxLocation.Text + "\\python\\Lib\\pywin32_system32\\pythoncom37.dll",
                    "C:\\Windows\\System32\\pythoncom37.dll");
                File.Copy(
                    tboxLocation.Text + "\\python\\Lib\\pywin32_system32\\pywintypes37.dll",
                    "C:\\Windows\\System32\\pywintypes37.dll");
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred while unzipping install files. Message: " + ex.Message, "Error");
                Process.Start(tboxLocation.Text);
            }

            if (cboxDesktopShortcut.Checked)
            {
                createShortcut();
            }

            GBRegistry.createRegistryKey(GBRegistry.GRAINBOUND_INSTALL_KEY, tboxLocation.Text);

            btnInstall.Enabled         = true;
            btnInstallLocation.Enabled = true;
            tboxLocation.Enabled       = true;
            lblStatus.Text             = "Status: Complete.";
            pgbProgress.Value          = 0;

            MessageBox.Show("GrainBound installation complete.", "Installation Complete");
            Application.Exit();
        }
Ejemplo n.º 4
0
 private string getCurrentVersion()
 {
     return(GBRegistry.checkRegistryKey(GBRegistry.GRAINBOUND_VERSION_KEY));
 }
Ejemplo n.º 5
0
 private void UninstallForm_Load(object sender, EventArgs e)
 {
     tboxLocation.Text = GBRegistry.checkRegistryKey(GBRegistry.GRAINBOUND_INSTALL_KEY);
 }