Esempio n. 1
0
        /// <summary>
        /// 从布局信息构造节点
        /// </summary>
        /// <param name="node"></param>
        /// <param name="windowList"></param>
        /// <param name="onWindowClose"></param>
        public virtual void CreateFromLayoutCfg(XmlElement node, List <SubWindow> windowList,
                                                System.Action <SubWindow> onWindowClose)
        {
            string weightStr     = node.GetAttribute("Weight");
            string depthStr      = node.GetAttribute("Depth");
            string horizontalStr = node.GetAttribute("Horizontal");

            weight       = float.Parse(weightStr);
            depth        = int.Parse(depthStr);
            isHorizontal = bool.Parse(horizontalStr);
            XmlNodeList nodes = node.ChildNodes;

            if (nodes.Count == 0)
            {
                return;
            }
            XmlElement[] sortnode = new XmlElement[nodes.Count];
            foreach (var n in nodes)
            {
                XmlElement nd       = (XmlElement)n;
                string     indexstr = nd.GetAttribute("Index");
                int        index    = int.Parse(indexstr);
                sortnode[index] = nd;
            }
            foreach (var n in sortnode)
            {
                if (n.Name == "SubWindowNode")
                {
                    SubWindowNode swnode = new SubWindowNode(true, 0);
                    swnode.CreateFromLayoutCfg(n, windowList, onWindowClose);
                    this.m_Childs.Add(swnode);
                }
                else if (n.Name == "SubWindowLeaf")
                {
                    SubWindowLeaf swleaf = new SubWindowLeaf(null, true, 0);
                    swleaf.CreateFromLayoutCfg(n, windowList, onWindowClose);
                    this.m_Childs.Add(swleaf);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 添加子窗口
        /// </summary>
        /// <param name="window"></param>
        /// <param name="index"></param>
        public virtual void AddWindow(SubWindow window, int index)
        {
            SubWindowLeaf item = new SubWindowLeaf(window, !isHorizontal, depth + 1);

            this.Insert(item, index);
        }