private static Dictionary<ProbeFileKey, Dictionary<USImageKey, USImageInfo>> GetProbes(List<ProbeUSImage> _rows) { var probes = new Dictionary<ProbeFileKey, Dictionary<USImageKey, USImageInfo>>(); foreach (var row in _rows) { var fileKey = new ProbeFileKey { Probe = row.Probe, Direction = row.Direction, }; Dictionary<USImageKey, USImageInfo> images; if (probes.ContainsKey(fileKey)) { images = probes[fileKey]; } else { images = new Dictionary<USImageKey, USImageInfo>(); probes.Add(fileKey, images); } var key = new USImageKey { Depth = row.Depth, Direction = row.Direction, }; USImageInfo info; if (images.ContainsKey(key)) { info = images[key]; } else { info = new USImageInfo { PixelSpacing = row.PixelSpacing, ImageShift = row.ImageShift, Guides = new Dictionary<Guide, Dictionary<LeftRight, NeedleGuideValues2>>(), }; images.Add(key, info); } Dictionary<LeftRight, NeedleGuideValues2> guides; if (info.Guides.ContainsKey(row.NeedleGuideName)) { guides = info.Guides[row.NeedleGuideName]; } else { guides = new Dictionary<LeftRight, NeedleGuideValues2>(); info.Guides.Add(row.NeedleGuideName, guides); } if (!guides.ContainsKey(row.LeftRight)) { guides.Add(row.LeftRight, row.NeedleGuideValues); } } return probes; }
private static void WriteProbeXML(ProbeFileKey _probe, Dictionary<USImageKey, USImageInfo> _images, string _fileName) { var settings = new XmlWriterSettings { Indent = true, IndentChars = " ", NewLineChars = "\r\n", NewLineHandling = NewLineHandling.Replace }; using (var writer = XmlWriter.Create(_fileName, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("SliceManagerSettings"); WriteHeader(writer); WriteImageOffsets(writer, _images); WriteSpacing2DOptions(writer, _images); WriteNeedleGuidePointsOptions(writer, _images); WriteFooter(writer, _probe); writer.WriteEndElement(); writer.WriteEndDocument(); } }
public static string GetBxFileName(ProbeFileKey _key) { var probeName = ""; switch (_key.Probe) { case Probe.BK8808: probeName = "8808"; break; case Probe.BK8818: probeName = "8818"; break; default: Debug.Assert(false); break; } var fireName = ""; switch (_key.Direction) { case Direction.SIDEFIRE: fireName = "SideFire"; break; case Direction.ENDFIRE: fireName = "EndFire"; break; case Direction.TRANSVERSE: fireName = "TransverseFire"; break; default: Debug.Assert(false); break; } var name = string.Format("{0}{1}Settings.xml", probeName, fireName); return name; }
private static void WriteFooter(XmlWriter writer, ProbeFileKey _probe) { var direction = _probe.Direction.ToString(); var probe = _probe.Probe.ToString(); writer.WriteElementString("DirectionOfFire", direction); writer.WriteElementString("Probe", probe); }
public bool Equals(ProbeFileKey _spacing) { var equals = false; if (_spacing != null) { equals = true; equals &= this.Probe == _spacing.Probe; equals &= this.Direction == _spacing.Direction; } return equals; }