private void RetrieveFont(XmlTextWriter writer, IJPMessageItem m) { writer.WriteStartElement("Font"); // Start Font { writer.WriteAttributeString("InterCharacterSpace", m.InterCharacterSpace.ToString()); writer.WriteAttributeString("IncreasedWidth", m.Bold.ToString()); writer.WriteAttributeString("DotMatrix", m.DotMatrix.ToString()); } writer.WriteEndElement(); // End Font writer.WriteStartElement("BarCode"); // Start Barcode { if (m.Barcode != IJPBarcode.Nothing) { writer.WriteAttributeString("HumanReadableFont", m.ReadableCode.ToString()); writer.WriteAttributeString("EANPrefix", m.Prefix.ToString()); writer.WriteAttributeString("DotMatrix", m.Barcode.ToString()); } } writer.WriteEndElement(); // End BarCode }
// Load the Calendar and date objects from the XML private bool LoadDateCount(IJPMessage m) { bool success = true; int calBlockNumber = 0; int cntBlockNumber = 0; int[] calStart = new int[Items.Count]; int[] calCount = new int[Items.Count]; int[] countStart = new int[Items.Count]; int[] countCount = new int[Items.Count]; for (int i = 0; i < Items.Count; i++) { IJPMessageItem item = (IJPMessageItem)m.Items[i]; if (Items[i].SelectSingleNode("Date") != null) { calCount[i] = item.CalendarBlockCount; if (calCount[i] > 0) { calStart[i] = calBlockNumber; calBlockNumber += calCount[i]; } } if (Items[i].SelectSingleNode("Counter") != null) { countCount[i] = item.CountBlockCount; if (countCount[i] > 0) { countStart[i] = cntBlockNumber; cntBlockNumber += countCount[i]; } } } for (int i = 0; i < Items.Count; i++) { if (Items[i].SelectSingleNode("Date") != null) { LoadCalendar(m.CalendarConditions, Items[i], calCount[i], calStart[i]); } if (Items[i].SelectSingleNode("Counter") != null) { LoadCount(m.CountConditions, Items[i], countCount[i], countStart[i]); } // Time Count is not by item but are by message. if (Items[i].SelectSingleNode("TimeCount") != null) { m.TimeCount = LoadTimeCount(Items[i].SelectSingleNode("TimeCount")); } // Shift codes are not by item but are by message. if (Items[i].SelectSingleNode("Shifts") != null) { LoadShift(m.ShiftCodes, Items[i].SelectSingleNode("Shifts")); } } Items = null; return(success); }
// Build the structure and load Items private bool AllocateRowsColumns(IJPMessage m, XmlNodeList msg) { XmlNode n; Items = new List <XmlNode>(); bool success = true; int[] columns = new int[100]; int[] ILS = new int[100]; int maxCol = 0; // Count the rows and columns foreach (XmlNode col in msg) { if (col is XmlWhitespace) { continue; } switch (col.Name) { case "Column": columns[maxCol] = 0; int.TryParse(GetXmlAttr(col, "InterLineSpacing"), out ILS[maxCol]); foreach (XmlNode item in col) { if (item is XmlWhitespace) { continue; } switch (item.Name) { case "Item": Items.Add(item); columns[maxCol]++; break; } } maxCol++; break; } } // Allocate the rows and columns int i = 0; for (int col = 0; col < maxCol; col++) { if (columns[col] == 0) { return(false); } m.AddColumn(); m.SetRow(col, (byte)columns[col]); for (int row = 0; row < columns[col]; row++) { IJPMessageItem item = (IJPMessageItem)m.Items[i]; if ((n = Items[i].SelectSingleNode("Font")) != null) { item.DotMatrix = ParseEnum <IJPDotMatrix>(GetXmlAttr(n, "DotMatrix")); item.InterCharacterSpace = (byte)GetXmlAttrN(n, "InterCharacterSpace"); item.LineSpacing = (byte)ILS[col]; item.Bold = (byte)GetXmlAttrN(n, "IncreasedWidth"); item.Text = FormatText(GetXmlValue(Items[i].SelectSingleNode("Text"))); } i++; } } LoadDateCount(m); return(success); }