// Used to write Farm Code for MSSE public bool WriteSelectedItems(int itemNo, string data) { bool success = true; // Get the number of items in the message int itemCount = p.GetDecAttribute(ccIDX.Number_Of_Items); // Read the section containing the text length of each item and convert to words Section <ccPC> pb = new Section <ccPC>(p, ccPC.Characters_per_Item, 0, itemCount, true); int[] cpi = pb.GetWords(0, itemCount); // Now read all the text int charCount = cpi.Sum(x => x); Section <ccPC> tpi = new Section <ccPC>(p, ccPC.Print_Character_String, 0, charCount * 2, true); // Break up the text by (Should be able to simplify this to avoid double conversion from bytes to UTF-8 to bytes). List <string> itemText = new List <string>(itemCount); int pos = 0; for (int i = 0; i < itemCount; i++) { if (i + 1 == itemNo) { itemText.Add(UTF8Hitachi.HandleBraces(data)); } else { itemText.Add(UTF8Hitachi.HandleBraces(p.FormatAttrText(tpi.GetAttributedChrs(pos, cpi[i])))); } pos += cpi[i]; } // Save the calendar information (may need to do the same for Counter control). int calCnt = p.GetDecAttribute(ccUI.Maximum_Calendar_And_Count); Section <ccCal>[] cs = new Section <ccCal> [calCnt]; for (int i = 0; i < cs.Length; i++) { cs[i] = new Section <ccCal>(p, ccCal.Offset_Year, ccCal.Zero_Suppress_DayOfWeek, i, true); } // Write the text WriteAllText(itemText); // Restore the Calendar information for (int i = 0; i < cs.Length; i++) { cs[i].WriteSection(); } return(success); }
private string[] AllocateOneColumn(ref bool barCodesExist, ref bool hasDateOrCount, Column col) { // Stack up the requests if 2 or more items if (col.Item.Length > 1) { p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1); } // Step thru the items in a column bottom-to-top string[] sp = new string[col.Item.Length]; for (int r = col.Item.GetUpperBound(0); r >= col.Item.GetLowerBound(0); r--) { Item item = col.Item[r]; FontDef font = item.Font; // Create a block write for ILS, Font, ICS, Bolding, and Barcode // Line spacing must be set to 0 if only one item in column // Cannot set barcode until text is written Section <ccPF> sect = new Section <ccPF>(p, ccPF.Line_Spacing, ccPF.Barcode_Type, r, false); { sect.SetAttribute(ccPF.Line_Spacing, r, col.Item.Length == 1 ? 0 : col.InterLineSpacing); sect.SetAttribute(ccPF.Dot_Matrix, r, font.DotMatrix); sect.SetAttribute(ccPF.InterCharacter_Space, r, font.InterCharacterSpace); sect.SetAttribute(ccPF.Character_Bold, r, font.IncreasedWidth); sect.SetAttribute(ccPF.Barcode_Type, r, 0); sect.WriteSection(); } // Convert string to Hitachi Attributed characters sp[r] = UTF8Hitachi.HandleBraces(item.Text); barCodesExist |= item.BarCode != null; hasDateOrCount |= item.Date != null | item.Counter != null; } // Now set them all at once if 2 or more items if (col.Item.Length > 1) { p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2); } return(sp); }
// Retrieve all logos private void RetrieveLogos(Lab lab) { for (int nozzle = 0; nozzle < p.NozzleCount; nozzle++) { Msg m = lab.Message[nozzle]; // Find out which logos are used List <logoInfo> neededLogo = new List <logoInfo>(); int n; for (int c = 0; c < m.Column.Length; c++) { for (int r = 0; r < m.Column[c].Item.Length; r++) { Item item = m.Column[c].Item[r]; if (!string.IsNullOrEmpty(item.Text)) { string s = UTF8Hitachi.HandleBraces(item.Text); for (int i = 0; i < s.Length; i++) { switch (s[i] >> 8) { case '\xF6': n = (s[i] & 0xFF) - 0x40; if (n >= 0 && n < 50) { neededLogo.Add(new logoInfo() { layout = logoLayout.Free, registration = n, dotMatrix = "N/A" }); } break; case '\xF1': n = (s[i] & 0xFF) - 0x40; if (n >= 0) { neededLogo.Add(new logoInfo() { layout = logoLayout.Fixed, registration = n, dotMatrix = item.Font.DotMatrix }); } break; case '\xF2': n = (s[i] & 0xFF) - 0x20; if (n >= 0 && n < 8) { neededLogo.Add(new logoInfo() { layout = logoLayout.Fixed, registration = n + 192, dotMatrix = item.Font.DotMatrix }); } break; } } } } } // Eliminate Duplicates neededLogo = (neededLogo.OrderBy(nl => nl.layout).ToList()).OrderBy(nl => nl.registration).ToList().OrderBy(nl => nl.dotMatrix).ToList(); int j = 0; while (j < neededLogo.Count - 1) { if (neededLogo[j].layout == neededLogo[j + 1].layout && neededLogo[j].registration == neededLogo[j + 1].registration && neededLogo[j].dotMatrix == neededLogo[j + 1].dotMatrix) { neededLogo.RemoveAt(j + 1); } else { j++; } } // List of retrieved logos List <Logo> retrievedLogos = new List <Logo>(); // Retrieve any fixed logos for (int i = 0; i < neededLogo.Count; i++) { switch (neededLogo[i].layout) { case logoLayout.Free: Log?.Invoke(p, $" \n// Retrieving Free Logo {neededLogo[i].registration}\n "); if (p.GetFreeLogo(neededLogo[i].registration, out int width, out int height, out byte[] freeData)) { Logo logo = new Logo() { Location = neededLogo[i].registration, Width = width, Height = height, RawData = p.byte_to_string(freeData), Layout = "Free" }; retrievedLogos.Add(logo); } break; case logoLayout.Fixed: Log?.Invoke(p, $" \n// Retrieving Fixed Logo: Dot Matrix {neededLogo[i].dotMatrix}, Location {neededLogo[i].registration}\n "); if (p.GetFixedLogo(neededLogo[i].dotMatrix, neededLogo[i].registration, out byte[] fixedData))