예제 #1
0
        private string GetNodeContentLevelPrefix(SimulateTreeNode node)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = node.Level; i > 0; i--)
            {
                sb.Append(GetNodeContentLevelPrefix(node, i));
            }

            return sb.ToString();
        }
예제 #2
0
        private string GetNodeContentLevelPrefix(SimulateTreeNode node)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = node.Level; i > 0; i--)
            {
                sb.Append(GetNodeContentLevelPrefix(node, i));
            }

            return(sb.ToString());
        }
예제 #3
0
        private SimulateTreeNode GetParentNode(List <SimulateTreeNode> silumateTree, int rowIndex)
        {
            SimulateTreeNode currentNode = silumateTree[rowIndex];

            if (currentNode.Level == 0)
            {
                return(null);
            }
            else
            {
                for (int i = rowIndex - 1; i >= 0; i--)
                {
                    SimulateTreeNode node = silumateTree[i];
                    if (node.Level == currentNode.Level - 1)
                    {
                        return(node);
                    }
                }
            }

            return(null);
        }
예제 #4
0
        private bool GetHasLittleBrother(List <SimulateTreeNode> silumateTree, int rowIndex)
        {
            SimulateTreeNode currentNode = silumateTree[rowIndex];

            if (rowIndex == silumateTree.Count - 1)
            {
                // 树的最后一个节点,当然没有弟节点
                return(false);
            }
            else
            {
                //SilumateTreeNode nextNode = silumateTree[rowIndex + 1];
                //if (nextNode.Level != currentNode.Level)
                //{
                //    return false;
                //}
                //else
                //{
                //    return true;
                //}
                for (int i = rowIndex + 1; i < silumateTree.Count; i++)
                {
                    SimulateTreeNode node = silumateTree[i];
                    if (node.Level == currentNode.Level)
                    {
                        return(true);
                    }
                    else if (node.Level < currentNode.Level)
                    {
                        return(false);
                    }
                }
            }

            return(false);
        }
예제 #5
0
        private string GetNodeContentLevelPrefix(SimulateTreeNode node, int level)
        {
            #region Rules

            //level = 0,
            //level = 1,    有弟节点  |-
            //              没弟节点  |_
            //level = 2,    父有弟节点  |   有弟节点  |-
            //              父没弟节点      没弟节点  |_
            //level = 3,    父的父有弟节点  |   父有弟节点  |   有弟节点  |-
            //              父的父没弟节点      父没弟节点      没弟节点  |_

            #endregion

            if (level == 1)
            {
                if (node.HasLittleBrother)
                {
                    return(X_ELBOW);
                }
                else
                {
                    return(X_ELBOW_END);
                }
            }
            else if (level == 2)
            {
                if (node.ParentNode.HasLittleBrother)
                {
                    return(X_ELBOW_LINE);
                }
                else
                {
                    return(X_ELBOW_EMPTY);
                }
            }
            else if (level == 3)
            {
                if (node.ParentNode.ParentNode.HasLittleBrother)
                {
                    return(X_ELBOW_LINE);
                }
                else
                {
                    return(X_ELBOW_EMPTY);
                }
            }
            else if (level == 4)
            {
                if (node.ParentNode.ParentNode.ParentNode.HasLittleBrother)
                {
                    return(X_ELBOW_LINE);
                }
                else
                {
                    return(X_ELBOW_EMPTY);
                }
            }
            else if (level == 5)
            {
                if (node.ParentNode.ParentNode.ParentNode.ParentNode.HasLittleBrother)
                {
                    return(X_ELBOW_LINE);
                }
                else
                {
                    return(X_ELBOW_EMPTY);
                }
            }
            else if (level == 6)
            {
                if (node.ParentNode.ParentNode.ParentNode.ParentNode.ParentNode.HasLittleBrother)
                {
                    return(X_ELBOW_LINE);
                }
                else
                {
                    return(X_ELBOW_EMPTY);
                }
            }

            // We support 6 levels at the most.
            return("  ");
        }
예제 #6
0
파일: Grid.cs 프로젝트: g992com/esb
        private void AfterDataBind(int recordCount)
        {
            if (!IsDatabasePaging)
            {
                // 如果不是数据库分页,则每次DataBind都要更新RecordCount的值
                // 数据库分页的话,RecordCount需要用户显式的赋值
                RecordCount = recordCount;
            }


            // 在所有行都绑定结束后,需要检查模拟树显示的列,并重新计算当前列的内容(在列内容前加上树分隔符)
            // 1.查找需要模拟树显示的列
            GridColumn simulateTreeColumn = null;
            foreach (GridColumn column in AllColumns)
            {
                if (!String.IsNullOrEmpty(column.DataSimulateTreeLevelField))
                {
                    simulateTreeColumn = column;
                    break;
                }
            }

            // 2.如果找到这样的列
            if (simulateTreeColumn != null)
            {
                List<SimulateTreeNode> silumateTree = new List<SimulateTreeNode>();

                // 存在需要模拟树显示的列
                for (int rowIndex = 0, rowCount = Rows.Count; rowIndex < rowCount; rowIndex++)
                {
                    GridRow row = Rows[rowIndex];
                    int level = Convert.ToInt32(row.GetPropertyValue(simulateTreeColumn.DataSimulateTreeLevelField));
                    object content = row.Values[simulateTreeColumn.ColumnIndex];

                    SimulateTreeNode node = new SimulateTreeNode();
                    node.Text = content.ToString();
                    node.Level = level;
                    node.HasLittleBrother = false;
                    node.ParentNode = null;
                    silumateTree.Add(node);
                }

                // 计算树
                SimulateTreeHeper treeHelper = new SimulateTreeHeper();
                treeHelper.ResolveSimulateTree(silumateTree, true);

                // 赋值
                for (int rowIndex = 0, rowCount = Rows.Count; rowIndex < rowCount; rowIndex++)
                {
                    Rows[rowIndex].Values[simulateTreeColumn.ColumnIndex] = silumateTree[rowIndex].Text;
                }
            }
        }
예제 #7
0
        private string GetNodeContentLevelPrefix(SimulateTreeNode node, int level)
        {
            #region Rules

            //level = 0, 
            //level = 1,    有弟节点  |-
            //              没弟节点  |_
            //level = 2,    父有弟节点  |   有弟节点  |-
            //              父没弟节点      没弟节点  |_    
            //level = 3,    父的父有弟节点  |   父有弟节点  |   有弟节点  |-
            //              父的父没弟节点      父没弟节点      没弟节点  |_   

            #endregion

            if (level == 1)
            {
                if (node.HasLittleBrother)
                {
                    return X_ELBOW;
                }
                else
                {
                    return X_ELBOW_END;
                }
            }
            else if (level == 2)
            {
                if (node.ParentNode.HasLittleBrother)
                {
                    return X_ELBOW_LINE;
                }
                else
                {
                    return X_ELBOW_EMPTY;
                }
            }
            else if (level == 3)
            {
                if (node.ParentNode.ParentNode.HasLittleBrother)
                {
                    return X_ELBOW_LINE;
                }
                else
                {
                    return X_ELBOW_EMPTY;
                }
            }
            else if (level == 4)
            {
                if (node.ParentNode.ParentNode.ParentNode.HasLittleBrother)
                {
                    return X_ELBOW_LINE;
                }
                else
                {
                    return X_ELBOW_EMPTY;
                }
            }
            else if (level == 5)
            {
                if (node.ParentNode.ParentNode.ParentNode.ParentNode.HasLittleBrother)
                {
                    return X_ELBOW_LINE;
                }
                else
                {
                    return X_ELBOW_EMPTY;
                }
            }
            else if (level == 6)
            {
                if (node.ParentNode.ParentNode.ParentNode.ParentNode.ParentNode.HasLittleBrother)
                {
                    return X_ELBOW_LINE;
                }
                else
                {
                    return X_ELBOW_EMPTY;
                }
            }

            // We support 6 levels at the most.
            return "  ";
        }