public static DialogResult DownloadAndUnpack(string URL, string Dir, string Title, string NamePrefixToDrop, UnpackFilter filter) { try { DownloadProgressForm frm = new DownloadProgressForm(URL, Dir, NamePrefixToDrop); frm._Filter = filter; frm.Text = Title; return(frm.ShowDialog()); } catch (System.Exception) { return(DialogResult.Cancel); } }
public static DialogResult DownloadAndUnpack(string URL, string Dir, string Title, string NamePrefixToDrop, UnpackFilter filter) { try { DownloadProgressForm frm = new DownloadProgressForm(URL, Dir, NamePrefixToDrop); frm._Filter = filter; frm.Text = Title; return frm.ShowDialog(); } catch (System.Exception) { return DialogResult.Cancel; } }
public static byte[] DownloadToArray(string URL, string Title, string NamePrefixToDrop) { try { DownloadProgressForm frm = new DownloadProgressForm(URL, null, NamePrefixToDrop); frm.Text = Title; if (frm.ShowDialog() == DialogResult.Cancel) return null; return frm.DownloadedData; } catch (System.Exception) { return null; } }
public static byte[] DownloadToArray(string URL, string Title, string NamePrefixToDrop) { try { DownloadProgressForm frm = new DownloadProgressForm(URL, null, NamePrefixToDrop); frm.Text = Title; if (frm.ShowDialog() == DialogResult.Cancel) { return(null); } return(frm.DownloadedData); } catch (System.Exception) { return(null); } }
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); } }
private void button1_Click(object sender, EventArgs e) { try { button1.Enabled = false; textBox4.Text = ""; string dir = textBox3.Text; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string vboxDir = dir + @"\VBox"; if (!Directory.Exists(vboxDir)) { Directory.CreateDirectory(vboxDir); } else if (checkBox1.Checked) { MessageBox.Show("Directory " + vboxDir + " already exists. It won't be deleted after successful build.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); checkBox1.Checked = false; } switch (DownloadProgressForm.DownloadAndUnpack(textBox1.Text, vboxDir, "Downloading VirtualBox OSE...", "", IsVBoxIncludeFile)) { case DialogResult.OK: break; case DialogResult.No: if (DownloadProgressForm.DownloadAndUnpack(textBox1.Text.Replace(".tar.bz2", "-OSE.tar.bz2"), vboxDir, "Downloading VirtualBox OSE...", "", IsVBoxIncludeFile) != DialogResult.OK) { return; } break; default: return; } string[] dirs = Directory.GetDirectories(vboxDir, "VirtualBox-*"); if (dirs.Length != 1) { MessageBox.Show("Directory " + vboxDir + " should only have 1 VirtualBox subdirectory", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string newDir = Path.GetDirectoryName(dirs[0]) + @"\main"; if (Directory.Exists(newDir)) { Directory.Delete(newDir, true); } Directory.Move(dirs[0], newDir); WebClient clt = new WebClient(); string ver = clt.DownloadString("http://virtualkd.sysprogs.org/vbox/autobox.ver"); string URL = string.Format("http://virtualkd.sysprogs.org/vbox/autobox-{0}.zip", ver); if (DownloadProgressForm.DownloadAndUnpack(URL, dir, "Downloading VBoxDD.dll sources...", "", null) != DialogResult.OK) { return; } _SLNFile = dir + @"\VBoxDD\VBoxDD.sln"; if (_DirForAutoMode != null) { _X64 = false; } LaunchBuild(); } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); button1.Enabled = true; } }