private void btnCustomCode_Click(object sender, EventArgs e) { var cit = lvIsos.SelectedRows[0]; var bmi = new BootMenuItem( cit.Cells[0].Value?.ToString() ?? "", cit.Cells[3].Value?.ToString() ?? "", SelectedImage.EntryType, cit.Cells[4].Value?.ToString() ?? "") { Start = false }; var cod = Grub2.GetCode(bmi); var edfrm = new EditCodeFrm("/images/" + Path.GetFileName(cit.Cells[4].Value.ToString())) { Code = cod }; if (edfrm.ShowDialog(this) == DialogResult.OK) { lvIsos.SelectedRows[0].Cells[5].Value = edfrm.Code == cod ? "" : edfrm.Code; CurImages.First(x => x.Name == cit.Cells[0].Value.ToString()).CustomCode = lvIsos.SelectedRows[0].Cells[5].Value.ToString(); } }
private void ProcessBackgroundImage(string workingDir) { Image img = null; ChangeProgress(30, 100, Strings.ExtractBaseDisk + " 4/6"); if (IsoBackgroundImage == "") { var ms = new MemoryStream(Resources.sharpboot); img = Image.FromStream(ms); } else if (IsoBackgroundImage != "$$NONE$$") { img = Image.FromFile(IsoBackgroundImage); } ChangeProgress(35, 100, Strings.ExtractBaseDisk + " 5/6"); Grub2.SetImage(img, Res, workingDir); ChangeProgress(45, 100, Strings.ExtractBaseDisk + " 6/6"); }
public override void DoWork() { tmpdir = FileIO.GetTemporaryDirectory(); ChangeStatus(Strings.Init); try { using (var ext = new SevenZipExtractor()) { var isodir = _usb ? OutputFilepath : Path.Combine(tmpdir, "iso"); if (_usb) { FormatDrive(); } if (IsCancelled) { return; } var workingDir = Path.Combine(isodir, "boot", "grub"); if (!Directory.Exists(workingDir)) { Directory.CreateDirectory(workingDir); } var isoroot = Path.Combine(isodir, "images"); var archs = Path.Combine(tmpdir, "arch"); Directory.CreateDirectory(archs); File.WriteAllBytes(Path.Combine(archs, "basedisk.7z"), Resources.basedisk); ChangeProgress(0, 100, Strings.ExtractBaseDisk + " 1/6"); ext.Extract(Path.Combine(archs, "basedisk.7z"), isodir); if (IsCancelled) { return; } ProcessBackgroundImage(workingDir); ChangeProgressBar(60, 100); if (IsCancelled) { return; } CopyFiles(isoroot, isodir); if (IsCancelled) { return; } ChangeAdditional(""); ChangeProgress(0, Categories.Count, Strings.GenMenus); var main = new BootMenu(Title, true); main.Items.Add(new BootMenuItem(Strings.BootFromHDD, Strings.BootFromHDD, EntryType.BootHDD)); var ii = 0; //var itype = new Func<string, EntryType>(fn => Path.GetExtension(fn).ToLower() == ".img" ? EntryType.IMG : EntryType.ISO); if (IsCancelled) { return; } foreach (var c in Categories) { if (string.IsNullOrWhiteSpace(c)) { ChangeProgress(ii, Categories.Count, Strings.GenMainMenu); foreach (var x in Images.Where(x => x.Category == c)) { main.Items.Add(new BootMenuItem(x.Name, x.Description, x.EntryType, x.FilePath, false, x.CustomCode)); } } else { ChangeProgress(ii, Categories.Count, string.Format(Strings.GenMenu, c)); var t = new BootMenu(c, false); foreach (var x in Images.Where(x => x.Category == c)) { t.Items.Add(new BootMenuItem(x.Name, x.Description, x.EntryType, x.FilePath, false, x.CustomCode)); } File.WriteAllText(Path.Combine(workingDir, Hash.CRC32(c)) + ".cfg", Grub2.GetCode(t, Res), Utils.GetEnc()); main.Items.Add(new BootMenuItem(c, c, EntryType.Category, Hash.CRC32(c), false)); } ii++; if (IsCancelled) { return; } } File.WriteAllText(Path.Combine(workingDir, "grub.cfg"), Grub2.GetCode(main, Res)); if (IsCancelled) { return; } if (_usb) { InstallBootloader(); } else { GenerateISO(archs, ext, isodir); } } } catch (OperationCanceledException) { CancelWork(); } finally { Cleanup(tmpdir); } }
private void InstallBootloader() { ChangeProgress(23, 100, string.Format(Strings.InstallingBoot, "Grub2", OutputFilepath)); Grub2.Install(OutputFilepath); }