Esempio n. 1
0
        public Yearbook process()
        {
            yearbook = new Yearbook();
            XmlNodeList nodes = doc.GetElementsByTagName(XmlElement.YEARBOOK);

            if (nodes.Count > 0)
            {
                nodes = nodes.Item(0).ChildNodes;
                foreach (XmlNode node in nodes)
                {
                    String value = node.InnerText;
                    switch (node.Name)
                    {
                    case XmlElement.APP_TITLE:
                        yearbook.AppTitle = node.InnerText;
                        break;

                    case XmlElement.YEAR:
                        yearbook.Year = node.InnerText;
                        break;

                    case XmlElement.TITLE_IMAGE:
                        if (!Utility.isEmpty(value))
                        {
                            yearbook.TitleImage = new FileInfo(value);
                        }
                        break;

                    case XmlElement.URL:
                        if (!Utility.isEmpty(value))
                        {
                            yearbook.Url = new Uri(value);
                        }
                        break;

                    case XmlElement.SECTIONS:
                        yearbook.Sections = processSections(node);
                        break;
                    }
                }

                // process XML file for each section
                IList <Section> sectionList = yearbook.Sections;
                foreach (Section section in sectionList)
                {
                    FileInfo file = section.File;
                    if (file != null && file.Exists)
                    {
                        processSectionFile(section);
                    }
                }
            }

            doc = null;

            return(yearbook);
        }
Esempio n. 2
0
        static void Main()
        {
            try
            {
                XmlReader reader   = new XmlReader(new FileInfo("yearbook.xml"));
                Yearbook  yearbook = reader.process();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm(yearbook));
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Yearbook", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
        public MainForm(Yearbook yearbook)
        {
            this.yearbook = yearbook;

            InitializeComponent();
            this.Text                     = yearbook.AppTitle;
            this.yearLabel.Text           = yearbook.Year;
            this.titleImage.ImageLocation = yearbook.TitleImage.ToString();

            IList <Section> sections  = yearbook.Sections;
            int             parentIdx = 0;

            foreach (Section section in sections)
            {
                TreeNode node = new TreeNode(section.Name);
                node.ToolTipText = section.Tooltip;
                IList <Section> subsections = section.Sections;
                if (subsections.Count > 0)
                {
                    int childIdx = 0;
                    foreach (Section subsection in subsections)
                    {
                        TreeNode subnode = new TreeNode(subsection.Name);
                        subnode.ToolTipText = subsection.Tooltip;
                        subnode.Tag         = new int[] { parentIdx, childIdx, -1 };
                        node.Nodes.Add(subnode);
                        getSubTree(subnode, subsection);
                        childIdx++;
                    }
                }
                node.Tag = new int[] { parentIdx, -1, -1 };
                this.treeView.Nodes.Add(node);

                parentIdx++;
            }
        }