Пример #1
0
        private void ShowAField(IFieldDescription fieldDescription)
        {
            Label fieldLbl = new Label {
                Text = "Field " + fieldDescription.FieldNumber
            };

            if (fieldDescription.FieldName != null)
            {
                fieldLbl.Text = fieldDescription.FieldName;
            }

            Entry fieldEntry = new Entry {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            fieldEntry.ClassId = fieldDescription.FieldNumber.ToString();

            StackLayout formCell = new StackLayout {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Orientation       = StackOrientation.Horizontal,
                Children          = { fieldLbl, fieldEntry }
            };

            Children.Add(formCell);
        }
        private IFieldDescription[] GetFieldsFromPrinter()
        {
            IConnection connection = myPrinter.Connection;

            IFieldDescription[] fields = new IFieldDescription[0];
            try
            {
                connection.Open();
                CheckPrinterLanguage(connection);
                IZebraPrinter printer      = ZebraPrinterFactory.Current.GetInstance(connection);
                byte[]        rawformat    = printer.RetrieveFormatFromPrinter(_format.Path);
                string        formatstring = Encoding.UTF8.GetString(rawformat, 0, rawformat.Length);
                fields = printer.GetVariableFields(formatstring);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception:" + e.Message);
                ShowErrorAlert("GetFieldsFromPrinter" + e.Message);
            }
            finally
            {
                if ((connection != null) && (connection.IsConnected))
                {
                    connection.Close();
                }
            }
            return(fields);
        }
 protected override void EmitBeginWriteField(ILGenerator gen, IFieldDescription field)
 {
     // XmlWriter.WriteStartElement("Field")
     gen.Emit(OpCodes.Ldarg_0);
     gen.Emit(OpCodes.Ldstr, XmlSerializer.FieldElementName);
     gen.Emit(OpCodes.Callvirt, XmlWriterWriteStartElement);
     gen.Emit(OpCodes.Ldarg_0);
     gen.Emit(OpCodes.Ldstr, XmlSerializer.NameAttributeName);
     gen.Emit(OpCodes.Ldstr, field.Name);
     gen.Emit(OpCodes.Callvirt, XmlWriterWriteAttributeString);
 }
        //modified from https://github.com/Zebra/LinkOS-Xamarin-Samples/blob/ZSDK_DevDemos/ZSDK_DevDemos/Xamarin_LinkOS_Developer_Demo/Xamarin_LinkOS_Developer_Demo/FormatView.cs
        private IFieldDescription[] PrintFormatOnPrinter(string fileNameOnPrinter, string[] mydata)
        {
            IConnection connection = myPrinter.Connection;

            IFieldDescription[] fields = new IFieldDescription[0];
            try
            {
                connection.Open();
                CheckPrinterLanguage(connection);
                IZebraPrinter printer = ZebraPrinterFactory.Current.GetInstance(connection);


                byte[] rawformat    = printer.RetrieveFormatFromPrinter(fileNameOnPrinter);
                string formatstring = Encoding.UTF8.GetString(rawformat, 0, rawformat.Length);
                fields = printer.GetVariableFields(formatstring);


                Dictionary <int, string> vars = new Dictionary <int, string>();
                int i = 0;
                foreach (IFieldDescription field in fields)
                {
                    vars.Add(field.FieldNumber, mydata[i]);
                    i++;
                }
                printer.PrintStoredFormat(fileNameOnPrinter, vars);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception:" + e.Message);
                ShowErrorAlert("GetFieldsFromPrinter" + e.Message);
            }
            finally
            {
                if ((connection != null) && (connection.IsConnected))
                {
                    connection.Close();
                }
            }
            return(fields);
        }
        protected override void EmitBeginReadField(ILGenerator gen, IFieldDescription field)
        {
            var correctField      = gen.DefineLabel();
            var actualElementName = gen.DeclareLocal(typeof(string));

            // If reader.Name == FieldElementName goto correctField
            gen.Emit(OpCodes.Ldarg_0);
            gen.Emit(OpCodes.Callvirt, XmlReaderGetName);
            gen.Emit(OpCodes.Stloc, actualElementName);
            gen.Emit(OpCodes.Ldloc, actualElementName);
            gen.Emit(OpCodes.Ldstr, XmlSerializer.FieldElementName);
            gen.Emit(OpCodes.Call, StringEquals);
            gen.Emit(OpCodes.Brtrue_S, correctField);
            // throw new XmlParseException
            EmitThrowXmlParseException(gen, actualElementName);

            gen.MarkLabel(correctField);
            gen.Emit(OpCodes.Ldarg_0);
            gen.Emit(OpCodes.Ldstr, field.Name);
            gen.Emit(OpCodes.Callvirt, XmlReaderMoveToAttributeByName);
            gen.Emit(OpCodes.Pop);
        }
Пример #6
0
 protected override void EmitEndWriteField(ILGenerator gen, IFieldDescription field)
 {
 }
 protected override void EmitBeginReadField(ILGenerator gen, IFieldDescription field)
 {
 }
 protected override void EmitEndReadField(ILGenerator gen, IFieldDescription field)
 {
     gen.Emit(OpCodes.Ldarg_0);
     gen.Emit(OpCodes.Callvirt, XmlReaderRead);
     gen.Emit(OpCodes.Pop);
 }
Пример #9
0
 FrameworkElementFactory IFieldFactory.CreateField(IFactoryContext context, IFieldDescription fieldDescription)
 {
     return(CreateField(context, (TFieldDescription)fieldDescription));
 }
 protected override void EmitEndWriteField(ILGenerator gen, IFieldDescription field)
 {
     // XmlWriter.WriteEndElement()
     gen.Emit(OpCodes.Ldarg_0);
     gen.Emit(OpCodes.Callvirt, XmlWriterWriteEndElement);
 }
Пример #11
0
 public GroupAdapter(GroupDescription groupDescription, IFieldDescription lastField)
 {
     GroupDescription = groupDescription;
     LastDescription  = (FieldDescription)lastField;
 }