private TView Create(XmlDocument document)
        {
            var view = new TView();

            XmlNode root   = document.FirstChild;
            var     header = root.SelectSingleNode("/view/header");

            var h = new TPage();

            if (header.Attributes["text"] != null)
            {
                h.Text = header.Attributes["text"].Value;
            }

            foreach (XmlNode group in header.SelectNodes("./group"))
            {
                var g = CreateGroup(group);
                h.Groups.Add(g);
            }

            view.Header = h;


            var pageList = root.SelectNodes("/view/pages/page");

            foreach (XmlNode page in pageList)
            {
                var p = new TPage();
                if (page.Attributes["text"] != null)
                {
                    p.Text = page.Attributes["text"].Value;
                }

                foreach (XmlNode group in page.SelectNodes("./group"))
                {
                    var g = CreateGroup(group);
                    p.Groups.Add(g);
                }

                view.Pages.Add(p);
            }

            var commands = root.SelectSingleNode("/view/commands");

            if (commands != null)
            {
                view.Commands = new List <TCommand>();
                foreach (XmlNode r in commands.SelectNodes("./command"))
                {
                    var fr = new TCommand();
                    fr.Id       = Int32.Parse(ReadAttribute(r, "id"));
                    fr.Text     = ReadAttribute(r, "text");
                    fr.Position = ReadAttribute(r, "position");
                    view.Commands.Add(fr);
                }
            }

            return(view);
        }
Beispiel #2
0
        private void ExtractPageFields(TPage p, ref List <TField> fields)
        {
            if (p == null)
            {
                return;
            }

            foreach (var g in p.Groups)
            {
                foreach (var r in g.Rows)
                {
                    fields.AddRange(r.Fields);
                }
            }
        }