Exemplo n.º 1
0
        public void Parse(string FilePath)
        {
            ID = "";
            coordinateSystem = null;
            labelLayout      = null;

            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(FilePath);
            XmlNodeList node = xDoc.GetElementsByTagName("paper");

            foreach (XmlNode nodex in node)
            {
                foreach (XmlAttribute attrib in nodex.Attributes)
                {
                    if (attrib.Name.Equals("type", StringComparison.OrdinalIgnoreCase))
                    {
                        ID = attrib.Value;
                    }
                }

                foreach (XmlNode nodexx in nodex.ChildNodes)
                {
                    if (nodexx.Name.Equals("coordinates", StringComparison.OrdinalIgnoreCase))
                    {
                        coordinateSystem = new Tools.CoordinateSystem();
                        coordinateSystem.Parse(nodexx);
                    }
                    else if (nodexx.Name.Equals("size", StringComparison.OrdinalIgnoreCase))
                    {
                        size = new ACA.LabelX.Tools.Size(0, 0, coordinateSystem.units);
                        size.Parse(nodexx);
                    }
                    else if (nodexx.Name.Equals("labelpos", StringComparison.OrdinalIgnoreCase))
                    {
                        labelLayout = new LabelLayout(coordinateSystem.units);
                        labelLayout.Parse(nodexx);
                    }
                    else if (nodexx.Name.Equals("offsets", StringComparison.OrdinalIgnoreCase))
                    {
                        foreach (XmlNode nodexxx in nodexx)
                        {
                            if (nodexxx.Name.Equals("offset", StringComparison.OrdinalIgnoreCase))
                            {
                                Offset offset = new Offset(coordinateSystem.units);
                                offset.Parse(nodexxx);

                                Offsets.Add(string.Format("{0}@{1}", offset.Printer, offset.Machine), offset);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        //Main Functions
        private void okBtn_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                newpaperdef    = new ACA.LabelX.Paper.PaperDef();
                newpaperdef.ID = idtxt.Text;
                newpaperdef.coordinateSystem = new CoordinateSystem(Convert.ToUInt32(DPIXtxt.Text), Convert.ToUInt32(DPIYtxt.Text), unitcombo.SelectedItem.ToString());
                newpaperdef.size             = new ACA.LabelX.Tools.Size(new Length(Convert.ToSingle(sizextxt.Text, CultureInfo.InvariantCulture), newpaperdef.coordinateSystem.units), new Length(Convert.ToSingle(sizeytxt.Text), newpaperdef.coordinateSystem.units));

                ACA.LabelX.Paper.LabelLayout templabellayout = new ACA.LabelX.Paper.LabelLayout(newpaperdef.coordinateSystem.units);
                templabellayout.LeftMargin              = new Length(Convert.ToSingle(horzmargintxt.Text, CultureInfo.InvariantCulture), newpaperdef.coordinateSystem.units);
                templabellayout.TopMargin               = new Length(Convert.ToSingle(vertmargintxt.Text, CultureInfo.InvariantCulture), newpaperdef.coordinateSystem.units);
                templabellayout.HorizontalCount         = Convert.ToUInt32(nrhorzlblstxt.Text);
                templabellayout.VerticalCount           = Convert.ToUInt32(nrvertlblstxt.Text);
                templabellayout.HorizontalInterlabelGap = new Length(Convert.ToSingle(horzgaptxt.Text, CultureInfo.InvariantCulture), newpaperdef.coordinateSystem.units);
                templabellayout.VerticalInterlabelGap   = new Length(Convert.ToSingle(vertgaptxt.Text, CultureInfo.InvariantCulture), newpaperdef.coordinateSystem.units);

                newpaperdef.labelLayout = templabellayout;

                //Add default offset to local offsets
                Offset tempDefaultOffset = new Offset(newpaperdef.coordinateSystem.units);
                tempDefaultOffset.LeftMarginOffset = new Length(Convert.ToSingle(defhorzoffsettxt.Text, CultureInfo.InvariantCulture), newpaperdef.coordinateSystem.units);
                tempDefaultOffset.TopMarginOffset  = new Length(Convert.ToSingle(defvertoffsettxt.Text, CultureInfo.InvariantCulture), newpaperdef.coordinateSystem.units);
                tempDefaultOffset.Machine          = "";
                tempDefaultOffset.Printer          = "";
                if (LocalOffsets.ContainsKey("@"))
                {
                    LocalOffsets.Remove("@");
                }
                LocalOffsets.Add("@", tempDefaultOffset);

                //Add all offsets to new paper
                newpaperdef.Offsets = LocalOffsets;


                if (mode == Mode.edit)
                {
                    File.Delete(paperDefinitionRootFolder + @"\" + newpaperdef.ID + @".xml");
                }
                savePaperDefTo(paperDefinitionRootFolder + @"\" + newpaperdef.ID + @".xml");
                PaperType    = newpaperdef.ID;
                DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show(GetString("INVALIDINPUTERROR"), GetString("INVALIDINPUTERRORTITLE"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }