Exemplo n.º 1
0
        /// <summary>
        /// Reads page item from Xml element and adds it as a child to the parent.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="categoryNode"></param>
        private void _AddPageItem(CategoryItem parent, XmlElement categoryNode)
        {
            PageItem newPage = new PageItem();

            string typeName = categoryNode.GetAttribute(XML_TYPE_ATTRIBUTE_NAME, "");

            newPage.PageType = Type.GetType(typeName);

            // page type should exist
            Debug.Assert(newPage.PageType != null);

            // add new page to the parent
            newPage.Parent = parent;
            parent.AddChild(newPage);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads category item from Xml element and adds it as a child to the parent.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="categoryNode"></param>
        private void _AddCategoryItem(CategoryItem parent, XmlElement categoryNode)
        {
            bool visible = true;

            if (null != categoryNode.Attributes[XML_VISIBLE_ATTRIBUTE_NAME])
            {
                visible = bool.Parse(categoryNode.Attributes[XML_VISIBLE_ATTRIBUTE_NAME].Value);
            }

            CategoryItem newCategory = new CategoryItem(visible);

            newCategory.Name = categoryNode.GetAttribute(XML_NAME_ATTRIBUTE_NAME, "");
            string captionID = categoryNode.GetAttribute(XML_CAPTIONID_ATTRIBUTE_NAME, "");

            newCategory.Caption = (string)App.Current.FindResource(captionID);

            string typeName = categoryNode.GetAttribute(XML_TYPE_ATTRIBUTE_NAME, "");

            newCategory.CategoryType = Type.GetType(typeName);

            // add new category to the parent
            newCategory.Parent = parent;
            parent.AddChild(newCategory);

            // process all other category childs
            foreach (XmlNode node in categoryNode.ChildNodes)
            {
                if (node.NodeType != XmlNodeType.Element)
                {
                    continue; // skip comments and other non element nodes
                }
                if (node.Name.Equals(XML_CATEGORY_ELEMENT_NAME, StringComparison.OrdinalIgnoreCase))
                {
                    _AddCategoryItem(newCategory as CategoryItem, node as XmlElement);
                }
                else if (node.Name.Equals(XML_PAGE_ELEMENT_NAME, StringComparison.OrdinalIgnoreCase))
                {
                    _AddPageItem(newCategory as CategoryItem, node as XmlElement);
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads application structure from resource xml file.
        /// </summary>
        private void _LoadApplicationStructure()
        {
            // load navigation tree from resources
            Assembly assembly = Assembly.GetExecutingAssembly();

            using (Stream xmlStream = assembly.GetManifestResourceStream("ESRI.ArcLogistics.App.NavigationTree.xml"))
            {
                XmlDocument navTreeDoc = new XmlDocument();
                navTreeDoc.Load(xmlStream);

                // create top level navigation category
                _navigationTree      = new CategoryItem(false); // NOTE: root not have GUI
                _navigationTree.Name = TREE_ITEM_NAME;

                // create navigation tree in memory
                XmlElement rootElement = navTreeDoc.DocumentElement;
                foreach (XmlNode node in rootElement.ChildNodes)
                {
                    if (node.NodeType != XmlNodeType.Element)
                    {
                        continue; // skip comments and other non element nodes
                    }
                    if (node.Name.Equals(XML_CATEGORY_ELEMENT_NAME, StringComparison.OrdinalIgnoreCase))
                    {
                        _AddCategoryItem(_navigationTree as CategoryItem, node as XmlElement);
                    }
                    else if (node.Name.Equals(XML_PAGE_ELEMENT_NAME, StringComparison.OrdinalIgnoreCase))
                    {
                        _AddPageItem(_navigationTree as CategoryItem, node as XmlElement);
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reads page item from Xml element and adds it as a child to the parent.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="categoryNode"></param>
        private void _AddPageItem(CategoryItem parent, XmlElement categoryNode)
        {
            PageItem newPage = new PageItem();

            string typeName = categoryNode.GetAttribute(XML_TYPE_ATTRIBUTE_NAME, "");
            newPage.PageType = Type.GetType(typeName);

            // page type should exist
            Debug.Assert(newPage.PageType != null);

            // add new page to the parent
            newPage.Parent = parent;
            parent.AddChild(newPage);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Reads category item from Xml element and adds it as a child to the parent.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="categoryNode"></param>
        private void _AddCategoryItem(CategoryItem parent, XmlElement categoryNode)
        {
            bool visible = true;
            if (null != categoryNode.Attributes[XML_VISIBLE_ATTRIBUTE_NAME])
                visible = bool.Parse(categoryNode.Attributes[XML_VISIBLE_ATTRIBUTE_NAME].Value);

            CategoryItem newCategory = new CategoryItem(visible);

            newCategory.Name = categoryNode.GetAttribute(XML_NAME_ATTRIBUTE_NAME, "");
            string captionID = categoryNode.GetAttribute(XML_CAPTIONID_ATTRIBUTE_NAME, "");
            newCategory.Caption = (string)App.Current.FindResource(captionID);

            string typeName = categoryNode.GetAttribute(XML_TYPE_ATTRIBUTE_NAME, "");
            newCategory.CategoryType = Type.GetType(typeName);

            // add new category to the parent
            newCategory.Parent = parent;
            parent.AddChild(newCategory);

            // process all other category childs
            foreach (XmlNode node in categoryNode.ChildNodes)
            {
                if (node.NodeType != XmlNodeType.Element)
                    continue; // skip comments and other non element nodes

                if (node.Name.Equals(XML_CATEGORY_ELEMENT_NAME, StringComparison.OrdinalIgnoreCase))
                    _AddCategoryItem(newCategory as CategoryItem, node as XmlElement);
                else if (node.Name.Equals(XML_PAGE_ELEMENT_NAME, StringComparison.OrdinalIgnoreCase))
                    _AddPageItem(newCategory as CategoryItem, node as XmlElement);
                else
                    throw new NotSupportedException();
            }
        }