public void LoadFormatFromXml(string fileName) { int track = 0; MList <SectorInfo> layout = new MList <SectorInfo>(50); MList <SectorInfo> temp = new MList <SectorInfo>(50); using (XmlTextReader xml = new XmlTextReader(fileName)) { while (xml.Read()) { if (xml.NodeType == XmlNodeType.EndElement) { break; } if (xml.NodeType != XmlNodeType.Element) { continue; } if (xml.Name == "DiskFormat") { string name = xml.GetAttribute("Name"); if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(name)) { Name = name; } while (xml.Read()) { if (xml.NodeType == XmlNodeType.EndElement) { break; } if (xml.NodeType != XmlNodeType.Element) { continue; } switch (xml.Name) { case "Track": TrackFormat tf = Tracks[track]; tf.Layout.EnsureCapacity(Int32.Parse(xml.GetAttribute("SectorCount"))); layout.Cnt = 0; if (!xml.IsEmptyElement) { while (xml.Read()) { if (xml.NodeType == XmlNodeType.EndElement) { break; } if (xml.NodeType != XmlNodeType.Element) { continue; } switch (xml.Name) { case "Sector": SectorInfo s = new SectorInfo() { Cylinder = Int32.Parse(xml.GetAttribute("Cylinder")), Head = Int32.Parse(xml.GetAttribute("Head")), SectorNumber = Int32.Parse(xml.GetAttribute("Number")), SizeCode = Int32.Parse(xml.GetAttribute("Size")), TimeMs = Double.Parse(xml.GetAttribute("Time"), NumberStyles.Any, CultureInfo.InvariantCulture) }; layout.Add(s); break; } } } if (tf.Layout.Cnt > 0) { tf.Layout.CopyTo(temp); layout.CopyTo(tf.Layout); for (int i = 0; i < temp.Cnt; i++) { int index = tf.FindSectorIndex(temp[i].SectorNumber); if (index < 0) { Log.Info?.Out($"Сектор не найден. Трек: {track} | Сектор: {temp[i].SectorNumber}"); continue; } tf.Layout.Data[index].Data = temp[i].Data; tf.Layout.Data[index].ProcessResult = temp[i].ProcessResult; tf.Layout.Data[index].MapCellValue = temp[i].MapCellValue; tf.Layout.Data[index].TimeCalculated = false; } } else { layout.CopyTo(tf.Layout); for (int i = 0; i < layout.Cnt; i++) { tf.Layout.Data[i].MapCellValue = MapCell.Unprocessed; tf.Layout.Data[i].TimeCalculated = false; } } tf.FormatName = tf.GetFormatName(); tf.SpinTime = tf.GetSpinTime(); tf.MapModified = true; track++; break; } } } } } }