private void StartWork(bool usb) { Form ask = null; if (usb) { var fs = new[] { "NTFS", "FAT32", "FAT16", "FAT12" }.AddRecommended( CurImages.Any(x => x.SizeB >= uint.MaxValue) ? 0 : 1); ask = new USBFrm(Strings.CreateMultibootUsb, Strings.Filesystem, Strings.OK, true, fs); } else { ask = new AskPath(); } if (ask.ShowDialog() == DialogResult.OK) { var fn = usb ? ((USBFrm)ask).SelectedUSB.Name.ToUpper().Substring(0, 3) : ((AskPath)ask).FileName; var g = new GenIsoFrm(fn, usb); g.WorkFinished += delegate { g_GenerationFinished(g); }; g.Title = txtTitle.Text; if (usb) { g.filesystem = ((USBFrm)ask).TheComboBox.SelectedItem.ToString().RemoveRecommended(); } switch (cbxBackType.SelectedIndex) { case 0: g.IsoBackgroundImage = ""; break; case 1: g.IsoBackgroundImage = txtBackFile.Text; break; default: g.IsoBackgroundImage = "$$NONE$$"; break; } g.Res = ((dynamic)cbxRes.SelectedItem).Val; g.Images = CurImages.Select( x => new ImageLine(x.Name, x.FilePath, x.Description, x.Category, x.CustomCode, x.EntryType)).ToList(); g.CustomFiles = CustomFiles; g.ShowDialog(this); FileIO.ClrTmp(); } }
private void FormatDrive() { // format if ( MessageBox.Show(Strings.FormatWillErase.Replace(@"\n", "\n"), "SharpBoot", MessageBoxButtons.YesNo) != DialogResult.Yes) { CancelWork(); return; } var tries = 1; while (true) { if (tries == 5) { MessageBox.Show(Strings.FormatError, "SharpBoot", MessageBoxButtons.OK, MessageBoxIcon.Error); CancelWork(); return; } ChangeProgress(0, 100, Strings.Formatting); var askform = new AskPath(); askform.SetTextMode(Text, Strings.VolumeLabel, string.Concat(Title.Where(char.IsLetter))); var volumeLabel = ""; if (askform.ShowDialog() == DialogResult.OK) { volumeLabel = askform.FileName; } else { CancelWork(); return; } var res = DriveIO.FormatDrive(OutputFilepath.Substring(0, 2), filesystem, label: volumeLabel); if (res == DriveIO.FormatResult.Success) { ChangeProgress(100, 100, Strings.Formatting); break; } switch (res) { case DriveIO.FormatResult.AccessDenied: MessageBox.Show(Strings.NeedAdmin, "SharpBoot", MessageBoxButtons.OK, MessageBoxIcon.Error); CancelWork(); return; case DriveIO.FormatResult.PartitionTooBig: MessageBox.Show(string.Format(Strings.PartitionTooBig, filesystem), "SharpBoot", MessageBoxButtons.OK, MessageBoxIcon.Error); CancelWork(); return; case DriveIO.FormatResult.UserCancelled: CancelWork(); return; default: if ( MessageBox.Show(Strings.FormatError, "SharpBoot", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Cancel) { CancelWork(); return; } tries++; break; } } }