Exemplo n.º 1
0
 public TextEdit(GameManager gameManager) : base(gameManager)
 {
     this.Add(Label = new Label.Label(gameManager));
     GameManager    = gameManager;
 }
Exemplo n.º 2
0
        public void Parse(string FilePath)
        {
            if (!File.Exists(FilePath))
            {
                throw new ApplicationException(string.Format("Cannot find file: {0}", FilePath));
            }

            Labels.Clear();
            DefaultLabel = null;
            destination  = null;

            ID    = "";
            From  = "";
            Group = "";
            User  = "";

            CreateTime      = "";
            PreviewFileName = "";
            AutoRelease     = false;

            XmlDocument xDoc = new XmlDocument();

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

            foreach (XmlNode nodex in node)
            {
                foreach (XmlAttribute attrib in nodex.Attributes)
                {
                    if (attrib.Name.Equals("id", StringComparison.OrdinalIgnoreCase))
                    {
                        ID = attrib.Value;
                    }
                    else if (attrib.Name.Equals("group", StringComparison.OrdinalIgnoreCase))
                    {
                        Group = attrib.Value;
                    }
                    else if (attrib.Name.Equals("from", StringComparison.OrdinalIgnoreCase))
                    {
                        From = attrib.Value;
                    }
                    else if (attrib.Name.Equals("user", StringComparison.OrdinalIgnoreCase))
                    {
                        User = attrib.Value;
                    }
                }

                foreach (XmlNode nodexx in nodex.ChildNodes)
                {
                    if (nodexx.Name.Equals("destination", StringComparison.OrdinalIgnoreCase))
                    {
                        destination = new Destination();
                        destination.Parse(nodexx);

                        if (destination.LabelType != null)
                        {
                            LabelDef = new Label.LabelDef();
                            string path = LabelDefinitionsPath + @"\" + destination.LabelType + ".xml";
                            if (File.Exists(path))
                            {
                                LabelDef.Parse(path);
                            }
                        }
                    }
                    else if (nodexx.Name.Equals("languages", StringComparison.OrdinalIgnoreCase))
                    {
                        languages = new Languages();
                        languages.Parse(nodexx);
                    }
                    else if (nodexx.Name.Equals("createtime", StringComparison.OrdinalIgnoreCase))
                    {
                        CreateTime = nodexx.InnerText;
                    }
                    else if (nodexx.Name.Equals("previewfilename", StringComparison.OrdinalIgnoreCase))
                    {
                        PreviewFileName = nodexx.InnerText;
                    }
                    else if (nodexx.Name.Equals("autorelease", StringComparison.OrdinalIgnoreCase))
                    {
                        AutoRelease = nodexx.InnerText.Equals("true", StringComparison.OrdinalIgnoreCase);
                    }
                    else if (nodexx.Name.Equals("labels", StringComparison.OrdinalIgnoreCase))
                    {
                        foreach (XmlNode nodexxx in nodexx.ChildNodes)
                        {
                            if (nodexxx.Name.Equals("label", StringComparison.OrdinalIgnoreCase))
                            {
                                Label.Label NewLabel = new Label.Label();
                                NewLabel.Parse(nodexxx);
                                if (NewLabel.Type == Label.Label.LabelType.DefaultLabel)
                                {
                                    DefaultLabel = NewLabel;
                                }
                                else
                                {
                                    Labels.Add(NewLabel);
                                }
                            }
                        }
                    }
                }
            }
        }