private void DrawAuxiliaryFields() { PKPassStringField eventtitle = (PKPassStringField)FindPKPassField(pk.SecondaryFields, "eventtitle"); DrawProperty(eventtitle?.Label, eventtitle?.Value, TextJustify.Left, 0.5, 7.6); PKPassField section = (PKPassField)FindPKPassField(pk.AuxiliaryFields, "section"); DrawProperty(section?.Label, "100", TextJustify.Left, 0.5, 6.6); PKPassNumberField row = (PKPassNumberField)FindPKPassField(pk.AuxiliaryFields, "row"); DrawProperty(row?.Label, row?.Value.ToString(), TextJustify.Left, 1.8, 6.6); PKPassNumberField seat = (PKPassNumberField)FindPKPassField(pk.AuxiliaryFields, "seat"); DrawProperty(seat?.Label, seat?.Value.ToString(), TextJustify.Left, 2.5, 6.6); PKPassStringField entryinfo = (PKPassStringField)FindPKPassField(pk.AuxiliaryFields, "entryinfo"); DrawProperty(entryinfo?.Label, entryinfo?.Value, TextJustify.Right, 7.9, 6.6); /* * string lavel; * string value; * * Item eventtitle = FindItem(PdfPassJson.EventTicket.SecondaryFields, "eventtitle"); * lavel = eventtitle?.Label; * value = eventtitle?.Value; * DrawProperty(lavel, value, TextJustify.Left, 0.5, 7.6); * * Item section = FindItem(PdfPassJson.EventTicket.AuxiliaryFields, "section"); * lavel = section?.Label; * value = section?.Value; * DrawProperty(lavel, value, TextJustify.Left, 0.5, 6.6); * * Item row = FindItem(PdfPassJson.EventTicket.AuxiliaryFields, "row"); * lavel = row?.Label; * value = row?.Value; * DrawProperty(lavel, value, TextJustify.Left, 1.8, 6.6); * * Item seat = FindItem(PdfPassJson.EventTicket.AuxiliaryFields, "seat"); * lavel = seat?.Label; * value = seat?.Value; * DrawProperty(lavel, value, TextJustify.Left, 2.5, 6.6); * * Item entryinfo = FindItem(PdfPassJson.EventTicket.AuxiliaryFields, "entryinfo"); * lavel = entryinfo?.Label; * value = entryinfo?.Value; * DrawProperty(lavel, value, TextJustify.Right, 7.9, 6.6); */ return; }
static void ParsePassFieldSet(JArray fieldItems, PKPassFieldSet set) { if (set == null) set = new PKPassFieldSet(); foreach (JObject item in fieldItems) { if (item["value"] == null) throw new MissingFieldException("Field must have a value field!"); if (item["key"] == null) throw new MissingFieldException("Field must have a key field!"); PKPassField field = null; double tmp = 0; DateTime tmpDate = DateTime.UtcNow; if (item["dateStyle"] != null || item["timeStyle"] != null || item["isRelative"] != null) { field = new PKPassDateField(); if (item["dateStyle"] != null) ((PKPassDateField)field).DateStyle = (PKPassFieldDateStyle)Enum.Parse(typeof(PKPassFieldDateStyle), item["dateStyle"].ToString()); if (item["timeStyle"] != null) ((PKPassDateField)field).TimeStyle = (PKPassFieldDateStyle)Enum.Parse(typeof(PKPassFieldDateStyle), item["timeStyle"].ToString()); if (item["isRelative"] != null) ((PKPassDateField)field).IsRelative = item["isRelative"].Value<bool>(); ((PKPassDateField)field).Value = tmpDate; } else if (double.TryParse(item["value"].ToString(), out tmp)) { field = new PKPassNumberField(); if (item["numberStyle"] != null) ((PKPassNumberField)field).NumberStyle = (PKPassFieldNumberStyle)Enum.Parse(typeof(PKPassFieldNumberStyle), item["numberStyle"].ToString()); ((PKPassNumberField)field).Value = tmp; } else { field = new PKPassStringField(); ((PKPassStringField)field).Value = item["value"].ToString(); } if (item["textAlignment"] != null) field.TextAlignment = (PKPassFieldTextAlignment)Enum.Parse(typeof(PKPassFieldTextAlignment), item["textAlignment"].ToString()); field.Key = item["key"].ToString(); if (item["label"] != null) field.Label = item["label"].ToString(); set.Add(field); } }