private void RetrieveUserPatternSettings(XmlTextWriter writer, IJPMessage m, IJP ijp) { List <LogoSave> neededLogos = new List <LogoSave>(); for (int i = 0; i < m.Items.Count; i++) { string s = m.Items[i].Text; for (int n = 0; n < s.Length; n++) { char c = s[n]; if (c >= IJPLib_XML.FirstFixedUP && c <= IJPLib_XML.LastFixedUP) { neededLogos.Add(new LogoSave() { fixedStyle = true, dm = m.Items[i].DotMatrix, location = c - IJPLib_XML.FirstFixedUP }); } else if (c >= IJPLib_XML.FirstFreeUP && c <= IJPLib_XML.LastFreeUP) { neededLogos.Add(new LogoSave() { fixedStyle = false, dm = m.Items[i].DotMatrix, location = c - IJPLib_XML.FirstFreeUP }); } } } // Any referenced? if (neededLogos.Count > 0) { // Eliminate duplicates neededLogos = neededLogos.OrderBy(o => o.location).OrderBy(o => o.dm).OrderBy(o => o.fixedStyle).ToList(); for (int i = 0; i < neededLogos.Count - 1; i++) { if (neededLogos[i].Equals(neededLogos[i = 1])) { neededLogos.RemoveAt(i + 1); } } // Output the remainder writer.WriteStartElement("Logos"); // Start Logos { //writer.WriteAttributeString("Folder", Properties.Settings.Default.MessageFolder); // Now write the logos IIJPUserPattern up; for (int i = 0; i < neededLogos.Count; i++) { writer.WriteStartElement("Logo"); // Start Logo { if (neededLogos[i].fixedStyle) { writer.WriteAttributeString("Layout", "Fixed"); up = ijp.GetFixedUserPattern(neededLogos[i].location + 1, neededLogos[i].dm); } else { writer.WriteAttributeString("Layout", "Free"); up = ijp.GetFreeUserPattern(neededLogos[i].location + 1); } writer.WriteAttributeString("DotMatrix", neededLogos[i].dm.ToString()); writer.WriteAttributeString("Location", neededLogos[i].location.ToString()); writer.WriteAttributeString("FileName", ""); writer.WriteAttributeString("Width", up.Pattern.Width.ToString()); writer.WriteAttributeString("Height", up.Pattern.Height.ToString()); writer.WriteAttributeString("RawData", BitMapToRawData(up.Pattern)); } writer.WriteEndElement(); // End Logo } } writer.WriteEndElement(); // End Logos } }