using System;
using System.IO;
using System.Collections.Generic;
using System.Xml;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace MYAPP.Manage.KRCode.Programming.Function
{
    public partial class Tree_FunctionType : MyApp.Web.UI.UserPage
    {
        override protected void AppInit()//程序基本信息初始化
        {
            base.AppInit();
        }

        override protected void DataInit()//数据初始化
        {

        }

        protected override void pl_register_script()
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof(index));
            base.pl_register_script();
        }

        protected void Page_Init(object sender, EventArgs e)
        {
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BuildTree();
            }
        }

        protected void BuildTree()
        {
            XmlDocument xmldoc = MyApp.Components.XML.XmlDocument.Load(MyApp.Components.KRCode.Programming.Get_Config_Name());
            XmlElement elem_Project = (XmlElement)MyApp.Components.XML.XmlDocument.SelectSingleNode(ref xmldoc, "/krpano/Functions/Type/Tree");

            TV_Tree.Nodes.Clear();
            ComponentArt.Web.UI.TreeViewNode Function_Root = CreateNode(elem_Project.GetAttribute("name"), "ROOT", true, elem_Project.GetAttribute("imageurl"), "", "", false);
            TV_Tree.Nodes.Add(Function_Root);

            XmlNodeList xmlnodelist = xmldoc.SelectNodes("/krpano/Functions/Type/Tree/node");
            foreach (XmlElement elem_item in xmlnodelist)
            {
                ComponentArt.Web.UI.TreeViewNode new_Node = CreateNode(elem_item.GetAttribute("name"), elem_item.GetAttribute("name"), true, "", "", "", false);
                Function_Root.Nodes.Add(new_Node);
           }
        }

        private ComponentArt.Web.UI.TreeViewNode CreateNode(string name, string id, bool expanded, string imageurl, string navurl, string target, bool _ShowCheckBox)
        {
            ComponentArt.Web.UI.TreeViewNode node = new ComponentArt.Web.UI.TreeViewNode();
            node.Text = name;
            node.NavigateUrl = navurl;
            node.Target = target;
            node.Value = id.ToString();
            node.ImageUrl = imageurl;
            node.Expanded = expanded;
            node.ShowCheckBox = _ShowCheckBox;
            return node;
        }
    }
}