Ejemplo n.º 1
0
        public override bool readFromXmlElement(XmlNode pCurNode)
        {
            XmlElement ele = (XmlElement)pCurNode;

            if (ele.Name != "KeyCard")
            {
                s_errorString = "error xml type error for KeyCard";
                return(false);
            }

            if (ele.HasAttribute("faceValue") == false)
            {
                s_errorString = "error xml type KeyCard do not have faceValue attribute";
                return(false);
            }

            m_nValue = int.Parse(ele.GetAttribute("faceValue"));

            XmlNode pchild = pCurNode.FirstChild;

            while (pchild != null)
            {
                NodeContribute pnodeChild = new NodeContribute(0);
                pnodeChild.readFromXmlElement(pchild);
                addChildNode(pnodeChild);
                pchild = pchild.NextSibling;
            }
            return(true);
        }
        public override TreeNode doAddChildNode()
        {
            int nIdx     = 0;
            int nRealIdx = -1;

            for (; nIdx < 3; ++nIdx)
            {
                if (vContributeBtn[nIdx] == null || vContributeBtn[nIdx].Enabled == false)
                {
                    continue;
                }

                if (vContributeBtn[nIdx].Checked)
                {
                    nRealIdx = nIdx;
                    break;
                }
            }

            if (nRealIdx == -1)
            {
                MessageBox.Show("请选择要配置贡献几张牌");
                return(null);
            }

            NodeContribute pNodeData = new NodeContribute(nRealIdx);

            if (m_pCurNodeData.addChildNode(pNodeData) == null)
            {
                MessageBox.Show("add node error , already exist");
                vContributeBtn[nIdx].Enabled = false;
                vContributeBtn[nIdx].Checked = false;
                return(null);
            }

            TreeNode pnode = new TreeNode();

            pnode.Tag  = pNodeData;
            pnode.Text = pNodeData.desc;

            refreshCurNodeData(m_pCurNodeData);
            return(pnode);
        }
        public override TreeNode doAddChildNode()
        {
            int nIdx = 0;
            int nRealIdx = -1;
            for (; nIdx < 3; ++nIdx)
            {
                if (vContributeBtn[nIdx] == null || vContributeBtn[nIdx].Enabled == false)
                {
                    continue;
                }

                if (vContributeBtn[nIdx].Checked)
                {
                    nRealIdx = nIdx;
                    break;
                }
            }

            if (nRealIdx == -1)
            {
                MessageBox.Show("请选择要配置贡献几张牌");
                return null;
            }

            NodeContribute pNodeData = new NodeContribute(nRealIdx);
            if (m_pCurNodeData.addChildNode(pNodeData) == null)
            {
                MessageBox.Show("add node error , already exist");
                vContributeBtn[nIdx].Enabled = false;
                vContributeBtn[nIdx].Checked = false;
                return null;
            }

            TreeNode pnode = new TreeNode();
            pnode.Tag = pNodeData;
            pnode.Text = pNodeData.desc;

            refreshCurNodeData(m_pCurNodeData);
            return pnode;
        }
Ejemplo n.º 4
0
        public override bool readFromXmlElement(XmlNode pCurNode)
        {
            XmlElement ele = (XmlElement)pCurNode;
            if (ele.Name != "KeyCard")
            {
                s_errorString = "error xml type error for KeyCard";
                return false;
            }

            if (ele.HasAttribute("faceValue") == false)
            {
                s_errorString = "error xml type KeyCard do not have faceValue attribute";
                return false;
            }

            m_nValue = int.Parse(ele.GetAttribute("faceValue"));

            XmlNode pchild = pCurNode.FirstChild;
            while (pchild != null)
            {
                NodeContribute pnodeChild = new NodeContribute(0);
                pnodeChild.readFromXmlElement(pchild);
                addChildNode(pnodeChild);
                pchild = pchild.NextSibling;
            }
            return true;
        }