private void ReadCatalogue(object sender, EventArgs e) { if (!ReadParameters(false)) { return; } SetProcessing(true); BackgroundWorker worker = new BackgroundWorker(); Log.Info?.Out($"Чтение каталога. DataRate: {Params.DataRate}"); int successfullyRead = 0; DiskReaderParams npars = new DiskReaderParams() { FirstSectorNum = 0, LastSectorNum = 9, DataRate = Params.DataRate, Image = new TrDosImage(9, null), SectorReadAttempts = Params.SectorReadAttempts, Side = DiskSide.Both, CurrentTrackFormat = new TrackFormat(TrackFormatName.TrDosSequential), ReadMode = ReadMode.Standard, TrackLayoutAutodetect = false, UpperSideHeadAutodetect = false, }; diskReader = new DiskReader() { Params = npars }; worker.DoWork += (object sndr, DoWorkEventArgs ee) => { try { if (!diskReader.OpenDriver()) { return; } successfullyRead = diskReader.ReadForward(); diskReader.CloseDriver(); Log.Info?.Out($"Чтение каталога завершено. Успешно прочитанных секторов: {successfullyRead}"); } catch (Exception ex) { Log.Error?.Out($"Исключение при чтении диска: {ex.Message} | StackTrace: {ex.StackTrace}"); } }; worker.RunWorkerCompleted += (object sender1, RunWorkerCompletedEventArgs ee) => { SetProcessing(false); if (MainForm.CatalogueForm == null) { MainForm.CatalogueForm = new CatalogueForm(); } if (successfullyRead > 1) { MainForm.CatalogueForm.ShowForm(diskReader.Params.Image as TrDosImage, false); } }; worker.RunWorkerAsync(); }
private void ReadRandomSectors(object sender, EventArgs e) { if (!ReadParameters()) { return; } SetProcessing(true); Log.Info?.Out($"Чтение случайных секторов. Side: {Params.Side}. DataRate: {Params.DataRate}"); diskReader = new DiskReader((DiskReaderParams)Params.Clone()); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (object sndr, DoWorkEventArgs ee) => { try { if (!diskReader.OpenDriver()) { return; } int successfullyRead = diskReader.ReadRandomSectors(TimeSpan.Zero); diskReader.CloseDriver(); Log.Info?.Out($"Успешно прочитанных секторов: {successfullyRead}"); } catch (Exception ex) { Log.Error?.Out($"Исключение при чтении диска: {ex.Message} | StackTrace: {ex.StackTrace}"); } }; worker.RunWorkerCompleted += (object sender1, RunWorkerCompletedEventArgs ee) => { SetProcessing(false); }; worker.RunWorkerAsync(); }
private void ReadBackward(object sender, EventArgs e) { if (!ReadParameters()) { return; } SetProcessing(true); Log.Info?.Out($"Чтение диска в обратном направлении. UpperSideHead: {upperSideString}. Side: {Params.Side}. DataRate: {Params.DataRate}. ReadMode: {(Params.TrackLayoutAutodetect ? "Fast" : "Standard")}"); diskReader = new DiskReader((DiskReaderParams)Params.Clone()); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (object sndr, DoWorkEventArgs ee) => { try { if (!diskReader.OpenDriver()) { return; } int successfullyRead = diskReader.ReadBackward(); diskReader.CloseDriver(); Log.Info?.Out($"Успешно прочитанных секторов: {successfullyRead}"); } catch (Exception ex) { Log.Error?.Out($"Исключение при чтении диска: {ex.Message} | StackTrace: {ex.StackTrace}"); } }; worker.RunWorkerCompleted += (object sender1, RunWorkerCompletedEventArgs ee) => { SetProcessing(false); }; worker.RunWorkerAsync(); }