예제 #1
0
        private void btnAuto_Click(object sender, EventArgs e)
        {
            if (comboBox2.SelectedIndex == -1)
            {
                MessageBox.Show("Please select an installation method", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (_Client.VirtualBoxPath == null)
            {
                MessageBox.Show("Please select VirtualBox path", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (textBox1.Text == "")
            {
                MessageBox.Show("Please specify VirtualBox version", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            WebClient clt = new WebClient();

            byte[] binaryFile = null;
            btnAuto.Enabled = false;
            try
            {
                if (!checkBox1.Checked)
                {
                    string URL = clt.DownloadString(string.Format("http://virtualkd.sysprogs.org/cgi-bin/getbin.pl?ver={0}&platform={1}", textBox1.Text, comboBox1.Text));
                    if (URL.StartsWith("http://"))
                    {
                        binaryFile = DownloadProgressForm.DownloadToArray(URL, "Downloading precompiled VboxDD.dll", null);
                    }
                }
            }
            catch (System.Exception)
            {
            }
            btnAuto.Enabled = true;

            if (binaryFile == null)
            {
                if (!checkBox1.Checked)
                {
                    if (MessageBox.Show("VirtualKD setup was not able to download the precompiled VBoxDD.dll for your version of VirtualBox. Do you want to build it from source code?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                    {
                        return;
                    }
                }

                binaryFile = VBoxBuildForm.FetchAndBuild(textBox1.Text, (comboBox1.SelectedIndex == 1));
                if (binaryFile == null)
                {
                    return;
                }
            }

            string dd  = _Client.VirtualBoxPath + @"\VBoxDD.dll";
            string dd0 = _Client.VirtualBoxPath + @"\VBoxDD0.dll";

            try
            {
                if (comboBox2.SelectedIndex == 0)
                {
                    if (!File.Exists(dd))
                    {
                        throw new FileNotFoundException("VBoxDD.dll is missing. Nothing to rename!");
                    }
                    if (File.Exists(dd0))
                    {
                        File.Delete(dd0);
                    }
                    File.Move(dd, dd0);
                }
                else
                {
                    if (File.Exists(dd))
                    {
                        File.Delete(dd);
                    }
                }

                using (FileStream fs = File.Create(dd))
                    fs.Write(binaryFile, 0, binaryFile.Length);

                MessageBox.Show("Integration successful", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(textBox1.Text))
            {
                Directory.CreateDirectory(textBox1.Text);
            }
            WebClient clt  = new WebClient();
            string    data = clt.DownloadString(textBox2.Text);
            Regex     r    = new Regex("A HREF=\"([0-9]+)\\.([0-9]+)\\.([0-9]+)/\"");
            Dictionary <string, bool> added = new Dictionary <string, bool>();

            checkedListBox1.Items.Clear();
            foreach (Match match in r.Matches(data))
            {
                int major = int.Parse(match.Groups[1].ToString());
                int minor = int.Parse(match.Groups[2].ToString());
                if (major < 3)
                {
                    continue;
                }

                string fullver = string.Format("{0}.{1}.{2}", match.Groups[1], match.Groups[2], match.Groups[3]);
                string ver     = string.Format("{0}.{1}.x", major, minor);
                if (!checkBox1.Checked)
                {
                    ver = fullver;
                }

                if (added.ContainsKey(ver))
                {
                    continue;
                }

                added[ver] = true;

                checkedListBox1.Items.Add(new BuildJob
                {
                    FullVersion  = fullver,
                    SavedVersion = ver
                });
            }

            Application.DoEvents();

            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                BuildJob job = checkedListBox1.Items[i] as BuildJob;
                if (Directory.Exists(textBox1.Text + "\\" + job.SavedVersion))
                {
                    checkedListBox1.SetItemChecked(i, true);
                    continue;
                }
                else
                {
                    checkedListBox1.SetItemChecked(i, true);
                    string dir = textBox1.Text + "\\" + job.SavedVersion;
                    Directory.CreateDirectory(dir);

                    VBoxBuildForm.FetchAndBuild(job.FullVersion, true, dir);
                }
            }
        }