예제 #1
0
        // -----------------------------------------------
        // Update Button
        // -----------------------------------------------
        // Launches Download and 7-Zip Extraction
        private void buttonUpdate_Click(object sender, RoutedEventArgs e)
        {
            // Add backslash to Location Textbox path if missing
            if (!textBoxLocation.Text.EndsWith("\\") && !string.IsNullOrWhiteSpace(textBoxLocation.Text))
            {
                textBoxLocation.Text = textBoxLocation.Text + "\\";
            }
            // Load the User's RetroArch Location from Text Box / Saved Settings
            Paths.retroarchPath = textBoxLocation.Text; //end with backslash


            // If RetroArch Path is empty, halt progress
            if (string.IsNullOrEmpty(Paths.retroarchPath) &&
                (string)comboBoxDownload.SelectedItem != "Stellar")    // ignore if Stellar Self Update
            {
                ready = false;
                MessageBox.Show("Please select your RetroArch main folder.");
            }

            // MUST BE IN THIS ORDER: 1. SetArchitecture -> 2. parsePage -> 3. SetArchiver  ##################
            // If you checkArchiver before parsePage, it will not set the Parse.nightly7z string in the CLI Arguments first
            // Maybe solve this by putting CLI Arguments in another method?

            // 1. Call SetArchitecture Method
            Paths.SetArchitecture(this);

            // 2. Call parse Page (HTML) Method
            Parse.ParseBuildbotPage(this);

            // 3. Call checkArchiver Method
            // If Archiver exists, Set string
            Archiver.SetArchiver(this);


            // -------------------------
            // Stellar Self-Update
            // -------------------------
            if ((string)comboBoxDownload.SelectedItem == "Stellar")
            {
                // Parse GitHub Page HTML
                Parse.ParseGitHubReleases(this);

                if (Parse.latestVersion != null && MainWindow.currentVersion != null)
                {
                    // Check if Stellar is the Latest Version
                    if (Parse.latestVersion > MainWindow.currentVersion)
                    {
                        // Yes/No Dialog Confirmation
                        //
                        MessageBoxResult result = MessageBox.Show("v" + Parse.latestVersion + "-" + Parse.latestBuildPhase + "\n\nDownload Update?", "Update Available", MessageBoxButton.YesNo);
                        switch (result)
                        {
                        case MessageBoxResult.Yes:
                            // Proceed
                            break;

                        case MessageBoxResult.No:
                            // Lock
                            MainWindow.ready = false;
                            break;
                        }
                    }
                    else if (Parse.latestVersion <= MainWindow.currentVersion)
                    {
                        // Lock
                        MainWindow.ready = false;
                        MessageBox.Show("This version is up to date.");
                    }
                    else // null
                    {
                        // Lock
                        MainWindow.ready = false;
                        MessageBox.Show("Could not find download. Try updating manually.");
                    }
                }
            }


            // -----------------------------------------------
            // If New Install (RetroArch + Cores)
            // -----------------------------------------------
            if ((string)comboBoxDownload.SelectedItem == "New Install")
            {
                // -------------------------
                // Create Cores Folder
                // -------------------------
                using (Process execMakeCoresDir = new Process())
                {
                    execMakeCoresDir.StartInfo.UseShellExecute        = false;
                    execMakeCoresDir.StartInfo.Verb                   = "runas"; //use with ShellExecute for admin
                    execMakeCoresDir.StartInfo.CreateNoWindow         = true;
                    execMakeCoresDir.StartInfo.RedirectStandardOutput = true;    //set to false if using ShellExecute
                    execMakeCoresDir.StartInfo.FileName               = "cmd.exe";
                    execMakeCoresDir.StartInfo.Arguments              = "/c cd " + "\"" + Paths.retroarchPath + "\"" + " && mkdir cores";
                    execMakeCoresDir.Start();
                    execMakeCoresDir.WaitForExit();
                    execMakeCoresDir.Close();
                }

                // Set Cores Folder (Dont Scan PC)
                Paths.coresPath = Paths.retroarchPath + "cores\\";
                // Call Parse Builtbot Page Method
                Parse.ParseBuildbotCoresIndex(this);
            }



            // -----------------------------------------------
            // If RetroArch+Cores or Cores Only Update
            // -----------------------------------------------
            // RA+Cores or Cores Selected
            if ((string)comboBoxDownload.SelectedItem == "New Install" ||
                (string)comboBoxDownload.SelectedItem == "RA+Cores" ||
                (string)comboBoxDownload.SelectedItem == "Cores" ||
                (string)comboBoxDownload.SelectedItem == "New Cores")
            {
                // Create Builtbot Cores List
                Parse.ParseBuildbotCoresIndex(this);

                // Create PC Cores List
                Parse.ScanPcCoresDir(this);

                // Create Cores to Update List
                Queue.UpdatedCores(this);

                // Check if Cores Up To Date
                // If All Cores up to date, display message
                Queue.CoresUpToDateCheck(this); //Note there are Clears() in this method
            }



            // -----------------------------------------------
            // Ready
            // -----------------------------------------------
            if (ready == true)
            {
                Download.StartDownload(this);
            }
            else
            {
                // Restart & Reset ready value
                ready = true;
                // Call Garbage Collector
                GC.Collect();
            }
        }