예제 #1
0
        /// <summary>
        /// 单元格触摸抬起方法
        /// </summary>
        /// <param name="cell">单元格</param>
        /// <param name="touchInfo">触摸信息</param>
        public override void onCellTouchUp(FCGridCell cell, FCTouchInfo touchInfo)
        {
            base.onCellTouchUp(cell, touchInfo);
            FCPoint mp = touchInfo.m_firstPoint;

            if (m_movingNode != null)
            {
                FCGridRow curRow = getRow(mp);
                //移动
                if (curRow != null)
                {
                    FCTreeNode curNode = curRow.getCell(0) as FCTreeNode;
                    if (curNode.AllowDragIn && m_movingNode != curNode)
                    {
                        FCTreeNode curNodeParent    = curNode.Parent;
                        FCTreeNode movingNodeParent = m_movingNode.Parent;
                        if (movingNodeParent != null)
                        {
                            movingNodeParent.removeNode(m_movingNode);
                        }
                        else
                        {
                            removeNode(m_movingNode);
                        }
                        //有父节点
                        if (curNodeParent != null)
                        {
                            if (movingNodeParent == curNodeParent)
                            {
                                curNodeParent.insertNode(curNodeParent.getNodeIndex(curNode), m_movingNode);
                            }
                            else
                            {
                                curNode.appendNode(m_movingNode);
                            }
                        }
                        //无父节点
                        else
                        {
                            if (movingNodeParent == curNodeParent)
                            {
                                insertNode(getNodeIndex(curNode), m_movingNode);
                            }
                            else
                            {
                                curNode.appendNode(m_movingNode);
                            }
                        }
                        curNode.expend();
                    }
                }
                m_movingNode = null;
                update();
            }
        }
예제 #2
0
        /// <summary>
        /// 创建树的节点
        /// </summary>
        /// <param name="node">节点</param>
        /// <param name="control">控件</param>
        /// <param name="treeNode">树节点</param>
        protected virtual void createTreeNode(XmlNode node, FCView control, FCTreeNode treeNode)
        {
            FCTree tree = control as FCTree;

            if (tree != null)
            {
                FCTreeNode appendNode = new FCTreeNode();
                if (treeNode == null)
                {
                    tree.appendNode(appendNode);
                }
                else
                {
                    treeNode.appendNode(appendNode);
                }
                setAttributesBefore(node, appendNode);
                foreach (XmlNode subNode in node.ChildNodes)
                {
                    if (subNode.Name.ToLower() == "node")
                    {
                        createTreeNode(subNode, control, appendNode);
                    }
                }
                setAttributesAfter(node, appendNode);
            }
        }
예제 #3
0
        /// <summary>
        /// 加载树的模板
        /// </summary>
        /// <param name="tree">树</param>
        /// <param name="node">节点</param>
        public static void TreeTemplate(FCTree tree, UIXmlEx xml, XmlNode node)
        {
            XmlDocument xmlDoc = node.OwnerDocument;

            tree.Size = new FCSize(200, 200);
            FCGridColumn column = new FCGridColumn("Column1");

            column.AllowSort = false;
            tree.addColumn(column);
            FCGridColumn column2 = new FCGridColumn("Column2");

            column2.AllowSort = false;
            tree.addColumn(column2);
            tree.update();
            FCTreeNode treeNode = new FCTreeNode();

            treeNode.Text = "Node1";
            tree.appendNode(treeNode);
            FCTreeNode subTreeNode = new FCTreeNode();

            subTreeNode.Text = "Node2";
            treeNode.appendNode(subTreeNode);
            tree.update();
            XmlNode columnsNode = xmlDoc.CreateNode(XmlNodeType.Element, "tr", "");

            node.AppendChild(columnsNode);
            XmlNode column1Node = xmlDoc.CreateNode(XmlNodeType.Element, "th", "");

            columnsNode.AppendChild(column1Node);
            XmlAttribute xmlAtr1 = xmlDoc.CreateAttribute("text");

            xmlAtr1.Value = "Column1";
            column1Node.Attributes.Append(xmlAtr1);
            XmlNode column2Node = xmlDoc.CreateNode(XmlNodeType.Element, "th", "");

            columnsNode.AppendChild(column2Node);
            XmlAttribute xmlAtr2 = xmlDoc.CreateAttribute("text");

            xmlAtr2.Value = "Column2";
            column2Node.Attributes.Append(xmlAtr2);
            XmlNode nodesNode = xmlDoc.CreateNode(XmlNodeType.Element, "nodes", "");

            node.AppendChild(nodesNode);
            XmlNode nodeNode = xmlDoc.CreateNode(XmlNodeType.Element, "node", "");

            nodesNode.AppendChild(nodeNode);
            XmlAttribute xmlAtr3 = xmlDoc.CreateAttribute("text");

            xmlAtr3.Value = "Node1";
            nodeNode.Attributes.Append(xmlAtr3);
            XmlNode subNodeNode = xmlDoc.CreateNode(XmlNodeType.Element, "node", "");

            nodeNode.AppendChild(subNodeNode);
            XmlAttribute xmlAtr4 = xmlDoc.CreateAttribute("text");

            xmlAtr4.Value = "Node2";
            subNodeNode.Attributes.Append(xmlAtr4);
        }